#### Current Version

Angular 13 and PrimeNG 13

#### Getting Started

Sakai is an application template for Angular and is distributed as a CLI project. In case CLI is not installed already, use the command below to set it up.

#### Dependencies

Sakai has no direct dependency other than PrimeNG. More information about dependencies is available at Why PrimeNG Templates article.

npm install -g @angular/cli

Once CLI is ready in your system, extract the contents of the Sakai zip file distribution, cd to the directory, install the libraries from npm and then execute "ng serve" to run the application in your local environment.

cd sakai-ng npm install ng serve

The application should run at http://localhost:4200/, you may now start with the development of your application.

#### Important CLI Commands

Following commands are derived from CLI.

Run 'ng serve' for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. Run 'ng generate component component-name' to generate a new component. You can also use `ng generate directive/pipe/service/class/module`. Run 'ng build' to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. Run 'ng test' to execute the unit tests via [Karma](https://karma-runner.github.io). Run 'ng e2e' to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). Run 'ng help' for more options.

##### Structure

Sakai consists of 2 main parts; the application layout, layout resources. app.component.html inside app folder is the html template for the base layout, required resources for the layout are placed inside the src/assets/layout folder and similarly theme resources are inside src/assets/theme folder.

##### Application Template

Main layout is the html template of the app.main.component.ts, it is divided into a couple of sections such as topbar, sidebar, right panel and footer. Here is the code for the main template. The component class app.main.component.ts implements the logic such as opening menus and managing layout modes.

<div class="layout-wrapper" [ngClass]="{ 'layout-overlay':isOverlay(), 'layout-static':isStatic(), 'layout-theme-light': !app.darkMode, 'layout-theme-dark': app.darkMode, 'layout-overlay-sidebar-active': overlayMenuActive, 'layout-static-sidebar-inactive': staticMenuInactive, 'layout-mobile-sidebar-active': menuActiveMobile, 'p-ripple-disabled': !app.ripple, 'p-input-filled' : app.inputStyle === 'filled'}" <app-topbar></app-topbar> <div class="layout-sidebar"> <app-menu></app-menu> </div> <div class="layout-main-container"> <div class="layout-main"> <router-outlet></router-outlet> </div> <app-footer></app-footer> </div> <app-config></app-config> <div *ngIf="menuActiveMobile" class="layout-mask p-component-overlay"></div> </div>

##### Menu

Menu is a separate component defined in app.menu.component.ts file based on PrimeNG MenuModel API. In order to define the menuitems, navigate to this file and define your own model as a nested structure. Here is the menu component from the sample application.

import { Component, OnInit } from '@angular/core'; import { AppMainComponent } from './app.main.component'; @Component({ selector: 'app-menu', templateUrl: './app.menu.component.html' }) export class AppMenuComponent implements OnInit, AfterViewInit { model: any[]; constructor(public appMain: AppMainComponent) { } ngOnInit() { this.model = [ { label: 'Home', items: [ {label: 'Dashboard', icon: 'pi pi-fw pi-home', routerLink: ['/']} ] }, { label: 'UI Kit', items: [ {label: 'Form Layout', icon: 'pi pi-fw pi-id-card', routerLink: ['/uikit/formlayout']}, {label: 'Input', icon: 'pi pi-fw pi-check-square', routerLink: ['/uikit/input']}, {label: 'Float Label', icon: 'pi pi-fw pi-bookmark', routerLink: ['/uikit/floatlabel']}, {label: 'Invalid State', icon: 'pi pi-fw pi-exclamation-circle', routerLink: ['/uikit/invalidstate']}, {label: 'Button', icon: 'pi pi-fw pi-mobile', routerLink: ['/uikit/button'], class: 'rotated-icon'}, {label: 'Table', icon: 'pi pi-fw pi-table', routerLink: ['/uikit/table']}, {label: 'List', icon: 'pi pi-fw pi-list', routerLink: ['/uikit/list']}, {label: 'Tree', icon: 'pi pi-fw pi-share-alt', routerLink: ['/uikit/tree']}, {label: 'Panel', icon: 'pi pi-fw pi-tablet', routerLink: ['/uikit/panel']}, {label: 'Overlay', icon: 'pi pi-fw pi-clone', routerLink: ['/uikit/overlay']}, {label: 'Media', icon: 'pi pi-fw pi-image', routerLink: ['/uikit/media']}, {label: 'Menu', icon: 'pi pi-fw pi-bars', routerLink: ['/uikit/menu'], children:[ {label: '', component: 'PersonalDemoComponent'}, {label: 'seat', component: 'SeatDemoComponent'}, {label: 'payment', component: 'PaymentDemoComponent'}, {label: 'confirmation', component: 'ConfirmationDemoComponent'}, ] }, {label: 'Message', icon: 'pi pi-fw pi-comment', routerLink: ['/uikit/message']}, {label: 'File', icon: 'pi pi-fw pi-file', routerLink: ['/uikit/file']}, {label: 'Chart', icon: 'pi pi-fw pi-chart-bar', routerLink: ['/uikit/charts']}, {label: 'Misc', icon: 'pi pi-fw pi-circle', routerLink: ['/uikit/misc']} ] }, { label: 'UI Blocks', items: [ {label: 'Free Blocks', icon: 'pi pi-fw pi-eye', routerLink: ['/blocks'], badge: 'NEW'}, {label: 'Timeline', icon: 'pi pi-fw pi-calendar', url: ['https://www.primefaces.org/primeblocks-ng']} ] }, { label: 'Icons', items: [ {label: 'PrimeIcons', icon: 'pi pi-fw pi-prime', routerLink: ['/icons']}, ] }, { label: 'Pages', icon: 'pi pi-fw pi-briefcase', routerLink: ['/pages'], items: [ {label: 'Crud', icon: 'pi pi-fw pi-pencil', routerLink: ['/pages/crud']}, {label: 'Timeline', icon: 'pi pi-fw pi-calendar', routerLink: ['/pages/timeline']}, {label: 'Not Found', icon: 'pi pi-fw pi-exclamation-circle', routerLink: ['/notfound']}, {label: 'Empty', icon: 'pi pi-fw pi-circle', routerLink: ['/pages/empty']} ] }, { label: 'Hierarchy', icon: 'pi pi-fw pi-align-left', items: [ { label: 'Submenu 1', icon: 'pi pi-fw pi-bookmark', items: [ { label: 'Submenu 1.1', icon: 'pi pi-fw pi-bookmark', items: [ {label: 'Submenu 1.1.1', icon: 'pi pi-fw pi-bookmark'}, {label: 'Submenu 1.1.2', icon: 'pi pi-fw pi-bookmark'}, {label: 'Submenu 1.1.3', icon: 'pi pi-fw pi-bookmark'}, ] }, { label: 'Submenu 1.2', icon: 'pi pi-fw pi-bookmark', items: [ {label: 'Submenu 1.2.1', icon: 'pi pi-fw pi-bookmark'} ] }, ] }, { label: 'Submenu 2', icon: 'pi pi-fw pi-bookmark', items: [ { label: 'Submenu 2.1', icon: 'pi pi-fw pi-bookmark', items: [ {label: 'Submenu 2.1.1', icon: 'pi pi-fw pi-bookmark'}, {label: 'Submenu 2.1.2', icon: 'pi pi-fw pi-bookmark'}, ] }, { label: 'Submenu 2.2', icon: 'pi pi-fw pi-bookmark', items: [ {label: 'Submenu 2.2.1', icon: 'pi pi-fw pi-bookmark'}, ] }, ] } ] }, { label: 'Get Started', items: [ { label: 'Documentation', icon: 'pi pi-fw pi-info-circle', routerLink: ['/documentation'] } { label: 'View Source', icon: 'pi pi-fw pi-search', url: ['https://github.com/primefaces/sakai-angular'] } ] } ]; } }

#### Integration with an Existing CLI Project

To setup Sakai in an existing project, follow the steps below;

- Copy the src/assets folder to your projects folder with the same name
- Copy all app.* files to the src/app folder of your application.

Install PrimeNG

npm install primeng@latest --save npm install primeicons@latest --save

Add PrimeNG CSS at styles section in angular.json.

"styles": [ "styles.scss" //your styles and overrides ],

Last part is adding theme and layout css files, in the CLI app they are defined using link tags in index.html so the demo can switch them on the fly by changing the path however if this is not a requirement, you may also add them to the styles configuration above so they go inside the bundle.

##### Theme

Sakai uses the free Saga, Arya and Vela themes which are distributed within PrimeNG, however it can be used with any PrimeNG theme as well such as material, tailwind and bootstrap.

##### SASS Variables

In case you'd like to customize the layout variables, open _variables.scss file under src/layout folder. Saving the changes will be reflected instantly at your browser.

###### src/assets/_variables.scss

A custom theme can be developed by the following steps.

- Choose a custom theme name such as "mytheme".
- Create a folder named "mytheme" under assets/theme folder.
- Create a file such as theme.scss under assets/theme/mytheme folder.
- Define the variables listed below in your file and import the ../../sass/theme/_theme.scss file.
- Build the scss to generate css
- Include the generated theme.css to your page.

Here are the variables required to create a theme.

$fontSize:1rem; $borderRadius:12px; $transitionDuration:.2s;