Skip to content

Commit

Permalink
switch from masthead switches to fullpage switches
Browse files Browse the repository at this point in the history
  • Loading branch information
evwilkin committed Feb 13, 2024
1 parent 0b898e8 commit 6f80c45
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 39 deletions.
19 changes: 19 additions & 0 deletions src/app/AppLayout/AppLayout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#primary-app-container {
z-index: var(--pf-v5-c-page__sidebar--ZIndex);
}

.ws-full-page-utils {
position: fixed;
right: 0;
bottom: 0;
padding: var(--pf-v5-global--spacer--lg);
}

.ws-full-page-utils::before {
position: absolute;
inset: 0;
content: "";
background-color: var(--pf-v5-global--BackgroundColor--100);
opacity: 0.8;
box-shadow: var(--pf-v5-global--BoxShadow--sm);
}
57 changes: 18 additions & 39 deletions src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { NavLink, useLocation } from 'react-router-dom';
import {
Button,
Flex,
Icon,

Check failure on line 6 in src/app/AppLayout/AppLayout.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Icon' is defined but never used
Masthead,
MastheadBrand,
Expand All @@ -28,6 +29,7 @@ import { IAppRoute, IAppRouteGroup, routes } from '@app/routes';
import { BarsIcon } from '@patternfly/react-icons';
import MoonIcon from '@patternfly/react-icons/dist/esm/icons/moon-icon';

Check failure on line 30 in src/app/AppLayout/AppLayout.tsx

View workflow job for this annotation

GitHub Actions / Lint

'MoonIcon' is defined but never used
import SunIcon from '@patternfly/react-icons/dist/esm/icons/sun-icon';
import './AppLayout.css';

interface IAppLayout {
children: React.ReactNode;
Expand Down Expand Up @@ -102,45 +104,6 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
</svg>
</MastheadBrand>
</MastheadMain>
<MastheadContent>
<Toolbar isFullHeight>
<ToolbarContent>
<ToolbarGroup
className="pf-m-align-end"
align={{ default: 'alignRight' }}
spaceItems={{ default: 'spaceItemsNone', md: 'spaceItemsMd' }}
>
<ToolbarItem>
<ToggleGroup aria-label="Dark theme toggle group">
<ToggleGroupItem
aria-label="light theme toggle"
icon={
<Icon size="md">
<SunIcon />
</Icon>
}
isSelected={!isDarkTheme}
onChange={toggleDarkTheme}
/>
<ToggleGroupItem
aria-label="dark theme toggle"
icon={
<Icon size="md">
<MoonIcon />
</Icon>
}
isSelected={isDarkTheme}
onChange={toggleDarkTheme}
/>
</ToggleGroup>
</ToolbarItem>
<ToolbarItem>
<Switch id="ws-rtl-switch" label={'RTL'} defaultChecked={false} onChange={() => toggleRTL()} />
</ToolbarItem>
</ToolbarGroup>
</ToolbarContent>
</Toolbar>
</MastheadContent>
</Masthead>
);

Expand Down Expand Up @@ -199,6 +162,22 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
return (
<Page mainContainerId={pageId} header={Header} sidebar={sidebarOpen && Sidebar} skipToContent={PageSkipToContent}>
{children}
<Flex direction={{ default: 'column' }} gap={{ default: 'gapLg' }} className="ws-full-page-utils">
<Switch
label="Dark theme"
defaultChecked={false}
onChange={() => document!.querySelector('html')!.classList.toggle('pf-v5-theme-dark')}
/>
<Switch
label="RTL"
defaultChecked={false}
onChange={() => {
const html = document.querySelector('html');
const curDir = html!.dir;
html!.dir = curDir !== 'rtl' ? 'rtl' : 'ltr';
}}
/>
</Flex>
</Page>
);
};
Expand Down

0 comments on commit 6f80c45

Please sign in to comment.