@patternfly/documentation-framework 1.2.67 → 1.2.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.2.68 (2022-11-28)
7
+
8
+ **Note:** Version bump only for package @patternfly/documentation-framework
9
+
10
+
11
+
12
+
13
+
6
14
  ## 1.2.67 (2022-11-22)
7
15
 
8
16
  **Note:** Version bump only for package @patternfly/documentation-framework
@@ -27,78 +27,16 @@
27
27
  }
28
28
 
29
29
  /* Search */
30
- #ws-global-search-wrapper {
31
- /* For icon */
32
- position: relative;
33
- }
34
30
  #algolia-autocomplete-listbox-0 {
35
31
  /* Fix search results overflowing page */
36
32
  min-width: 480px !important;
37
33
  }
38
- #ws-global-search {
39
- background-color: transparent;
40
- border: none;
41
- /* For icon */
42
- padding-left: var(--pf-global--spacer--xl);
43
- width: 200px;
44
- }
45
- .ws-hide-search-input .algolia-autocomplete,
46
- .ws-hide-search-input #ws-global-search {
47
- display: none !important;
48
- }
49
- .ws-toggle-search {
50
- /* Search icon is taller than it is wide */
51
- margin-top: 2px;
52
- }
53
- #ws-global-search-wrapper > .global-search-icon {
54
- position: absolute;
55
- top: 10px;
56
- left: 4px;
57
- }
58
- #ws-global-search,
59
- #ws-global-search::placeholder {
60
- color: #fff;
61
- }
62
- #ws-global-search:focus {
63
- outline-offset: 2px;
34
+ .ws-global-search.pf-c-input-group {
35
+ /* remove white background on dark Masthead */
36
+ --pf-c-input-group--BackgroundColor: none;
64
37
  }
65
38
 
66
- /* TODO: PageHeaderTools on small viewports */
67
- @media (max-width: 670px) {
68
- #ws-global-search-wrapper,
69
- .ws-toggle-search {
70
- display: none;
71
- visibility: hidden;
72
- }
73
- }
74
- @media (max-width: 430px) {
75
- .ws-page-header > .pf-c-page__header-brand > .pf-c-page__header-brand-link {
76
- display: none;
77
- visibility: hidden;
78
- }
79
- }
80
-
81
- /* Version toggle */
82
- .ws-org-version-toggle {
83
- color: var(--pf-global--Color--light-100);
84
- }
85
- .ws-org-version-toggle::before {
86
- content: none !important;
87
- }
88
- .ws-org-version-toggle:hover {
89
- border-bottom: 1px solid #fff;
90
- }
91
- .ws-org-version-toggle-expanded::before {
92
- border-left: none;
93
- border-right: none;
94
- border-top: none;
95
- border-bottom: 2px solid #fff;
96
- }
97
39
  /* For tiny (200px) viewports */
