From 1ec321a1074647529b4253038c4d19b88ab8e60d Mon Sep 17 00:00:00 2001 From: Sebastian-ubs <141921979+Sebastian-ubs@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:01:25 +0200 Subject: [PATCH] preview: intersected color preview for the theme colors page (#996) preview: different theme color display --- .../preview/components/guide.component.tsx | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/lib/platform-bible-react/src/preview/components/guide.component.tsx b/lib/platform-bible-react/src/preview/components/guide.component.tsx index 3240c94ec7..06aae9c833 100644 --- a/lib/platform-bible-react/src/preview/components/guide.component.tsx +++ b/lib/platform-bible-react/src/preview/components/guide.component.tsx @@ -12,19 +12,29 @@ import { DirToggle, DirectionProps } from '../direction-toggle'; import { ThemeButton } from '../theme-toggle.component'; import { useTheme } from '../theme-provider.component'; -function createColorCells(color: string) { +function createColorCells(color: string, invert: boolean = false) { const colorString = getComputedStyle(document.documentElement).getPropertyValue(`--${color}`); - const additionalClasses = colorString.split(', ')[2] === '0%' ? ' pr-text-white' : ''; return ( <> - {color} - - - + {invert ? '' : {color}} + {createPreviewCell( + color, + colorString.split(', ')[2] === '0%' ? 'white' : 'inherit', + colorString, + )} + {invert ? {color} : ''} ); } +function createPreviewCell(color: string, foreground: string, text: string) { + return ( + + + + ); +} + function Guide({ direction, onChangeDirection: setDirection }: DirectionProps) { return (
@@ -203,23 +213,39 @@ function Guide({ direction, onChangeDirection: setDirection }: DirectionProps) { className="pr-bg-background-foreground pr-bg-accent pr-bg-accent-foreground pr-bg-background pr-bg-border pr-bg-card pr-bg-card-foreground pr-bg-destructive pr-bg-destructive-foreground pr-bg-input pr-bg-muted pr-bg-muted-foreground pr-bg-popover pr-bg-popover-foreground pr-bg-primary pr-bg-primary pr-bg-primary-foreground pr-bg-ring pr-bg-secondary pr-bg-secondary-foreground" /> + + + + + + + {['primary', 'secondary', 'destructive', 'muted', 'accent', 'popover', 'card'].map( (color) => { return ( + {createPreviewCell(color, `${color}-foreground`, color)} {createColorCells(color)} - {createColorCells(`${color}-foreground`)} + {createColorCells(`${color}-foreground`, true)} ); }, )} + {createPreviewCell('background', 'foreground', 'background')} {createColorCells('background')} - {createColorCells('foreground')} + {createColorCells('foreground', true)} {['border', 'input', 'ring'].map((color) => { - return {createColorCells(color)}; + return ( + + + ); })}
Preview + BackgroundForeground +
+ {createColorCells(color)} +