Skip to content

Commit

Permalink
revert: removed isTransparent prop
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-krakowski committed Jul 12, 2021
1 parent a1d0785 commit ce37c7e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ import { Meta, ColorPalette, ColorItem } from '@storybook/addon-docs';
Apple60: 'rgba(102,191,60,.6)',
Apple30: 'rgba(102,191,60,.3)',
}}
isTransparent
/>
</ColorPalette>
10 changes: 2 additions & 8 deletions lib/components/src/Colors/colorpalette.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Dark theme Colors
<ColorPalette>
{Object.entries(convert(themes.dark).color).map(([k, v]) => {
if (typeof v === 'string' && (v.match(/^#/) || v.match(/^rgb/) || k.match(/color/i))) {
return <ColorItem key={k} title={k} colors={{ [k]: v }} isTransparent />;
return <ColorItem key={k} title={k} colors={{ [k]: v }} />;
} else if (typeof v === 'object') {
return (
<ColorItem
Expand All @@ -29,7 +29,6 @@ Dark theme Colors
: acc,
{}
)}
isTransparent
/>
);
}
Expand All @@ -50,7 +49,6 @@ Dark theme Backgrounds
key={k}
title={k}
colors={{ [k]: v }}
isTransparent
/>
);
} else if (typeof v === 'object') {
Expand All @@ -60,7 +58,6 @@ Dark theme Backgrounds
key={k}
title={k}
colors={colors}
isTransparent
/>
);
}
Expand All @@ -75,7 +72,7 @@ Light theme Colors
<ColorPalette>
{Object.entries(convert(themes.light).color).map(([k, v]) => {
if (typeof v === 'string' && (v.match(/^#/) || v.match(/^rgb/) || k.match(/color/i))) {
return <ColorItem key={k} title={k} colors={{ [k]: v }} isTransparent/>;
return <ColorItem key={k} title={k} colors={{ [k]: v }} />;
} else if (typeof v === 'object') {
return (
<ColorItem
Expand All @@ -89,7 +86,6 @@ Light theme Colors
: acc,
{}
)}
isTransparent
/>
);
}
Expand All @@ -110,7 +106,6 @@ Light theme Backgrounds
key={k}
title={k}
colors={{ [k]: v }}
isTransparent
/>
);
} else if (typeof v === 'object') {
Expand All @@ -120,7 +115,6 @@ Light theme Backgrounds
key={k}
title={k}
colors={colors}
isTransparent
/>
);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/components/src/blocks/ColorPalette.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const defaultStyle = () => (
'rgba(102,191,60,.6)',
'rgba(102,191,60,.3)',
]}
isTransparent
/>
<ColorItem
title="gradient"
Expand Down Expand Up @@ -56,7 +55,6 @@ export const NamedColors = () => (
Apple60: 'rgba(102,191,60,.6)',
Apple30: 'rgba(102,191,60,.3)',
}}
isTransparent
/>
<ColorItem
title="gradient"
Expand Down
30 changes: 8 additions & 22 deletions lib/components/src/blocks/ColorPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,15 @@ const Swatch = styled.div<SwatchProps>(({ background }) => ({
},
}));

interface SwatchColorsProps {
isTransparent: boolean;
}
const SwatchColors = styled.div<SwatchColorsProps>(({ theme, isTransparent }) => ({
const SwatchColors = styled.div(({ theme }) => ({
...getBlockBackgroundStyle(theme),
display: 'flex',
flexDirection: 'row',
height: 50,
marginBottom: 5,
overflow: 'hidden',

...(isTransparent && {
backgroundColor: 'white',
backgroundImage: `repeating-linear-gradient(-45deg, #ccc, #ccc 1px, #fff 1px, #fff 16px)`,
}),
backgroundColor: 'white',
backgroundImage: `repeating-linear-gradient(-45deg, #ccc, #ccc 1px, #fff 1px, #fff 16px)`,
}));

const SwatchSpecimen = styled.div({
Expand Down Expand Up @@ -142,7 +136,6 @@ interface ColorProps {
title: string;
subtitle: string;
colors: Colors;
isTransparent?: boolean;
}

function renderSwatch(color: string, index: number) {
Expand All @@ -160,20 +153,18 @@ function renderSwatchLabel(color: string, index: number, colorDescription?: stri
);
}

function renderSwatchSpecimen(colors: Colors, isTransparent: boolean) {
function renderSwatchSpecimen(colors: Colors) {
if (Array.isArray(colors)) {
return (
<SwatchSpecimen>
<SwatchColors isTransparent={isTransparent}>
{colors.map((color, index) => renderSwatch(color, index))}
</SwatchColors>
<SwatchColors>{colors.map((color, index) => renderSwatch(color, index))}</SwatchColors>
<SwatchLabels>{colors.map((color, index) => renderSwatchLabel(color, index))}</SwatchLabels>
</SwatchSpecimen>
);
}
return (
<SwatchSpecimen>
<SwatchColors isTransparent={isTransparent}>
<SwatchColors>
{Object.values(colors).map((color, index) => renderSwatch(color, index))}
</SwatchColors>
<SwatchLabels>
Expand All @@ -187,19 +178,14 @@ function renderSwatchSpecimen(colors: Colors, isTransparent: boolean) {
* A single color row your styleguide showing title, subtitle and one or more colors, used
* as a child of `ColorPalette`.
*/
export const ColorItem: FunctionComponent<ColorProps> = ({
title,
subtitle,
colors,
isTransparent,
}) => {
export const ColorItem: FunctionComponent<ColorProps> = ({ title, subtitle, colors }) => {
return (
<Item>
<ItemDescription>
<ItemTitle>{title}</ItemTitle>
<ItemSubtitle>{subtitle}</ItemSubtitle>
</ItemDescription>
<Swatches>{renderSwatchSpecimen(colors, isTransparent)}</Swatches>
<Swatches>{renderSwatchSpecimen(colors)}</Swatches>
</Item>
);
};
Expand Down

0 comments on commit ce37c7e

Please sign in to comment.