-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(isct-137): added loader component v4
- Loading branch information
Showing
14 changed files
with
170 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './public-api'; |
3 changes: 3 additions & 0 deletions
3
projects/fusion-ui/components/loader/v4/loader.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<svg class="fu-circle-svg" width="100%" height="100%"> | ||
<circle cx="50%" cy="50%" r="43.75%" [style.stroke-width]="strokeWidth" [style.animation-duration]="animationSpeed + 's'"/> | ||
</svg> |
41 changes: 41 additions & 0 deletions
41
projects/fusion-ui/components/loader/v4/loader.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
$pi: 3.14159265358979; | ||
|
||
:host { | ||
display: flex; | ||
box-sizing: border-box; | ||
width: 100%; | ||
height: 100%; | ||
|
||
box-sizing: border-box; | ||
position: relative; | ||
color: #ccc; | ||
|
||
.fu-circle-svg { | ||
margin: 0 auto; | ||
box-sizing: content-box; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
} | ||
|
||
.fu-circle-svg circle { | ||
stroke: currentColor; | ||
fill: transparent; | ||
transform-origin: center; | ||
stroke-dasharray: calc($pi * 50% * 2); | ||
animation: spinner linear 0s infinite normal none running; | ||
animation-duration: 1.4s | ||
} | ||
|
||
@keyframes spinner { | ||
from { | ||
stroke-dashoffset: calc($pi * 50% * 2); | ||
transform: rotateZ(0deg); | ||
} | ||
to { | ||
stroke-dashoffset: calc(calc($pi * 50% * 2) * -1); | ||
transform: rotateZ(390deg); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
projects/fusion-ui/components/loader/v4/loader.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LoaderComponent } from './loader.component'; | ||
|
||
describe('LoaderComponent', () => { | ||
let component: LoaderComponent; | ||
let fixture: ComponentFixture<LoaderComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ LoaderComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LoaderComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
projects/fusion-ui/components/loader/v4/loader.component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {StoryFn, Meta} from '@storybook/angular'; | ||
import {moduleMetadata} from '@storybook/angular'; | ||
import {dedent} from 'ts-dedent'; | ||
import {CommonModule} from '@angular/common'; | ||
import {LoaderComponent} from '@ironsource/fusion-ui/components/loader/v4'; | ||
|
||
export default { | ||
title: 'V4/Components/Loader', | ||
component: LoaderComponent, | ||
decorators: [ | ||
moduleMetadata({ | ||
declarations: [], | ||
imports: [CommonModule] | ||
}) | ||
], | ||
tags: ['autodocs'], | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: dedent` | ||
A loader web component is a visual element designed to indicate that content or data is being loaded or processed on a webpage. The loader informs users that the system is working in the background to fetch or process information, preventing confusion or frustration during brief delays. Loader web components enhance user experience by providing a clear visual cue of ongoing activity, allowing users to understand that their request is being handled. | ||
##Usage | ||
- Put \`\`\`import { LoaderComponent } from '@ironsource/fusion-ui/components/loader/v4';\`\`\` in your component script block | ||
- Add it to your component (if it standalone component) or module import \`\`\`imports: [CommonModule, LoaderComponent],\`\`\` | ||
- And use it in component template: \`\`\`<fusion-loader [style.width]="size" [style.height]="size" [strokeWidth]="strokeWidth"></fusion-loader>\`\`\` | ||
` | ||
} | ||
}, | ||
options: { | ||
showPanel: true, | ||
panelPosition: 'bottom' | ||
} | ||
}, | ||
args: { | ||
size: '100px', | ||
strokeWidth: 2 | ||
} | ||
} as Meta<LoaderComponent>; | ||
|
||
const LoaderTemplate: StoryFn<LoaderComponent> = (args: LoaderComponent) => ({ | ||
props: args, | ||
template: `<fusion-loader [style.width]="size" [style.height]="size" [strokeWidth]="strokeWidth"></fusion-loader>` | ||
}); | ||
|
||
export const Basic = { | ||
render: LoaderTemplate | ||
}; |
22 changes: 22 additions & 0 deletions
22
projects/fusion-ui/components/loader/v4/loader.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {ChangeDetectionStrategy, Component, Input} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'fusion-loader', | ||
standalone: true, | ||
imports: [CommonModule], | ||
templateUrl: './loader.component.html', | ||
styleUrls: ['./loader.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class LoaderComponent { | ||
@Input() set strokeWidth(value: number) { | ||
this._strokeWidth = value; | ||
} | ||
|
||
get strokeWidth(): number { | ||
return this._strokeWidth ?? 2; | ||
} | ||
|
||
private _strokeWidth: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"$schema": "../../../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public-api.ts" | ||
}, | ||
"allowedNonPeerDependencies": ["."] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './loader.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters