Skip to content

Commit

Permalink
improve blocks to add classes
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl committed Dec 1, 2023
1 parent 5204593 commit ffe43ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
16 changes: 13 additions & 3 deletions src/utils/Theme/helpers/ColorBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import React from 'react';
import { useTheme } from '../ThemeContext';
import chroma from 'chroma-js';

export const ColorBlock = ({ name, color }) => (
export const ColorBlock = ({ name, color, className }) => (
<div
key={name}
style={{
border: 'solid 1px var(--slate-500)',
borderRadius: 'var(--border-radius-md)',
overflow: 'hidden'
}}
className={className}
>
<div
style={{
Expand Down Expand Up @@ -47,7 +48,12 @@ export const ColorBlock = ({ name, color }) => (
</div>
);

export const ColorPaletteBlock = ({ name, color, showName = true }) => {
export const ColorPaletteBlock = ({
name,
color,
className,
showName = true
}) => {
const valid = chroma.valid(color);
const fontColor =
valid && !name.includes('overlay')
Expand All @@ -59,6 +65,7 @@ export const ColorPaletteBlock = ({ name, color, showName = true }) => {
return (
<div
key={name}
className={className}
style={{
borderRight: 'solid 1px var(--slate-500)'
}}
Expand All @@ -67,7 +74,8 @@ export const ColorPaletteBlock = ({ name, color, showName = true }) => {
style={{
padding: 'var(--spacing-md)',
background: color,
height: '100%'
height: '100%',
minHeight: 50
}}
>
{showName && (
Expand Down Expand Up @@ -98,10 +106,12 @@ export const ColorPaletteBlock = ({ name, color, showName = true }) => {
export const ColorPaletteBlocks = ({
name,
colors,
className,
token = null,
showNames = true
}) => (
<div
className={className}
style={{
marginBottom: 'var(--spacing-xl)'
}}
Expand Down
7 changes: 6 additions & 1 deletion src/utils/Theme/helpers/IconBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ export interface IconBlockProps {
name: string;
component?: any;
src?: any;
className?: string;
}

export const IconBlock: FC<IconBlockProps> = ({
name,
src,
className,
component: Component
}) => (
<div
className={className}
style={{
display: 'flex',
flexDirection: 'column',
Expand Down Expand Up @@ -45,16 +48,18 @@ export const IconBlock: FC<IconBlockProps> = ({

export interface IconBlocksProps {
icons: IconBlockProps[];
className?: string;
}

export const IconBlocks: FC<IconBlocksProps> = ({ icons }) => (
export const IconBlocks: FC<IconBlocksProps> = ({ icons, className }) => (
<div
style={{
display: 'grid',
gridGap: 'var(--spacing-lg)',
gridTemplateColumns: 'repeat(auto-fill, minmax(120px, 1fr))',
justifyItems: 'stretch'
}}
className={className}
>
{icons.map(key => (
<IconBlock key={key.name} {...key} />
Expand Down
10 changes: 6 additions & 4 deletions src/utils/Theme/helpers/TypographyBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { useTheme } from '../ThemeContext';
import { camelToDash } from '../utils';

export const TypographyLetterBlock = ({ fontFamily }) => (
export const TypographyLetterBlock = ({ fontFamily, className }) => (
<div
className={className}
style={{
fontFamily,
display: 'flex',
Expand All @@ -28,8 +29,8 @@ export const TypographyLetterBlock = ({ fontFamily }) => (
</div>
);

export const TypographySizeBlock = ({ sizes }) => (
<div>
export const TypographySizeBlock = ({ sizes, className }) => (
<div className={className}>
{Object.keys(sizes).map(size => (
<div
key={size}
Expand Down Expand Up @@ -74,8 +75,9 @@ export const TypographySizeBlock = ({ sizes }) => (
</div>
);

export const TypographyWeightBlock = ({ weights }) => (
export const TypographyWeightBlock = ({ weights, className }) => (
<div
className={className}
style={{
padding: 'var(--spacing-md)',
borderRadius: 'var(--border-radius-md)',
Expand Down

0 comments on commit ffe43ed

Please sign in to comment.