Gathering detailed insights and metrics for @uoh/ngx-theme
Gathering detailed insights and metrics for @uoh/ngx-theme
University of Haifa theme containing core features for angular apps development
npm install @uoh/ngx-theme
Typescript
Module System
Node Version
NPM Version
TypeScript (66.54%)
SCSS (15.87%)
HTML (13.46%)
JavaScript (3.72%)
CSS (0.42%)
Total Downloads
8,148
Last Day
1
Last Week
18
Last Month
113
Last Year
769
1 Stars
379 Commits
2 Branches
4 Contributors
Minified
Minified + Gzipped
Latest Version
11.2.2
Package Id
@uoh/ngx-theme@11.2.2
Unpacked Size
739.27 kB
Size
192.69 kB
File Count
184
NPM Version
6.14.13
Node Version
14.17.0
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
-61.7%
18
Compared to previous week
Last month
151.1%
113
Compared to previous month
Last year
-41.4%
769
Compared to previous year
1
4
A collection of University of Haifa modules to be integrated in an Angular project using Material Design (see the CHANGELOG).
@angular/material
& @angular/cdk
.index.html
.Rubik
) to the index.html
.angular.json
file.app.module
(the accessibility/body, header, footer, back-to-top & spinner modules) and sets them into the app.component
html.1$ ng add @uoh/ngx-theme
The scss mixins will be imported in the stylePreprocessorOptions
--> includePaths
section in the angular.json
file. Thus, they will be available throughout all the scss in your app.
Thus, for example, you can import & use the theme mixins in the following way:
1// app.component.scss 2@import 'theme'; 3 4// Hide the .my-class elements on medium screens 5@include uoh-screen(medium) { 6 .my-class { 7 display: none; 8 } 9}
1$ npm install @uoh/ngx-theme --save
This library includes the following modules:
mat-card
).uoh-content
.This theme contains a default and a dark color theme, a layout design and presets for responsive tables. It also contains scss functions and mixins to make the application styling easier.
ng add
)Add a link
tag to the head
section of your index.html
file to import the Rubik
font (the theme font).
For example:
1<link href="https://fonts.googleapis.com/css?family=Rubik:400,700&display=swap" rel="stylesheet">
ng add
)First, install angular material.
Secondly, add the following tag to the head
section of your index.html
file (required for the accessibility, header and back-to-top modules):
1<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
ng add
)Add the following line to the options
--> assets
array under both the build
and the test
sections in the angular.json
file:
1{ "glob": "favicon.ico", "input": "./node_modules/@uoh/ngx-theme/assets", "output": "/" }
ng add
)Add the following lines to the styles.scss
file in your application:
1@import '~@uoh/ngx-theme/theme'; // Or in angular 6 and above add './node_modules/@uoh/ngx-theme/theme' to build->options->stylePreprocessorOptions->includePaths` section in the `angular.json` file 2 3@include uoh-theme();
The uoh-theme
mixin contains the configurations for all the modules. If you want to avoid some of these presets (to minimize the size of the css output) you must pass a configuration map parameter to the mixin with the modules you want to exclude.
For example:
1// Exclude all the modules (include only the core): 2$config: ( 3 layout: false, 4 table: false, 5 card: false, 6 extra: false, 7 print: false, 8 accessibility: false, 9 header: false, 10 footer: false, 11 spinner: false, 12 content-padding: false 13); 14 15@include uoh-theme($config...);
The layout is based on the window sizes defined in the material specifications: xsmall
, small
, medium
, large
, xlarge
(for further information see: material breakpoints). The layout presets includes the classes uoh-hide-on-#{window-size}
which hide the contents when the window size is between the minimum and the maximum breakpoints defined in the material specifications. The presets includes also a fill-remaining-space
class to fill the remaining space in a flexbox.
Furthermore, you can use one of the following mixins or functions to implement a custom behavior.
uoh-screen
: Sets the content to the screen breakpoints min and max widths.uoh-screen-min
: Sets the content to the screen breakpoint's min-width. For example: 'medium' will set the content to min-width: 960px.uoh-screen-max
: Sets the content to the screen breakpoint's max-width. For example: 'medium' will set the content to max-width: 1279.99px.Usage:
1// For a certain window size 2@include uoh-screen(medium) { 3 .my-component { 4 display: none; 5 } 6} 7 8// Will result in: 9@media screen and (min-width: 960px) and (max-width: 1279.99px) { 10 .my-component { 11 display: none; 12 } 13} 14 15// Or include a range of window sizes 16@include uoh-screen(small, large) { 17 .my-component { 18 display: block; 19 } 20} 21 22// Will result in: 23@media screen and (min-width: 600px) and (max-width: 1919.99px) { 24 .my-component { 25 display: none; 26 } 27} 28 29// Or use the min / max mixins 30@include uoh-screen-min(small) { 31 // or uoh-screen-max(small) 32 .my-component { 33 display: none; 34 } 35} 36 37// Will result in: 38@media screen and (min-width: 600px) { 39 // and (max-width: 600px) for uoh-screen-max 40 .my-component { 41 display: none; 42 } 43}
uoh-breakpoint-min
: Returns the minimum value for a breakpoint. For example: 'medium' will return 1024px.uoh-breakpoint-max
: Returns the maximum value for a breakpoint. For example: 'medium' will return 1439px.uoh-breakpoint-next
: Returns the name of the next breakpoint. For example: 'medium' will return 'large'.Usage:
1.my-component { 2 min-width: uoh-breakpoint-min(small); // Compiles to min-width: 600px 3 max-width: uoh-breakpoint-max(small); // Compiles to max-width: 1023px 4} 5.my-other-component { 6 $next-breakpoint: uoh-breakpoint-next(small); // Returns medium 7 max-width: uoh-breakpoint-max($next-breakpoint); // Compiles to max-width: 1439px 8}
In order to utilize the responsive support for your tables you need to add the uoh-table
class to your table and set a title property for each column as follows:
1 <table mat-table [dataSource]="dataSource" matSort class="uoh-table" dir="rtl"> 2 <ng-container matColumnDef="courseName"> 3 <th mat-cell-header *matHeaderCellDef mat-sort-header>קורס</th> 4 <td mat-cell *matCellDef="let course" class="row-title"> 5 {{course.courseNumber}} - {{course.courseName}} 6 </td> 7 </ng-container> 8 <ng-container matColumnDef="lecturer"> 9 <th mat-cell-header *matHeaderCellDef mat-sort-header>מרצה</th> 10 <td mat-cell title="מרצה" *matCellDef="let course">{{course.lecturer}}</td> 11 </ng-container> 12 13 <tr mat-header-row *matHeaderRowDef="columnsDisplayed"></tr> 14 <tr mat-row *matRowDef="let course; columns: columnsDisplayed" (click)="selection.toggle(course)"></tr> 15 </table>
On mobile this will be transformed to something similar as the following:
(course number) - (course name)
קורס: (lecturer)
Please, note that the
row-title
class transforms the cell into the title of the row (kind of a header) in the mobile version.
Once the core theming was installed, you can use the $default-theme
and $dark-theme
variables in order to your components themes:
1@import '~@uoh/ngx-theme/theme'; 2@import './app/app.component.theme.scss'; 3 4@include uoh-core(); 5@include app-theme($default-theme); 6 7// You have to use the same class name to be compatible with the accessibility module. 8.dark-theme { 9 @include app-theme($dark-theme); 10}
The theme file also includes two presets: the uoh-success
, uoh-success-fill
, uoh-error
and the uoh-error-fill
classes. These can be used in your application to set two extra types of messages.
It includes the following classes: uoh-no-print
and uoh-print-only
. The first one eliminates the html tag and its children from print. The second one, sets a tag and its children to be visible only on print.
This module adds an accessibility menu to set the font size and the theme for the application.
Import the UohAccessibilityModule
in your app.module.ts
. For example:
1import { UohAccessibilityModule } from '@uoh/ngx-theme'; 2 3@NgModule({ 4 declarations: [AppComponent], 5 imports: [BrowserModule, UohAccessibilityModule, MatCardModule], 6 providers: [], 7 bootstrap: [AppComponent] 8}) 9export class AppModule {}
Then, wrap all the contents of your app (including header, footer, etc.) inside the uoh-accessibility
tag:
1<uoh-accessibility [dir]="dir" manifestUrl="https://www.example.com/accessibility-manifest"> 2 <mat-card class="small-card"> 3 <mat-card-content> 4 <div style="text-align:center"> 5 <h1> 6 Welcome to {{ title }}! 7 </h1> 8 </div> 9 <h2>University of Haifa</h2> 10 </mat-card-content> 11 </mat-card> 12</uoh-accessibility>
Note: You can set the direction of all the app contents by setting the
dir
input variable tortl
(default) orltr
.
Note: You can provide your own link to the accessibility manifest instead of using the default one, linked to the University of Haifa accessibility manifest.
Note: If you want to set custom labels for the buttons and headers you can set the
labels
input. To learn about the fields that should be set in this input object you can import theUohAccessibilityLabels
from the same module. For example:
1labels: UohAccessibilityLabels = { 2 header: 'Accessibility', 3 increaseFont: 'Increase font size', 4 decreaseFont: 'Decrease font size', 5 lowContrast: 'High contrast', 6 highContrast: 'Low contrast', 7 reset: 'Reset', 8 manifest: 'Accessibility manifest' 9};
This module contains the uoh-body
component which is used to wrap your app components and apply to them the design rules of this theme. The uoh-body
is required if you do not use the accessibility module. For example:
1<uoh-body dir="rtl"> 2 <uoh-spinner></uoh-spinner> 3 <uoh-header subtitle="בדיקה" [user]="user" (logOut)="logOut()"></uoh-header> 4 <uoh-back-to-top minScroll="100"></uoh-back-to-top> 5 <router-outlet></router-outlet> 6 <uoh-footer [version]="false"></uoh-footer> 7</uoh-body>
Note: You can set the
dir
of theuoh-body
as in the accessibility module.
This module contains a header with the title for the application, the university logo and logic for log-in functionality.
Add the following line to the options
--> assets
array under both the build
and the test
sections in the angular.json
file:
1{ "glob": "**/*", "input": "./node_modules/@uoh/ngx-theme/assets", "output": "/assets/" }
In order to import the module add the following lines to your app.module.ts
:
1import { UohHeaderModule } from '@uoh/ngx-theme'; 2 3@NgModule({ 4 imports: [ UohHeaderModule ], 5 ... 6})
Then add the uoh-header
component to the top section of your app.component.html
. For example:
1 <uoh-header header="מינה" subheader="מערכת לניהול השגים" [user]="user" (logOut)="onLogOut($event)"> 2 <a uohHeaderLink="https://www.haifa.ac.il" uohHeaderLinkIcon="face"> אוני׳ חיפה </a> 3 <a uohHeaderLink="https://www.google.com"> גוגל </a> 4 <a [uohHeaderRouterLink]="['two']" uohHeaderLinkIcon="thumb_up_alt"> דף 2 </a> 5 <a [uohHeaderMenuLink]="menu" uohHeaderLinkIcon="help"> עזרה </a> 6 </uoh-header> 7 <mat-menu #menu="matMenu"> <button mat-menu-item>מוקד תמיכה</button> <button mat-menu-item>הדרכות וידיאו</button> </mat-menu>
Note: If you use
uoh-accessibility
remember to include theuoh-header
inside it.
The header component accepts five input variables:
header
: A string to be used as the main header title.subheader
: A string to be used as the header subtitle. If left undefined it will not be displayed.user
: An object containing the name, the details and last login of the user. If set, a log out button will be displayed on the header, next to the user name. When the user presses the log out button an event will be fired. This event can be catched by binding a function to the logOut
output.labels
: An object containing the labels for buttons and headers: the alt attribute for the logo, the label for the logout button and the aria-label for the more links button (mobile view). For more information about the fields integrating it use the UohHeaderLabels
from the same module.logoLinkUrl
: A string containing the url to open when the logo is clicked. The default url is https://www.haifa.ac.il/
.clickableTitle
: Whether clicking on the header and subheader the user should be redirected to the starting page in the app. The default is true
.Furthermore, the uohHeaderLink
, uohHeaderRouterLink
and uohHeaderMenuLink
directives can be used to display links in the header (these should be contained inside the uoh-header
tags):
uohHeaderLink
is used to add external links.uohHeaderRouterLink
is used to set internal links (routerLinks
).uohHeaderMenuLink
is used to display menus (a mat-menu
instance should be passed).
The uohHeaderLinkIcon
option can be used to display a mat-icon
next to the link label (see above example).For example, in your component ts file:
1export class AppComponent { 2 header = 'Registration'; 3 user: UohHeaderUser; 4 labels: UohHeaderLabels = { 5 logo: 'University of Haifa', 6 logOut: 'Logout', 7 links: 'Some links' 8 }; 9 private authorize$: Subscription; 10 11 constructor(private authService: AuthService) {} 12 13 onLogIn(username: string, password: string): void { 14 this.authorize$ = this.authService.authorize(username, password).subscribe(user => { 15 this.user = { 16 name: `${user.firstName} ${user.lastName}`, 17 details: `${user.email}<br>Birthdate: ${user.birthdate}`, 18 lastLogin: `Last login on ${user.lastLogin}` 19 }; 20 }); 21 } 22 23 onLogOut(loggedOut: boolean): void { 24 this.user = undefined; 25 console.log('log out', loggedOut); 26 } 27}
This module contains a footer with details about the university and the current version of the application (optional).
In order to import the module add the following lines to your app.module.ts
:
1import { UohFooterModule } from '@uoh/ngx-theme'; 2 3@NgModule({ 4 imports: [ UohFooterModule ], 5 ... 6})
Then add the uoh-footer
component to the bottom section of your app.component.html
. For example:
1<uoh-footer [version]="false"></uoh-footer>
The footer component accepts a version
input variable. If it is omitted, the component will try to automatically retrieve the version number from your app's package.json
file. Alternatively, you can pass a string to it in order to set a custom version name or false
(as in the above example) if you don't want it to be displayed.
The theme includes a set of cards with different sizes according to the layout breakpoints: uoh-card-xsmall
with max-width: 599.99px
, uoh-card-small
with max-width: 959.99px
and so on.
The card module includes both a uohCard
directive (applicable also to mat-card
components) and a uoh-card
component.
Usage:
1<uoh-card size="xsmall" collapse="true"> 2 <h3>Test!</h3> 3 <p>Hello this is a test for uoh-card</p> 4</uoh-card>
Or use the directive to apply it to other html tag:
1<mat-card uohCard="medium" uohCardCollapse="false"> 2 <mat-card-content> 3 <p>Hello this is a test for uoh-card</p> 4 </mat-card-content> 5</mat-card>
The uoh-card
accepts a size
(the default is medium
) and a collapse
input (which defaults to true
). If the collapse is set to true
and there is no content-padding
(see the Include the theme
section above), the borders of the uoh-cards will collapse when the breakpoint is reached. For example: if the size
is set to xsmall
is used, the box-shadow will disappear when the screen less or equal to 599.99px.
Please, note also that there is no max-width set for the
xlarge
size.
This module adds a button that returns the focus to the top of the page.
In order to import this module add the following lines to your app.module.ts
:
1import { UohBackToTopModule } from '@uoh/ngx-theme'; 2 3@NgModule({ 4 imports: [ UohBackToTopModule ], 5 ... 6})
Then add the following line to your app.component.html
or your components html templates, depending on whether you want the component in all your pages or custom sections of your application:
1<uoh-back-to-top [minScroll]="75"></uoh-back-to-top>
The component accepts a minScroll
input variable to set the minimum amount of pixels scrolled required in order to display the back-to-top button. If left unset, the default value for this variable is 100
pixels.
Note: If needed you can inject the
UohBackToTop
service and use the same functionality in your components. The service includes a cross-browserback
method which returns the focus to the top of the page.
If you want to add this functionality only for mobile you will have to add the following configuration to your styles.scss
:
1.uoh-back-to-top { 2 display: none; 3} 4 5@media screen and (max-width: 600px) { 6 .uoh-back-to-top { 7 display: block; 8 } 9}
This module includes a spinner loader with the logo of the university.
In order to import the spinner module add the following lines to your app.module.ts
:
1import { UohSpinnerModule } from '@uoh/ngx-theme'; 2 3@NgModule({ 4 imports: [ UohSpinnerModule ], 5 ... 6})
Then add the uoh-spinner
component to your app.component.html
:
1<uoh-spinner [size]="{width: 120}" [duration]="2000" [fps]="60" [minStrokeWidth]="5" [maxStrokeWidth]="30" 2 [circle]="{stop1: 0.5, stop2: 0.7}"></uoh-spinner>
size
- An object containing the width and/or the height of the spinner. Note: only one of them is required, the other will be automatically calculated to constrain proportionsduration
- A number representing the duration for the animation in millisecondsfps
- A number representing the frames per second for the animationminStrokeWidth
- A number representing the minimum width of the linemaxStrokeWidth
- A number representing the maximum width of the line (the starting point)circle
- An object containing two stops representing the percentage of frames to reach the minimum (step1) and the maximum widths (step2)path
- A string containing svg coordinates for the figure (equivalent to the d attribute in a svg path)The spinner is activated and deactivated by calling the UohSpinner
methods add
and remove
, respectively.
Note that the remove
method will cancel only the last add
method called. Thus, if you called the add
method consecutively more than once and call the remove
method once, the spinner will still be on screen. If you want to remove all the spinners from screen at once use the clear
method. For further information refer to issue number #7.
Furthermore, you can use the observable pipeable versions of the above methods:
addOnEvent
- Adds a spinner when the observable firesremoveOnFinalize
- Removes a spinner when the observable finalizesclearOnFinalize
- Removes all the spinners when the observable finalizesThe UohSpinner
exposes an Observable of type Boolean named loading
, which can be used to determine if a loading procedure is taking place.
For example, in your component.ts:
1import { UohSpinner } from '@uoh/ngx-theme'; 2 3@Component({ 4 selector: 'app', 5 template: ` 6 <h1>{{ title }}</h1> 7 <button (click)="loadStuff()" [disabled]="spinner.loading | async">Load Stuff</button> 8 <uoh-spinner></uoh-spinner> 9 ` 10}) 11export class AppComponent { 12 data: Stuff[]; 13 14 constructor(public spinner: UohSpinner, private apiService: ApiService) {} 15 16 loadStuff(): void { 17 this.spinner.add(); 18 this.apiService 19 .loadStuff() 20 .pipe(this.spinner.clearOnFinalize()) 21 .subscribe(data => (this.data = data)); 22 } 23 24 loadMoreStudd(): void { 25 this.test$ = of(1000, 2000, 2340).pipe( 26 concatMap(val => 27 of(`Delayed by ${val}`).pipe( 28 this.spinner.addOnEvent(), 29 delay(val) 30 this.spinner.removeOnFinalize() 31 ) 32 ) 33 ); 34 } 35}
This service can be used to get the properties of the uoh-content
(that is, the tag that wraps all your app contents).
You can get the following properties: width, height, top, right, bottom, left, x and y (the last two if they are supported by the browser).
MIT © Pablo Saracusti
No vulnerabilities found.
No security vulnerabilities found.