-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add progress bar component EBS-1515 (#238)
* feat(ui): add progress bar component EBS-1515 * chore(styles): update metadata-card shades and bordering EBS-1515 * feat(ui): add progress bar component EBS-1515 * feat(ui): add progress bar component improved desktop view EBS-1515 * feat(ui): clean up inputs and split html EBS-1515 * format(ui): made Stylelint config more flexible with font-weight and border-radius values * format(ui): lower severity of block-no-empty rule Stylelint reports * refactor(ui): refactored cvi-progress-bar styles and ProgressBarComponent Angular component, removed dead code * docs(ui): added an HTML story for cvi-progress-bar Sass component --------- Co-authored-by: Aleksandr Beliaev <[email protected]>
- Loading branch information
1 parent
514abae
commit 8e8ee93
Showing
14 changed files
with
461 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,7 @@ | |
.cvi-metadata-card { | ||
@include cvi-metadata-card; | ||
} | ||
|
||
.cvi-progress-bar { | ||
@include cvi-progress-bar; | ||
} |
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,126 @@ | ||
@mixin cvi-progress-bar($base: &) { | ||
--comment: 'Progress bar component that appears as a horizontal bar on desktop and a circle on mobile'; | ||
|
||
/* stylelint-disable-next-line color-no-hex, declaration-property-value-allowed-list */ | ||
--color: #599e75; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
@include cvi-breakpoint-down(sm) { | ||
position: relative; | ||
width: calc(var(--circle-radius) * 2 * 1px); | ||
height: calc(var(--circle-radius) * 2 * 1px); | ||
} | ||
|
||
@include cvi-breakpoint-up(sm) { | ||
gap: var(--cvi-spacing-haapsalu); | ||
} | ||
|
||
@at-root { | ||
#{$base}.is-progress-finished { | ||
#{$base}__label-wrapper { | ||
@include cvi-breakpoint-down(sm) { | ||
font-size: var(--cvi-font-size-70); | ||
} | ||
} | ||
} | ||
|
||
#{$base}__circular-bar { | ||
@include cvi-breakpoint-down(sm) { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
z-index: -1; | ||
} | ||
|
||
@include cvi-breakpoint-up(sm) { | ||
display: none; | ||
} | ||
} | ||
|
||
#{$base}__circular-bar-background { | ||
fill: none; | ||
stroke: var(--cvi-color-black-coral-0); | ||
stroke-width: var(--circle-stroke-width); | ||
} | ||
|
||
#{$base}__circular-bar-progress { | ||
fill: none; | ||
stroke: var(--color); | ||
stroke-width: var(--circle-stroke-width); | ||
transform: rotate(-90deg); | ||
transform-origin: 50% 50%; | ||
transition: stroke-dashoffset 0.35s; | ||
stroke-linecap: round; | ||
} | ||
|
||
#{$base}__horizontal-bar { | ||
--height: 18px; | ||
|
||
@include cvi-breakpoint-down(sm) { | ||
display: none; | ||
} | ||
|
||
@include cvi-breakpoint-up(sm) { | ||
width: 100%; | ||
height: var(--height); | ||
border-radius: calc(var(--height) / 2); | ||
background-color: var(--cvi-color-black-coral-0); | ||
position: relative; | ||
|
||
&::before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: var(--progress); | ||
height: 100%; | ||
background-color: var(--color); | ||
border-radius: inherit; | ||
} | ||
} | ||
} | ||
|
||
#{$base}__numeric-content { | ||
color: var(--cvi-color-black-coral-20); | ||
font-weight: var(--cvi-font-weight-delta); | ||
|
||
@include cvi-breakpoint-down(sm) { | ||
font-size: var(--cvi-font-size-250); | ||
} | ||
} | ||
|
||
#{$base}__label-wrapper { | ||
display: flex; | ||
align-items: center; | ||
font-size: var(--cvi-font-size-80); | ||
line-height: var(--cvi-line-height-300); | ||
|
||
@include cvi-breakpoint-down(sm) { | ||
flex-direction: column; | ||
text-align: center; | ||
padding-inline: calc( | ||
var(--circle-stroke-width) * 1px + var(--cvi-spacing-paldiski) | ||
); | ||
} | ||
|
||
@include cvi-breakpoint-up(sm) { | ||
gap: var(--cvi-spacing-paldiski); | ||
} | ||
} | ||
|
||
#{$base}__label { | ||
color: var(--cvi-color-black-coral-12); | ||
} | ||
|
||
#{$base}__success-icon { | ||
fill: var(--color); | ||
|
||
@include cvi-breakpoint-down(sm) { | ||
height: 40px; | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ $cvi-font-sizes: ( | |
|
||
$cvi-line-heights: ( | ||
100: 1, | ||
300: 1.3, | ||
500: 1.5 | ||
); | ||
|
||
|
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,24 @@ | ||
<div class="cvi-progress-bar__label-wrapper"> | ||
<cvi-ng-icon *ngIf="progressFinished" name="check" svgClass="cvi-progress-bar__success-icon"> | ||
</cvi-ng-icon> | ||
|
||
<span class="cvi-progress-bar__label"> | ||
<ng-container *ngIf="!progressFinished"> | ||
{{ progressMessage }} | ||
</ng-container> | ||
<ng-container *ngIf="progressFinished"> | ||
{{ successMessage }} | ||
</ng-container> | ||
</span> | ||
|
||
<span *ngIf="!progressFinished" class="cvi-progress-bar__numeric-content"> | ||
{{ progressValue }}/{{ progressValueMax }} | ||
</span> | ||
</div> | ||
|
||
<div *ngIf="!progressFinished" class="cvi-progress-bar__horizontal-bar"></div> | ||
|
||
<svg class="cvi-progress-bar__circular-bar" xmlns="http://www.w3.org/2000/svg" [attr.width]="getCircleDiameter()" [attr.height]="getCircleDiameter()" [attr.viewBox]="'0 0 ' + getCircleDiameter() + ' ' + getCircleDiameter()"> | ||
<circle class="cvi-progress-bar__circular-bar-background" [attr.cx]="circleRadius" [attr.cy]="circleRadius" [attr.r]="getCircleBoundaries()" /> | ||
<circle class="cvi-progress-bar__circular-bar-progress" [attr.cx]="circleRadius" [attr.cy]="circleRadius" [attr.r]="getCircleBoundaries()" [ngStyle]="{ 'stroke-dasharray': getCircleCircumference() + ' ' + getCircleCircumference(), 'stroke-dashoffset': getCircleOffset() }" /> | ||
</svg> |
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,13 @@ | ||
## General description | ||
|
||
| Feature | Description | | ||
|----------------------------|-------------------| | ||
| Selector | `cvi-ng-progress-bar` | | ||
| Component name | `ProgressBarComponent` | | ||
| Content | - | | ||
| Permitted parent/ancestors | - | | ||
| Permitted children | - | | ||
|
||
## Where to use | ||
|
||
Use if you need to visualise a progress. The component renders as a circle on mobile and as a horizontal bar on desktop. |
108 changes: 108 additions & 0 deletions
108
libs/ui/src/lib/progress-bar/progress-bar.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,108 @@ | ||
import { componentWrapperDecorator, Meta } from '@storybook/angular'; | ||
import notes from '../progress-bar/progress-bar.component.md'; | ||
import { ProgressBarComponent } from './progress-bar.component'; | ||
|
||
const wrapperDecorators = [ | ||
componentWrapperDecorator(ProgressBarComponent, ({ args }) => { | ||
return args; | ||
}), | ||
]; | ||
|
||
export default { | ||
title: 'Angular/Progress bar', | ||
component: ProgressBarComponent, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: notes, | ||
}, | ||
}, | ||
layout: 'padded', | ||
}, | ||
args: { | ||
progressValue: 0, | ||
progressMessage: 'Lõpetatud tegevused:', | ||
successMessage: 'Kõik tegevused lõpetatud', | ||
}, | ||
} as Meta<ProgressBarComponent>; | ||
|
||
export const Default = { | ||
render: (args: ProgressBarComponent) => ({ | ||
props: args, | ||
template: `{{ content }}`, | ||
}), | ||
decorators: wrapperDecorators, | ||
}; | ||
|
||
export const Mobile0 = { | ||
...Default, | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'iphone12mini', | ||
}, | ||
}, | ||
}; | ||
|
||
export const Mobile1 = { | ||
...Default, | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'iphone12mini', | ||
}, | ||
}, | ||
args: { | ||
progressValue: 1, | ||
}, | ||
}; | ||
|
||
export const Mobile2 = { | ||
...Default, | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'iphone12mini', | ||
}, | ||
}, | ||
args: { | ||
progressValue: 2, | ||
}, | ||
}; | ||
|
||
export const Mobile3 = { | ||
...Default, | ||
parameters: { | ||
viewport: { | ||
defaultViewport: 'iphone12mini', | ||
}, | ||
}, | ||
args: { | ||
progressValue: 3, | ||
}, | ||
}; | ||
|
||
export const Desktop0 = { | ||
...Default, | ||
args: { | ||
progressValue: 0, | ||
}, | ||
}; | ||
|
||
export const Desktop1 = { | ||
...Default, | ||
args: { | ||
progressValue: 1, | ||
}, | ||
}; | ||
|
||
export const Desktop2 = { | ||
...Default, | ||
args: { | ||
progressValue: 2, | ||
}, | ||
}; | ||
|
||
export const Desktop3 = { | ||
...Default, | ||
args: { | ||
progressValue: 3, | ||
}, | ||
}; |
Oops, something went wrong.