morpheus
INBOX
UPDATES
PROJECTS
CALENDAR

Layout

Morpheus utilizes JSF templating APIs and provides a main template.xhtml along with additional topbar, menu, footer fragments for the base layout. These xhtml files must be placed under WEB-INF folder and client pages should reference the template.xhtml as their template. Provided empty.xhtml is a sample content page using the main template.xhtml that defines "content" as the main ui:define placeholder. By default template defines 3 placeholders (page title, header content and actual content)to insert content and you can add more as per your requirements.

Sample page below uses the main template from Morpheus.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/template.xhtml">
                
    <ui:define name="title">Test Page</ui:define>

    <ui:define name="content">
        Content goes here
    </ui:define>
</ui:composition>

Other required resources are the css, js and images that are located inside resources/morpheus-layout folder, simply copy the morpheus-layout folder to your %WEB-APP-FOLDER%/resources folder so that final path would be %WEB-APP-FOLDER%/resources/morpheus-layout/. Please refer to demo app or maven project of the demo app as the reference.

Theme

Morpheus provides 3 PrimeFaces themes out of the box, setup of a theme simple as including the theme jar in your classpath and defining primefaces.THEME context parameter in web.xml such as "primefaces-morpheus-green". Full list of available themes are;

  • primefaces-morpheus-green
  • primefaces-morpheus-blue
  • primefaces-morpheus-orange

A custom theme can be developed by the following steps.

  • Choose a custom theme name such as primefaces-morpheus-myown.
  • Create a folder named primefaces-morpheus-myown and place an empty theme.scss inside
  • Copy the sass folder from the distribution to your application.
  • Define the variables listed below and import the /sass/theme/_theme.scss file.
  • Build the scss to generate css
  • Set primefaces.THEME context parameter as morpheus-myown
  • Either bundle the css in a jar file or serve from webapp/resources/primefaces-morpheus-myown folder

Here are the variables required to create a theme, you may need to change the last line according to the relative path of the sass folder in your application.

$primaryColor: #61d42d;
$highlightTextColor:#ffffff;
$buttonTextColor:#ffffff;

@import '../sass/theme/_theme';

An example sass command to compile the css would be;

sass src/main/webapp/resources/primefaces-morpheus-myown/theme.scss src/main/webapp/resources/primefaces-morpheus-myown/theme.css  --sourcemap=none

Watch mode is handy to avoid compiling everytime when a change is made, instead use the following command so that sass generates the file whenever you make a customization. This builds all css files whenever a change is made to any scss file.

sass -w src/main/webapp/resources/ --sourcemap=none

Same can also be applied to layout itself;

  • Choose a layout name such as layout-myown.
  • Create an empty file named layout-myown.scss inside resources/morpheus-layout/css folder.
  • Define the variables listed below and import the /sass/layout/_layout.scss file.
  • Build the scss to generate css
  • Serve the css by importing it using a link tag or h:outputStylesheet.

Here are the variables required to create a layout, you may need to change the last line according to the relative path of the sass folder in your application.

$primaryColor: #61d42d;
$highlightTextColor:#ffffff;
$buttonTextColor:#ffffff;

@import '../../sass/layout/_layout';

For both cases, several .scss files such as _layout.scss, _theme.scss or _variables.scss has to be present relative to your scss files, these are available inside the sass folder in the distribution.

In case you'd like to customize the structure not just the colors, the _variables.scss is where the structural variables (e.g. font size, paddings) for the layout are defined.

/* Common */
$fontSize:13px;
$textColor:#777777;
$textSecondaryColor:lighten($textColor,5%);
$borderRadius:3px;
$dividerColor:#eaeaea;
$iconFontSize:16px;
$iconWidth:16px;
$iconHeight:16px;
$mainColor: #61d42d;

/* Layout */
$bodyBgColor:#f8f8f8;
$footerBgColor:#dee0e3;
$footerLinkHoverColor: #494949;
$menuBgColor: #2C2C2C;
$menuBgColorActive: #1f1f1f;
$menuTextColor: #c4c4c4;

/* Topbar */
$topbarMenuTextColor:#ffffff;
$topbarMenuTextHoverColor:#e3e3e3;
$topbarSubmenuBgColor:#f7f7f7;
$topbarSubmenuItemHoverBgColor:#e3e3e3;
$topbarButtonHoverBgColor: #f5f5f5;
$topbarButtonHoverColor:#494949;
$topbarIconColor:#afafaf;
$topbarBgColor: #ffffff;

/* Tab */
$progressBarBgColor: #eeeeee;
$progressBarFirstColor: #92f5a1;
$progressBarSecondColor: #c4e3c9;
$progressBarThirdColor: #c8cfc9;
$progressBarForthColor: #dedede;

/******************************/
/*           THEME            */
/******************************/

