Skip to content

Commit 299b94c

Browse files
Merge branch 'patternfly:main' into main
2 parents b684115 + 6493439 commit 299b94c

File tree

346 files changed

+348
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+348
-141
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"clean": "lerna run clean && rm -rf build",
1616
"serve": "npx pf-docs-framework serve build/patternfly-org/site",
1717
"test": "yarn workspace patternfly-org test:a11y:ci",
18-
"screenshots": "node node_modules/puppeteer/install.js && yarn workspace patternfly-org screenshots",
18+
"screenshots": "yarn workspace patternfly-org screenshots",
1919
"start": "yarn develop",
2020
"start:extensions": "yarn develop:extensions",
2121
"uninstall": "find . -name node_modules | xargs rm -rf",
@@ -30,9 +30,9 @@
3030
]
3131
},
3232
"devDependencies": {
33-
"@patternfly/patternfly": "^6.0.0",
33+
"@patternfly/patternfly": "^6.1.0-prerelease.2",
3434
"@patternfly/react-code-editor": "^6.0.0",
35-
"@patternfly/react-core": "^6.0.0",
35+
"@patternfly/react-core": "^6.1.0-prerelease.2",
3636
"@patternfly/react-table": "^6.0.0",
3737
"@octokit/rest": "^19.0.7",
3838
"glob": "^8.1.0",

packages/ast-helpers/CHANGELOG.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,82 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# 1.4.0-alpha.132 (2024-12-04)
7+
8+
**Note:** Version bump only for package @patternfly/ast-helpers
9+
10+
11+
12+
13+
14+
# 1.4.0-alpha.131 (2024-12-03)
15+
16+
17+
### Bug Fixes
18+
19+
* Update text to 'Edit this page on Github' ([#4401](https://github.com/patternfly/patternfly-org/issues/4401)) ([22e6668](https://github.com/patternfly/patternfly-org/commit/22e6668c50c1a85f9a23f3bc0a7ed89d2637a7c0))
20+
21+
22+
23+
24+
25+
# 1.4.0-alpha.130 (2024-12-03)
26+
27+
**Note:** Version bump only for package @patternfly/ast-helpers
28+
29+
30+
31+
32+
33+
# 1.4.0-alpha.129 (2024-11-26)
34+
35+
36+
### Bug Fixes
37+
38+
* bump puppeteer and update screenshots ([#4394](https://github.com/patternfly/patternfly-org/issues/4394)) ([1ac1dac](https://github.com/patternfly/patternfly-org/commit/1ac1dace5994978d921008e0332ea55e21874137))
39+
40+
41+
42+
43+
44+
# 1.4.0-alpha.128 (2024-11-22)
45+
46+
47+
### Bug Fixes
48+
49+
* improve handling of dark mode preferences ([#4389](https://github.com/patternfly/patternfly-org/issues/4389)) ([1580900](https://github.com/patternfly/patternfly-org/commit/1580900ab1e27bdc3373d91e97c521da30878ac5)), closes [#4365](https://github.com/patternfly/patternfly-org/issues/4365)
50+
51+
52+
53+
54+
55+
# 1.4.0-alpha.127 (2024-11-22)
56+
57+
58+
### Reverts
59+
60+
* Revert "chore: upgrade Yarn to the latest version (#4387)" (#4391) ([14a81bf](https://github.com/patternfly/patternfly-org/commit/14a81bf15e81a7faa8ebea4c44e4fca2c6fae964)), closes [#4387](https://github.com/patternfly/patternfly-org/issues/4387) [#4391](https://github.com/patternfly/patternfly-org/issues/4391)
61+
62+
63+
64+
65+
66+
# 1.4.0-alpha.126 (2024-11-21)
67+
68+
**Note:** Version bump only for package @patternfly/ast-helpers
69+
70+
71+
72+
73+
74+
# 1.4.0-alpha.125 (2024-11-20)
75+
76+
**Note:** Version bump only for package @patternfly/ast-helpers
77+
78+
79+
80+
81+
682
# 1.4.0-alpha.124 (2024-11-15)
783

884

packages/ast-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@patternfly/ast-helpers",
33
"description": "Acorn AST helpers for working with live code",
4-
"version": "1.4.0-alpha.124",
4+
"version": "1.4.0-alpha.132",
55
"author": "Red Hat",
66
"license": "MIT",
77
"publishConfig": {

packages/documentation-framework/CHANGELOG.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,82 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 6.0.16 (2024-12-04)
7+
8+
**Note:** Version bump only for package @patternfly/documentation-framework
9+
10+
11+
12+
13+
14+
## 6.0.15 (2024-12-03)
15+
16+
17+
### Bug Fixes
18+
19+
* Update text to 'Edit this page on Github' ([#4401](https://github.com/patternfly/patternfly-org/issues/4401)) ([22e6668](https://github.com/patternfly/patternfly-org/commit/22e6668c50c1a85f9a23f3bc0a7ed89d2637a7c0))
20+
21+
22+
23+
24+
25+
## 6.0.14 (2024-12-03)
26+
27+
**Note:** Version bump only for package @patternfly/documentation-framework
28+
29+
30+
31+
32+
33+
## 6.0.13 (2024-11-26)
34+
35+
36+
### Bug Fixes
37+
38+
* bump puppeteer and update screenshots ([#4394](https://github.com/patternfly/patternfly-org/issues/4394)) ([1ac1dac](https://github.com/patternfly/patternfly-org/commit/1ac1dace5994978d921008e0332ea55e21874137))
39+
40+
41+
42+
43+
44+
## 6.0.12 (2024-11-22)
45+
46+
47+
### Bug Fixes
48+
49+
* improve handling of dark mode preferences ([#4389](https://github.com/patternfly/patternfly-org/issues/4389)) ([1580900](https://github.com/patternfly/patternfly-org/commit/1580900ab1e27bdc3373d91e97c521da30878ac5)), closes [#4365](https://github.com/patternfly/patternfly-org/issues/4365)
50+
51+
52+
53+
54+
55+
## 6.0.11 (2024-11-22)
56+
57+
58+
### Reverts
59+
60+
* Revert "chore: upgrade Yarn to the latest version (#4387)" (#4391) ([14a81bf](https://github.com/patternfly/patternfly-org/commit/14a81bf15e81a7faa8ebea4c44e4fca2c6fae964)), closes [#4387](https://github.com/patternfly/patternfly-org/issues/4387) [#4391](https://github.com/patternfly/patternfly-org/issues/4391)
61+
62+
63+
64+
65+
66+
## 6.0.10 (2024-11-21)
67+
68+
**Note:** Version bump only for package @patternfly/documentation-framework
69+
70+
71+
72+
73+
74+
## 6.0.9 (2024-11-20)
75+
76+
**Note:** Version bump only for package @patternfly/documentation-framework
77+
78+
79+
80+
81+
682
## 6.0.8 (2024-11-15)
783

884

packages/documentation-framework/layouts/sideNavLayout/sideNavLayout.js

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState, createContext } from 'react';
1+
import React, { useEffect, useState, createContext, useCallback } from 'react';
22
import {
33
Button,
44
Page,
@@ -232,6 +232,26 @@ export function attachDocSearch(algolia, inputSelector, timeout) {
232232
}
233233
}
234234

235+
const DARK_MODE_CLASS = "pf-v6-theme-dark";
236+
const DARK_MODE_STORAGE_KEY = "dark-mode";
237+
238+
/**
239+
* Determines if dark mode is enabled based on the stored value or the system preference.
240+
* @returns {boolean} true if dark mode is enabled, false otherwise
241+
*/
242+
function isDarkModeEnabled() {
243+
// When running in prerender mode we can't access the browser APIs.
244+
if (process.env.PRERENDER) {
245+
return false;
246+
}
247+
248+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
249+
const storedValue = localStorage.getItem(DARK_MODE_STORAGE_KEY);
250+
const isEnabled = storedValue === null ? mediaQuery.matches : storedValue === "true";
251+
252+
return isEnabled;
253+
}
254+
235255
export const SideNavLayout = ({ children, groupedRoutes, navOpen: navOpenProp }) => {
236256
const algolia = process.env.algolia;
237257
const hasGdprBanner = process.env.hasGdprBanner;
@@ -245,7 +265,63 @@ export const SideNavLayout = ({ children, groupedRoutes, navOpen: navOpenProp })
245265

246266
const [versions, setVersions] = useState({ ...staticVersions });
247267
const [isRTL, setIsRTL] = useState(false);
248-
const [isDarkTheme, setIsDarkTheme] = React.useState(false);
268+
const [isDarkTheme, setIsDarkThemeInternal] = useState(() => isDarkModeEnabled());
269+
270+
/**
271+
* Stores the dark mode preference in local storage and updates the dark mode class.
272+
*/
273+
const setIsDarkTheme = useCallback((value) => {
274+
localStorage.setItem(DARK_MODE_STORAGE_KEY, value.toString());
275+
updateDarkMode();
276+
}, []);
277+
278+
/**
279+
* Updates the dark mode class to the root element depending on whether dark mode is enabled.
280+
*/
281+
const updateDarkMode = useCallback(() => {
282+
const isEnabled = isDarkModeEnabled();
283+
const root = document.documentElement;
284+
285+
if (isEnabled) {
286+
root.classList.add(DARK_MODE_CLASS);
287+
} else {
288+
root.classList.remove(DARK_MODE_CLASS);
289+
}
290+
291+
setIsDarkThemeInternal(isEnabled);
292+
}, []);
293+
294+
useEffect(() => {
295+
// When running in prerender mode we can't access the browser APIs.
296+
if (process.env.PRERENDER) {
297+
return;
298+
}
299+
300+
// Update the dark mode when the the user changes their system/browser preference.
301+
const onQueryChange = () => {
302+
// Remove the stored value to defer to the system preference.
303+
localStorage.removeItem(DARK_MODE_STORAGE_KEY);
304+
updateDarkMode();
305+
};
306+
307+
// Update the dark mode when the user changes the preference in another context (e.g. tab or window).
308+
/** @type {(event: StorageEvent) => void} */
309+
const onStorageChange = (event) => {
310+
if (event.key === DARK_MODE_STORAGE_KEY) {
311+
updateDarkMode();
312+
}
313+
};
314+
315+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
316+
317+
mediaQuery.addEventListener("change", onQueryChange);
318+
window.addEventListener("storage", onStorageChange);
319+
320+
return () => {
321+
mediaQuery.removeEventListener("change", onQueryChange);
322+
window.removeEventListener("storage", onStorageChange);
323+
};
324+
}, []);
249325

250326
useEffect(() => {
251327
if (typeof window === 'undefined') {

packages/documentation-framework/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@patternfly/documentation-framework",
33
"description": "A framework to build documentation for PatternFly.",
4-
"version": "6.0.8",
4+
"version": "6.0.16",
55
"author": "Red Hat",
66
"license": "MIT",
77
"private": false,
@@ -13,7 +13,7 @@
1313
"@babel/preset-env": "^7.24.3",
1414
"@babel/preset-react": "^7.24.1",
1515
"@mdx-js/util": "1.6.16",
16-
"@patternfly/ast-helpers": "^1.4.0-alpha.124",
16+
"@patternfly/ast-helpers": "^1.4.0-alpha.132",
1717
"@reach/router": "npm:@gatsbyjs/reach-router@1.3.9",
1818
"autoprefixer": "9.8.6",
1919
"babel-loader": "^9.1.3",
@@ -45,8 +45,8 @@
4545
"postcss": "8.4.32",
4646
"postcss-loader": "7.1.0",
4747
"process": "^0.11.10",
48-
"puppeteer": "19.11.1",
49-
"puppeteer-cluster": "0.23.0",
48+
"puppeteer": "^23.6.1",
49+
"puppeteer-cluster": "^0.24.0",
5050
"react-docgen": "5.3.1",
5151
"react-ssr-prepass": "1.5.0",
5252
"remark-footnotes": "1.0.0",
@@ -73,9 +73,9 @@
7373
"webpack-merge": "5.8.0"
7474
},
7575
"peerDependencies": {
76-
"@patternfly/patternfly": "^6.0.0",
76+
"@patternfly/patternfly": "^6.1.0-prerelease.2",
7777
"@patternfly/react-code-editor": "^6.0.0",
78-
"@patternfly/react-core": "^6.0.0",
78+
"@patternfly/react-core": "^6.1.0-prerelease.2",
7979
"@patternfly/react-table": "^6.0.0",
8080
"react": "^17.0.0 || ^18.0.0",
8181
"react-dom": "^17.0.0 || ^18.0.0"

packages/documentation-framework/templates/html.ejs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
6+
<meta name="color-scheme" content="light dark">
67
<meta name="description" content="PatternFly is Red Hat's open source design system. It consists of components, documentation, and code for building enterprise applications at scale.">
78
<title><%= title %></title>
89
<link rel="shortcut icon" href="/assets/Favicon-Light.png">
@@ -13,6 +14,41 @@
1314
<meta name="mobile-web-app-capable" content="yes">
1415
<meta name="theme-color" content="#151515">
1516
<meta name="application-name" content="PatternFly docs">
17+
<script>
18+
(() => {
19+
"use strict";
20+
21+
const DARK_MODE_CLASS = "pf-v6-theme-dark";
22+
const DARK_MODE_STORAGE_KEY = "dark-mode";
23+
const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
24+
25+
// Ensure that the dark mode is correctly set before the page starts rendering.
26+
updateDarkMode();
27+
28+
/**
29+
* Applies the dark mode class to the root element if dark mode is enabled.
30+
*/
31+
function updateDarkMode() {
32+
const isEnabled = isDarkModeEnabled();
33+
const root = document.documentElement;
34+
35+
if (isEnabled) {
36+
root.classList.add(DARK_MODE_CLASS);
37+
}
38+
}
39+
40+
/**
41+
* Determines if dark mode is enabled based on the stored value or the system preference.
42+
* @returns {boolean} true if dark mode is enabled, false otherwise
43+
*/
44+
function isDarkModeEnabled() {
45+
const storedValue = localStorage.getItem(DARK_MODE_STORAGE_KEY);
46+
const isEnabled = storedValue === null ? darkModeQuery.matches : storedValue === "true";
47+
48+
return isEnabled;
49+
}
50+
})();
51+
</script>
1652
<%= htmlWebpackPlugin.tags.headTags %>
1753
</head>
1854
<body>

packages/documentation-framework/templates/mdx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
222222
)
223223
}
224224
>
225-
View source on GitHub
225+
Edit this page on GitHub
226226
</a>
227227
</StackItem>
228228
)}

0 commit comments

Comments
 (0)