98
- .ws-org-version-switcher .pf-c-dropdown__toggle >.pf-c-dropdown__toggle-text {
99
- white-space: normal;
100
- }
101
-
102
- .ws-github-pageheader {
103
- color: var(--pf-global--Color--light-100) !important;
40
+ .ws-masthead .pf-c-toolbar__item {
41
+ min-width: 0;
104
42
  }
@@ -2,39 +2,51 @@ import React, { useEffect, useState } from 'react';
2
2
  import {
3
3
  Button,
4
4
  Page,
5
- PageHeader,
6
5
  PageSidebar,
7
- PageHeaderTools,
8
- PageHeaderToolsItem,
9
- TextInput,
10
6
  Brand,
11
7
  Dropdown,
12
8
  DropdownToggle,
13
9
  DropdownItem,
14
10
  DropdownGroup,
15
11
  Divider,
12
+ Masthead,
13
+ MastheadToggle,
14
+ MastheadMain,
15
+ MastheadContent,
16
+ MastheadBrand,
17
+ PageToggleButton,
18
+ Toolbar,
19
+ ToolbarGroup,
20
+ ToolbarContent,
21
+ ToolbarItem,
16
22
  SkipToContent,
17
- Switch
23
+ Switch,
24
+ SearchInput
18
25
  } from '@patternfly/react-core';
19
- import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
20
26
  import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
21
- import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
27
+ import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
22
28
  import GithubIcon from '@patternfly/react-icons/dist/esm/icons/github-icon';
23
29
  import { SideNav, TopNav, GdprBanner } from '../../components';
24
30
  import staticVersions from '../../versions.json';
25
- import logo from '../logo.svg';
31
+ import logoMd from '@patternfly/patternfly/assets/images/logo__pf--reverse-on-md.svg';
32
+ import logo from '@patternfly/patternfly/assets/images/logo__pf--reverse--base.svg';
33
+ import logoBase from '@patternfly/patternfly/assets/images/logo__pf--reverse--base.png';
26
34
 
27
35
  const HeaderTools = ({
28
36
  versions,
29
37
  hasVersionSwitcher,
30
- hasSearch,
38
+ algolia,
31
39
  hasDarkThemeSwitcher,
40
+ topNavItems,
32
41
  pathPrefix
33
42
  }) => {
34
43
  const initialVersion = staticVersions.Releases.find(release => release.latest);
35
- const [isDropdownOpen, setDropdownOpen] = useState(false);
36
- const [isSearchExpanded, setSearchExpanded] = useState(false);
37
44
  const latestVersion = versions.Releases.find(version => version.latest);
45
+ const hasSearch = algolia;
46
+ const [isDropdownOpen, setDropdownOpen] = useState(false);
47
+ const [searchValue, setSearchValue] = React.useState('');
48
+ const [isSearchExpanded, setIsSearchExpanded] = React.useState(false);
49
+
38
50
  const getDropdownItem = version => (
39
51
  <DropdownItem
40
52
  key={version.name}
@@ -45,111 +57,103 @@ const HeaderTools = ({
45
57
  }
46
58
  />
47
59
  );
48
- const searchRef = React.useRef();
60
+
61
+ const onChange = (value) => {
62
+ setSearchValue(value);
63
+ };
64
+
65
+ const onToggleExpand = (isSearchExpanded) => {
66
+ setIsSearchExpanded(!isSearchExpanded);
67
+ };
49
68
 
50
69
  useEffect(() => {
51
- const handleSearchHotkeys = (event) => {
52
- const tagName = event.target.tagName.toLowerCase();
53
- const isContentEditable = event.target.contentEditable === 'true';
54
- if (
55
- (event.code === 'Slash' || event.code === 'KeyS') &&
56
- tagName !== 'input' &&
57
- tagName !== 'textarea' &&
58
- !isContentEditable
59
- ) {
60
- setSearchExpanded(true);
61
- setTimeout(() => searchRef.current && searchRef.current.focus(), 0);
62
- } else if (event.code === 'Escape' && event.target === searchRef.current) {
63
- setSearchExpanded(false);
64
- }
65
- };
66
- window.addEventListener('keyup', handleSearchHotkeys);
67
- return () => window.removeEventListener('keyup', handleSearchHotkeys);
68
- }, []);
70
+ // reattach algolia to input each time search is expanded
71
+ if (hasSearch && isSearchExpanded) {
72
+ attachDocSearch(algolia, '.ws-global-search .pf-c-text-input-group__text-input', 1000);
73
+ }
74
+ }, [isSearchExpanded])
69
75
 
70
76
  return (
71
- <PageHeaderTools>
72
- {hasDarkThemeSwitcher && (
73
- <PageHeaderToolsItem>
74
- <Switch id="ws-theme-switch" label="Dark theme" defaultChecked={false} onChange={() =>
75
- document.querySelector('html').classList.toggle('pf-theme-dark')} />
76
- </PageHeaderToolsItem>
77
- )}
78
- {hasSearch && (
79
- <PageHeaderToolsItem id="ws-global-search-wrapper" className={isSearchExpanded ? '' : 'ws-hide-search-input'}>
80
- <TextInput id="ws-global-search" ref={searchRef} placeholder="Search" />
81
- {isSearchExpanded && <SearchIcon className="global-search-icon" />}
82
- </PageHeaderToolsItem>
83
- )}
84
- {hasSearch && (
85
- <Button
86
- aria-label={`${isSearchExpanded ? 'Collapse' : 'Expand'} search input`}
87
- variant="plain"
88
- className="ws-toggle-search"
89
- onClick={() => {
90
- setSearchExpanded(!isSearchExpanded);
91
- if (!isSearchExpanded) {
92
- setTimeout(() => searchRef.current && searchRef.current.focus(), 0);
93
- }
94
- }}
95
- >
96
- {isSearchExpanded
97
- ? <TimesIcon />
98
- : <SearchIcon className="global-search-icon" />
99
- }
100
- </Button>
101
- )}
102
- <PageHeaderToolsItem>
103
- <Button
104
- component="a"
105
- variant="link"
106
- href="//github.com/patternfly"
107
- target="top"
108
- aria-label="Link to PatternFly GitHub page"
109
- className="ws-github-pageheader pf-u-mr-sm"
77
+ <Toolbar isFullHeight>
78
+ <ToolbarContent>
79
+ {topNavItems.length > 0 && (
80
+ <ToolbarItem className="pf-m-overflow-container">
81
+ <TopNav navItems={topNavItems} />
82
+ </ToolbarItem>
83
+ )}
84
+ <ToolbarGroup
85
+ alignment={{ default: 'alignRight' }}
86
+ spacerItems={{ default: 'spacerNone', md: 'spacerMd' }}
110
87
  >
111
- <GithubIcon />
112
- </Button>
113
- </PageHeaderToolsItem>
114
- {hasVersionSwitcher && (
115
- <PageHeaderToolsItem>
116
- <Dropdown
117
- className="ws-org-version-switcher"
118
- onSelect={() => setDropdownOpen(!isDropdownOpen)}
119
- toggle={(
120
- <DropdownToggle
121
- className={`ws-org-version-toggle${isDropdownOpen ? '-expanded': ''}`}
122
- onToggle={() => setDropdownOpen(!isDropdownOpen)}
123
- >
124
- Release {initialVersion.name}
125
- </DropdownToggle>
126
- )}
127
- isOpen={isDropdownOpen}
128
- dropdownItems={[
129
- <DropdownGroup key="latest" label="Latest">
130
- {getDropdownItem(latestVersion)}
131
- </DropdownGroup>,
132
- <DropdownGroup key="Previous" label="Previous releases">
133
- {Object.values(versions.Releases)
134
- .filter(version => !version.hidden && !version.latest)
135
- .slice(0,3)
136
- .map(getDropdownItem)}
137
- </DropdownGroup>,
138
- <Divider key="divider" className="ws-switcher-divider"/>,
139
- <DropdownItem
140
- key="PatternFly 3"
141
- className="ws-patternfly-3"
142
- target="_blank"
143
- href="https://pf3.patternfly.org/"
144
- >
145
- PatternFly 3
146
- <ExternalLinkAltIcon />
147
- </DropdownItem>
148
- ]}
149
- />
150
- </PageHeaderToolsItem>
151
- )}
152
- </PageHeaderTools>
88
+ {hasDarkThemeSwitcher && (
89
+ <ToolbarItem>
90
+ <Switch id="ws-theme-switch" label="Dark theme" defaultChecked={false} onChange={() =>
91
+ document.querySelector('html').classList.toggle('pf-theme-dark')} />
92
+ </ToolbarItem>
93
+ )}
94
+ {hasSearch && (
95
+ <ToolbarItem>
96
+ <SearchInput
97
+ className="ws-global-search"
98
+ placeholder="Search"
99
+ value={searchValue}
100
+ onChange={onChange}
101
+ onClear={() => onChange('')}
102
+ expandableInput={{ isExpanded: isSearchExpanded, onToggleExpand, toggleAriaLabel: 'Expandable search input toggle' }}
103
+ />
104
+ </ToolbarItem>
105
+ )}
106
+ <ToolbarItem>
107
+ <Button
108
+ component="a"
109
+ variant="plain"
110
+ href="//github.com/patternfly"
111
+ target="top"
112
+ aria-label="PatternFly GitHub page"
113
+ >
114
+ <GithubIcon />
115
+ </Button>
116
+ </ToolbarItem>
117
+ {hasVersionSwitcher && (
118
+ <ToolbarItem>
119
+ <Dropdown
120
+ isFullHeight
121
+ onSelect={() => setDropdownOpen(!isDropdownOpen)}
122
+ isOpen={isDropdownOpen}
123
+ toggle={(
124
+ <DropdownToggle
125
+ onToggle={() => setDropdownOpen(!isDropdownOpen)}
126
+ >
127
+ Release {initialVersion.name}
128
+ </DropdownToggle>
129
+ )}
130
+ dropdownItems={[
131
+ <DropdownGroup key="latest" label="Latest">
132
+ {getDropdownItem(latestVersion)}
133
+ </DropdownGroup>,
134
+ <DropdownGroup key="Previous" label="Previous releases">
135
+ {Object.values(versions.Releases)
136
+ .filter(version => !version.hidden && !version.latest)
137
+ .slice(0,3)
138
+ .map(getDropdownItem)}
139
+ </DropdownGroup>,
140
+ <Divider key="divider" className="ws-switcher-divider"/>,
141
+ <DropdownItem
142
+ key="PatternFly 3"
143
+ className="ws-patternfly-3"
144
+ target="_blank"
145
+ href="https://pf3.patternfly.org/"
146
+ >
147
+ PatternFly 3
148
+ <ExternalLinkAltIcon />
149
+ </DropdownItem>
150
+ ]}
151
+ />
152
+ </ToolbarItem>
153
+ )}
154
+ </ToolbarGroup>
155
+ </ToolbarContent>
156
+ </Toolbar>
153
157
  );
154
158
  }