/* Headers */
$headerPadding:6px 12px;
$headerBgColor:#f1f1f1;
$headerTextColor:#858585;
$headerHoverBgColor:#dcdcdc;
$headerBorderColor:#eaeaea;
$headerIconColor:#858585;
$headerIconHoverColor:#6c6c6c;
$headerHoverTextColor: #6c6c6c;

/* Contents */
$contentPadding:6px 12px;
$contentBorderColor:#eaeaea;
$contentBgColor:#ffffff;

/* Panels */
$panelHeaderBgColor:#e2e2e2;
$headerSecondaryBgColor: #c0c0c0;
$headerSecondaryBgHoverColor: #999999;
$headerSecondaryBgActiveColor: #737373;

/* Forms */
$inputBgColor:#ffffff;
$inputPadding:4px;
$inputBorderColor:#cfcfcf;
$inputHoverBorderColor:#afafaf;
$inputInvalidBorderColor:#e13131;
$inputTextColor: #777777;
$inputBtnBgColor:#c0c0c0;
$inputBtnBgHoverColor:#999999;
$inputBtnBgActiveColor:#737373;

/* List Items */
$listItemPadding:6px 12px;
$listItemBgColor:#f9f9f9;
$listItemHoverBgColor:#e2e2e2;
$listItemHoverTextColor:#777777;

/* Messages */
$infoMessageBgColor:#ddedf4;
$infoMessageTextColor:#393b38;
$warnMessageBgColor:#fff7e1;
$warnMessageTextColor:#393b38;
$errorMessageBgColor:#ffddd5;
$errorMessageTextColor:#393b38;
$fatalMessageBgColor:#e1e1e1;
$fatalMessageTextColor:#393b38;

/* Data */
$paginatorBgColor:#f1f1f1;
$paginatorHoverBgColor:#e2e2e2;
$datatableOddRowBgColor:#ffffff;
$datatableEvenRowBgColor:#f8f8f8;
$datatableHoverBgColor:#e2e2e2;

/* Predefined Colors */
$yellow:#fbc948;
$blue:#6ec5ff;
$orange:#ff9c59;
$purple:#985edb;
$pink:#f18983;
$green:#61d42d;
$black:#777777;

Menu

Menu is a regular JSF component that supports PrimeFaces MenuModel API allowing both declarative and programmatic approaches. State is saved via a cookie and to remove it define a widgetVar to the menu and call PF('yourwidgetvar').clearMenuState(). To use the menu add the primefaces-morpheus-{version}.jar to your classpath and import the http://primefaces.org/morpheus namespace.

xmlns:pm="http://primefaces.org/morpheus">

<pm:tabMenu>
    <pm:tab icon="fa fa-cube" title="Features">
        <h:form id="menu-form">
            <pm:menu widgetVar="menu">
            </pm:menu>
        </h:Form>
    </pm:tab>
    <pm:tab icon="fa fa-inbox" title="Inbox">
    </pm:tab>
    <pm:tab icon="fa fa-calendar-o" title="Calendar">
    </pm:tab>
</pm:tabMenu>

Menu has 2 modes, inline and overlay. Layout wrapper element in template.xhtml is used to define which mode to use by adding specific classes. List below indicates the style classes for each mode.

  • Static: Default mode
  • Overlay: "layout-overlay-menu"

For example to create an overlay menu, the div element should be in following form;

<div class="layout-wrapper layout-overlay-menu">
    ...
</div>

Icons

Morpheus Layout uses font awesome icons for layout so enable font awesome support in PrimeFaces by setting primefaces.FONT_AWESOME context parameter in web.xml as true. If your PrimeFaces version does not have the font awesome integration, include the font-awesome manually in your application.

Card

Card is a section to group content and layout provides a built-in css for it. Apply .card style class to your container to use it. If the card has a title defined with h5 tag, add card-w-title to adjust paddings.

<div class="card">
    Content here
</div>

<div class="card card-w-title">
    <h5>Card with Title<h5>
    Content here
</div>

Grid CSS

Morpheus uses new PrimeFaces Grid CSS (ui-g-*) throughout the samples, we strongly suggest using Grid CSS as your layout framework as it is well tested and supported by PrimeFaces. Grid CSS is automatically included on newer versions however if your PrimeFaces version is older than 5.3.14, add the provided grid.css file under /Morpheus-layout/css/ folder to your template manually.

Tips

  • Familiarity with SASS is required to make customizations to the layout and theme.
  • Demo application war and the maven project tag are included in distribution however you don't necessarily need them to install Morpheus, the actual artifacts required are the layout zip file and the theme jar.
  • Sample demo application war includes the JSF libraries so it is suggested to remove them from the war file when you deploy to an appserver.
  • When running the maven project, you need to build the sass with (sass --update src/main/webapp/resources/ --sourcemap=none) command.

Migration Guide

1.0 to 1.0.1

  • Update layout css files
  • Replace theme jar with new jar