-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ld-loading): implement loading indicator
- Loading branch information
1 parent
44cffca
commit 8d242a6
Showing
9 changed files
with
151 additions
and
0 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
/** | ||
* @prop --ld-loading-size: Size of the loading indicator (1.5rem by default). | ||
*/ | ||
.ld-loading { | ||
--ld-loading-size: 1.5rem; | ||
height: var(--ld-loading-size); | ||
width: var(--ld-loading-size); | ||
display: inline-flex; | ||
flex-shrink: 0; | ||
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyMyAyMyI+PGRlZnMvPjxjaXJjbGUgY3g9IjExLjUiIGN5PSIxMS41IiByPSI5LjUiIHN0cm9rZT0iI0JGQkZCRiIgc3Ryb2tlLWRhc2hhcnJheT0iMi41NSA1IiBzdHJva2Utd2lkdGg9IjQiLz48L3N2Zz4='); | ||
background-size: 100%; | ||
background-repeat: no-repeat; | ||
animation: ld-loading-animation 1.5s linear infinite; | ||
} | ||
|
||
@keyframes ld-loading-animation { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
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,17 @@ | ||
import '../../components' // type definitions for type checks and intelliSense | ||
import { Component, h, Host } from '@stencil/core' | ||
|
||
/** | ||
* @virtualProp ref - reference to component | ||
* @virtualProp {string | number} key - for tracking the node's identity when working with lists | ||
*/ | ||
@Component({ | ||
tag: 'ld-loading', | ||
styleUrl: 'ld-loading.css', | ||
shadow: false, | ||
}) | ||
export class LdLoading { | ||
render() { | ||
return <Host class="ld-loading"></Host> | ||
} | ||
} |
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 @@ | ||
--- | ||
eleventyNavigation: | ||
key: Loading Indicator | ||
parent: Components | ||
layout: layout.njk | ||
title: Loading Indicator | ||
permalink: components/ld-loading/ | ||
--- | ||
|
||
# ld-loading | ||
|
||
Use the `ld-loading` component to indicate that the user should wait for a process to complete. Combine it with textual information on what is going on for a better user experience. | ||
|
||
{% example %} | ||
<ld-loading></ld-loading> | ||
|
||
<!-- CSS component --> | ||
|
||
<span class="ld-loading"></span> | ||
{% endexample %} | ||
|
||
## CSS Variables | ||
|
||
| Variable | Description | Default | | ||
| -------------------- | ----------------------------- | -------- | | ||
| `--ld-loading-size` | Size of the loading indicator | `1.5rem` | | ||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| -------- | --------- | -------------------------------------------------------- | ------------------ | ----------- | | ||
| `key` | `key` | for tracking the node's identity when working with lists | `string \| number` | `undefined` | | ||
| `ref` | `ref` | reference to component | `any` | `undefined` | | ||
|
||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
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,29 @@ | ||
import { newE2EPage } from '@stencil/core/testing' | ||
|
||
jest.useRealTimers() | ||
|
||
async function getPageWithContent(content, theme = 'none') { | ||
const page = await newE2EPage() | ||
await page.setContent( | ||
`<div class="ld-theme-${theme}" style="height: 100vh; display: grid; place-items: center">${content}</div>` | ||
) | ||
await page.addStyleTag({ path: './dist/css/liquid.global.css' }) | ||
await page.addStyleTag({ path: './dist/css/ld-loading.css' }) | ||
return page | ||
} | ||
|
||
const allowableMismatchedRatio = 0.02 | ||
|
||
describe('ld-loading', () => { | ||
it('renders', async () => { | ||
const page = await getPageWithContent(`<ld-loading></ld-loading>`) | ||
const results = await page.compareScreenshot() | ||
expect(results).toMatchScreenshot({ allowableMismatchedRatio }) | ||
}) | ||
|
||
it('renders as css component', async () => { | ||
const page = await getPageWithContent(`<span class="ld-loading"></span>`) | ||
const results = await page.compareScreenshot() | ||
expect(results).toMatchScreenshot({ allowableMismatchedRatio }) | ||
}) | ||
}) |
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,14 @@ | ||
import { newSpecPage } from '@stencil/core/testing' | ||
import { LdLoading } from '../ld-loading' | ||
|
||
describe('ld-loading', () => { | ||
it('renders', async () => { | ||
const page = await newSpecPage({ | ||
components: [LdLoading], | ||
html: `<ld-loading></ld-loading>`, | ||
}) | ||
expect(page.root).toEqualHtml(` | ||
<ld-loading class="ld-loading"></ld-loading> | ||
`) | ||
}) | ||
}) |