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 5, 2024
1 parent 3faf7aa commit d900fd7
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 @@ -125,7 +125,16 @@ export interface IColorsPage {
// eslint-disable-next-line react/prop-types
export default function ColorsPage({ data, pageContext }: 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 d900fd7

Please sign in to comment.