Skip to content

Commit

Permalink
fix: rray colors handling
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Feb 22, 2021
1 parent e0958a5 commit 50ad9e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions ui/components/src/Tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { Document, Example, ControlTypes } from '@component-controls/core';
import { tailwind } from '@theme-ui/presets';
import { ThemeProvider } from '../ThemeContext/ThemeContext';
import { Tag, TagProps } from './Tag';

export default {
Expand All @@ -15,3 +17,11 @@ export const overview: Example<TagProps> = ({ color }) => {
overview.controls = {
color: { type: ControlTypes.COLOR, value: 'red' },
};

export const twilwindArrayColors: Example<TagProps> = () => {
return (
<ThemeProvider theme={tailwind as any}>
<Tag color="red">some text</Tag>
</ThemeProvider>
);
};
8 changes: 6 additions & 2 deletions ui/components/src/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@ export interface TagProps {
raw?: string;
}

const defColor = 'white';
/**
* A container component to display text in a colored box, with a semi-transparent background.
*/
export const Tag: FC<TagProps & Omit<BoxProps, 'variant'>> = ({
children,
raw,
color = 'white',
color = defColor,
borderSize = 2,
transparentAmount = 0.85,
variant,
...rest
}) => {
const theme = useTheme() as Theme;
const resolvedColor = getColor(theme, color);
let resolvedColor = getColor(theme, color);
if (typeof resolvedColor !== 'string') {
resolvedColor = defColor;
}
return (
<Box
as="span"
Expand Down

0 comments on commit 50ad9e1

Please sign in to comment.