-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(navigation): covert sass vars to css vars. Add colors prop to co…
…mponent - add css custom properties - user can now change basic colors with a new color object to override css vars - add industrial strength string to kebab case util that handles numbers (into common)
- Loading branch information
Showing
5 changed files
with
121 additions
and
37 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
$lightColor: #f1efef; | ||
$darkColor: #555; | ||
$white: #fff; | ||
$black: #000; |
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 { CSSProperties } from 'react'; | ||
import { utils } from '@unleashit/common'; | ||
|
||
// export interface Colors { | ||
// light?: CSSProperties['color']; | ||
// lightDarker5?: CSSProperties['color']; | ||
// lightDarker10?: CSSProperties['color']; | ||
// lightDarker15?: CSSProperties['color']; | ||
// dark?: CSSProperties['color']; | ||
// darkLighter5?: CSSProperties['color']; | ||
// darkLighter10?: CSSProperties['color']; | ||
// darkLighter15?: CSSProperties['color']; | ||
// textLight?: CSSProperties['color']; | ||
// textDark?: CSSProperties['color']; | ||
// } | ||
|
||
// export const mapColorsToStyles = (colors?: Colors) => { | ||
// const styles: Record<string, string> = {}; | ||
// if (!colors) return styles; | ||
// | ||
// colors.light && (styles['--unl-navigation-light'] = colors.light); | ||
// colors.dark && (styles['--unl-navigation-dark'] = colors.dark); | ||
// colors.textLight && | ||
// (styles['--unl-navigation-text-light'] = colors.textLight); | ||
// colors.textDark && (styles['--unl-navigation-text-dark'] = colors.textDark); | ||
// colors.lightDarker5 && | ||
// (styles['--unl-navigation-light-darker-5'] = colors.lightDarker5); | ||
// colors.lightDarker10 && | ||
// (styles['--unl-navigation-light-darker-10'] = colors.lightDarker10); | ||
// colors.lightDarker15 && | ||
// (styles['--unl-navigation-light-darker-15'] = colors.lightDarker15); | ||
// colors.darkLighter5 && | ||
// (styles['--unl-navigation-dark-lighter-5'] = colors.darkLighter5); | ||
// colors.darkLighter10 && | ||
// (styles['--unl-navigation-dark-lighter-10'] = colors.darkLighter10); | ||
// colors.darkLighter15 && | ||
// (styles['--unl-navigation-dark-lighter-15'] = colors.darkLighter15); | ||
// return styles; | ||
// }; | ||
|
||
const colorKeys = [ | ||
'light', | ||
'dark', | ||
'textLight', | ||
'textDark', | ||
'lightDarker5', | ||
'lightDarker10', | ||
'lightDarker15', | ||
'darkLighter5', | ||
'darkLighter10', | ||
'darkLighter15', | ||
] as const; | ||
|
||
export type Colors = { | ||
[key in (typeof colorKeys)[number]]?: CSSProperties['color']; | ||
}; | ||
|
||
export const mapColorsToStyles = (colors?: Colors) => { | ||
if (!colors) return {}; | ||
|
||
const styles: Partial<Record<string, string>> = {}; | ||
|
||
colorKeys.forEach((key) => { | ||
if (colors[key]) { | ||
const kebabCaseKey = `--unl-navigation-${utils.stringToKebab(key)}`; | ||
|
||
styles[kebabCaseKey] = colors[key]; | ||
} | ||
}); | ||
|
||
return styles; | ||
}; |
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