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(ui, components): style the loader with the design-system #9249

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
53 changes: 33 additions & 20 deletions lib/components/src/Loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
import { keyframes, styled } from '@storybook/theming';
import React from 'react';
import { styled } from '@storybook/theming';
import { transparentize, opacify } from 'polished';
import { rotate360 } from '../shared/animation';

const spin = keyframes`
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
`;

export const Loader = styled.div(({ theme }) => ({
animation: `${spin} 1s linear infinite`,
borderRadius: '50%',
height: 48,
left: 'calc(50% - 24px)',
const LoaderWrapper = styled.div(({ theme }) => ({
borderRadius: '3em',
cursor: 'progress',
display: 'inline-block',
overflow: 'hidden',
position: 'absolute',
top: 'calc(50% - 24px)',
width: 48,
transition: 'all 200ms ease-out',
verticalAlign: 'top',
top: '50%',
left: '50%',
marginTop: -16,
marginLeft: -16,
height: 32,
width: 32,
zIndex: 4,
border: `3px solid ${theme.color.secondary}`,
borderTop: '3px solid transparent',
borderWidth: 2,
borderStyle: 'solid',
borderColor: transparentize(0.06, theme.appBorderColor),
borderTopColor: opacify(0.07, theme.appBorderColor),
animation: `${rotate360} 0.7s linear infinite`,
}));

export function Loader({ ...props }) {
return (
<LoaderWrapper
aria-label="Content is loading ..."
aria-live="polite"
role="status"
{...props}
/>
);
}
10 changes: 10 additions & 0 deletions lib/components/src/shared/animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { keyframes } from '@storybook/theming';

export const rotate360 = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
`;
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/SidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const Item = styled(({ className, children, id }) => (
}),
({ theme, loading }) =>
loading && {
'&& > svg + span': { background: theme.color.medium },
'&& > svg + span': { background: theme.appBorderColor },
'&& > *': theme.animation.inlineGlow,
'&& > span': { borderColor: 'transparent' },
}
Expand Down