added menu-icons and asidenavbar-styling

This commit is contained in:
Felix Hamann 2018-03-17 19:23:45 +01:00
parent d480195b2d
commit d8f2ce6e90
8 changed files with 84 additions and 17 deletions

View File

@ -82,6 +82,7 @@ mkYesodData "UniWorX" $(parseRoutesFile "routes")
data MenuItem = MenuItem data MenuItem = MenuItem
{ menuItemLabel :: Text { menuItemLabel :: Text
, menuItemIcon :: Maybe Text
, menuItemRoute :: Route UniWorX , menuItemRoute :: Route UniWorX
, menuItemAccessCallback :: Handler Bool , menuItemAccessCallback :: Handler Bool
} }
@ -280,31 +281,37 @@ defaultLinks :: [MenuTypes]
defaultLinks = -- Define the menu items of the header. defaultLinks = -- Define the menu items of the header.
[ NavbarRight $ MenuItem [ NavbarRight $ MenuItem
{ menuItemLabel = "Home" { menuItemLabel = "Home"
, menuItemIcon = Just "home"
, menuItemRoute = HomeR , menuItemRoute = HomeR
, menuItemAccessCallback = return True , menuItemAccessCallback = return True
} }
, NavbarLeft $ MenuItem , NavbarLeft $ MenuItem
{ menuItemLabel = "Kurse" { menuItemLabel = "Kurse"
, menuItemIcon = Just "book"
, menuItemRoute = CourseListR , menuItemRoute = CourseListR
, menuItemAccessCallback = return True , menuItemAccessCallback = return True
} }
, NavbarLeft $ MenuItem , NavbarLeft $ MenuItem
{ menuItemLabel = "Users" { menuItemLabel = "Users"
, menuItemIcon = Just "user"
, menuItemRoute = UsersR , menuItemRoute = UsersR
, menuItemAccessCallback = return True -- Creates a LOOP: (Authorized ==) <$> isAuthorized UsersR False , menuItemAccessCallback = return True -- Creates a LOOP: (Authorized ==) <$> isAuthorized UsersR False
} }
, NavbarRight $ MenuItem , NavbarRight $ MenuItem
{ menuItemLabel = "Profile" { menuItemLabel = "Profile"
, menuItemIcon = Just "user"
, menuItemRoute = ProfileR , menuItemRoute = ProfileR
, menuItemAccessCallback = isJust <$> maybeAuthPair , menuItemAccessCallback = isJust <$> maybeAuthPair
} }
, NavbarSecondary $ MenuItem , NavbarSecondary $ MenuItem
{ menuItemLabel = "Login" { menuItemLabel = "Login"
, menuItemIcon = Just "login"
, menuItemRoute = AuthR LoginR , menuItemRoute = AuthR LoginR
, menuItemAccessCallback = isNothing <$> maybeAuthPair , menuItemAccessCallback = isNothing <$> maybeAuthPair
} }
, NavbarSecondary $ MenuItem , NavbarSecondary $ MenuItem
{ menuItemLabel = "Logout" { menuItemLabel = "Logout"
, menuItemIcon = Just "logout"
, menuItemRoute = AuthR LogoutR , menuItemRoute = AuthR LogoutR
, menuItemAccessCallback = isJust <$> maybeAuthPair , menuItemAccessCallback = isJust <$> maybeAuthPair
} }
@ -341,11 +348,19 @@ defaultMenuLayout menu widget = do
pc <- widgetToPageContent $ do pc <- widgetToPageContent $ do
addStylesheetRemote "https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,800,900" addStylesheetRemote "https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,800,900"
addStylesheet $ StaticR css_fonts_css
addStylesheet $ StaticR css_icons_css
$(widgetFile "default-layout") $(widgetFile "default-layout")
$(widgetFile "standalone/showHide") $(widgetFile "standalone/showHide")
$(widgetFile "standalone/sortable") $(widgetFile "standalone/sortable")
$(widgetFile "standalone/inputs") $(widgetFile "standalone/inputs")
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet") withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")
where
iconToText :: Maybe Text -> Text
iconToText mText =
"" ++ case mText of
Nothing -> ""
Just text -> text
-- How to run database actions. -- How to run database actions.
instance YesodPersist UniWorX where instance YesodPersist UniWorX where

View File

@ -66,6 +66,7 @@ getCourseListTermR tidini = do
let pageLinks = let pageLinks =
[ NavbarLeft $ MenuItem [ NavbarLeft $ MenuItem
{ menuItemLabel = "Neuer Kurs" { menuItemLabel = "Neuer Kurs"
, menuItemIcon = Just "book"
, menuItemRoute = CourseEditR , menuItemRoute = CourseEditR
, menuItemAccessCallback = (== Authorized) <$> isAuthorized CourseEditR False , menuItemAccessCallback = (== Authorized) <$> isAuthorized CourseEditR False
} }

9
static/css/fonts.css Normal file
View File

@ -0,0 +1,9 @@
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'),
url('../fonts/glyphicons-halflings-regular.woff') format('woff'),
url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),
url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

24
static/css/icons.css Normal file
View File

@ -0,0 +1,24 @@
.glyphicon::before {
position: absolute;
left: 4px;
margin: 0 13px;
font-family: 'Glyphicons Halflings';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.glyphicon--home::before {
content: '\e021';
}
.glyphicon--book::before {
content: '\e043';
}
.glyphicon--user::before {
content: '\e008';
}
.glyphicon--login::before {
content: '\e161';
}
.glyphicon--logout::before {
content: '\e163';
}

View File

@ -6,13 +6,13 @@
$case menuType $case menuType
$of NavbarLeft (MenuItem label icon route _) $of NavbarLeft (MenuItem label icon route _)
<li .asidenav__list-item :Just route == mcurrentRoute:.asidenav__list-item--active> <li .asidenav__list-item :Just route == mcurrentRoute:.asidenav__list-item--active>
<a .asidenav__link.asidenav__icon--#{icon} href=@{route}>#{label} <a .asidenav__link :isJust icon:.glyphicon :isJust icon:.glyphicon--#{iconToText icon} href=@{route}>#{label}
$of _ $of _
<div .asidenav__box> <div .asidenav__box>
<h3 .asidenav__box-title>WiSe 17/18 <h3 .asidenav__box-title>WiSe 17/18
<ul .asidenav__list> <ul .asidenav__list.asidenav__list--padded>
<li>CD <li>Vorlesung 1
<li>IxD <li>Vorlesung 2
<li>Funktionale Programmierung <li>Vorlesung 3
<li>Programmierung und Modellierung <li>Vorlesung 4

View File

@ -13,10 +13,12 @@
transition: opacity .2s ease; transition: opacity .2s ease;
} }
.main__aside--collapsed:hover {
overflow: visible;
}
.main__aside--collapsed { .main__aside--collapsed {
width: 50px; width: 50px;
} }
.main__aside--collapsed .asidenav__box { .main__aside--collapsed .asidenav__box {
opacity: 0; opacity: 0;
} }
@ -25,12 +27,10 @@
} }
.main__aside--collapsed:not(.main__aside--transitioning) .asidenav__box { .main__aside--collapsed:not(.main__aside--transitioning) .asidenav__box {
visibility: hidden;
pointer-events: none;
z-index: -10;
height: 0; height: 0;
padding: 0; padding: 0;
margin: 0; margin: 0;
visibility: hidden;
} }
.asidenav { .asidenav {
@ -42,21 +42,31 @@
margin: 10px 0; margin: 10px 0;
padding: 10px 0; padding: 10px 0;
border-bottom: 4px solid var(--whitebase); border-bottom: 4px solid var(--whitebase);
background-color: var(--darkbase);
} }
.asidenav__box-title { .asidenav__box-title {
margin-left: -10px; padding: 7px 13px;
} }
.asidenav .asidenav__link { .asidenav__list--padded {
padding: 0 13px;
}
.asidenav__list-item--active .asidenav__link {
background-color: var(--darkbase);
color: white;
}
.asidenav__link {
position: relative; position: relative;
display: block; display: block;
padding: 4px 7px; padding: 4px 7px;
line-height: 40px; line-height: 40px;
margin: 4px 0; margin: 4px 0;
padding-left: 60px; padding-left: 54px;
color: var(--darkbase);
background-color: white; background-color: white;
color: var(--darkbase);
} }
.asidenav .asidenav__link:hover { .asidenav .asidenav__link:hover {

View File

@ -6,10 +6,10 @@
$case menuType $case menuType
$of NavbarRight (MenuItem label icon route _) $of NavbarRight (MenuItem label icon route _)
<li .navbar__list-item :Just route == mcurrentRoute:.navbar__list-item--active> <li .navbar__list-item :Just route == mcurrentRoute:.navbar__list-item--active>
<a .navbar__link href=@{route}>#{label} <a .navbar__link :isJust icon:.glyphicon :isJust icon:.glyphicon--#{iconToText icon} href=@{route}>#{label}
$of NavbarSecondary (MenuItem label icon route _) $of NavbarSecondary (MenuItem label icon route _)
<li .navbar__list-item.navbar__list-item--secondary :Just route == mcurrentRoute:.navbar__list-item--active> <li .navbar__list-item.navbar__list-item--secondary :Just route == mcurrentRoute:.navbar__list-item--active>
<a .navbar__link href=@{route}>#{label} <a .navbar__link :isJust icon:.glyphicon :isJust icon:.glyphicon--#{iconToText icon} href=@{route}>#{label}
$of _ $of _
<div .navbar__pushdown> <div .navbar__pushdown>

View File

@ -18,6 +18,7 @@
} }
.navbar .navbar__link { .navbar .navbar__link {
position: relative;
display: inline-block; display: inline-block;
height: 100%; height: 100%;
padding: 0 13px; padding: 0 13px;
@ -25,9 +26,13 @@
text-transform: uppercase; text-transform: uppercase;
} }
.navbar .navbar__link.glyphicon {
padding-left: 50px;
}
.navbar__list-item--secondary { .navbar__list-item--secondary {
margin-left: 20px; margin-left: 20px;
background-color: var(--fontsec); color: var(--fontsec);
} }
.navbar__list-item--secondary + .navbar__list-item--secondary { .navbar__list-item--secondary + .navbar__list-item--secondary {
margin-left: 0; margin-left: 0;
@ -43,6 +48,9 @@
color: var(--whitebase); color: var(--whitebase);
background-color: var(--darkbase); background-color: var(--darkbase);
} }
.navbar__list-item--secondary > .navbar__link {
color: var(--greybase);
}
.navbar--sticky { .navbar--sticky {
position: fixed; position: fixed;