-
Notifications
You must be signed in to change notification settings - Fork 5
feat: added loading indicator (circular spinner) #10
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7022602
feat: added loading indicator (circular spinner)
annsch 74f6c61
Update CHANGELOG.md
mfranzke a35630a
fix: using pseudo patterns for loading indicator due to code review f…
annsch d2b4658
Merge branch 'loading-spinner' of https://github.com/db-ui/core into …
annsch a2d8617
test: update backstop.json
annsch 3140e5c
Merge branch 'main' into loading-spinner
annsch 5c5ef74
Update _loading-indicator.md
mfranzke a6bd897
Merge branch 'main' into loading-spinner
mfranzke dfda260
Merge branch 'main' into loading-spinner
mfranzke e3d084a
chore: corrected those URLs
mfranzke 3867b2c
chore: let's simplify this to reduce the amount of testcases
mfranzke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
32 changes: 32 additions & 0 deletions
32
source/_patterns/01-elements/loading-indicator/_loading-indicator.md
This file contains hidden or 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,32 @@ | ||
| --- | ||
| title: loading | ||
| state: inprogress | ||
| --- | ||
|
|
||
| Progress spinners (loading indicators) show the user that a longer-lasting action is being carried out. | ||
| Progress/Loading Indicators are used when the application executes a server request or processes data in the frontend. The component is used as soon as the execution and the resulting delay are noticeable to the user. This keeps the user aware that his or her action is being executed. | ||
|
|
||
| ## Accessibility | ||
|
|
||
| SVGs are often conveyed inconsistently to assistive technologies. The component’s accessibility is also highly contextual. | ||
| For optimal user experience, use the aria-description prop to let assistive technology users know the purpose of the loading spinner. | ||
|
|
||
| ### `aria-live` and dynamic creation of html content | ||
|
|
||
| Using JavaScript (e.g. in context of frameworks like Angular, VueJS or React), it is possible to dynamically change parts of a page without requiring the entire page to reload — for instance, to update a list of search results on the fly, or to display a discreet alert or notification which does not require user interaction. While these changes are usually visually apparent to users who can see the page, they may not be obvious to users of assistive technologies. ARIA live regions fill this gap and provide a way to programmatically expose dynamic content changes in a way that can be announced by assistive technologies. | ||
|
|
||
| `aria-live` triggers screen readers when an element with aria-live (or text within an element with aria-live) is added or removed from the DOM. In contrast, when you unhide a hidden element, neither elements nor text are added or removed from the DOM, so the element's aria-live property doesn’t come into play. | ||
|
|
||
| Note that the live region needs to be present in the markup before the notification is generated or updated. If you dynamically generate both at the same time and inject them into the page, they will generally not be announced by assistive technologies. | ||
|
|
||
| You also need to adapt the `role` and `aria-live` level depending on the content. Further information can be found here [https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) | ||
|
|
||
| ## Recommendations | ||
|
|
||
| ### Do | ||
|
|
||
| If the application is waiting for a process, it makes sense to display an indicator in a central location. | ||
|
|
||
| ### Don‘t | ||
|
|
||
| An indicator should not be used to visualize the application waiting for user input. |
9 changes: 9 additions & 0 deletions
9
source/_patterns/01-elements/loading-indicator/_loading-indicator.variables.scss
This file contains hidden or 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,9 @@ | ||
| @import "../../../css/db-ui-core.variables"; | ||
|
|
||
| $db-spinner-sizes: ( | ||
| "xs": 20px, | ||
| "s": 28px, | ||
| "m": 36px, | ||
| "l": 44px, | ||
| "xl": 52px | ||
| ); |
16 changes: 16 additions & 0 deletions
16
source/_patterns/01-elements/loading-indicator/loading-indicator.hbs
This file contains hidden or 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,16 @@ | ||
| <svg | ||
| class="elm-loadingindicator" | ||
| viewBox="0 0 44 44" | ||
| aria-labelledby="elm-loadingindicator__description" role="img" | ||
| {{#if size }} data-size="{{ size }}"{{/if }} | ||
| > | ||
| <title id="elm-loadingindicator__description">{{aria-description}}</title> | ||
| <circle | ||
| class="elm-loadingindicator__circle" | ||
| cx="22" | ||
| cy="22" | ||
| r="20" | ||
| fill="none" | ||
| stroke-miterlimit="10" | ||
| ></circle> | ||
mfranzke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </svg> | ||
3 changes: 3 additions & 0 deletions
3
source/_patterns/01-elements/loading-indicator/loading-indicator.json
This file contains hidden or 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 @@ | ||
| { | ||
| "aria-description": "Example description for loading spinner" | ||
| } |
86 changes: 86 additions & 0 deletions
86
source/_patterns/01-elements/loading-indicator/loading-indicator.scss
This file contains hidden or 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,86 @@ | ||
| @charset "utf-8"; | ||
| @use "sass:math"; | ||
|
|
||
| @import "loading-indicator.variables"; | ||
|
|
||
| .elm-loadingindicator { | ||
| display: block; | ||
| } | ||
|
|
||
| @mixin loadingindicator--sizes($prefix) { | ||
| @each $size in (xl l m s xs) { | ||
| $stroke-width: 3px; | ||
| @if $size == s or $size == xs { | ||
| $stroke-width: 2px; | ||
| } | ||
| //.#{$prefix}loadingindicator--size-#{$size} { | ||
| &%size-#{$size} { | ||
| --loadingindicator--stroke-width: #{math.div( | ||
| 44px, | ||
| map-get($db-spinner-sizes, $size) | ||
| ) * | ||
| $stroke-width}; | ||
| --loadingindicator--r: 19px; | ||
| height: map-get($db-spinner-sizes, $size); | ||
| width: map-get($db-spinner-sizes, $size); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .elm-loadingindicator { | ||
| color: $db-color-red-500; | ||
| animation: loadingindicator-rotate 3s linear infinite; | ||
|
|
||
| @include loadingindicator--sizes("elm-"); | ||
|
|
||
| @extend %size-m; // default | ||
|
|
||
| &[data-size="xs"] { | ||
| @extend %size-xs; | ||
| } | ||
| &[data-size="s"] { | ||
| @extend %size-s; | ||
| } | ||
| &[data-size="m"] { | ||
| @extend %size-m; | ||
| } | ||
| &[data-size="l"] { | ||
| @extend %size-l; | ||
| } | ||
| &[data-size="xl"] { | ||
| @extend %size-xl; | ||
| } | ||
| } | ||
|
|
||
| .elm-loadingindicator__circle { | ||
| r: var(--loadingindicator--r); | ||
| stroke-dasharray: 1, 200; | ||
| stroke-dashoffset: 0; | ||
| stroke: currentcolor; | ||
| stroke-width: var(--loadingindicator--stroke-width); | ||
| animation: loadingindicator-stroke 1.5s ease-in-out infinite; | ||
| stroke-linecap: round; | ||
| } | ||
|
|
||
| @keyframes loadingindicator-rotate { | ||
| 100% { | ||
| transform: rotate(360deg); | ||
| } | ||
| } | ||
|
|
||
| @keyframes loadingindicator-stroke { | ||
| 0% { | ||
| stroke-dasharray: 1, 200; | ||
| stroke-dashoffset: 0; | ||
| } | ||
|
|
||
| 50% { | ||
| stroke-dasharray: 96, 200; | ||
| stroke-dashoffset: -32; | ||
| } | ||
|
|
||
| 100% { | ||
| stroke-dasharray: 96, 200; | ||
| stroke-dashoffset: -124; | ||
| } | ||
| } |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-S.md
This file contains hidden or 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,4 @@ | ||
| --- | ||
| title: Loading Indicator Size S | ||
| order: 2 | ||
| --- |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-XS.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "size": "xs", | ||
| "aria-description": "Example description for xs loading spinner" | ||
| } |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-XS.md
This file contains hidden or 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,4 @@ | ||
| --- | ||
| title: Loading Indicator Size XS | ||
| order: 1 | ||
| --- |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-l.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "size": "l", | ||
| "aria-description": "Example description for loading spinner size L" | ||
| } |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-l.md
This file contains hidden or 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,4 @@ | ||
| --- | ||
| title: Loading Indicator Size L | ||
| order: 4 | ||
| --- |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-m.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "size": "m", | ||
| "aria-description": "Example description for loading spinner size M" | ||
| } |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-m.md
This file contains hidden or 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,4 @@ | ||
| --- | ||
| title: Loading Indicator Size M | ||
| order: 3 | ||
| --- |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-s.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "size": "s", | ||
| "aria-description": "Example description for s loading spinner" | ||
| } |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-xl.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "size": "xl", | ||
| "aria-description": "Example description for loading spinner size XL" | ||
| } |
4 changes: 4 additions & 0 deletions
4
source/_patterns/01-elements/loading-indicator/loading-indicator~size-xl.md
This file contains hidden or 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,4 @@ | ||
| --- | ||
| title: Loading Indicator Size XL | ||
| order: 5 | ||
| --- |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.