0.0.3 • Published 2 years ago

@advinow-medical/portal-common-ui v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

PortalCommonUI

UI components library project.

Instruction

Firstly you shoul install dependencies

npm install --save bootstrap jquery popper.js

Add to build in angular.json

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.css",
  "src/styles.scss"
],
"scripts": [
  "node_modules/jquery/dist/jquery.min.js",
  "node_modules/popper.js/dist/umd/popper.min.js",
  "node_modules/bootstrap/dist/js/bootstrap.min.js"
]

Import library in app.module.ts

import { PortalCommonuiModule } from 'portal-common-ui';

@NgModule({
  ...,
  imports: [
    ...,
    PortalCommonuiModule
  ],
})

Components

Button

AttributeValuesDefaultDescription
colorprimary/secondary/success/danger/warning/info/light/dark/linkprimaryButton color
disabledtrue/falsefalseButton disable state
outlinetrue/falsefalseButton outline style
sizesmall/large/defaultdefaultButton size
href(URL)null
routerLink(Route)null
dataToggle(Bootstrap data-toggle attribute)
dataTarget(Bootstrap data-target attribute)
<pcu-button
  (click)="myClickMethod()"
  outline=true
  disabled=true
  color="secondary">
  Button
</pcu-button>

Dropdown

AttributeValuesDefaultDescription
colorprimary/secondary/success/danger/warning/info/light/dark/linkprimaryDropdown button color
disabledtrue/falsefalseDropdown button disable state
outlinetrue/falsefalseDropdown button outline style
sizesmall/large/defaultdefaultDropdown button size
buttonLabel(String)Dropdown button text
linkLabel(String)Dropdown button (link) text
<pcu-dropdown
  outline="true"
  buttonLabel="dropdown"
  color="danger"
>
  <a #item>Action</a>
  <a #item>Another action</a>
  <a #item>Something else here</a>
</pcu-dropdown>

Navbar

AttributeValuesDefaultDescription
navbarColordark/linkdarkNavbar color
<pcu-navbar>
  <a #navbar-brand href="#">Brand</a>
  <pcu-navbar-toggler
    #toggler
    target="#header"
  ></pcu-navbar-toggler>

  <pcu-navbar-menu id="header" #menu>
    <li class="nav-item active">
      <a class="nav-link" href="#">Home</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Second</a>
    </li>
    <li class="nav-item dropdown">
      <pcu-dropdown linkLabel="Download link">
        <a #item href="#">1</a>
        <a #item href="#">2</a>
        <a #item href="#">3</a>
      </pcu-dropdown>
    </li>
  </pcu-navbar-menu>
</pcu-navbar>

Table

AttributeValuesDefaultDescription
head(Array of String or Object or TemplateRef)[]Table head items Object params: - colspan - class - style - label
body(Array of String or Object or TemplateRef)[]Table body items Object params: - class - style - content
headColorlight/darkTable head color
tableColorlight/darkTable body color
headTextAlignleft/center/rightleftText aligment for table head items
bodyTextAlignleft/center/rightleftText aligment for table body items
firstColumnTextAlignleft/center/rightleftText aligment for first column of table head and body
<pcu-table
  [head]="['1', '2', { colspan: 2, label: '3')]"
  [data]="data"
>
</pcu-table>
export class MyComponent {
  public data: Array<Array<any>> = [
    ['1:1', '2:1', '3:1', { content: '4:1' }],
    ['1:2', '2:2', '3:2', '4:2']
  ];

  constructor() {
  }
}

Cell with custom element:

<pcu-table
  [head]="['1', '2', '3', '4']"
  [data]="data"
>
</pcu-table>
<ng-template #btn>
  <pcu-button size="small">
    Button
  </pcu-button>
</ng-template>
export class MyComponent implements OnInit {
  @ViewChild('btn') btn: TemplateRef<any>;

  public data: Array<Array<any>> = [];

  constructor() {
  }

  ngOnInit(): void {
    this.data = [
      ['1:1', '2:1', '3:1', this.btn],
      ['1:2', '2:2', '3:2', this.bt]
    ];
  }
}

Copy field

AttributeValuesDefaultDescription
value(String)Value to copy
<pcu-copy-field value="Value to copy"></pcu-copy-field>

Form field

AttributeValuesDefaultDescription
label(String)Field label
<pcu-form-field label="Field label">
  <input type="text" class="form-control">
</pcu-form-field>

Modal

AttributeValuesDefaultDescription
headerStyles(Object){}Modal header styles
bodyStyles(Object){}Modal body styles
footerStyles(Object){}Modal footer styles
<pcu-button (click)="myModal.show()">
  Open Modal
</pcu-button>

<pcu-modal #myModal>
  <ng-container class="pcu-modal-header">
    <h5 class="modal-title">Modal title</h5>
    <button type="button" class="close" aria-label="Close" (click)="myModal.hide()">
      <span aria-hidden="true">&times;</span>
    </button>
  </ng-container>

  <ng-container class="pcu-modal-body">
    Modal content
  </ng-container>

  <ng-container class="pcu-modal-footer">
    Modal footer
  </ng-container>
</pcu-modal>

Password

AttributeValuesDefaultDescription
name(String)Field form name attribute
sizesmall/large/defaultdefaultField size
<pcu-password name="password"></pcu-password>
<pcu-password name="password_confirm"></pcu-password>

Search field

<pcu-search-field></pcu-search-field>

Select

AttributeValuesDefaultDescription
data(Array of Object{label, value, selected, disabled})[]Select options
sizesmall/large/defaultdefaultSelect field size
multipletrue/falsefalseMultiple select
title(String)'Nothing selected'Default text of not selected items
name(String)HTML name attribute
onChange(Functions)Function to trigger event on change
<pcu-select data="[{ label: '1' }, { label: '2' }, { label: '3' }]">
</pcu-select>

Sidebar

AttributeValuesDefaultDescription
sideMenuItems(Array of Object{label, link})Sidebar items
<pcu-sidebar sideMenuItems="[{ label: 1, link: '/1' }, { label: 2, link: '/2' }]">
</pcu-sidebar>

Layouts

Sidebar layout

AttributeValuesDefaultDescription
title(String)Page title
templateTitle(Object{content, context})
sidebarMenuItems(Array)Items for sidebar (see Sidebar component)
breadcrumb(Array of Object{label, link}/String)Page breadcrumb. If item == Object, then item will displaying as link, if item == String, then item will display as simple text
<pcu-sidebar-layout
  sidebarMenuItems="..." 
  title="Page title" 
  [breadcrumb]="[{ label: 'previous page', link: ['..'] }, 'current page']"
></pcu-sidebar-layout>

Simple layout

AttributeValuesDefaultDescription
title(StringPage title
templateTitle(Object{content, context})
breadcrumb(Array of Object{label, link}/String)Page breadcrumb. If item == Object, then item will displaying as link, if item == String, then item will display as simple text
<pcu-simple-layout
  title="Page title" 
  [breadcrumb]="[{ label: 'previous page', link: ['..'] }, 'current page']"
></pcu-simple-layout>