-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8114ef5
commit 71ba0de
Showing
10 changed files
with
260 additions
and
63 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
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
70 changes: 70 additions & 0 deletions
70
ui/components/src/ActionContainer/ActionContainer.stories.tsx
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,70 @@ | ||
import React from 'react'; | ||
import { Donut } from 'theme-ui'; | ||
import { ExternalLink } from '../ExternalLink'; | ||
import { ActionContainer } from './ActionContainer'; | ||
|
||
export default { | ||
title: 'Components/ActionContainer', | ||
component: ActionContainer, | ||
}; | ||
|
||
export const overview = () => { | ||
return ( | ||
<ActionContainer | ||
actions={[ | ||
{ | ||
title: 'action 1', | ||
onClick: () => console.log('clicked'), | ||
}, | ||
{ | ||
title: <ExternalLink href="https://google.com">google</ExternalLink>, | ||
onClick: () => console.log('clicked'), | ||
}, | ||
]} | ||
> | ||
<Donut value={1 / 2} /> | ||
</ActionContainer> | ||
); | ||
}; | ||
|
||
export const order = () => ( | ||
<ActionContainer | ||
actions={[ | ||
{ | ||
title: 'action 1', | ||
onClick: () => console.log('clicked'), | ||
order: 1, | ||
}, | ||
{ | ||
title: <ExternalLink href="https://google.com">google</ExternalLink>, | ||
onClick: () => console.log('clicked'), | ||
order: 0, | ||
}, | ||
]} | ||
> | ||
<Donut value={1 / 2} /> | ||
</ActionContainer> | ||
); | ||
|
||
export const override = () => ( | ||
<ActionContainer | ||
actions={[ | ||
{ | ||
title: 'action 1', | ||
onClick: () => console.log('clicked'), | ||
id: 'copy', | ||
}, | ||
{ | ||
title: <ExternalLink href="https://google.com">google</ExternalLink>, | ||
onClick: () => console.log('clicked'), | ||
}, | ||
{ | ||
//this will override the action above | ||
title: 'Copy', | ||
id: 'copy', | ||
}, | ||
]} | ||
> | ||
<Donut value={1 / 2} /> | ||
</ActionContainer> | ||
); |
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,44 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { transparentize } from 'polished'; | ||
import { jsx, Box, useThemeUI } from 'theme-ui'; | ||
import { ActionBar, ActionItem } from '../ActionBar'; | ||
|
||
export interface ActionContainerProps { | ||
/** | ||
* optional actions provided to the component | ||
*/ | ||
actions?: ActionItem[]; | ||
} | ||
|
||
/** | ||
* a boxed container with actions. | ||
*/ | ||
export const ActionContainer: FC<ActionContainerProps> = ({ | ||
children, | ||
actions, | ||
}) => { | ||
const { theme } = useThemeUI(); | ||
return ( | ||
<div> | ||
{actions && <ActionBar actions={actions} />} | ||
<Box | ||
sx={{ | ||
borderRadius: 4, | ||
boxShadow: `${transparentize( | ||
0.9, | ||
theme.colors?.text as string, | ||
)} 0 1px 3px 1px, ${transparentize( | ||
0.9, | ||
theme.colors?.text as string, | ||
)} 0 0 0 1px`, | ||
'*:first-child': { | ||
paddingTop: 3, | ||
}, | ||
}} | ||
> | ||
{children} | ||
</Box> | ||
</div> | ||
); | ||
}; |
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 './ActionContainer'; |
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
Oops, something went wrong.