-
Notifications
You must be signed in to change notification settings - Fork 0
WEBDEV-8019 Add basic loading indicator #17
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
rebecca-shoptaw
merged 14 commits into
main
from
webdev-8019-add-basic-loading-indicator
Jan 13, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8353aa6
Begin drafting status indicator
rebecca-shoptaw 8570c4d
Draft new loading indicator
rebecca-shoptaw 26bccd4
Draft adjustments to story
rebecca-shoptaw 465179e
Adjust and clarify demo
rebecca-shoptaw 6d53986
Simplify and localize indicator title
rebecca-shoptaw af7df53
Tidy up and incorporate theme styles into indicator
rebecca-shoptaw ed59784
Improve a11y approach
rebecca-shoptaw 83683eb
Make title customizable
rebecca-shoptaw f7deae7
Add title config to story
rebecca-shoptaw 81f208a
Rename everything
rebecca-shoptaw 43a350f
Ensure loadingTitle updates properly in story
rebecca-shoptaw 273e0ac
Reorganize app root
rebecca-shoptaw 6bbc0e0
Remove story light/dark toggle
rebecca-shoptaw 69041f0
Reorganize app root
rebecca-shoptaw 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
113 changes: 113 additions & 0 deletions
113
src/elements/ia-status-indicator/ia-status-indicator-story.ts
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,113 @@ | ||
| import { html, LitElement, TemplateResult } from 'lit'; | ||
| import { customElement, query, queryAll, state } from 'lit/decorators.js'; | ||
|
|
||
| import { IAStatusIndicator } from './ia-status-indicator'; | ||
|
|
||
| import './ia-status-indicator'; | ||
| import '@demo/story-template'; | ||
|
|
||
| @customElement('ia-status-indicator-story') | ||
| export class IAStatusIndicatorStory extends LitElement { | ||
| @queryAll('.style-input') | ||
| private styleInputs?: NodeListOf<HTMLInputElement>; | ||
|
|
||
| @query('#loading-title') | ||
| private loadingTitleInput!: HTMLInputElement; | ||
|
|
||
| /* Applied styles for the component, in "--my-variable: #f00;" format */ | ||
| @state() | ||
| private stringifiedStyles: string = ''; | ||
|
|
||
| /* Applied properties fro the component in .myprop=${'foo'} format */ | ||
| @state() | ||
| private stringifiedProps: string = ''; | ||
|
|
||
| @query('ia-status-indicator') | ||
| private component!: IAStatusIndicator; | ||
|
|
||
| render() { | ||
| return html` | ||
| <story-template | ||
| elementTag="ia-status-indicator" | ||
| .exampleUsage=${this.exampleUsage} | ||
| > | ||
| <div slot="demo"> | ||
| <ia-status-indicator | ||
| style=${this.stringifiedStyles} | ||
| ></ia-status-indicator> | ||
| </div> | ||
|
|
||
| <div slot="settings"> | ||
| <table> | ||
| <tr> | ||
| <td>Title</td> | ||
| <td> | ||
| <input | ||
| class="prop-input" | ||
| type="text" | ||
| id="loading-title" | ||
| data-prop="title" | ||
| value="Content loading..." | ||
| /> | ||
| </td> | ||
| <td>Color</td> | ||
| <td> | ||
| ${this.createStyleInput( | ||
| 'color', | ||
| '--ia-theme-primary-text-color', | ||
| '#3d7581', | ||
| 'color', | ||
| )} | ||
| </td> | ||
| <td>Width</td> | ||
| <td> | ||
| ${this.createStyleInput( | ||
| 'width', | ||
| '--ia-theme-icon-width', | ||
| '30px', | ||
| )} | ||
| </td> | ||
| </tr> | ||
| </table> | ||
| <button @click=${this.apply}>Apply</button> | ||
| </div> | ||
| </story-template> | ||
| `; | ||
| } | ||
|
|
||
| private get exampleUsage(): string { | ||
| return `<ia-status-indicator${this.stringifiedProps ? ' ' + this.stringifiedProps : ''}${this.stringifiedStyles ? ` style="${this.stringifiedStyles}"` : ''}></ia-status-indicator>`; | ||
| } | ||
|
|
||
| private createStyleInput( | ||
| id: string, | ||
| cssVariable: string, | ||
| defaultValue: string = '', | ||
| type: 'text' | 'color' = 'text', | ||
| ): TemplateResult { | ||
| return html` | ||
| <input | ||
| id=${id} | ||
| type=${type} | ||
| class="style-input" | ||
| value=${defaultValue} | ||
| data-variable=${cssVariable} | ||
| /> | ||
| `; | ||
| } | ||
|
|
||
| private apply() { | ||
| const loadingTitle = this.loadingTitleInput.value; | ||
| this.component.loadingTitle = loadingTitle; | ||
| this.stringifiedProps = `.loadingTitle=\${'${loadingTitle}'}`; | ||
|
|
||
| const appliedStyles: string[] = []; | ||
|
|
||
| this.styleInputs?.forEach((input) => { | ||
| if (!input.dataset.variable || !input.value) return; | ||
| appliedStyles.push(`${input.dataset.variable}: ${input.value};`); | ||
rebecca-shoptaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| this.stringifiedStyles = appliedStyles.join(' '); | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
src/elements/ia-status-indicator/ia-status-indicator.test.ts
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,37 @@ | ||
| import { fixture } from '@open-wc/testing-helpers'; | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { html } from 'lit'; | ||
|
|
||
| import type { IAStatusIndicator } from './ia-status-indicator'; | ||
| import './ia-status-indicator'; | ||
|
|
||
| describe('IA Status Indicator', () => { | ||
| test('renders a circular loading indicator by default', async () => { | ||
| const el = await fixture<IAStatusIndicator>( | ||
| html`<ia-status-indicator></ia-status-indicator>`, | ||
| ); | ||
| const circularLoadingIndicator = el.shadowRoot?.querySelector( | ||
| '.circular-loading-indicator', | ||
| ); | ||
| expect(circularLoadingIndicator).toBeDefined(); | ||
| }); | ||
|
|
||
| test('uses a custom loading text for the indicator if desired', async () => { | ||
| const el = await fixture<IAStatusIndicator>( | ||
| html`<ia-status-indicator | ||
| .loadingTitle=${'Download in progress...'} | ||
| ></ia-status-indicator>`, | ||
| ); | ||
| const indicatorTitle = el.shadowRoot?.querySelector('title'); | ||
| expect(indicatorTitle?.innerHTML).to.contain('Download in progress...'); | ||
| }); | ||
|
|
||
| test('uses a default title if no title provided', async () => { | ||
| const el = await fixture<IAStatusIndicator>( | ||
| html`<ia-status-indicator></ia-status-indicator>`, | ||
| ); | ||
|
|
||
| const indicatorTitle = el.shadowRoot?.querySelector('title'); | ||
| expect(indicatorTitle?.innerHTML).to.contain('Loading...'); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.