Skip to content

Commit

Permalink
Added loadable styles
Browse files Browse the repository at this point in the history
  • Loading branch information
maryo committed Mar 17, 2020
1 parent 235cb05 commit 5ed4325
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "@vanio-cz/angular-material",
"homepage": "https://github.com/vaniocz/angular-material#readme",
"version": "0.0.4",
"version": "0.0.6",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"postbuild": "node -e \"var fs = require('fs'); fs.createReadStream('src/theming.scss').pipe(fs.createWriteStream('dist/theming.scss'))\"",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
Expand Down
11 changes: 3 additions & 8 deletions src/angular-material-module.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
import {MatDialogModule} from '@angular/material/dialog';
import {MatIconModule} from '@angular/material/icon';

import {ConfirmComponent} from './confirm/confirm-component';
import {ToasterComponent} from './toaster/toaster-component';
import {MatDialogModule} from "@angular/material/dialog";
import {MatButtonModule} from "@angular/material/button";

@NgModule({
imports: [
CommonModule,
MatButtonModule,
MatDialogModule,
MatIconModule,
],
imports: [CommonModule, MatButtonModule, MatDialogModule, MatIconModule],
declarations: [ConfirmComponent, ToasterComponent],
})
export class AngularMaterialModule {}
58 changes: 58 additions & 0 deletions src/theming.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@mixin loadable-theme($theme) {
$primary-color: mat-color(map-get($theme, primary));

.loadable {
position: relative;

&::before {
background-color: rgba(white, 0.75);
content: "";
opacity: 0;
position: absolute; top: 0; right: 0; bottom: 0; left: 0;
transition: opacity 0.3s ease, visibility 0.3s ease;
visibility: hidden;
}

&::after {
align-items: center;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" class="spinner" viewBox="0 0 100 100"><style>.spinner{animation:rotator 5s linear infinite;transform-origin:center}@keyframes rotator{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.path{stroke-dasharray:270;stroke-dashoffset:0;transform-origin:center;stroke:%23#{unquote("#{str-slice(ie-hex-str($primary-color), 4)}")};animation:dash 1.4s ease-in-out infinite}@keyframes dash{0%{stroke-dashoffset:265}50%{stroke-dashoffset:65;transform:rotate(90deg)}100%{stroke-dashoffset:265;transform:rotate(360deg)}}</style><circle class="path" fill="none" stroke-width="10" stroke-linecap="butt" cx="50" cy="50" r="40"/></svg>');
background-position: center calc(50% - 12px);
background-repeat: no-repeat;
background-size: 48px;
color: $primary-color;
display: flex;
justify-content: center;
opacity: 0;
padding-top: 55px;
position: absolute; top: 0; right: 0; bottom: 0; left: 0;
text-align: center;
transition: opacity 0.3s ease, visibility 0.3s ease;
visibility: hidden;
}

&:lang(en)::after {
content: "Loading…";
}

&:lang(cs)::after {
content: "Načítám…";
}

&.is-loading {
cursor: progress !important;

&::before,
&::after {
opacity: 1;
visibility: visible;
}
}
}

button.loadable.loadable::after {
background-position: center;
background-size: 20px;
content: "";
padding-top: 0;
}
}
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
"lib": [
"es2018",
"dom"
],
"paths": {
"@vanio-cz/angular-material/*": ["src/*"]
}
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
Expand Down

0 comments on commit 5ed4325

Please sign in to comment.