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

feat: loading skeleton components #41

Merged
merged 27 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c94b232
feat: basic experiment for wrapping loading skeleton
Carl-J-M Mar 1, 2024
d71cc8d
feat: update story example and css
Carl-J-M Mar 4, 2024
3c56beb
fix: fit-content on typographic styles
Carl-J-M Mar 4, 2024
d2c597b
feat: LoadingButton
Carl-J-M Mar 25, 2024
3de0828
feat: LoadingImage
Carl-J-M Mar 25, 2024
70fa4ed
fix: remove loadingSkeleton wrapper example
Carl-J-M Mar 25, 2024
a654907
feat: loading text & standardisation
Carl-J-M Apr 9, 2024
e1d2454
fix: pulse.css
Carl-J-M Apr 9, 2024
99911c7
fix: add pulse animation duration variable, fix imports
Carl-J-M Apr 9, 2024
abe8245
fix: import paths for pulse.css
Carl-J-M Apr 9, 2024
92e7626
fix: return button attributes
Carl-J-M Apr 9, 2024
b472db7
fix: extract common styles to mixin, import mixin
Carl-J-M Apr 11, 2024
c14e6c9
fix: force apply class with shared styles to custom element
Carl-J-M Apr 11, 2024
05272c6
fix: missing controls on loading button story
Carl-J-M Apr 11, 2024
b40befd
feat: button common styles mixin
Carl-J-M Apr 11, 2024
919903b
fix: import mixin, remove duplicate common styles
Carl-J-M Apr 11, 2024
92b371c
fix: enforce common button styles class on custom element definition
Carl-J-M Apr 11, 2024
062082c
fix: remove debugging comments
Carl-J-M Apr 11, 2024
db9722b
docs: loading skeleton demo story
gavmck Apr 12, 2024
0277c3e
Merge branch 'feature/loading-skeleton-demo' into feat/etch-371-loadi…
Carl-J-M Apr 12, 2024
e0c0dae
docs: page loading skeleton
Carl-J-M Apr 12, 2024
3ceef84
chore: revert button styles
Carl-J-M Apr 12, 2024
42c219c
chore: loading page example and loadingImg
Carl-J-M Apr 15, 2024
0dee162
refactor: share pulse styles and support theme context
gavmck Apr 15, 2024
0700d55
docs: update story names
gavmck Apr 15, 2024
4d93879
refactor: explain why button styles are split
gavmck Apr 15, 2024
ac3838b
docs: explain style approach
gavmck Apr 15, 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
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { StorybookConfig } from '@storybook/web-components-vite';

Check warning on line 1 in .storybook/main.ts

View workflow job for this annotation

GitHub Actions / lint

File ignored by default.

