From 84d8c82e93d81528b37a1df4586296a31edcc102 Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Tue, 27 Apr 2021 18:13:58 -0700 Subject: [PATCH] chore #306 - Extract ProgressBar component --- .../ProgressBar/ProgressBar.stories.tsx | 22 +++++ src/components/ProgressBar/index.tsx | 93 +++++++++++++++++++ src/components/index.ts | 3 + 3 files changed, 118 insertions(+) create mode 100644 src/components/ProgressBar/ProgressBar.stories.tsx create mode 100644 src/components/ProgressBar/index.tsx diff --git a/src/components/ProgressBar/ProgressBar.stories.tsx b/src/components/ProgressBar/ProgressBar.stories.tsx new file mode 100644 index 00000000..93844800 --- /dev/null +++ b/src/components/ProgressBar/ProgressBar.stories.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import { Meta, Story } from '@storybook/react/types-6-0' +import { ProgressBar, ProgressBarProps } from '.' + +export default { + argTypes: { + classes: { control: { disable: true } } + }, + component: ProgressBar, + decorators: [ + (ProgressBarStory: Story) => ( +
+ +
+ ) + ], + title: 'ProgressBar' +} as Meta + +const Template: Story = args => + +export const Default = Template.bind({}) diff --git a/src/components/ProgressBar/index.tsx b/src/components/ProgressBar/index.tsx new file mode 100644 index 00000000..6b6c9bd0 --- /dev/null +++ b/src/components/ProgressBar/index.tsx @@ -0,0 +1,93 @@ +import cn from 'classnames' +import { createUseStyles } from 'react-jss' +import React, { FC } from 'react' +import { styleguide, themedStyles, ThemeType } from '../assets/styles' + +const { dark, light } = ThemeType + +const { + colors: { blacks, grays }, + flexCenter, + spacing +} = styleguide + +/* eslint-disable quotes */ +const useStyles = createUseStyles({ + container: { + ...flexCenter, + flexDirection: 'column' + }, + percentage: { + '&:before': { + animation: 'percent 4s forwards', + color: themedStyles[light].base.color, + content: "'0%'" + }, + alignSelf: 'center', + paddingTop: spacing['m+'] + }, + progressBar: { + animation: 'load 4s normal forwards', + background: blacks['lighten-80'], + borderRadius: '100px', + boxShadow: '', + height: 16, + width: 0 + }, + progressBarContainer: { + alignItems: 'center', + background: grays['lighten-40'], + borderRadius: '100px', + display: 'flex', + height: 16, + justifyContent: 'flex-start', + position: 'relative', + width: 500 + }, + // eslint-disable-next-line sort-keys + '@global': { + '@keyframes load': { + '0%': { width: 0 }, + '100%': { width: '100%' } + }, + '@keyframes percent': { + '0%': { content: "'Tightening the screws...'" }, + '25%': { content: "'Setting the sails...'" }, + '50%': { content: "'Grinding the ax...'" }, + '75%': { content: "'Kneading the dough...'" }, + // eslint-disable-next-line sort-keys + '100%': { content: "'Liftoff!'" } + }, + [`.${dark}`]: { + '& $percentage:before': { + color: themedStyles[dark].base.color + }, + '& $progressBar': { + background: themedStyles[dark].base.borderColor + }, + '& $progressBarContainer': { + background: blacks['darken-40'] + } + } + } +}) +/* eslint-enable quotes */ + +export interface ProgressBarProps { + classes: string[] +} + +export const ProgressBar: FC = ({ + classes = [] +}: ProgressBarProps) => { + const compClasses = useStyles() + + return ( +
+
+
+
+
+
+ ) +} diff --git a/src/components/index.ts b/src/components/index.ts index dcb2e654..6187e72a 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -16,6 +16,8 @@ export * from './Icon' export * from './IconButton' export * from './JSONPathPicker' export * from './Link' +export * from './Logs' +export * from './Markdown' export * from './Modal' export * from './Menu' export * from './MultipleChoice' @@ -23,6 +25,7 @@ export * from './Notification' export * from './NotificationV2' export * from './PageLoader' export * from './Popover' +export * from './ProgressBar' export * from './RadioGroup' export * from './Select' export * from './ShortcutMicrocopy'