diff --git a/code/src/ui/src/components/ColorSelect.css b/code/src/ui/src/components/ColorSelect.css index 00fbf514..9032a486 100644 --- a/code/src/ui/src/components/ColorSelect.css +++ b/code/src/ui/src/components/ColorSelect.css @@ -1,4 +1,8 @@ div.MuiPopover-paper > ul.MuiMenu-list > div.shade-row { display: flex; overflow: hidden; -} \ No newline at end of file +} +.baseLabel{ + font-size: var(--caption-boldFontSize); + font-weight: var(--caption-boldFontWeight); +} diff --git a/code/src/ui/src/components/ColorSelect.tsx b/code/src/ui/src/components/ColorSelect.tsx index d171cb1e..6c627fff 100644 --- a/code/src/ui/src/components/ColorSelect.tsx +++ b/code/src/ui/src/components/ColorSelect.tsx @@ -8,8 +8,12 @@ import { Event, EventType, PropertyColorShade, Shade } from '@finos/a11y-theme-b import { ColorShade } from '../components/ColorShade'; import './ColorSelect.css'; +// baseColorHex is an optional property that allows the caller to specify a set of hex color values +// which this component will label as "base" if they appear in the selectable shades list. A "base" color is +// one of the actual colors that the user manually added to the color palette and not a calculated shade. interface Props { value: PropertyColorShade; + baseColorHex?: Set; label?: string; defaultValue?: string; } @@ -26,13 +30,14 @@ class GridShade { } } -export const ColorSelect: React.FC = ({value, label, defaultValue}) => { +export const ColorSelect: React.FC = ({value,baseColorHex, label, defaultValue}) => { const [_selectedValue, _setSelectedValue] = useState(defaultValue || ""); const [_selectableValues, _setSelectableValues] = useState([]); const [_selectableValuesGrid, _setSelectableValuesGrid] = useState(); const [_longestRow, _setLongestRow] = useState(0); const [_disabled, _setDisabled] = useState(false); + const [_shadeLabel, _setShadeLabel] = useState(""); useEffect(() => { if (value) { @@ -120,6 +125,7 @@ export const ColorSelect: React.FC = ({value, label, defaultValue}) => { const newSelectedValue = _selectableValues[indexOfSelectedItem].shade; value.setValue(newSelectedValue); _setSelectedValue(selectedValue); + _setShadeLabel(_getShadeLabel(newSelectedValue)); console.log(`Color changed by UI to ${value}`); } }; @@ -140,6 +146,10 @@ export const ColorSelect: React.FC = ({value, label, defaultValue}) => { return _selectableValues[parseInt(index)].shade; } + const _getShadeLabel = (shade: Shade): string => { + const label = `${shade.getLabel()}`; + return label; + } // this code will turn the unordered list (
    ) internally used by // Mui Select into a grid. Each menu item in the list will be positioned // in the grid based on where that shade was in the selectableValuesGrid @@ -179,7 +189,11 @@ export const ColorSelect: React.FC = ({value, label, defaultValue}) => { {_selectableValues && _selectableValues.map((gridShade, i) => { return( - +
    + + {baseColorHex?.has(gridShade.shade.hex.toLowerCase())&&
    Base
    } + {!baseColorHex?.has(gridShade.shade.hex.toLowerCase())&&
    } +
    ); })} @@ -194,4 +208,4 @@ export const ColorSelect: React.FC = ({value, label, defaultValue}) => { ); } -} \ No newline at end of file +} diff --git a/code/src/ui/src/components/ColorShade.css b/code/src/ui/src/components/ColorShade.css index bc66a5e8..60d68748 100644 --- a/code/src/ui/src/components/ColorShade.css +++ b/code/src/ui/src/components/ColorShade.css @@ -21,7 +21,7 @@ margin: 8px auto; } li .Hex { - margin-right: 8px; + margin: 2px; } .color-block .Hex { margin: 8px auto !important; diff --git a/code/src/ui/src/components/ColorShadeCss.tsx b/code/src/ui/src/components/ColorShadeCss.tsx index 988ee3ab..815f059e 100644 --- a/code/src/ui/src/components/ColorShadeCss.tsx +++ b/code/src/ui/src/components/ColorShadeCss.tsx @@ -59,10 +59,11 @@ interface Props { label?: string; showId?: boolean; showDetails?: boolean; + isBaseColor?:boolean; } -export const ColorShadeCss: React.FC = ({className, name, id, lm, label, showId, showDetails}) => { +export const ColorShadeCss: React.FC = ({className, name, id, lm, label, showId, showDetails,isBaseColor}) => { const [_shade, _setShade] = useState(); let base = name+"-"+id; @@ -102,10 +103,13 @@ export const ColorShadeCss: React.FC = ({className, name, id, lm, label, }, []); return ( -
    +
    {label &&
    {label}
    } {showId &&
    {id}
    }
    Aa
    + {isBaseColor&&
    Base
    } + {/* just to fix uppermargin */} + {!isBaseColor&&
    } {showDetails &&
    Color: {backgroundValue}
    } diff --git a/code/src/ui/src/components/CreateColorTheme.tsx b/code/src/ui/src/components/CreateColorTheme.tsx index ac745695..425228df 100644 --- a/code/src/ui/src/components/CreateColorTheme.tsx +++ b/code/src/ui/src/components/CreateColorTheme.tsx @@ -4,7 +4,7 @@ */ import React, { useEffect, useRef, useState } from 'react'; import { Button, Grid } from '@mui/material'; -import { ColorTheme, ColorThemes, Event, EventType, Shade } from '@finos/a11y-theme-builder-sdk'; +import { ColorPalette, ColorTheme, ColorThemes, Event, EventType, Shade } from '@finos/a11y-theme-builder-sdk'; import { ColorSelect } from './ColorSelect'; import { ColorPairSelect } from './ColorPairSelect'; import { ColorGradient } from './ColorGradient'; @@ -18,10 +18,11 @@ import { GeneratedCodeSection } from '../pages/content/GeneratedCodeSection' interface Props { atom: ColorThemes; + colorPalette: ColorPalette; handleDefaultThemeInitialized: (newDefaultThemeName: string) => void; } -export const CreateColorTheme: React.FC = ({atom, handleDefaultThemeInitialized}) => { +export const CreateColorTheme: React.FC = ({atom,colorPalette, handleDefaultThemeInitialized}) => { const defaultIconShade = Shade.fromHex("#ffffff"); @@ -29,6 +30,7 @@ export const CreateColorTheme: React.FC = ({atom, handleDefaultThemeIniti const [_themeInitialized, _setThemeInitialized] = useState(false); const [_iconColor, _setIconColor] = useState(defaultIconShade); const [_openConfirmation, _setOpenConfirmation] = useState(false); + const [_baseColorsHex, _setBaseColorsHex] = useState>(); const colorIconRef = useRef(null); @@ -99,7 +101,17 @@ export const CreateColorTheme: React.FC = ({atom, handleDefaultThemeIniti handleDefaultThemeInitialized(_colorTheme?.name || ""); } } - + useEffect(() => { + const baseColorsHex= new Set; + colorPalette.getColors().map((color)=>{ + const hexValue = color.hex?.getValue(); + if (hexValue) { + baseColorsHex.add(hexValue); + } + }); + _setBaseColorsHex(baseColorsHex); + }, [colorPalette]) + if (_colorTheme) { return (
    @@ -120,9 +132,9 @@ export const CreateColorTheme: React.FC = ({atom, handleDefaultThemeIniti
    Theme Colors
    - - - + + +
    diff --git a/code/src/ui/src/components/DisplayColorPalette.tsx b/code/src/ui/src/components/DisplayColorPalette.tsx index aa93ea73..f90cbda2 100644 --- a/code/src/ui/src/components/DisplayColorPalette.tsx +++ b/code/src/ui/src/components/DisplayColorPalette.tsx @@ -41,6 +41,12 @@ export const DisplayColorPalette: React.FC = ({ colorPalette, colors, lig
    {color.name}
    {color.light.shades.map((shade, i) => { + if(shade.hex.toLowerCase()==color.hex.getValue()){ + console.log("found base color",color.name); + return( + + ) + } return ( ); @@ -58,6 +64,11 @@ export const DisplayColorPalette: React.FC = ({ colorPalette, colors, lig
    {color.name}
    {color.dark.shades.map((shade, i) => { + if(shade.hex.toLowerCase()==color.hex.getValue()){ + console.log("found base color"); + return( + + )} return ( ); diff --git a/code/src/ui/src/pages/atoms/ColorThemeAtom.tsx b/code/src/ui/src/pages/atoms/ColorThemeAtom.tsx index 06b0747d..202b249c 100644 --- a/code/src/ui/src/pages/atoms/ColorThemeAtom.tsx +++ b/code/src/ui/src/pages/atoms/ColorThemeAtom.tsx @@ -3,16 +3,17 @@ * Licensed under Apache-2.0 License. See License.txt in the project root for license information */ import React, { useEffect, useState } from 'react'; -import { ColorThemes } from '@finos/a11y-theme-builder-sdk'; +import { ColorThemes, ColorPalette} from '@finos/a11y-theme-builder-sdk'; import { CreateColorTheme } from '../../components/CreateColorTheme'; import { DisplayColorTheme } from '../../components/DisplayColorTheme'; interface Props { atom: ColorThemes; + colorPalette:ColorPalette; defaultColor?: string; } -export const ColorThemeAtom: React.FC = ({ atom }) => { +export const ColorThemeAtom: React.FC = ({ atom, colorPalette}) => { const [_themeInitialized, _setThemeInitialized] = useState(false); @@ -30,7 +31,7 @@ export const ColorThemeAtom: React.FC = ({ atom }) => { ); } return ( - + ); } diff --git a/code/src/ui/src/pages/content/atoms/AtomContent.tsx b/code/src/ui/src/pages/content/atoms/AtomContent.tsx index 1d0e8a52..9625e0bb 100644 --- a/code/src/ui/src/pages/content/atoms/AtomContent.tsx +++ b/code/src/ui/src/pages/content/atoms/AtomContent.tsx @@ -239,7 +239,7 @@ export const AtomContent: React.FC = ({ user, designSystem }) => { )} {showAtom === atoms.colorThemes.value && ( - + )} {showAtom === atoms.subcolorThemes.value && (