Skip to content

Commit

Permalink
docs: fix theme switcher on the Colors page (#2628)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Aug 1, 2024
1 parent 2a84448 commit c547147
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions www/src/pages/foundations/colors.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import React, { useState, useEffect, useContext } from 'react';
import { graphql } from 'gatsby';
import PropTypes from 'prop-types';
import classNames from 'classnames';
Expand Down Expand Up @@ -122,7 +122,16 @@ export interface IColorsPage {
// eslint-disable-next-line react/prop-types
export default function ColorsPage({ data }: IColorsPage) {
const { settings } = useContext(SettingsContext);
const styles = typeof window !== 'undefined' ? getComputedStyle(document.body) : null;
const [styles, setStyles] = useState<CSSStyleDeclarationType>(null);

useEffect(() => {
setTimeout(() => {
if (typeof window !== 'undefined') {
const newStyles = getComputedStyle(document.body);
setStyles(newStyles);
}
}, 500);
}, [settings.theme]);

parseColors(data.allCssUtilityClasses.nodes); // eslint-disable-line react/prop-types

Expand Down

0 comments on commit c547147

Please sign in to comment.