Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1358 progress bar component #1377

Merged
merged 74 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
81c6153
Progress bar component - initial structure
anna-lach Jun 24, 2024
abab6e5
indeterminate property
anna-lach Jun 25, 2024
6985dc3
Merge remote-tracking branch 'origin/main' into feature/1358-POC-prog…
anna-lach Jun 25, 2024
807d2fd
updated color of hint in SL theme
DanielleRameau Jun 25, 2024
045408f
added height token and color tokens progress bar in SL theme
DanielleRameau Jun 25, 2024
dadbdc7
added progress bar warning colors
DanielleRameau Jun 25, 2024
2c2aef8
Some progress bar properties, partially added styling and story changes
anna-lach Jun 25, 2024
2286bd8
Merge remote-tracking branch 'origin/main' into 'feature/1358-POC-pro…
anna-lach Jun 26, 2024
b8270b4
improved warning color palette SL
DanielleRameau Jun 26, 2024
9c685d8
updated warning color progress bar
DanielleRameau Jun 26, 2024
c2473f8
changed warning color progress bar
DanielleRameau Jun 26, 2024
4b77e1c
component changes, stories, partially styling, properties and layout
anna-lach Jun 26, 2024
38a416d
added spacing token for progress bar
DanielleRameau Jun 27, 2024
3ccd426
Added 1 background color token for the progress bar
DanielleRameau Jun 27, 2024
08d1e69
proper icons for statuses/states, stories improvements, styling chang…
anna-lach Jun 27, 2024
1dc1a26
updated spacing gaps in progress bar
DanielleRameau Jun 28, 2024
3d09422
Merge remote-tracking branch 'origin/main' into 'feature/1358-POC-pro…
anna-lach Jun 28, 2024
cd5b658
Styling improvements, state instead of status, stories changes, remov…
anna-lach Jun 28, 2024
ef81f61
Merge remote-tracking branch 'origin/main' into 'feature/1358-POC-pro…
anna-lach Jul 1, 2024
f52d525
update
DanielleRameau Jul 1, 2024
bedfc11
last update
DanielleRameau Jul 1, 2024
d62b6bc
progress bar docs directory structure
anna-lach Jul 1, 2024
983f5f1
component changes after new figma improvements, styles changes, parti…
anna-lach Jul 1, 2024
808e59d
improved danger color
DanielleRameau Jul 1, 2024
3e3258c
improved all story
anna-lach Jul 2, 2024
f05f820
updated progress bar bingel int and dc
DanielleRameau Jul 2, 2024
d3b7c60
updated progress bar clickedu
DanielleRameau Jul 2, 2024
4e265b1
updated progress bar etsl
DanielleRameau Jul 2, 2024
d33e836
updated progress bar itslearning
DanielleRameau Jul 2, 2024
789439a
updated progress bar kampus
DanielleRameau Jul 2, 2024
8337512
improved helper kampus
DanielleRameau Jul 2, 2024
178243b
improved hint bingel dc + int
DanielleRameau Jul 2, 2024
36e6acf
updated hint clickedu
DanielleRameau Jul 2, 2024
5dbe64d
updated hint etsl
DanielleRameau Jul 2, 2024
c9df0af
updated hint itslearning
DanielleRameau Jul 2, 2024
9a00e44
updated magister light progress bar
DanielleRameau Jul 2, 2024
d7af2ea
updated magister dark progress bar
DanielleRameau Jul 2, 2024
83b4af2
updated hint magister dark
DanielleRameau Jul 2, 2024
3359e22
updated max online progress bar
DanielleRameau Jul 2, 2024
d34dc13
updated progress bar my digital book
DanielleRameau Jul 2, 2024
faf3d01
updated progress bar neon light
DanielleRameau Jul 2, 2024
014d7f8
neon dark
DanielleRameau Jul 2, 2024
346ab07
updated TEAS progress bar
DanielleRameau Jul 2, 2024
1630c39
indeterminate animation changes, accessibility improvements, stories …
anna-lach Jul 2, 2024
e987148
dependencies and component cleaning
anna-lach Jul 3, 2024
a6746ce
styling cleanup
anna-lach Jul 3, 2024
6b289f2
Merge remote-tracking branch 'origin/main' into feature/1358-POC-prog…
anna-lach Jul 3, 2024
1a92f02
Stories changes
anna-lach Jul 3, 2024
5f1d14f
Partially added unit tests
anna-lach Jul 3, 2024
875f7c7
Added progress bar documentation
DanielleRameau Jul 3, 2024
41022a8
Merge branch 'feature/1358-POC-progress-indicator-component' of https…
DanielleRameau Jul 4, 2024
53aea8f
added descriptions
DanielleRameau Jul 4, 2024
7e2fb78
Unit tests changes, improved accessibility - added aria-live to the c…
anna-lach Jul 4, 2024
a44abae
Merge remote-tracking branch 'origin/feature/1358-POC-progress-indica…
anna-lach Jul 4, 2024
c6a8c18
Merge remote-tracking branch 'origin/main' into feature/1358-POC-prog…
anna-lach Jul 4, 2024
ab5f4f3
More tests added, some small changes and renaming
anna-lach Jul 5, 2024
3c1052b
removed coverage
anna-lach Jul 5, 2024
fe01d5b
unnecessary test removed
anna-lach Jul 5, 2024
891192e
removed console log
anna-lach Jul 5, 2024
54f71f5
Merge branch 'feature/1358-POC-progress-indicator-component' of https…
DanielleRameau Jul 5, 2024
803f0c5
tests fixes
anna-lach Jul 5, 2024
2301f91
aria-live change
anna-lach Jul 5, 2024
772a804
aria-live changes
anna-lach Jul 5, 2024
83ca904
aria-live improvement to read % every time, tests fixes
anna-lach Jul 5, 2024
00ffa9d
Dev part of documentation, aria-busy changes
anna-lach Jul 5, 2024
b903d58
Improved accessibility and styling
anna-lach Jul 5, 2024
efb6004
test fixed
anna-lach Jul 5, 2024
65d0d3b
Partially added changes after code review
anna-lach Jul 8, 2024
5344eb9
changes after code review
anna-lach Jul 8, 2024
7f5b2f4
variant instead of state
anna-lach Jul 8, 2024
15aaa84
Changeset
anna-lach Jul 8, 2024
268df9d
dependencies changes
anna-lach Jul 8, 2024
184e02e
website changes - with `variant`
anna-lach Jul 8, 2024
e013343
changeset changes to patch and new changeset for SL theme - warning c…
anna-lach Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/components/format-date/src/format-date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FormatDate } from './format-date.js';