const config: StorybookConfig = {
stories: [
'../components/**/*.mdx',
'../components/**/*.stories.@(js|jsx|mjs|ts|tsx)',
'../docs/**/*.mdx',
'../docs/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
'@storybook/addon-links',
Expand Down
15 changes: 10 additions & 5 deletions components/content/Img/Img.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ diamond-img {
display: inline-block;

&[block],
&[block] img {
&[block] img,
&[block] diamond-loading-img {
display: block;
}

&[responsive] {
width: 100%;

img {
img,
diamond-loading-img {
height: auto;
width: 100%;
}
Expand All @@ -21,15 +23,18 @@ diamond-img {
}

&[aspect-ratio],
&[aspect-ratio] img {
&[aspect-ratio] img,
&[aspect-ratio] diamond-loading-img {
aspect-ratio: var(--diamond-img-aspect-ratio);
}

&[object-fit] img {
&[object-fit] img,
&[object-fit] diamond-loading-img {
object-fit: var(--diamond-img-object-fit);
}

&[object-position] img {
&[object-position] img,
&[object-position] diamond-loading-img {
object-position: var(--diamond-img-object-position);
}
}
6 changes: 5 additions & 1 deletion components/content/Img/Img.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ export interface ImgAttributes {

@customElement('diamond-img')
export class Img extends LitElement {
@property({ reflect: true, attribute: 'aria-hidden' }) ariaHidden:
| string
| null = 'true';
@property({ reflect: true }) block?: string | boolean;
@property({ reflect: true }) responsive?: string | boolean;
@property({ reflect: true, attribute: 'aspect-ratio' }) aspectRatio = 'auto';
@property({ reflect: true, attribute: 'aspect-ratio' }) aspectRatio?: string =
'inherit';
@property({ reflect: true }) radius?: string | boolean;
@property({ reflect: true, attribute: 'object-fit' }) objectFit?:
| 'fill'
Expand Down
16 changes: 16 additions & 0 deletions components/content/LoadingButton/LoadingButton.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StoryObj } from '@storybook/web-components';
import { html } from 'lit';

import './LoadingButton';

export default {
component: 'diamond-loading-button',
};

export const LoadingButton: StoryObj = {
render: () => html`
<diamond-button width="full-width">
<diamond-loading-button>Button text</diamond-loading-button>
</diamond-button>
`,
};
23 changes: 23 additions & 0 deletions components/content/LoadingButton/LoadingButton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { LitElement, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';

import { pulse } from '../../../lib/pulse';

@customElement('diamond-loading-button')
export class LoadingButton extends LitElement {
@property({ reflect: true, attribute: 'aria-hidden' }) ariaHidden:
| string
| null = 'true';

static readonly styles = [pulse];

render() {
return html`<slot></slot>`;
}
}

declare global {
interface HTMLElementTagNameMap {
'diamond-loading-button': LoadingButton;
}
}
24 changes: 24 additions & 0 deletions components/content/LoadingImg/LoadingImg.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { StoryObj } from '@storybook/web-components';
import { html } from 'lit';

import './LoadingImg';

export default {
component: 'diamond-loading-img',
};

export const LoadingImg: StoryObj = {
render: (args) => html`
<diamond-img>
<diamond-loading-img
height="${args.height}"
width="${args.width}"
></diamond-loading-img>
</diamond-img>
`,
};

LoadingImg.args = {
width: 400,
height: 300,
};
39 changes: 39 additions & 0 deletions components/content/LoadingImg/LoadingImg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { LitElement, css, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';

import { pulse } from '../../../lib/pulse';

@customElement('diamond-loading-img')
export class LoadingImg extends LitElement {
@property({ reflect: true }) width: string = '0';
@property({ reflect: true }) height: string = '0';

static readonly styles = [
pulse,
css`
:host {
aspect-ratio: var(--diamond-loading-img-width) /
var(--diamond-loading-img-height);
height: calc(var(--diamond-loading-img-height) * 1px);
width: calc(var(--diamond-loading-img-width) * 1px);
}
`,
];

render() {
return html`
<style>
:host {
--diamond-loading-img-width: ${this.width};
--diamond-loading-img-height: ${this.height};
}
</style>
`;
}
}

declare global {
interface HTMLElementTagNameMap {
'diamond-loading-img': LoadingImg;
}
}
19 changes: 19 additions & 0 deletions components/content/LoadingText/LoadingText.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { StoryObj } from '@storybook/web-components';
import { html } from 'lit';

import './LoadingText';

export default {
component: 'diamond-loading-text',
};

export const LoadingText: StoryObj = {
render: () => html`
<h1>
<diamond-loading-text>Loading title</diamond-loading-text>
</h1>
<p>
<diamond-loading-text>Loading text</diamond-loading-text>
</p>
`,
};
22 changes: 22 additions & 0 deletions components/content/LoadingText/LoadingText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { LitElement, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';

import { pulse } from '../../../lib/pulse';

@customElement('diamond-loading-text')
export class LoadingText extends LitElement {
@property({ reflect: true, attribute: 'aria-hidden' }) ariaHidden:
| string
| null = 'true';
static readonly styles = [pulse];

render() {
return html`<slot></slot>`;
}
}

declare global {
interface HTMLElementTagNameMap {
'diamond-loading-text': LoadingText;
}
}
23 changes: 18 additions & 5 deletions components/control/Button/Button.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ diamond-button {
--_line-height: var(--diamond-button-line-height);
display: inline-block;

/* Structural button styles */
diamond-loading-button,
button,
a,
input:not([type='file']),
input[type='file']::file-selector-button {
align-items: center;
appearance: none;
background: var(--_background);
border: var(--diamond-border);
border-color: var(--_border-color);
border-radius: var(--diamond-button-border-radius);
color: var(--_color);
cursor: pointer;
display: inline-flex;
font: inherit;
Expand All @@ -39,7 +37,6 @@ diamond-button {
-webkit-tap-highlight-color: transparent;
text-align: center;
text-decoration: none;
text-shadow: var(--diamond-button-text-shadow);
touch-action: manipulation;
-webkit-touch-callout: none;
transition:
Expand All @@ -62,6 +59,18 @@ diamond-button {
}
}

/* Presentational button styles */
button,
a,
input:not([type='file']),
input[type='file']::file-selector-button {
background: var(--_background);
border: var(--diamond-border);
border-color: var(--_border-color);
color: var(--_color);
text-shadow: var(--diamond-button-text-shadow);
}

svg {
block-size: var(--diamond-icon-size);
flex-shrink: 0;
Expand Down Expand Up @@ -94,6 +103,7 @@ diamond-button {
&[width='full-width'] {
display: block;

diamond-loading-button,
button,
a,
input {
Expand All @@ -105,6 +115,7 @@ diamond-button {
&[width='full-width-mobile'] {
display: block;

diamond-loading-button,
button,
a,
input {
Expand All @@ -117,6 +128,7 @@ diamond-button {
--_line-height: 1;
--_padding-inline: var(--diamond-button-padding-block);

diamond-loading-button,
button,
a,
input {
Expand Down Expand Up @@ -165,6 +177,7 @@ diamond-button {
/* Text button is square */
--_padding-inline: var(--diamond-button-padding-block);

diamond-loading-button,
button,
a,
input {
Expand Down
Loading
Loading