From c81ea58d3a2e3e4e5f8f08ca2210106950c11cb0 Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Wed, 29 Dec 2021 16:51:48 +0300 Subject: [PATCH] Doc update and use --mask-bg for mask --- .../documentation.component.html | 224 ++---------------- src/assets/sass/layout/_responsive.scss | 2 +- src/assets/sass/layout/_variables.scss | 1 - 3 files changed, 15 insertions(+), 212 deletions(-) diff --git a/src/app/components/documentation/documentation.component.html b/src/app/components/documentation/documentation.component.html index 9703b67..ac08ffb 100755 --- a/src/app/components/documentation/documentation.component.html +++ b/src/app/components/documentation/documentation.component.html @@ -1,8 +1,7 @@
- -

Current Version

+

Current Version

Angular 13 and PrimeNG 13

Getting Started

@@ -10,25 +9,23 @@ 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, +

Once CLI is ready in your system, clone the github repository, cd to the directory, install the libraries from npm and then execute "ng serve" to run the application in your local environment.

+git clone https://github.com/primefaces/sakai-ng.git 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.

+

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

-

Important CLI Commands

+
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. @@ -44,7 +41,10 @@ Run 'ng e2e' to execute the end-to-end tests via [Protractor](http://www.protrac Run 'ng help' for more options. -
Structure
+
Dependencies
+

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

+ +

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.

@@ -53,213 +53,17 @@ Run 'ng help' for more options.

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']}, - {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.

+

Sakai layout derives the color scheme from the PrimeNG theme being used so that it can be combined any theme such as PrimeOne, Material, Bootstrap and others with dark mode alternatives.

SASS Variables
-

In case you'd like to customize the layout variables, open _variables.scss file under src/layout folder. Saving the changes +

In case you'd like to customize the layout variables, open _variables.scss file under src/assets/sass/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; - \ No newline at end of file +
+
+
\ No newline at end of file diff --git a/src/assets/sass/layout/_responsive.scss b/src/assets/sass/layout/_responsive.scss index f210730..d94d09c 100644 --- a/src/assets/sass/layout/_responsive.scss +++ b/src/assets/sass/layout/_responsive.scss @@ -64,7 +64,7 @@ .layout-mask { z-index: 998; - background-color: $maskBg; + background-color: var(--mask-bg); &.layout-mask-enter-from, &.layout-mask-leave-to { diff --git a/src/assets/sass/layout/_variables.scss b/src/assets/sass/layout/_variables.scss index e49d703..3886613 100644 --- a/src/assets/sass/layout/_variables.scss +++ b/src/assets/sass/layout/_variables.scss @@ -2,4 +2,3 @@ $fontSize:10px; $borderRadius:12px; $transitionDuration:.2s; -$maskBg:rgba(0, 0, 0, 0.4);