diff --git a/showcases/patternhub/components/copy-clipboard-button/index.tsx b/showcases/patternhub/components/copy-clipboard-button/index.tsx index 67544245182..d0cc9a7d0e1 100644 --- a/showcases/patternhub/components/copy-clipboard-button/index.tsx +++ b/showcases/patternhub/components/copy-clipboard-button/index.tsx @@ -1,5 +1,5 @@ -import { type ReactNode, useEffect, useState } from 'react'; -import { DBButton, DBTooltip } from '../src'; +import { type MouseEvent, type ReactNode, useEffect, useState } from 'react'; +import { DBButton, DBTooltip } from '../../../../output/react/src/index'; export type CopyClipboardButtonProps = { name: string; @@ -14,9 +14,7 @@ const CopyClipboardButton = ({ }: CopyClipboardButtonProps) => { const [justCopied, setJustCopied] = useState(false); - const onCopyButtonClick = async ( - event: React.MouseEvent - ) => { + const onCopyButtonClick = async (event: MouseEvent) => { event.stopPropagation(); if (typeof navigator !== 'undefined') { diff --git a/showcases/patternhub/components/foundations/colors/colors-grid/index.tsx b/showcases/patternhub/components/foundations/colors/colors-grid/index.tsx new file mode 100644 index 00000000000..29d90480b11 --- /dev/null +++ b/showcases/patternhub/components/foundations/colors/colors-grid/index.tsx @@ -0,0 +1,63 @@ +import checkerboard from '../../../../assets/images/checkerboard.png'; +import CopyClipboardButton from '../../../copy-clipboard-button'; +import { type ColorValue } from '../data'; + +const ColorsGrid = ({ + values, + prefixClass, + dataAttributeName, + showCheckerboard, + enableDarkMode, + variant +}: { + values: ColorValue[]; + prefixClass: string; + dataAttributeName: string; + showCheckerboard: boolean; + enableDarkMode: boolean; + variant: 'class' | 'dataAttribute'; +}) => { + const getText = (value: string) => + variant === 'class' + ? `${prefixClass}${value}` + : `${dataAttributeName}="${value}"`; + + const getAttributes = (value: string) => + variant === 'class' + ? { className: `${prefixClass}${value}` } + : { [dataAttributeName]: value }; + + return ( +
+ {' '} + {values.map((value, index) => { + const v = typeof value === 'string' ? value : value.value; + const appendix = + typeof value === 'string' ? undefined : value.appendix; + return ( +
+ + {getText(v)} + {appendix} + + + Copied to clipboard + +
+ ); + })} +
+ ); +}; + +export default ColorsGrid; diff --git a/showcases/patternhub/components/foundations/colors/colors-overview-tabs/index.tsx b/showcases/patternhub/components/foundations/colors/colors-overview-tabs/index.tsx new file mode 100644 index 00000000000..a08b3cd474b --- /dev/null +++ b/showcases/patternhub/components/foundations/colors/colors-overview-tabs/index.tsx @@ -0,0 +1,72 @@ +import { useState } from 'react'; +import { + DBSwitch, + DBTabItem, + DBTabList, + DBTabPanel, + DBTabs +} from '../../../../../../output/react/src'; +import ColorsGrid from '../colors-grid'; +import { type ColorValue } from '../data'; + +const ColorsOverviewTabs = ({ + values, + prefixClass, + dataAttributeName +}: { + values: ColorValue[]; + prefixClass: string; + dataAttributeName: string; +}) => { + const [showCheckerboard, setShowCheckerboard] = useState(false); + const [enableDarkMode, setEnableDarkMode] = useState(false); + + return ( + <> +
+ { + setShowCheckerboard(event.target.checked); + }}> + Show checkerboard + + { + setEnableDarkMode(event.target.checked); + }}> + Preview dark mode + +
+ + + Classes + Data Attributes + + + + + + + + + + ); +}; + +export default ColorsOverviewTabs; diff --git a/showcases/patternhub/components/foundations/colors/data.ts b/showcases/patternhub/components/foundations/colors/data.ts new file mode 100644 index 00000000000..bf2b8b43958 --- /dev/null +++ b/showcases/patternhub/components/foundations/colors/data.ts @@ -0,0 +1,38 @@ +export const semanticColors = [ + 'neutral', + 'brand', + 'critical', + 'successful', + 'warning', + 'informational' +]; + +export const additionalColors = [ + 'yellow', + 'orange', + 'red', + 'pink', + 'violet', + 'blue', + 'cyan', + 'turquoise', + 'green' +]; + +export const backgroundColors = [ + 'lvl-1', + 'lvl-2', + 'lvl-3', + 'transparent-full', + 'transparent-semi' +]; + +export const onBackgroundColors = [ + { value: 'default' }, + { value: 'weak' }, + { value: 'contrast' }, + { value: 'contrast-weak', appendix: ' *' }, + { value: 'border', appendix: ' *' } +]; + +export type ColorValue = string | { value: string; appendix?: string }; diff --git a/showcases/patternhub/pages/foundations/colors/overview.tsx b/showcases/patternhub/pages/foundations/colors/overview.tsx index c4f9d900b06..6fe8a41c144 100644 --- a/showcases/patternhub/pages/foundations/colors/overview.tsx +++ b/showcases/patternhub/pages/foundations/colors/overview.tsx @@ -1,173 +1,12 @@ -import { useState } from 'react'; import DefaultPage from '../../../components/default-page'; +import { DBInfotext } from '../../../../../output/react/src'; +import ColorsOverviewTabs from '../../../components/foundations/colors/colors-overview-tabs'; import { - DBIcon, - DBInfotext, - DBTabs, - DBTabList, - DBTabPanel, - DBTabItem, - DBSwitch -} from '../../../../../output/react/src'; -import checkerboard from '../../../assets/images/checkerboard.png'; -import CopyClipboardButton from '../../../components/copy-clipboard-button'; - -const semanticColors = [ - 'neutral', - 'brand', - 'critical', - 'successful', - 'warning', - 'informational' -]; - -const additionalColors = [ - 'yellow', - 'orange', - 'red', - 'pink', - 'violet', - 'blue', - 'cyan', - 'turquoise', - 'green' -]; - -const backgroundColors = [ - 'lvl-1', - 'lvl-2', - 'lvl-3', - 'transparent-full', - 'transparent-semi' -]; - -const onBackgroundColors = [ - { value: 'default' }, - { value: 'weak' }, - { value: 'contrast' }, - { value: 'contrast-weak', appendix: ' *' }, - { value: 'border', appendix: ' *' } -]; - -type ColorValue = string | { value: string; appendix?: string }; - -const ColorsGrid = ({ - values, - prefixClass, - dataAttributeName, - showCheckerboard, - enableDarkMode, - variant -}: { - values: ColorValue[]; - prefixClass: string; - dataAttributeName: string; - showCheckerboard: boolean; - enableDarkMode: boolean; - variant: 'class' | 'dataAttribute'; -}) => { - const getText = (value: string) => - variant === 'class' - ? `${prefixClass}${value}` - : `${dataAttributeName}="${value}"`; - - const getAttributes = (value: string) => - variant === 'class' - ? { className: `${prefixClass}${value}` } - : { [dataAttributeName]: value }; - - return ( -
- {' '} - {values.map((value, index) => { - const v = typeof value === 'string' ? value : value.value; - const appendix = - typeof value === 'string' ? undefined : value.appendix; - return ( -
- - {getText(v)} - {appendix} - - - Copied to clipboard - -
- ); - })} -
- ); -}; - -const ColorsOverviewTabs = ({ - values, - prefixClass, - dataAttributeName -}: { - values: ColorValue[]; - prefixClass: string; - dataAttributeName: string; -}) => { - const [showCheckerboard, setShowCheckerboard] = useState(false); - const [enableDarkMode, setEnableDarkMode] = useState(false); - - return ( - <> -
- { - setShowCheckerboard(event.target.checked); - }}> - Show checkerboard - - { - setEnableDarkMode(event.target.checked); - }}> - Preview dark mode - -
- - - Classes - Data Attributes - - - - - - - - - - ); -}; + additionalColors, + backgroundColors, + onBackgroundColors, + semanticColors +} from '../../../components/foundations/colors/data'; const ColorOverview = () => { return ( @@ -242,9 +81,9 @@ const ColorOverview = () => {

Semantic container color

- These semantic colours are used to give a container a + These semantic colors are used to give a container a corresponding meaning. Neutral stands for - the regular colour scheme, which is usually applied to root. + the regular color scheme, which is usually applied to root.