155
159
 
@@ -160,7 +164,7 @@ export function attachDocSearch(algolia, inputSelector, timeout) {
160
164
  inputSelector,
161
165
  autocompleteOptions: {
162
166
  hint: false,
163
- appendTo: `${inputSelector}-wrapper`,
167
+ appendTo: `.ws-global-search .pf-c-text-input-group`,
164
168
  },
165
169
  debug: process.env.NODE_ENV !== 'production',
166
170
  ...algolia
@@ -188,9 +192,6 @@ export const SideNavLayout = ({ children, groupedRoutes, navOpen: navOpenProp })
188
192
  if (typeof window === 'undefined') {
189
193
  return;
190
194
  }
191
- if (algolia) {
192
- attachDocSearch(algolia, '#ws-global-search', 1000);
193
- }
194
195
  if (hasVersionSwitcher && window.fetch) {
195
196
  fetch('/versions.json').then(res => {
196
197
  if (res.ok) {
@@ -209,20 +210,36 @@ export const SideNavLayout = ({ children, groupedRoutes, navOpen: navOpenProp })
209
210
  );
210
211
 
211
212
  const Header = (
212
- <PageHeader
213
- className="ws-page-header"
214
- headerTools={(algolia || hasVersionSwitcher) && <HeaderTools
215
- versions={versions}
216
- hasSearch={algolia}
217
- hasVersionSwitcher={hasVersionSwitcher}
218
- hasDarkThemeSwitcher={hasDarkThemeSwitcher}
219
- pathPrefix={pathPrefix} />}
220
- logo={prnum ? `PR #${prnum}` : <Brand src={logo} alt="Patternfly Logo" />}
221
- logoProps={{ href: prurl || pathPrefix || '/' }}
222
- showNavToggle
223
- topNav={topNavItems.length > 0 && <TopNav navItems={topNavItems} />}
224
- />
225
- );
213
+ <Masthead className="ws-masthead">
214
+ <MastheadToggle>
215
+ <PageToggleButton variant="plain" aria-label="Global navigation">
216
+ <BarsIcon />
217
+ </PageToggleButton>
218
+ </MastheadToggle>
219
+ <MastheadMain>
220
+ <MastheadBrand href={prurl || pathPrefix || '/'}>
221
+ {prnum ? `PR #${prnum}` : (
222
+ <Brand src={logoBase} alt="PatternFly logo" widths={{ default: '180px', '2xl': '220px' }}>
223
+ <source media="(min-width: 768px)" srcSet={logoMd} />
224
+ <source srcSet={logo} />
225
+ </Brand>
226
+ )}
227
+ </MastheadBrand>
228
+ </MastheadMain>
229
+ <MastheadContent>
230
+ {(algolia || hasVersionSwitcher) && (
231
+ <HeaderTools
232
+ versions={versions}
233
+ algolia={algolia}
234
+ hasVersionSwitcher={hasVersionSwitcher}
235
+ hasDarkThemeSwitcher={hasDarkThemeSwitcher}
236
+ pathPrefix={pathPrefix}
237
+ topNavItems={topNavItems}
238
+ />
239
+ )}
240
+ </MastheadContent>
241
+ </Masthead>
242
+ )
226
243
 
227
244
  return (
228
245
  <React.Fragment>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@patternfly/documentation-framework",
3
3
  "description": "A framework to build documentation for PatternFly.",
4
- "version": "1.2.67",
4
+ "version": "1.2.68",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -85,5 +85,5 @@
85
85
  "react": "^16.8.0 || ^17.0.0",
86
86
  "react-dom": "^16.8.0 || ^17.0.0"
87
87
  },
88
- "gitHead": "afa3104aee0156e2cb29a2393d70d3e314e0c31a"
88
+ "gitHead": "a4203fb1da4eca1a509e74dd9e62e9e2cdac2603"
89
89
  }