-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Counter * reduce size, change global styles
- Loading branch information
1 parent
1028284
commit a8a011e
Showing
8 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { css } from '@emotion/react'; | ||
import theme from '../theme'; | ||
|
||
type CounterProps = PropsWithChildren<{ | ||
/** | ||
* The color of the counter | ||
* @default 'default' | ||
**/ | ||
variant?: 'default' | 'danger'; | ||
}>; | ||
|
||
const counterCSS = css` | ||
display: inline-block; | ||
padding: 0 var(--ac-global-dimension-static-size-65); | ||
border-radius: calc( | ||
( | ||
${theme.typography.sizes.small.lineHeight}px + 2 * | ||
var(--ac-global-dimension-static-size-25) / 2 | ||
) | ||
); | ||
background-color: var(--ac-global-background-color-light); | ||
font-size: ${theme.typography.sizes.small.fontSize}px; | ||
line-height: ${theme.typography.sizes.small.lineHeight}px; | ||
color: var(--ac-global-text-color-900); | ||
&[data-variant='danger'] { | ||
background-color: var(--ac-global-background-color-danger); | ||
} | ||
`; | ||
|
||
export function Counter(props: CounterProps) { | ||
const { children, variant = 'default' } = props; | ||
return ( | ||
<span css={counterCSS} data-variant={variant} className="ac-counter"> | ||
{children} | ||
</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Counter"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { withDesign } from 'storybook-addon-designs'; | ||
import { LabelGroup, Label, LabelProps } from '../src/label'; | ||
import { Counter, Provider } from '../src'; | ||
|
||
const meta: Meta = { | ||
title: 'Counter', | ||
component: Counter, | ||
decorators: [withDesign], | ||
argTypes: { | ||
children: { | ||
control: { | ||
type: 'text', | ||
default: 'Label', | ||
}, | ||
}, | ||
}, | ||
parameters: { | ||
controls: { expanded: true }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
/** | ||
* A gallery of all the variants | ||
*/ | ||
export const Gallery = () => ( | ||
<Provider> | ||
<div | ||
css={css` | ||
display: flex; | ||
gap: 4px; | ||
`} | ||
> | ||
<Counter>12</Counter> | ||
<Counter variant="danger">12</Counter> | ||
</div> | ||
</Provider> | ||
); | ||
|
||
const Template: Story<LabelProps> = args => <Label {...args}>Label Text</Label>; | ||
|
||
// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test | ||
// https://storybook.js.org/docs/react/workflows/unit-testing | ||
export const Default = Template.bind({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters