@patternfly/design-tokens 1.0.0

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.
Files changed (39) hide show
  1. package/build/css/_tokens-charts.scss +159 -0
  2. package/build/css/_tokens-dark.scss +355 -0
  3. package/build/css/_tokens-default.scss +418 -0
  4. package/build/css/_tokens-palette.scss +75 -0
  5. package/build-js-for-docs.js +38 -0
  6. package/build.js +55 -0
  7. package/config.chart.json +23 -0
  8. package/config.dark.json +23 -0
  9. package/config.default.json +23 -0
  10. package/config.palette-colors.json +23 -0
  11. package/generate-fed-package-json.js +65 -0
  12. package/package.json +52 -0
  13. package/patternfly-a11y.config.js +24 -0
  14. package/patternfly-docs/content/all-patternfly-tokens.md +9 -0
  15. package/patternfly-docs/content/tokensTable.js +143 -0
  16. package/patternfly-docs/generated/index.js +12 -0
  17. package/patternfly-docs/generated/react.js +59 -0
  18. package/patternfly-docs/generated/tokens/all-patternfly-tokens/tokens.js +34 -0
  19. package/patternfly-docs/pages/index.js +27 -0
  20. package/patternfly-docs/patternfly-docs.config.js +6 -0
  21. package/patternfly-docs/patternfly-docs.css.js +8 -0
  22. package/patternfly-docs/patternfly-docs.routes.js +12 -0
  23. package/patternfly-docs/patternfly-docs.source.js +20 -0
  24. package/patternfly-docs/scssAsJson.json +1 -0
  25. package/plugins/export-patternfly-tokens/README.md +22 -0
  26. package/plugins/export-patternfly-tokens/code.js +85 -0
  27. package/plugins/export-patternfly-tokens/export.html +179 -0
  28. package/plugins/export-patternfly-tokens/manifest.json +12 -0
  29. package/release.config.js +13 -0
  30. package/tokens/AsExported.text +3388 -0
  31. package/tokens/dark/base.dark.json +331 -0
  32. package/tokens/dark/palette.color.json +295 -0
  33. package/tokens/dark/semantic.dark.json +1359 -0
  34. package/tokens/default/base.dimension.json +171 -0
  35. package/tokens/default/base.json +329 -0
  36. package/tokens/default/chart.json +695 -0
  37. package/tokens/default/palette.color.json +295 -0
  38. package/tokens/default/semantic.dimension.json +383 -0
  39. package/tokens/default/semantic.json +1110 -0
