Skip to content

Commit

Permalink
fix: change root element var
Browse files Browse the repository at this point in the history
  • Loading branch information
goshander committed Nov 22, 2023
1 parent 48daab3 commit d041c19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/components/AsideHeader/AsideHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

$block: '.#{variables.$ns}aside-header';

:root {
--gn-aside-top-panel-height: 0px;
}

.g-root {
--gn-aside-header-background-color: var(--g-color-base-warning-light);
--gn-aside-header-collapse-button-divider-line-color: var(
Expand All @@ -14,6 +10,8 @@ $block: '.#{variables.$ns}aside-header';
--gn-aside-header-footer-item-icon-color: var(--g-color-text-primary);
--gn-aside-header-subheader-item-icon-color: var(--g-color-text-primary);
--gn-aside-header-item-icon-background-size: 38px;

--gn-aside-top-panel-height: 0px;
}

.g-root_theme_light,
Expand Down
10 changes: 6 additions & 4 deletions src/components/AsideHeader/useAsideHeaderTopPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type AsideHeaderTopPanel = {
updateTopSize: () => void;
};

const G_ROOT_CLASS_NAME = 'g-root';

const useRefHeight = (ref: React.RefObject<HTMLDivElement>) => {
const [topHeight, setTopHeight] = React.useState(0);
React.useEffect(() => {
Expand All @@ -28,10 +30,10 @@ export const useAsideHeaderTopPanel = ({
const topHeight = useRefHeight(topRef);

const setAsideTopPanelHeight = React.useCallback((clientHeight: number) => {
document.documentElement.style.setProperty(
'--gn-aside-top-panel-height',
clientHeight + 'px',
);
const gRootElement = document
.getElementsByClassName(G_ROOT_CLASS_NAME)
.item(0) as HTMLElement | null;
gRootElement?.style.setProperty('--gn-aside-top-panel-height', clientHeight + 'px');
}, []);

const updateTopSize = React.useCallback(() => {
Expand Down

0 comments on commit d041c19

Please sign in to comment.