diff --git a/code/src/ui/src/components/AccessibilityLayersButton.tsx b/code/src/ui/src/components/AccessibilityLayersButton.tsx index c82762b1..44db6cf4 100644 --- a/code/src/ui/src/components/AccessibilityLayersButton.tsx +++ b/code/src/ui/src/components/AccessibilityLayersButton.tsx @@ -16,7 +16,13 @@ interface Props { export const AccessibilityLayersButton: React.FC = ({ designSystem}) => { - const layersProperty = (designSystem.layers).properties; + //TODO until we support color blindness styling, don't offer it as an + // accessibility layer option to select from + //const layersProperty = (designSystem.layers).properties; + const layersProperty = [ + designSystem.layers.dyslexia, + designSystem.layers.motionSensitivity + ] const getValueFromLayersProperty = () => { let r = []; for (var i=0; i = ({user, storage, themeName, setThemeName}) => { @@ -40,6 +45,8 @@ const DesignSystemPage: React.FC = ({user, storage, themeName, setThemeNa const [themeBuilder, setThemeBuilder] = useState(); const [designSystemNames, setDesignSystemNames] = useState([]); const [designSystem, setDesignSystem] = useState(); + const [designSystemContentClassName, setDesignSystemContentClassName] = useState("design-system-container"); + const [designSystemContainerAttributes, setDesignSystemContentAttributes] = useState({}) const [tabIndex, setTabIndex] = useState(null); const handleTabChange = (event:any, newTabIndex:string) => { @@ -94,9 +101,47 @@ const DesignSystemPage: React.FC = ({user, storage, themeName, setThemeNa designSystem.code.setCSSVarListener("css", setCssValue); const pref = new Preferences(designSystem.name); setTabIndex(pref.get("content-selected") || "atoms"); + + // listen for changes in selected accessibility layers so that appropriate + // styles can be set + const layerChangeListener = function (event: EventValueChange) { + UpdateContainerLayerInfo(); + }; + designSystem.layers.colorBlind.setPropertyListener("colorBlindListener", layerChangeListener); + designSystem.layers.dyslexia.setPropertyListener("dyslexiaListener", layerChangeListener); + designSystem.layers.motionSensitivity.setPropertyListener("motionSensativityListener", layerChangeListener); + + UpdateContainerLayerInfo(); } }, [designSystem]) + // Update the class names on the design system container div + // taking into account which accessibility layers have been + // selected by the user + const UpdateContainerLayerInfo = () => { + let dsccn = "design-system-container"; + let attributes: AccessibleLayerContainerAttributes = {}; + if (designSystem) { + //TODO re-enable when color blindness styling is available + // and the color blind accessibility layer is + // re-introduced to the UI + //if (designSystem.layers.colorBlind.getValue()) { + // dsccn += " color-blind"; + //} + if (designSystem.layers.dyslexia.getValue()) { + dsccn += " dyslexic"; + attributes["data-typography"] = "dyslexic"; + } + if (designSystem.layers.motionSensitivity.getValue()) { + dsccn += " motion-sensitive"; + attributes["data-animation"] = "sensitive"; + } + } + + setDesignSystemContentClassName(dsccn); + setDesignSystemContentAttributes(attributes); + } + const TopNavTab = styled(Tab)(({ theme }) => ({ ":hover": { backgroundColor: "rgba(0, 0, 0, 0.04)", @@ -116,9 +161,10 @@ const DesignSystemPage: React.FC = ({user, storage, themeName, setThemeNa } if (designSystem && themeBuilder && tabIndex) + return ( -
+
@@ -170,7 +216,6 @@ const DesignSystemPage: React.FC = ({user, storage, themeName, setThemeNa
); - return(
No design system loaded
) }