describe('sl-format-number', () => {
let el: FormatDate;
const date = new Date(Date.UTC(2022, 11, 17, 14, 5, 42));
const date = new Date(2022, 11, 17, 14, 5, 42);

describe('defaults', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -111,7 +111,6 @@ describe('sl-format-number', () => {
el.timeZoneName = 'long';

await el.updateComplete;
console.log(el.renderRoot);
expect(el.renderRoot).to.have.trimmed.text('12/17/2022, Coordinated Universal Time');
});

Expand Down
1 change: 1 addition & 0 deletions packages/components/progress-bar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/progress-bar.js';
49 changes: 49 additions & 0 deletions packages/components/progress-bar/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@sl-design-system/progress-bar",
"version": "0.0.0",
"description": "Progress-bar component for the SL Design System",
"license": "Apache-2.0",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"repository": {
"type": "git",
"url": "https://github.com/sl-design-system/components.git",
"directory": "packages/components/progress-bar"
},
"homepage": "https://sanomalearning.design/components/progress-bar",
"bugs": {
"url": "https://github.com/sl-design-system/components/issues"
},
"type": "module",
"main": "./index.js",
"module": "./index.js",
"types": "./index.d.ts",
"customElements": "custom-elements.json",
"exports": {
".": "./index.js",
"./package.json": "./package.json",
"./register.js": "./register.js"
},
"files": [
"**/*.d.ts",
"**/*.js",
"**/*.js.map",
"custom-elements.json"
],
"sideEffects": [
"register.js"
],
"scripts": {
"test": "echo \"Error: run tests from monorepo root.\" && exit 1"
},
"dependencies": {
"@sl-design-system/icon": "^1.0.0"
},
"devDependencies": {
"lit": "^3.1.4"
},
"peerDependencies": {
"lit": "^3.1.2"
anna-lach marked this conversation as resolved.
Show resolved Hide resolved
}
}
3 changes: 3 additions & 0 deletions packages/components/progress-bar/register.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ProgressBar } from './src/progress-bar.js';

customElements.define('sl-progress-bar', ProgressBar);
109 changes: 109 additions & 0 deletions packages/components/progress-bar/src/progress-bar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
$states: active, success, warning, error;

:host {
--_border-radius: var(--sl-border-radius-full);
--_label-font: var(--sl-text-input-field-label-label-md);
--_helper-font: var(--sl-text-input-field-label-hint-md);
--_helper-color: var(--sl-color-input-helper-text-default);
--_helper-color-error: var(--sl-color-progressbar-error-track);
--_height: var(--sl-size-progressbar);
anna-lach marked this conversation as resolved.
Show resolved Hide resolved
--_gap: var(--sl-space-progressbar-vertical-gap);
--_label-gap: var(--sl-space-progressbar-horizontal-gap);
--_indeterminate-duration: 20s;
--_bar-background: var(--sl-color-progressbar-background);
anna-lach marked this conversation as resolved.
Show resolved Hide resolved

@media (prefers-reduced-motion: no-preference) {
--_indeterminate-duration: 1.2s;
}

color: var(--_helper-color);
display: flex;
flex-direction: column;
font: var(--_helper-font);
gap: var(--_gap);
}

@each $state in $states {
:host([state='#{$state}']) {
--_progress-background: var(--sl-color-progressbar-#{$state}-track);
--_icon-fill: var(--sl-color-progressbar-#{$state}-track);
}
}

:host([indeterminate][state='active']) {
.progress {
anna-lach marked this conversation as resolved.
Show resolved Hide resolved
animation: var(--_indeterminate-duration) ease 500ms infinite normal none running indeterminate;
position: relative;
}
}

:host([state='error']) {
::slotted(*) {
anna-lach marked this conversation as resolved.
Show resolved Hide resolved
color: var(--_helper-color-error);
}
}

.label {
anna-lach marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
font: var(--_label-font);
gap: var(--_label-gap);
justify-content: space-between;

sl-icon {
--sl-icon-fill-default: var(--_icon-fill);
}
}

.helper {
display: flex;
anna-lach marked this conversation as resolved.
Show resolved Hide resolved
gap: var(--_label-gap);
justify-content: space-between;

sl-icon {
--sl-icon-fill-default: var(--_icon-fill);
}
}

::slotted(*) {
color: var(--_helper-color);
font: var(--_helper-font);
}

.container {
align-items: stretch;
background: var(--_bar-background);
block-size: var(--_height);
border-radius: var(--_border-radius);
display: flex;
inline-size: 100%;
overflow: hidden;
position: relative;
}

.progress {
background: var(--_progress-background);
border-radius: var(--_border-radius);
transform-origin: left;
transition:
400ms width,
400ms background-color;
}

/** Hiding the aria-live element for the UI, but not for the screen readers. */
#live {
block-size: 0;
inline-size: 0;
overflow: hidden;
}

@keyframes indeterminate {
0% {
inline-size: 80%;
inset-inline-start: -80%;
}

100% {
inline-size: 10%;
inset-inline-start: 110%;
}
}
128 changes: 128 additions & 0 deletions packages/components/progress-bar/src/progress-bar.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { expect, fixture } from '@open-wc/testing';
import { html } from 'lit';
import '../register.js';
import { type ProgressBar } from './progress-bar.js';

describe('sl-progress-bar', () => {
let el: ProgressBar;
let progressBar: HTMLDivElement;

beforeEach(async () => {
el = await fixture(html`<sl-progress-bar> Downloaded 30% of 100% </sl-progress-bar>`);

progressBar = el.renderRoot.querySelector('div.container') as HTMLDivElement;
});

it('should have active state by default', () => {
expect(el).to.have.attribute('state', 'active');
});

it('should have no icon by default', () => {
const icon = el.renderRoot.querySelector('sl-icon') as HTMLElement;

expect(icon).not.to.exist;
});

it('should not have any label by default', () => {
expect(el).not.to.have.attribute('label');
});

it('should have 0 value by default', () => {
expect(el).not.to.have.attribute('value', '0');
});

it('should have determinate progress bar by default', () => {
expect(progressBar).to.have.attribute('aria-valuenow');
expect(el).not.to.have.attribute('indeterminate');
});

it('should have a progressbar role', () => {
expect(progressBar).to.have.attribute('role', 'progressbar');
});

it('should have the correct attributes', () => {
expect(progressBar).to.have.attribute('aria-describedby', 'helper');
expect(progressBar).to.have.attribute('aria-valuemin', '0');
expect(progressBar).to.have.attribute('aria-valuemax', '100');
expect(progressBar).to.have.attribute('aria-valuenow', '0');
});

it('should have aria-live by default', () => {
const ariaLive = el.renderRoot.querySelector('#live') as HTMLElement;
expect(ariaLive).to.have.attribute('aria-live', 'polite');
expect(ariaLive).to.have.rendered.text('state active 0%');
});

it('should be labelled properly when the label is set', async () => {
el.label = 'Progress label';
await el.updateComplete;

const label = el.renderRoot.querySelector('span.label') as HTMLElement;

expect(label).to.have.trimmed.text('Progress label');
expect(progressBar).to.have.attribute('aria-labelledby', 'label');
});

it('should have the proper icon when the success state is set', async () => {
el.label = 'Progress label';
el.state = 'success';
await el.updateComplete;

const label = el.renderRoot.querySelector('span.label') as HTMLElement,
icon = label?.querySelector('sl-icon') as HTMLElement;

expect(label).to.exist;
expect(label).to.have.trimmed.text('Progress label');
expect(icon).to.have.attribute('name', 'circle-check-solid');
});

it('should have the proper icon when the warning state is set', async () => {
el.label = 'Progress label';
el.state = 'warning';
await el.updateComplete;

const label = el.renderRoot.querySelector('span.label') as HTMLElement,
icon = label?.querySelector('sl-icon') as HTMLElement;

expect(label).to.exist;
expect(label).to.have.trimmed.text('Progress label');
expect(icon).to.have.attribute('name', 'octagon-exclamation-solid');
});

it('should have the proper icon when the error state is set', async () => {
el.label = 'Progress label';
el.state = 'error';
await el.updateComplete;

const label = el.renderRoot.querySelector('span.label') as HTMLElement,
icon = label?.querySelector('sl-icon') as HTMLElement;

expect(label).to.exist;
expect(label).to.have.trimmed.text('Progress label');
expect(icon).to.have.attribute('name', 'triangle-exclamation-solid');
});

it('should have the icon in the helper text part when there is no label', async () => {
const label = el.renderRoot.querySelector('span.label') as HTMLElement;
expect(label).not.to.exist;

el.state = 'success';
await el.updateComplete;

const helper = el.renderRoot.querySelector('span.helper') as HTMLElement,
helperIcon = helper?.querySelector('sl-icon') as HTMLElement;

expect(helper).to.exist;
expect(helperIcon).to.exist;
});

it('should change the aria-live when the value and state have changed', async () => {
el.value = 60;
el.state = 'warning';
await el.updateComplete;

const ariaLive = el.renderRoot.querySelector('#live') as HTMLElement;
expect(ariaLive).to.have.attribute('aria-live', 'polite');
expect(ariaLive).to.have.rendered.text('state warning 60%');
});
});
Loading