-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make typography documentation theme sensitive
- Loading branch information
Showing
7 changed files
with
137 additions
and
44 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
31 changes: 31 additions & 0 deletions
31
packages/dnb-design-system-portal/src/docs/uilib/typography/_helpers.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,31 @@ | ||
import { useTheme } from '@dnb/eufemia/shared' | ||
|
||
import propertiesSbanken from '@dnb/eufemia/src/style/themes/theme-sbanken/properties' | ||
import propertiesUi from '@dnb/eufemia/src/style/themes/theme-ui/properties' | ||
import propertiesEiendom from '@dnb/eufemia/src/style/themes/theme-eiendom/properties' | ||
|
||
const properties = { | ||
sbanken: propertiesSbanken, | ||
ui: propertiesUi, | ||
eiendom: propertiesEiendom, | ||
} | ||
|
||
export const GetPropValue = (prop) => { | ||
const theme = useTheme() | ||
const p = properties[theme.name][prop] | ||
if (p && p.startsWith('var(')) { | ||
return GetPropValue(p.substring(4, p.indexOf(')'))) | ||
} | ||
return p | ||
} | ||
|
||
export const GetPropAsPx = (prop) => { | ||
return RemToPx(GetPropValue(prop)) | ||
} | ||
|
||
const RemToPx = (rem = '') => { | ||
if (rem.endsWith('rem')) { | ||
return parseFloat(rem) * 16 + 'px' | ||
} | ||
return rem | ||
} |
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
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