Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/page/theming/ColorGenerator/index.tsx
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { Fragment, useEffect, useRef, useState } from 'react';

import styles from './styles.module.scss';

Expand DownExpand Up@@ -49,6 +49,7 @@ const ColorGenerator = (props) => {

return (
<li
key={name}
className={clsx(styles.item, { [styles.isOpen]: isOpen })}
onClick={() => setActiveColor(activeColor === name ? null : name)}
>
Expand DownExpand Up@@ -97,15 +98,15 @@ const ColorGenerator = (props) => {
:root {'{'}
{'\n'}
{Object.entries(colors).map(([name, color], i) => (
<>
<Fragment key={i}>
{'\t'}--ion-color-{name}: {color.value};{'\n'}
{'\t'}--ion-color-{name}-rgb: {color.valueRgb};{'\n'}
{'\t'}--ion-color-{name}-contrast: {color.contrast};{'\n'}
{'\t'}--ion-color-{name}-contrast-rgb: {color.contrastRgb};{'\n'}
{'\t'}--ion-color-{name}-shade: {color.shade};{'\n'}
{'\t'}--ion-color-{name}-tint: {color.tint};{'\n'}
{'\n'}
</>
</Fragment>
))}
{'}'}
{'\n'}
Expand Down
3 changes: 2 additions & 1 deletion src/components/page/theming/_utils/index.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,9 +13,10 @@ export const generateColor = (value: string): ColorVariable => {
const contrast = color.contrast();
const tint = color.tint();
const shade = color.shade();
const formattedValue = value.startsWith('#') ? value : `#${value}`;

return {
value,
value: formattedValue,
valueRgb: rgbToString(color.rgb),
contrast: contrast.hex,
contrastRgb: rgbToString(contrast.rgb),
Expand Down