-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move color components to separate directory
fix: issues with wrong import for components
- Loading branch information
Showing
6 changed files
with
186 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
showcases/patternhub/components/foundations/colors/colors-grid/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div | ||
className="color-overview-container db-font-size-sm" | ||
data-color-scheme={enableDarkMode ? 'dark' : 'light'}> | ||
<span | ||
style={{ | ||
backgroundImage: showCheckerboard | ||
? `url(${checkerboard.src})` | ||
: 'none' | ||
}} | ||
/>{' '} | ||
{values.map((value, index) => { | ||
const v = typeof value === 'string' ? value : value.value; | ||
const appendix = | ||
typeof value === 'string' ? undefined : value.appendix; | ||
return ( | ||
<div {...getAttributes(v)}> | ||
<span> | ||
{getText(v)} | ||
{appendix} | ||
</span> | ||
<CopyClipboardButton | ||
name={`copy-button-${index}`} | ||
copyText={getText(v)}> | ||
Copied to clipboard | ||
</CopyClipboardButton> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ColorsGrid; |
72 changes: 72 additions & 0 deletions
72
showcases/patternhub/components/foundations/colors/colors-overview-tabs/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<boolean>(false); | ||
const [enableDarkMode, setEnableDarkMode] = useState<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<div className="color-overview-switches"> | ||
<DBSwitch | ||
checked={showCheckerboard} | ||
onChange={(event) => { | ||
setShowCheckerboard(event.target.checked); | ||
}}> | ||
Show checkerboard | ||
</DBSwitch> | ||
<DBSwitch | ||
checked={enableDarkMode} | ||
onChange={(event) => { | ||
setEnableDarkMode(event.target.checked); | ||
}}> | ||
Preview dark mode | ||
</DBSwitch> | ||
</div> | ||
<DBTabs> | ||
<DBTabList> | ||
<DBTabItem>Classes</DBTabItem> | ||
<DBTabItem>Data Attributes</DBTabItem> | ||
</DBTabList> | ||
<DBTabPanel> | ||
<ColorsGrid | ||
variant="class" | ||
values={values} | ||
prefixClass={prefixClass} | ||
dataAttributeName={dataAttributeName} | ||
showCheckerboard={showCheckerboard} | ||
enableDarkMode={enableDarkMode} | ||
/> | ||
</DBTabPanel> | ||
<DBTabPanel> | ||
<ColorsGrid | ||
variant="dataAttribute" | ||
values={values} | ||
prefixClass={prefixClass} | ||
dataAttributeName={dataAttributeName} | ||
showCheckerboard={showCheckerboard} | ||
enableDarkMode={enableDarkMode} | ||
/> | ||
</DBTabPanel> | ||
</DBTabs> | ||
</> | ||
); | ||
}; | ||
|
||
export default ColorsOverviewTabs; |
38 changes: 38 additions & 0 deletions
38
showcases/patternhub/components/foundations/colors/data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters