@patternfly/documentation-framework 5.1.0 → 5.1.2

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,25 @@
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
+ ## 5.1.2 (2023-08-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * clean up h2 and dark theme switcher styles ([#3690](https://github.com/patternfly/patternfly-org/issues/3690)) ([8319c0c](https://github.com/patternfly/patternfly-org/commit/8319c0ccecb018f72b277e070e4ccab1896f6cab))
12
+
13
+
14
+
15
+
16
+
17
+ ## 5.1.1 (2023-08-09)
18
+
19
+ **Note:** Version bump only for package @patternfly/documentation-framework
20
+
21
+
22
+
23
+
24
+
6
25
  # 5.1.0 (2023-08-08)
7
26
 
8
27
 
@@ -130,12 +130,12 @@ function getReactParams(title, code, scope, lang, relativeImports, relPath, sour
130
130
  // Ignore
131
131
  }
132
132
 
133
- // Point to sourcelink for @patternfly images
133
+ // Update image imports from package to sourcelink - note this relies on image import path in example .md to be accurate
134
134
  if (relPath.includes('@patternfly')) {
135
135
  const imgImportRegex = /(import \W*(\w*)\W*[^'"`]*['"`](.*\.(?:png|jpe?g|webp|gif|svg))['"])/gm;
136
136
  let imgImportMatch;
137
137
  while ((imgImportMatch = imgImportRegex.exec(code))) {
138
- const [match, importDeclaration, imgName, relImgPath] = imgImportMatch;
138
+ const [_match, importDeclaration, imgName, relImgPath] = imgImportMatch;
139
139
  // Point to sourceLink hosted file
140
140
  const sourceLinkPath = new URL(relImgPath, sourceLink.replace('/blob/', '/raw/')).href;
141
141
  const hostedImageDeclaration = `const ${imgName} = "${sourceLinkPath}"`;
@@ -143,15 +143,18 @@ function getReactParams(title, code, scope, lang, relativeImports, relPath, sour
143
143
  }
144
144
  }
145
145
 
146
- const relImportRegex = /(import[\s*{])([\w*{}\n\r\t, ]+)([\s*]from\s["']([\.\/]+.*)["'])/gm;
146
+ // Add absolute imports to codesandbox file - comes from mdx-hast-to-jsx.js
147
+ if (relativeImports?.length > 0) {
148
+ const absoluteImports = relativeImports.split(';,').join(';\n');
149
+ code = `${absoluteImports}\n${code}`;
150
+ }
151
+ // Remove relative imports from codesandbox file (ignore images, which are addressed separately above)
152
+ const relImportRegex = /(import [^'"]*)['"](?:[\.\/]+(?:node_modules\/)?)(@?(?:(?!\.svg|\.jpe?g|\.png).)+)['"][;?]/gm;
147
153
  let relImportMatch;
148
154
  while (relImportMatch = relImportRegex.exec(code)) {
149
- const [ relImportName, _name, relImportPath ] = relImportMatch;
150
- if (relativeImports[relImportName]) {
151
- code = code.replace(relImportPath, relativeImports[relImportName]);
152
- }
155
+ const [ relImportStatement, _relImportItems, _relImportPath ] = relImportMatch;
156
+ code = code.replace(relImportStatement, '');
153
157
  }
154
-
155
158
 
156
159
  const dependencies = {
157
160
  '@patternfly/react-core': versions.Releases[0].versions['@patternfly/react-core']
@@ -197,14 +200,14 @@ function getReactParams(title, code, scope, lang, relativeImports, relPath, sour
197
200
  </html>`,
198
201
  },
199
202
  [lang === 'ts' ? 'index.tsx' : 'index.js']: {
200
- content: `import ReactDOM from 'react-dom';
203
+ content: `import { createRoot } from "react-dom/client";
201
204
  import "@patternfly/react-core/dist/styles/base.css";
202
205
  import './fonts.css';
203
206
 
204
207
  ${code}
205
208
 
206
- const rootElement = document.getElementById("root");
207
- ReactDOM.render(<${toRender} />, rootElement);`
209
+ const container = document.getElementById("root");
210
+ createRoot(container).render(<${toRender} />);`
208
211
  },
209
212
  'fonts.css': {
210
213
  content: overpass
@@ -213,8 +216,8 @@ ReactDOM.render(<${toRender} />, rootElement);`
213
216
  content: {
214
217
  dependencies: {
215
218
  ...dependencies,
216
- 'react': '^16.8.0',
217
- 'react-dom': '^16.8.0'
219
+ 'react': '^18',
220
+ 'react-dom': '^18'
218
221
  }
219
222
  },
220
223
  },
@@ -36,3 +36,9 @@
36
36
  .ws-masthead .pf-v5-c-toolbar__item {
37
37
  min-width: 0;
38
38
  }
39
+
40
+ .ws-masthead .pf-v5-c-switch {
41
+ align-items: center;
42
+ --pf-v5-c-switch__input--not-checked__label--Color: var(--pf-v5-global--Color--100);
43
+ --pf-v5-c-switch__input--checked__label--Color: var(--pf-v5-global--Color--100);
44
+ }
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": "5.1.0",
4
+ "version": "5.1.2",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -17,7 +17,7 @@
17
17
  "@babel/plugin-transform-react-jsx": "7.17.12",
18
18
  "@babel/preset-env": "7.18.2",
19
19
  "@mdx-js/util": "1.6.16",
20
- "@patternfly/ast-helpers": "^1.1.0",
20
+ "@patternfly/ast-helpers": "^1.1.2",
21
21
  "@reach/router": "npm:@gatsbyjs/reach-router@1.3.9",
22
22
  "autoprefixer": "9.8.6",
23
23
  "babel-loader": "9.1.2",
@@ -87,5 +87,5 @@
87
87
  "react": "^17.0.0 || ^18.0.0",
88
88
  "react-dom": "^17.0.0 || ^18.0.0"
89
89
  },
90
- "gitHead": "bde845f520e6199295febe8b3b7c9ad9413a9ac4"
90
+ "gitHead": "d4410030244dfaba10f35dd528223cc2abf92a8c"
91
91
  }
@@ -71,25 +71,14 @@ function serializeRoot(node, options) {
71
71
  .map(node => node.value)
72
72
  .map(imp => imp.replace(/(['"])\./g, (_, match) => `${match}${getRelPath()}${path.posix.sep}\.`));
73
73
 
74
- // Map relative import name to '@package...'
75
- const relativeImportsRegex = /(?:[\.\/]+.*)(@.*)['"]/gm;
74
+ // Build array of absolute import paths for relative imports
75
+ const relativeImportsRegex = /(import [^'"]*)['"](?:[\.\/]+(?:node_modules\/)?)(@?(?:(?!\.svg|\.jpe?g|\.png).)+)['"][;?]/gm;
76
76
  let relativeImportMatch;
77
- let relativeImportMatches = {};
78
- while (relativeImportMatch = relativeImportsRegex.exec(importStatements[0])) {
79
- const [_match, absoluteImportPath] = relativeImportMatch;
80
- if (absoluteImportPath && !absoluteImportPath.includes('srcImport')) {
81
- // `@patternfly/react-core/src/demos/./examples/DashboardWrapper` to `DashboardWrapper`
82
- let relativeFileImport = /(\.+\/.*)/gm.exec(absoluteImportPath);
83
- if (relativeFileImport) {
84
- // Build map of relative imports (from example.js code) to npm package import path (used in codesandbox.js)
85
- const relativeFilePath = relativeFileImport[0];
86
- const relativeImportName = relativeFilePath
87
- .split('/')
88
- .pop()
89
- .split('.')
90
- .shift();
91
- relativeImportMatches[relativeImportName] = absoluteImportPath;
92
- }
77
+ let relativeImportMatches = [];
78
+ while (relativeImportMatch = relativeImportsRegex.exec(importStatements.join())) {
79
+ const [match, importItems, absoluteImportPath] = relativeImportMatch;
80
+ if (absoluteImportPath && !match.includes('srcImport')) {
81
+ relativeImportMatches.push(`${importItems}'${absoluteImportPath}';`);
93
82
  }
94
83
  }
95
84
 
@@ -120,12 +109,8 @@ const pageData = ${JSON.stringify(pageData, null, 2)};
120
109
  ' ' + liveContext
121
110
  }\n};\n`
122
111
  }
123
- if (relativeImportMatches) {
124
- res += `pageData.relativeImports = {\n${
125
- ' ' + Object.entries(relativeImportMatches)
126
- .map(([key, val]) => `'${key}': '${val}'`)
127
- .join(',\n ')
128
- }\n};\n`;
112
+ if (relativeImportMatches.length > 0) {
113
+ res += `pageData.relativeImports = "${relativeImportMatches}"\n`;
129
114
  }
130
115
  if (examples) {
131
116
  res += `pageData.examples = {\n${
package/templates/mdx.css CHANGED
@@ -191,8 +191,7 @@
191
191
  margin-bottom: var(--pf-v5-c-content--h2--MarginBottom);
192
192
  font-size: var(--pf-v5-c-content--h2--FontSize);
193
193
  font-weight: var(--pf-v5-c-content--h2--FontWeight);
194
- line-height: var(--pf-v5-c-content--h2--LineHeight); }
195
- .ws-h2:not(:first-child) {
194
+ line-height: var(--pf-v5-c-content--h2--LineHeight);
196
195
  margin-top: var(--pf-v5-c-content--h2--MarginTop); }
197
196
  .ws-h3 {
198
197
  margin-bottom: var(--pf-v5-c-content--h3--MarginBottom);