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(TDP-12824): Design system Loading to have defined size available #5222

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .changeset/poor-grapes-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@talend/design-system": major
---

# BREAKING CHANGE
Design system - `Loading` component now has a built in size from **XS** to **XXL** and default is **M**.
Since it now has a default size it won't take up all the size available and you might have have to adapt your current styling to it.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ exports[`Accordion should render a11y html 1`] = `
class="theme-status__icon"
>
<svg
style="width: 100%; height: 100%;"
style="width: 1rem; height: 1rem;"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ exports[`Button should render a11y html 1`] = `
<svg
aria-hidden="true"
data-test="button.loading"
style="width: 100%; height: 100%;"
style="width: 1rem; height: 1rem;"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
Expand Down
77 changes: 47 additions & 30 deletions packages/design-system/src/components/Loading/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
import { forwardRef, HTMLAttributes } from 'react';

export type LoadingProps = HTMLAttributes<SVGSVGElement>;
import { IconSize } from '@talend/icons';

export const Loading = forwardRef<SVGSVGElement, LoadingProps>((props, ref) => (
<svg
xmlns="http://www.w3.org/2000/svg"
style={{ width: '100%', height: '100%' }}
viewBox="0 0 16 16"
ref={ref}
{...props}
>
<g>
<path
fill="currentColor"
d="M8 0a8 8 0 100 16A8 8 0 008 0zm0 14.227A6.227 6.227 0 118 1.773a6.227 6.227 0 010 12.454z"
opacity=".2"
/>
<path
fill="currentColor"
d="M11.11 2.611l.886-1.534A7.951 7.951 0 008 0v1.773c1.134 0 2.195.308 3.11.838z"
>
<animateTransform
attributeName="transform"
type="rotate"
from="0 8 8"
to="360 8 8"
dur=".85s"
repeatCount="indefinite"
declare type LoadingIconSize = IconSize | 'XL' | 'XXL';
const getNumericSize = (size: LoadingIconSize) => {
return {
XS: '0.5rem',
S: '0.75rem',
M: '1rem',
L: '1.5rem',
XL: '2.5rem',
XXL: '4rem',
}[size];
};

export type LoadingProps = HTMLAttributes<SVGSVGElement> & { size?: LoadingIconSize };

export const Loading = forwardRef<SVGSVGElement, LoadingProps>((props, ref) => {
const size = getNumericSize(props.size || 'M');
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
ref={ref}
{...props}
style={{ width: size, height: size, ...props.style }}
>
<g>
<path
fill="currentColor"
d="M8 0a8 8 0 100 16A8 8 0 008 0zm0 14.227A6.227 6.227 0 118 1.773a6.227 6.227 0 010 12.454z"
opacity=".2"
/>
</path>
</g>
</svg>
));
<path
fill="currentColor"
d="M11.11 2.611l.886-1.534A7.951 7.951 0 008 0v1.773c1.134 0 2.195.308 3.11.838z"
>
<animateTransform
attributeName="transform"
type="rotate"
from="0 8 8"
to="360 8 8"
dur=".85s"
repeatCount="indefinite"
/>
</path>
</g>
</svg>
);
});

Loading.displayName = 'Loading';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Loading should render a11y html 1`] = `
<main>
<svg
style="width: 100%; height: 100%;"
style="width: 1rem; height: 1rem;"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
Expand Down
13 changes: 9 additions & 4 deletions packages/design-system/src/stories/feedback/Loading.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import tokens from '@talend/design-tokens';
import { Loading } from '../..';
import { StackVertical } from '../..';

export default {
component: Loading,
title: 'Feedback/Loading',
};

export const Default = () => (
<div style={{ maxWidth: tokens.coralSizingMaximal }}>
<Loading />
</div>
<StackVertical gap="S">
<Loading size="XS" />
<Loading size="S" />
<Loading size="M" />
<Loading size="L" />
<Loading size="XL" />
<Loading size="XXL" />
</StackVertical>
);
Loading