Skip to content

Commit d9a5076

Browse files
author
manuel.carrera
committed
chore: Merge master into prerelease/minor [skip release]
2 parents 9ebd23f + 2ad2b08 commit d9a5076

File tree

8 files changed

+131
-51
lines changed

8 files changed

+131
-51
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Optional breaking changes message. If your PR includes breaking changes. It is e
2020

2121
## Checklist
2222

23-
- [ ] MDX documentation adheres to Canvas Kit's [Documentation Guidelines](https://workday.github.io/canvas-kit/?path=/docs/guides-documentation-guidelines--page)
23+
- [ ] MDX documentation adheres to Canvas Kit's [Documentation Guidelines](https://workday.github.io/canvas-kit/?path=/docs/guides-documentation-guidelines--docs)
2424
- [ ] Label `ready for review` has been added to PR
2525

2626
## For the Reviewer

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Contributing to Canvas
22

33
You may read our contribution guidelines
4-
[here](https://workday.github.io/canvas-kit/?path=/docs/guides-contributing--page).
4+
[here](https://workday.github.io/canvas-kit/?path=/docs/guides-contributing--docs).

modules/react/loading-dots/lib/LoadingDots.tsx

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,61 +15,71 @@ const keyframesLoading = keyframes({
1515
},
1616
});
1717

18-
const singleLoadingDotStencil = createStencil({
18+
export interface LoadingDotsProps extends CSProps {
19+
/**
20+
* Applies backgroundColor to loading dots, intended for use with the circle variant design on grey/dark/image-based backgrounds.
21+
* @default `system.color.bg.alt.strong`
22+
*/
23+
loadingDotColor?: string;
24+
/**
25+
* Duration of the loading animation in milliseconds.
26+
* @default `40ms`
27+
*/
28+
animationDurationMs?: string;
29+
}
30+
31+
export const loadingDotsStencil = createStencil({
1932
vars: {
2033
animationDurationMs: '40ms',
34+
loadingDotColor: system.color.bg.alt.strong,
2135
},
22-
base: ({animationDurationMs}) => ({
23-
backgroundColor: system.color.bg.alt.strong,
24-
width: system.space.x4,
25-
height: system.space.x4,
26-
fontSize: system.space.zero,
27-
borderRadius: system.shape.round,
28-
transform: 'scale(0)',
29-
display: 'inline-block',
30-
animationName: keyframesLoading,
31-
animationDuration: calc.multiply(animationDurationMs, 35),
32-
animationIterationCount: 'infinite',
33-
animationTimingFunction: 'ease-in-out',
34-
animationFillMode: 'both',
35-
'&:nth-child(1)': {
36-
animationDelay: '0ms',
37-
},
38-
'&:nth-child(2)': {
39-
animationDelay: calc.multiply(animationDurationMs, 4),
40-
},
41-
'&:nth-child(3)': {
42-
animationDelay: calc.multiply(animationDurationMs, 8),
43-
},
44-
}),
45-
});
46-
47-
/**
48-
* The actual loading dot div.
49-
*/
50-
const LoadingAnimationDot = () => <div {...singleLoadingDotStencil()} />;
51-
52-
/**
53-
* A simple container for the loading dots.
54-
*/
55-
const loadingDotsStencil = createStencil({
56-
base: {
36+
base: ({loadingDotColor, animationDurationMs}) => ({
5737
display: 'inline-flex',
5838
gap: system.space.x2,
59-
},
39+
'& [data-part="loading-animation-dot"]': {
40+
backgroundColor: loadingDotColor,
41+
width: system.space.x4,
42+
height: system.space.x4,
43+
fontSize: system.space.zero,
44+
borderRadius: system.shape.round,
45+
transform: 'scale(0)',
46+
display: 'inline-block',
47+
animationName: keyframesLoading,
48+
animationDuration: calc.multiply(animationDurationMs, 35),
49+
animationIterationCount: 'infinite',
50+
animationTimingFunction: 'ease-in-out',
51+
animationFillMode: 'both',
52+
'&:nth-child(1)': {
53+
animationDelay: '0ms',
54+
},
55+
'&:nth-child(2)': {
56+
animationDelay: calc.multiply(animationDurationMs, 4),
57+
},
58+
'&:nth-child(3)': {
59+
animationDelay: calc.multiply(animationDurationMs, 8),
60+
},
61+
},
62+
}),
6063
});
6164

6265
/**
6366
* A simple component that displays three horizontal dots, to be used when some data is loading.
6467
*/
6568
export const LoadingDots = createComponent('div')({
6669
displayName: 'LoadingDots',
67-
Component: (elemProps: CSProps, ref, Element) => {
70+
Component: (
71+
{loadingDotColor, animationDurationMs, ...elemProps}: LoadingDotsProps,
72+
ref,
73+
Element
74+
) => {
6875
return (
69-
<Element ref={ref} {...handleCsProp(elemProps, loadingDotsStencil())}>
70-
<LoadingAnimationDot />
71-
<LoadingAnimationDot />
72-
<LoadingAnimationDot />
76+
<Element
77+
ref={ref}
78+
{...handleCsProp(elemProps, loadingDotsStencil({loadingDotColor, animationDurationMs}))}
79+
>
80+
<div data-part="loading-animation-dot" />
81+
<div data-part="loading-animation-dot" />
82+
<div data-part="loading-animation-dot" />
7383
</Element>
7484
);
7585
},

modules/react/loading-dots/stories/LoadingDots.mdx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
1+
import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
22
import {Basic} from './examples/Basic';
33
import {RTL} from './examples/RTL';
44
import {Accessible} from './examples/Accessible';
5+
import {CustomShape} from './examples/CustomShape';
6+
import {CustomColorAndAnimation} from './examples/CustomColorAndAnimation';
57
import * as LoadingDotsStories from './LoadingDots.stories';
68

79
<Meta of={LoadingDotsStories} />
@@ -11,7 +13,7 @@ import * as LoadingDotsStories from './LoadingDots.stories';
1113
Loading Dots make users aware that content is currently being loaded, processing, or that change
1214
will occur on the page.
1315

14-
[> Workday Design Reference](https://design.workday.com/components/indicators/loading-dots)
16+
[> Workday Design Reference](https://canvas.workdaydesign.com/components/indicators/loading-dots/)
1517

1618
## Installation
1719

@@ -29,10 +31,20 @@ yarn add @workday/canvas-kit-react
2931

3032
<ExampleCodeBlock code={RTL} />
3133

34+
### Custom Shape
35+
36+
<ExampleCodeBlock code={CustomShape} />
37+
38+
### Custom Color and Animation
39+
40+
<ExampleCodeBlock code={CustomColorAndAnimation} />
41+
3242
### Custom Styles
3343

3444
Loading Dots supports custom styling via the `cs` prop. For more information, check our
35-
["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-how-to-customize-styles--page).
45+
["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-how-to-customize-styles--docs).
46+
47+
Custom styling is also supported through the [Loading Dots documented props below](#props).
3648

3749
### Adding screen reader support to loading animations
3850

@@ -50,7 +62,6 @@ components included in Canvas to describe both the appearance and disappearance
5062

5163
<ExampleCodeBlock code={Accessible} />
5264

53-
## Props
65+
## Component API
5466

55-
Loading Dots does not have any documented props. Undocumented props are spread to its outermost
56-
element.
67+
<SymbolDoc name="LoadingDots" fileName="/react/" />

modules/react/loading-dots/stories/LoadingDots.stories.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {LoadingDots} from '@workday/canvas-kit-react/loading-dots';
77
import {Basic as BasicExample} from './examples/Basic';
88
import {RTL as RTLExample} from './examples/RTL';
99
import {Accessible as AccessibleExample} from './examples/Accessible';
10+
import {CustomShape as CustomShapeExample} from './examples/CustomShape';
11+
import {CustomColorAndAnimation as CustomColorAndAnimationExample} from './examples/CustomColorAndAnimation';
1012

1113
export default {
1214
title: 'Components/Indicators/Loading Dots',
@@ -30,3 +32,9 @@ export const RTL: Story = {
3032
export const Accessible: Story = {
3133
render: AccessibleExample,
3234
};
35+
export const CustomShape: Story = {
36+
render: CustomShapeExample,
37+
};
38+
export const CustomColorAndAnimation: Story = {
39+
render: CustomColorAndAnimationExample,
40+
};

modules/react/loading-dots/stories/examples/Accessible.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {LoadingDots} from '@workday/canvas-kit-react/loading-dots';
3-
import {base, system} from '@workday/canvas-tokens-web';
3+
import {system} from '@workday/canvas-tokens-web';
44
import {Flex} from '@workday/canvas-kit-react/layout';
55
import {SecondaryButton} from '@workday/canvas-kit-react/button';
66
import {createStyles} from '@workday/canvas-kit-styling';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import {LoadingDots} from '@workday/canvas-kit-react/loading-dots';
3+
import {system} from '@workday/canvas-tokens-web';
4+
import {createStyles} from '@workday/canvas-kit-styling';
5+
6+
const styleOverrides = {
7+
parentContainer: createStyles({
8+
display: 'flex',
9+
gap: system.space.x4,
10+
}),
11+
};
12+
13+
export const CustomColorAndAnimation = () => {
14+
return (
15+
<div className={styleOverrides.parentContainer}>
16+
<LoadingDots loadingDotColor={system.color.fg.primary.default} animationDurationMs="60ms" />
17+
</div>
18+
);
19+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import {LoadingDots, loadingDotsStencil} from '@workday/canvas-kit-react/loading-dots';
3+
import {system} from '@workday/canvas-tokens-web';
4+
import {createStyles, createStencil} from '@workday/canvas-kit-styling';
5+
6+
const styleOverrides = {
7+
parentContainer: createStyles({
8+
display: 'flex',
9+
gap: system.space.x4,
10+
}),
11+
};
12+
13+
const loadingStencil = createStencil({
14+
base: {
15+
borderRadius: system.shape.round,
16+
backgroundColor: system.color.bg.overlay,
17+
height: 80,
18+
width: 80,
19+
alignItems: 'center',
20+
justifyContent: 'center',
21+
display: 'flex',
22+
[loadingDotsStencil.vars.loadingDotColor]: system.color.icon.inverse,
23+
},
24+
});
25+
26+
export const CustomShape = () => {
27+
return (
28+
<div className={styleOverrides.parentContainer}>
29+
<LoadingDots cs={loadingStencil()} />
30+
</div>
31+
);
32+
};

0 commit comments

Comments
 (0)