Skip to content

Commit bdcd2b8

Browse files
mcokeredonehoo
andauthored
fix: enable HC switcher, add beta label (#4766)
* fix: enable HC switcher, add beta label * chore: add labels, popover to theme switcher * chore: theme selector updates * chore: remove unused import * Update packages/documentation-framework/components/themeSelector/themeSelector.js Co-authored-by: Erin Donehoo <105813956+edonehoo@users.noreply.github.com> * Update packages/documentation-framework/components/themeSelector/themeSelector.js Co-authored-by: Erin Donehoo <105813956+edonehoo@users.noreply.github.com> --------- Co-authored-by: Erin Donehoo <105813956+edonehoo@users.noreply.github.com>
1 parent 175a84c commit bdcd2b8

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

packages/documentation-framework/components/themeSelector/themeSelector.js

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ import {
1010
ToggleGroup,
1111
ToggleGroupItem,
1212
Icon,
13-
Divider
13+
Divider,
14+
Label,
15+
Popover,
16+
Button
1417
} from '@patternfly/react-core';
18+
import { HelpIcon, ExternalLinkAltIcon } from '@patternfly/react-icons';
1519
import { useTheme, THEME_TYPES } from '../../hooks/useTheme';
1620

1721
const SunIcon = (
@@ -45,6 +49,47 @@ const DesktopIcon = (
4549
</svg>
4650
);
4751

52+
const ColorSchemeGroupLabel = () => {
53+
return (
54+
<div className="pf-v6-c-menu__group-title" id="theme-selector-color-scheme-title">
55+
Color scheme
56+
</div>
57+
);
58+
};
59+
60+
const HighContrastGroupLabel = () => {
61+
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
62+
63+
return (
64+
<div className="pf-v6-c-menu__group-title">
65+
High contrast{' '}
66+
<Popover
67+
onClick={(e) => e.stopPropagation()}
68+
headerContent={"Under development"}
69+
headerComponent="h1"
70+
bodyContent={
71+
"We are still working to add high contrast support across all PatternFly components and extensions. This beta allows you to preview our progress."
72+
}
73+
footerContent={
74+
<Button icon={<ExternalLinkAltIcon />} component="a" isInline variant="link" href="/design-foundations/theming" target="_blank">
75+
Learn more
76+
</Button>
77+
}
78+
aria-label="More info about high contrast"
79+
appendTo={() => document.body}
80+
>
81+
<Button
82+
variant="plain"
83+
hasNoPadding
84+
icon={<HelpIcon />}
85+
aria-label="High contrast help"
86+
/>
87+
</Popover>{' '}&nbsp;
88+
<Label color="blue" isCompact>Beta</Label>
89+
</div>
90+
)
91+
};
92+
4893
export const ThemeSelector = ({ id }) => {
4994
const { mode: themeMode, setMode: setThemeMode, modes: colorModes } = useTheme(THEME_TYPES.COLOR);
5095
const {
@@ -109,8 +154,8 @@ export const ThemeSelector = ({ id }) => {
109154
preventOverflow: true
110155
}}
111156
>
112-
<SelectGroup>
113-
<SelectList aria-label="Light/Dark theme switcher">
157+
<SelectGroup label={ColorSchemeGroupLabel}>
158+
<SelectList aria-labelledby="theme-selector-color-scheme-title">
114159
<SelectOption value={colorModes.SYSTEM} icon={DesktopIcon} description="Follow system preference">
115160
System
116161
</SelectOption>
@@ -124,7 +169,7 @@ export const ThemeSelector = ({ id }) => {
124169
</SelectGroup>
125170
{process.env.hasHighContrastSwitcher && (<>
126171
<Divider />
127-
<SelectGroup label="High Contrast">
172+
<SelectGroup label={HighContrastGroupLabel}>
128173
<MenuSearch>
129174
<MenuSearchInput>
130175
<ToggleGroup aria-label="High contrast theme switcher">

packages/documentation-site/patternfly-docs/patternfly-docs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (process.env.EXTENSIONS_ONLY === 'true') {
3131
hasDesignGuidelines: true,
3232
hasThemeSwitcher: true,
3333
hasFeedbackButton: true,
34-
hasHighContrastSwitcher: false,
34+
hasHighContrastSwitcher: true,
3535
componentsData,
3636
sideNavItems: [
3737
{ section: 'get-started' },

0 commit comments

Comments
 (0)