Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BD-46] fix: fixed replacing CSS variables on the Colors page #2628

Merged
Merged
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
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 @@ -121,7 +121,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
Loading