@@ -0,0 +1,23 @@
1
+ {
2
+ "source": ["tokens/default/*.json"],
3
+ "platforms": {
4
+ "css": {
5
+ "transformGroup": "patternfly/css",
6
+ "buildPath": "build/css/",
7
+ "prefix": "pf-t",
8
+ "files": [{
9
+ "destination": "_tokens-default.scss",
10
+ "format": "css/variables",
11
+ "options": {
12
+ "outputReferences": true
13
+ },
14
+ "filter": {
15
+ "attributes": {
16
+ "category": "global"
17
+ }
18
+ }
19
+ }
20
+ ]
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "source": ["tokens/default/*.json"],
3
+ "platforms": {
4
+ "css": {
5
+ "transformGroup": "patternfly/css",
6
+ "buildPath": "build/css/",
7
+ "prefix": "pf-t",
8
+ "files": [{
9
+ "destination": "_tokens-palette.scss",
10
+ "format": "css/variables",
11
+ "options": {
12
+ "outputReferences": true
13
+ },
14
+ "filter": {
15
+ "attributes": {
16
+ "category": "color"
17
+ }
18
+ }
19
+ }
20
+ ]
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,65 @@
1
+ const fse = require('fs-extra');
2
+ const glob = require('glob');
3
+ const path = require('path');
4
+
5
+ const root = process.cwd();
6
+
7
+ const sourceFiles = glob
8
+ .sync(`${root}/src/*/`)
9
+ .map((name) => name.replace(/\/$/, ''));
10
+
11
+ const indexTypings = glob.sync(`${root}/src/index.d.ts`);
12
+
13
+ async function copyTypings(files, dest) {
14
+ const cmds = [];
15
+ files.forEach((file) => {
16
+ const fileName = file.split('/').pop();
17
+ cmds.push(fse.copyFile(file, `${dest}/${fileName}`));
18
+ });
19
+ return Promise.all(cmds);
20
+ }
21
+
22
+ async function createPackage(file) {
23
+ const fileName = file.split('/').pop();
24
+ const esmSource = glob.sync(`${root}/dist/esm/${fileName}/**/index.js`)[0];
25
+ /**
26
+ * Prevent creating package.json for directories with no JS files (like CSS directories)
27
+ */
28
+ if (!esmSource) {
29
+ return;
30
+ }
31
+
32
+ const destFile = `${path.resolve(`${root}/dist/esm`, fileName)}/package.json`;
33
+
34
+ const esmRelative = path.relative(file.replace('/dist/esm', ''), esmSource);
35
+ const content = {
36
+ main: 'index.js',
37
+ module: esmRelative,
38
+ };
39
+ const typings = glob.sync(`${root}/src/${fileName}/*.d.ts`);
40
+ const cmds = [];
41
+ content.typings = 'index.d.ts';
42
+ cmds.push(copyTypings(typings, `${root}/dist/${fileName}`));
43
+ cmds.push(fse.writeJSON(destFile, content));
44
+ return Promise.all(cmds);
45
+ }
46
+
47
+ async function generatePackages(files) {
48
+ const cmds = files.map((file) => createPackage(file));
49
+ return Promise.all(cmds);
50
+ }
51
+
52
+ async function run(files) {
53
+ try {
54
+ await generatePackages(files);
55
+ if (indexTypings.length === 1) {
56
+ copyTypings(indexTypings, root);
57
+ }
58
+ } catch (error) {
59
+ // eslint-disable-next-line no-console
60
+ console.error(error);
61
+ process.exit(1);
62
+ }
63
+ }
64
+
65
+ run(sourceFiles);
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@patternfly/design-tokens",
3
+ "version": "1.0.0",
4
+ "description": "Define the design tokens for patternfly design system and component library",
5
+ "main": "dist/esm/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "scripts": {
8
+ "build": "yarn build:scss && yarn build:js-from-scss",
9
+ "build:fed:packages": "node generate-fed-package-json.js",
10
+ "build:scss": "node ./build.js",
11
+ "build:js-from-scss": "node ./build-js-for-docs.js",
12
+ "clean": "rimraf dist",
13
+ "docs:develop": "pf-docs-framework start",
14
+ "docs:build": "yarn build:scss && yarn build:js-from-scss && pf-docs-framework build all --output public",
15
+ "docs:serve": "pf-docs-framework serve public --port 5000",
16
+ "docs:screenshots": "pf-docs-framework screenshots --urlPrefix http://localhost:5000",
17
+ "test:a11y": "patternfly-a11y --config patternfly-a11y.config",
18
+ "serve:a11y": "yarn serve coverage"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/patternfly/design-tokens"
23
+ },
24
+ "author": "Red Hat",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/patternfly/design-tokens/issues"
28
+ },
29
+ "homepage": "https://github.com/patternfly/design-tokens#readme",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@patternfly/react-core": "^6.0.0-alpha.5"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "^16.8 || ^17 || ^18",
38
+ "react-dom": "^18.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@patternfly/documentation-framework": "6.0.0-alpha.10",
42
+ "@patternfly/patternfly": "6.0.0-alpha.38",
43
+ "@patternfly/react-code-editor": "6.0.0-alpha.5",
44
+ "@patternfly/react-table": "6.0.0-alpha.5",
45
+ "rimraf": "^2.6.2",
46
+ "@patternfly/patternfly-a11y": "^4.3.1",
47
+ "react-monaco-editor": "^0.51.0",
48
+ "style-dictionary": "^3.8.0",
49
+ "glob": "^7.1.2",
50
+ "fs-extra": "^11.2.0"
51
+ }
52
+ }
@@ -0,0 +1,24 @@
1
+ const { fullscreenRoutes } = require('@patternfly/documentation-framework/routes');
2
+
3
+ /**
4
+ * Wait for a selector before running axe
5
+ *
6
+ * @param page page from puppeteer
7
+ */
8
+ async function waitFor(page) {
9
+ await page.waitForSelector('#root > *');
10
+ }
11
+
12
+ module.exports = {
13
+ prefix: 'http://localhost:5000',
14
+ waitFor,
15
+ crawl: false,
16
+ urls: ['/','/tokens/all-patternfly-tokens'],
17
+ ignoreRules: [
18
+ 'color-contrast',
19
+ 'landmark-no-duplicate-main',
20
+ 'landmark-main-is-top-level',
21
+ 'scrollable-region-focusable'
22
+ ].join(','),
23
+ ignoreIncomplete: true
24
+ };
@@ -0,0 +1,9 @@
1
+ ---
2
+ section: tokens
3
+ id: All PatternFly tokens
4
+ ---
5
+
6
+
7
+ import { TokensTable } from './tokensTable.js';
8
+
9
+ <TokensTable/>
@@ -0,0 +1,143 @@
1
+ import React from "react";
2
+ import {
3
+ SearchInput,
4
+ Toolbar,
5
+ ToolbarItem,
6
+ ToolbarContent,
7
+ } from "@patternfly/react-core";
8
+ import {
9
+ Table,
10
+ Thead,
11
+ Th,
12
+ Tr,
13
+ Tbody,
14
+ Td,
15
+ ExpandableRowContent,
16
+ OuterScrollContainer,
17
+ InnerScrollContainer,
18
+ } from "@patternfly/react-table";
19
+
20
+ // eslint-disable-next-line camelcase
21
+ import global_spacer_md from "@patternfly/react-tokens/dist/esm/global_spacer_md";
22
+ import LevelUpAltIcon from "@patternfly/react-icons/dist/esm/icons/level-up-alt-icon";
23
+
24
+ import * as scssAsJson from "../scssAsJson";
25
+
26
+ export const TokensTable = () => {
27
+ const scssVariables = Object.keys(scssAsJson);
28
+ const [searchValue, setSearchValue] = React.useState('');
29
+ const [expandedTokens, setExpandedTokens] = React.useState([]);
30
+ const setExpanded = (tokenName, isExpanding = true) =>
31
+ setExpandedTokens((prevExpanded) => {
32
+ const otherExpandedTokens = prevExpanded.filter((n) => n !== tokenName);
33
+ return isExpanding ? [...otherExpandedTokens, tokenName] : otherExpandedTokens;
34
+ });
35
+ const isTokenExpanded = (tokenName) => expandedTokens.includes(tokenName);
36
+
37
+ const showTokenChain = (tokenName) => {
38
+ let tokenChain = [];
39
+ let tokenValue = scssAsJson[tokenName];
40
+
41
+ while (tokenValue !== undefined) {
42
+ tokenChain = [...tokenChain, tokenValue]
43
+ tokenValue = scssAsJson[tokenValue];
44
+ }
45
+
46
+ return (
47
+ <div>
48
+ <div
49
+ className="ws-css-property"
50
+ style={{
51
+ padding: `4px 0 4px calc(${global_spacer_md.value} * ${3})`
52
+ }}>
53
+ <LevelUpAltIcon style={{ transform: 'rotate(90deg)' }} />
54
+ <span style={{ paddingLeft: '16px' }}>
55
+ {tokenName}
56
+ </span>
57
+ </div>
58
+ {tokenChain.map((nextValue, index) => (
59
+ <div
60
+ key={index}
61
+ style={{
62
+ padding: `4px 0 4px calc(${global_spacer_md.value} * ${index + 4})`
63
+ }}
64
+ >
65
+ <LevelUpAltIcon style={{ transform: 'rotate(90deg)' }} />
66
+ <span style={{ paddingLeft: '16px' }}>
67
+ {nextValue}
68
+ </span>
69
+ </div>
70
+ ))}
71
+ </div>
72
+ )
73
+ };
74
+
75
+ return (
76
+ <React.Fragment>
77
+ <Toolbar id="filter-toolbar">
78
+ <ToolbarContent>
79
+ <ToolbarItem variant="search-filter">
80
+ <SearchInput
81
+ aria-label="Search all tokens"
82
+ placeholder="Search all tokens"
83
+ value={searchValue}
84
+ onChange={(_event, value) => setSearchValue(value)}
85
+ onClear={() => setSearchValue("")}
86
+ />
87
+ </ToolbarItem>
88
+ </ToolbarContent>
89
+ </Toolbar>
90
+ <OuterScrollContainer>
91
+ <InnerScrollContainer>
92
+ <Table variant="compact">
93
+ <Thead>
94
+ <Th></Th>
95
+ <Th>Name</Th>
96
+ <Th>Value</Th>
97
+ </Thead>
98
+ {scssVariables.map((tokenName, rowIndex) => {
99
+ if (tokenName === 'default') {
100
+ return undefined
101
+ } else if (searchValue !== '' && !tokenName.includes(searchValue)) {
102
+ return undefined
103
+ } else {
104
+ const isResolved = scssAsJson[scssAsJson[tokenName]] === undefined;
105
+ return (
106
+ <Tbody key={`row-${tokenName}`} isExpanded={isTokenExpanded(tokenName)}>
107
+ <Tr>
108
+ <Td
109
+ expand={
110
+ !isResolved
111
+ ? {
112
+ rowIndex,
113
+ isExpanded: isTokenExpanded(tokenName),
114
+ onToggle: () =>
115
+ setExpanded(tokenName, !isTokenExpanded(tokenName)),
116
+ expandId: `${tokenName}-expandable-toggle`,
117
+ }
118
+ : undefined
119
+ }
120
+ />
121
+ <Td>{tokenName}</Td>
122
+ <Td>{scssAsJson[scssAsJson[tokenName]] === undefined && scssAsJson[tokenName]}</Td>
123
+ </Tr>
124
+ {!isResolved && (
125
+ <Tr isExpanded={isTokenExpanded(tokenName)}>
126
+ <Td />
127
+ <Td noPadding dataLabel="Details" colSpan={2}>
128
+ <ExpandableRowContent>
129
+ {showTokenChain(scssAsJson[tokenName])}
130
+ </ExpandableRowContent>
131
+ </Td>
132
+ </Tr>
133
+ )}
134
+ </Tbody>
135
+ )
136
+ }
137
+ })}
138
+ </Table>
139
+ </InnerScrollContainer>
140
+ </OuterScrollContainer>
141
+ </React.Fragment>
142
+ )
143
+ };
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ '/tokens/all-patternfly-tokens/tokens': {
3
+ id: "All PatternFly tokens",
4
+ title: "All PatternFly tokens",
5
+ toc: [],
6
+ section: "tokens",
7
+ subsection: "",
8
+ source: "tokens",
9
+ tabName: null,
10
+ Component: () => import(/* webpackChunkName: "tokens/all-patternfly-tokens/tokens/index" */ './tokens/all-patternfly-tokens/tokens')
11
+ }
12
+ };
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { AutoLinkHeader, Example, Link as PatternflyThemeLink } from '@patternfly/documentation-framework/components';
3
+ import { ExtendedButton } from "@patternfly/design-tokens";
4
+ const pageData = {
5
+ "id": "design-tokens",
6
+ "section": "extensions",
7
+ "source": "react",
8
+ "slug": "/extensions/design-tokens/react",
9
+ "sourceLink": "https://github.com/patternfly/patternfly-react/blob/main/packages/module/patternfly-docs/content/extensions/design-tokens/examples/basic.md",
10
+ "propComponents": [
11
+ {
12
+ "name": "ExtendedButton",
13
+ "description": "",
14
+ "props": [
15
+ {
16
+ "name": "children",
17
+ "type": "React.ReactNode",
18
+ "description": "Content to render inside the extended button component"
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "examples": [
24
+ "Example"
25
+ ],
26
+ "fullscreenExamples": [
27
+ "Fullscreen example"
28
+ ]
29
+ };
30
+ pageData.liveContext = {
31
+ ExtendedButton
32
+ };
33
+ pageData.relativeImports = {
34
+
35
+ };
36
+ pageData.examples = {
37
+ 'Example': props =>
38
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { ExtendedButton } from '@patternfly/design-tokens';\n\nexport const BasicExample: React.FunctionComponent = () => <ExtendedButton>My custom extension button</ExtendedButton>;\n","title":"Example","lang":"js"}}>
39
+
40
+ </Example>,
41
+ 'Fullscreen example': props =>
42
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { ExtendedButton } from '@patternfly/design-tokens';\n\nexport const BasicExample: React.FunctionComponent = () => <ExtendedButton>My custom extension button</ExtendedButton>;\n","title":"Fullscreen example","lang":"js","isFullscreen":true}}>
43
+
44
+ </Example>
45
+ };
46
+
47
+ const Component = () => (
48
+ <React.Fragment>
49
+ <AutoLinkHeader {...{"id":"basic-usage","size":"h2","className":"ws-title ws-h2"}}>
50
+ {`Basic usage`}
51
+ </AutoLinkHeader>
52
+ {React.createElement(pageData.examples["Example"])}
53
+ {React.createElement(pageData.examples["Fullscreen example"])}
54
+ </React.Fragment>
55
+ );
56
+ Component.displayName = 'ExtensionsPatternflyExtensionSeedReactDocs';
57
+ Component.pageData = pageData;
58
+
59
+ export default Component;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { AutoLinkHeader, Example, Link as PatternflyThemeLink } from '@patternfly/documentation-framework/components';
3
+ import { TokensTable } from '../../../content/./tokensTable.js';
4
+ const pageData = {
5
+ "id": "All PatternFly tokens",
6
+ "section": "tokens",
7
+ "subsection": "",
8
+ "deprecated": false,
9
+ "beta": false,
10
+ "demo": false,
11
+ "newImplementationLink": false,
12
+ "source": "tokens",
13
+ "tabName": null,
14
+ "slug": "/tokens/all-patternfly-tokens/tokens",
15
+ "sourceLink": "https://github.com/patternfly/patternfly-org/blob/main/packages/module/patternfly-docs/content/all-patternfly-tokens.md",
16
+ "relPath": "packages/module/patternfly-docs/content/all-patternfly-tokens.md"
17
+ };
18
+ pageData.liveContext = {
19
+ TokensTable
20
+ };
21
+ pageData.relativeImports = "import { TokensTable } from 'content/./tokensTable.js';"
22
+ pageData.examples = {
23
+
24
+ };
25
+
26
+ const Component = () => (
27
+ <React.Fragment>
28
+ <TokensTable/>
29
+ </React.Fragment>
30
+ );
31
+ Component.displayName = 'TokensAllPatternflyTokensTokensDocs';
32
+ Component.pageData = pageData;
33
+
34
+ export default Component;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { Title, PageSection } from '@patternfly/react-core';
3
+
4
+ const centerStyle = {
5
+ flexGrow: 1,
6
+ display: 'flex',
7
+ alignItems: 'center',
8
+ justifyContent: 'center'
9
+ };
10
+
11
+ const IndexPage = () => {
12
+ return (
13
+ <PageSection variant="light" style={centerStyle}>
14
+ <div style={{ flex: 'none', textAlign: 'center' }}>
15
+ <Title size="4xl" headingLevel="h1">
16
+ My extension docs
17
+ </Title>
18
+ <Title size="2xl" headingLevel="h2">
19
+ {'Hi people!'}
20
+ </Title>
21
+ <p>Welcome to my extension docs.</p>
22
+ </div>
23
+ </PageSection>
24
+ );
25
+ };
26
+
27
+ export default IndexPage;
@@ -0,0 +1,6 @@
1
+ // This module is shared between NodeJS and babelled ES5
2
+ module.exports = {
3
+ sideNavItems: [{ section: 'tokens' }],
4
+ topNavItems: [],
5
+ port: 8006
6
+ };
@@ -0,0 +1,8 @@
1
+ // Patternfly
2
+ import '@patternfly/patternfly/patternfly.css';
3
+ // Patternfly utilities
4
+ import '@patternfly/patternfly/patternfly-addons.css';
5
+ // Global theme CSS
6
+ import '@patternfly/documentation-framework/global.css';
7
+
8
+ // Add your extension CSS below
@@ -0,0 +1,12 @@
1
+ // This module is shared between NodeJS and babelled ES5
2
+ const isClient = Boolean(process.env.NODE_ENV);
3
+
4
+ module.exports = {
5
+ '/': {
6
+ SyncComponent: isClient && require('./pages/index').default
7
+ },
8
+ '/404': {
9
+ SyncComponent: isClient && require('@patternfly/documentation-framework/pages/404/index').default,
10
+ title: '404 Error'
11
+ }
12
+ };
@@ -0,0 +1,20 @@
1
+ const path = require('path');
2
+
3
+ module.exports = (sourceMD) => {
4
+
5
+ // Parse md files
6
+ const contentBase = path.join(__dirname, './content');
7
+ sourceMD(path.join(contentBase, '/*.md'), 'tokens');
8
+
9
+ /**
10
+ If you want to parse content from node_modules instead of providing a relative/absolute path,
11
+ you can do something similar to this:
12
+ const extensionPath = require
13
+ .resolve('@patternfly/react-log-viewer/package.json')
14
+ .replace('package.json', 'src');
15
+ sourceProps(path.join(extensionPath, '/**\/*.tsx'), propsIgnore);
16
+ sourceMD(path.join(extensionPath, '../patternfly-docs/**\/examples/*.md'), 'react');
17
+ sourceMD(path.join(extensionPath, '../patternfly-docs/**\/demos/*.md'), 'react-demos');
18
+ sourceMD(path.join(extensionPath, '../patternfly-docs/**\/design-guidelines/*.md'), 'design-guidelines');
19
+ */
20
+ };