diff --git a/ui/components/src/ActionBar/ActionBar.stories.tsx b/ui/components/src/ActionBar/ActionBar.stories.tsx index 947a48f92..727cd764d 100644 --- a/ui/components/src/ActionBar/ActionBar.stories.tsx +++ b/ui/components/src/ActionBar/ActionBar.stories.tsx @@ -14,7 +14,7 @@ const Container: React.FC = ({ children }) => ( {children} @@ -30,7 +30,7 @@ export const simple = () => ( onClick: () => console.log('clicked'), }, { - title: 'action 2', + title: google, onClick: () => console.log('clicked'), }, ]} diff --git a/ui/components/src/ActionBar/ActionBar.tsx b/ui/components/src/ActionBar/ActionBar.tsx index feb151739..664c18fc9 100644 --- a/ui/components/src/ActionBar/ActionBar.tsx +++ b/ui/components/src/ActionBar/ActionBar.tsx @@ -1,7 +1,8 @@ /** @jsx jsx */ import React, { FunctionComponent, MouseEvent } from 'react'; import styled from '@emotion/styled'; -import { Box, Button, jsx } from 'theme-ui'; +import { transparentize } from 'polished'; +import { Theme, Box, Button, jsx, useThemeUI } from 'theme-ui'; export interface ActionItem { title: React.ReactNode; @@ -25,42 +26,66 @@ const StyledFlex = styled.div` width: 100%; `; -const ActionColors = (disabled: boolean | undefined) => ({ - backgroundColor: 'highlight', - color: disabled ? '#ddd' : 'background', - cursor: disabled ? 'not-allowed' : undefined, - px: 2, - py: 1, - lineHeight: 1, - borderRadius: 0, - border: 'none', -}); +const ActionColors = ({ + theme, + disabled, +}: { + theme: Theme; + disabled: boolean | undefined; +}) => { + console.log(theme); + return { + backgroundColor: transparentize( + 0.15, + theme.colors?.['highlight'] as string, + ), + color: disabled ? '#ddd' : 'background', + cursor: disabled ? 'not-allowed' : undefined, + px: 2, + py: 1, + lineHeight: 1, + borderRadius: 1, + display: 'inline-block', + boxShadow: `${transparentize( + 0.9, + theme.colors?.text as string, + )} 0 1px 3px 1px, ${transparentize( + 0.35, + theme.colors?.text as string, + )} 0 0 0 1px`, + border: `1px solid ${theme.colors?.['highlight'] as string}`, + }; +}; export const ActionBar: FunctionComponent = ({ actionItems, -}) => ( - - - {actionItems - .filter(({ hidden }) => !hidden) - .map(({ title, onClick, disabled }, index: number) => ( - - {typeof title === 'string' ? ( - - ) : ( - title - )} - - ))} - - -); +}) => { + const { theme } = useThemeUI(); + return ( + + + {actionItems + .filter(({ hidden }) => !hidden) + .map(({ title, onClick, disabled }, index: number) => ( + + {typeof title === 'string' ? ( + + ) : ( + title + )} + + ))} + + + ); +}; diff --git a/ui/components/src/BlockContainer/BlockContainer.tsx b/ui/components/src/BlockContainer/BlockContainer.tsx index 7f12ad4a2..067aa96ba 100644 --- a/ui/components/src/BlockContainer/BlockContainer.tsx +++ b/ui/components/src/BlockContainer/BlockContainer.tsx @@ -1,6 +1,7 @@ /** @jsx jsx */ import React, { FC } from 'react'; -import { jsx, Flex, Link, Divider } from 'theme-ui'; +import { transparentize } from 'polished'; +import { jsx, Flex, Link, Divider, Box, useThemeUI } from 'theme-ui'; import Octicon, { Link as LinkIcon, ChevronRight, @@ -11,11 +12,6 @@ import { Subtitle } from '../Subtitle'; import { Collapsible } from '../Collapsible'; import { ActionBar, ActionItem } from '../ActionBar'; -const SpacedBlockContainer = styled.div(() => ({ - position: 'relative', - margin: '25px 0 40px 0', -})); - const FramedBlockContainer = styled.div(() => ({ boxSadow: 'rgba(0, 0, 0, 0.1) 0px 1px 3px 0px', borderRadius: 4, @@ -39,6 +35,7 @@ export const BlockContainer: FC = ({ actions, }) => { const [isOpen, setIsOpen] = React.useState(true); + const { theme } = useThemeUI(); const id = title ? title.toLowerCase().replace(/\s/g, '-') : undefined; //workaround for storybook iframe url const url = @@ -46,7 +43,14 @@ export const BlockContainer: FC = ({ ? document.referrer : document.location.href) || ''; return ( - + = ({ )} - - {title && {title}} - setIsOpen(!isOpen)} - > - - + {title && ( + setIsOpen(!isOpen)} + > + + {title} + + + + )} {actions && } - {children} + + {children} + {!isOpen && } - + ); };