handoff-app 0.5.1 → 0.5.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 +15 -0
- package/components/Header.tsx +1 -1
- package/components/util/index.ts +37 -25
- package/config.ts +2 -12
- package/figma-exporter/dist/declarations/src/config.d.ts +13 -10
- package/figma-exporter/dist/declarations/src/utils/config.d.ts +0 -6
- package/figma-exporter/src/config.d.ts +13 -10
- package/figma-exporter/src/utils/config.ts +1 -23
- package/package.json +1 -1
- package/pages/[level1]/[level2]/index.tsx +0 -3
- package/pages/[level1]/index.tsx +0 -3
- package/pages/assets/fonts.tsx +10 -14
- package/pages/assets/icons/{[name].tsx → [name]/index.tsx} +19 -15
- package/pages/assets/icons/index.tsx +12 -11
- package/pages/assets/index.tsx +8 -7
- package/pages/assets/logos.tsx +8 -7
- package/pages/changelog.tsx +11 -11
- package/pages/components/[component]/index.tsx +12 -25
- package/pages/components/index.tsx +15 -24
- package/pages/foundations/colors.tsx +28 -25
- package/pages/foundations/effects.tsx +21 -18
- package/pages/foundations/index.tsx +9 -8
- package/pages/foundations/logo.tsx +14 -14
- package/pages/foundations/typography.tsx +42 -41
- package/pages/index.tsx +11 -10
- package/public/assets/icons.html +40 -40
- package/public/assets/icons.svg +1 -1
- package/public/tokens.zip +0 -0
package/Changelog.md
CHANGED
|
@@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.5.2] - 2023-06-14
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- Tokens, changelog and previews are now read form the file system using the `fs.readFileSync` instead of the `import` statement.
|
|
14
|
+
- Updated the Next.js app pages to utilize `getStaticProps` for fetching of the configuration and the exported tokens.
|
|
15
|
+
- Removed `componentExists` utility method as it's no longer used
|
|
16
|
+
- Removed `mapComponentSize` utility method as it's no longer used
|
|
17
|
+
|
|
18
|
+
### Bugfixes
|
|
19
|
+
|
|
20
|
+
- By changing the way in which the configuration, tokens, changelog and previews are read and passed into the pages a bug has been resolved that would occur while running the `fetch` command while the `dev` command was already running which would cause the app from stop responding correctly and would require app restart.
|
|
21
|
+
|
|
9
22
|
## [0.5.1] - 2023-06-01
|
|
10
23
|
|
|
11
24
|
### Changes
|
|
@@ -136,6 +149,8 @@ integration: {
|
|
|
136
149
|
|
|
137
150
|
- The new exportable schema has normalized the token output, fixing several small
|
|
138
151
|
inconsistencies in the way tokens were created.
|
|
152
|
+
- Fixes a warning caused by loading the config into the next app outside of the
|
|
153
|
+
static properties
|
|
139
154
|
|
|
140
155
|
## [0.4.3] - 2023-04-19
|
|
141
156
|
|
package/components/Header.tsx
CHANGED
package/components/util/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Config } from 'client-config';
|
|
2
2
|
import { getConfig } from 'config';
|
|
3
|
-
import {
|
|
3
|
+
import { ChangelogRecord } from 'figma-exporter/src/changelog';
|
|
4
|
+
import { ExportResult } from 'figma-exporter/src/config';
|
|
5
|
+
import { Component } from 'figma-exporter/src/exporters/components/extractor';
|
|
6
|
+
import { ExportableDefinition, ExportableOptions, PreviewJson, PreviewObject } from 'figma-exporter/src/types';
|
|
4
7
|
import { filterOutNull } from 'figma-exporter/src/utils';
|
|
5
8
|
import * as fs from 'fs-extra';
|
|
6
9
|
import matter from 'gray-matter';
|
|
@@ -43,21 +46,37 @@ export interface DocumentationProps {
|
|
|
43
46
|
content: string;
|
|
44
47
|
menu: SectionLink[];
|
|
45
48
|
current: SectionLink;
|
|
49
|
+
config: Config;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ChangelogDocumentationProps extends DocumentationProps {
|
|
53
|
+
changelog: ChangelogRecord[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FontDocumentationProps extends DocumentationProps {
|
|
57
|
+
customFonts: string[];
|
|
58
|
+
design: ExportResult['design'];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface AssetDocumentationProps extends DocumentationProps {
|
|
62
|
+
assets: ExportResult['assets'];
|
|
46
63
|
}
|
|
47
64
|
|
|
48
65
|
export interface ComponentDocumentationProps extends DocumentationProps {
|
|
49
66
|
scss: string;
|
|
50
67
|
css: string;
|
|
51
68
|
types: string;
|
|
52
|
-
componentFound: boolean;
|
|
53
|
-
component: string;
|
|
54
69
|
exportable: ExportableDefinition;
|
|
70
|
+
components: Component[];
|
|
71
|
+
previews: PreviewObject[];
|
|
72
|
+
component: string;
|
|
55
73
|
}
|
|
56
74
|
|
|
57
75
|
export interface FoundationDocumentationProps extends DocumentationProps {
|
|
58
76
|
scss: string;
|
|
59
77
|
css: string;
|
|
60
78
|
types: string;
|
|
79
|
+
design: ExportResult['design'];
|
|
61
80
|
}
|
|
62
81
|
/**
|
|
63
82
|
* List the default paths
|
|
@@ -159,26 +178,6 @@ export const buildL2StaticPaths = () => {
|
|
|
159
178
|
return paths;
|
|
160
179
|
};
|
|
161
180
|
|
|
162
|
-
/**
|
|
163
|
-
* Does a component exist in figma? Check the length of the component tokens
|
|
164
|
-
* @param component
|
|
165
|
-
* @param config
|
|
166
|
-
* @returns
|
|
167
|
-
*/
|
|
168
|
-
export const componentExists = (component: string, config?: Config): boolean => {
|
|
169
|
-
if (!config) {
|
|
170
|
-
config = getConfig();
|
|
171
|
-
}
|
|
172
|
-
const componentKey = pluralizeComponent(component) ?? false;
|
|
173
|
-
// If this is a component (we define it in the tokens file)
|
|
174
|
-
// but it has a length of 0, return the menu as undefined even
|
|
175
|
-
// if its set in the file list
|
|
176
|
-
if (config.components[componentKey] && config.components[componentKey].length === 0) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
return true;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
181
|
/**
|
|
183
182
|
* Build the static menu for rendeirng pages
|
|
184
183
|
* @returns SectionLink[]
|
|
@@ -187,7 +186,6 @@ export const staticBuildMenu = () => {
|
|
|
187
186
|
// Contents of docs
|
|
188
187
|
const files = fs.readdirSync('docs');
|
|
189
188
|
const sections: SectionLink[] = [];
|
|
190
|
-
const config = getConfig();
|
|
191
189
|
|
|
192
190
|
// Build path tree
|
|
193
191
|
const custom = files
|
|
@@ -281,7 +279,6 @@ export const fetchCompDocPageMarkdown = (path: string, slug: string | undefined,
|
|
|
281
279
|
return {
|
|
282
280
|
props: {
|
|
283
281
|
...fetchDocPageMarkdown(path, slug, id).props,
|
|
284
|
-
// componentFound: slug ? componentExists(slug, undefined) : false,
|
|
285
282
|
scss: slug ? fetchTokensString(slug, 'scss') : '',
|
|
286
283
|
css: slug ? fetchTokensString(slug, 'css') : '',
|
|
287
284
|
types: slug ? fetchTokensString(slug, 'types') : '',
|
|
@@ -367,6 +364,21 @@ export const fetchFoundationDocPageMarkdown = (path: string, slug: string | unde
|
|
|
367
364
|
};
|
|
368
365
|
};
|
|
369
366
|
|
|
367
|
+
export const getTokens = () : ExportResult => {
|
|
368
|
+
const data = fs.readFileSync('./exported/tokens.json', 'utf-8');
|
|
369
|
+
return JSON.parse(data.toString()) as ExportResult;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export const getChangelog = () => {
|
|
373
|
+
const data = fs.readFileSync('./exported/changelog.json', 'utf-8');
|
|
374
|
+
return JSON.parse(data.toString()) as ChangelogRecord[];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export const getPreview = () : PreviewJson => {
|
|
378
|
+
const data = fs.readFileSync('./exported/preview.json', 'utf-8');
|
|
379
|
+
return JSON.parse(data.toString()) as PreviewJson;
|
|
380
|
+
}
|
|
381
|
+
|
|
370
382
|
/**
|
|
371
383
|
* Reduce a slug which can be either an array or string, to just a string by
|
|
372
384
|
* plucking the first element
|
package/config.ts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import config from './client-config';
|
|
2
2
|
import type { Config } from './figma-exporter/src/config';
|
|
3
|
-
import type { ChangelogRecord } from './figma-exporter/src/changelog';
|
|
4
|
-
import type { PreviewJson } from 'figma-exporter/src/types';
|
|
5
|
-
import elements from './exported/tokens.json';
|
|
6
|
-
import changelog from './exported/changelog.json';
|
|
7
|
-
import preview from './exported/preview.json';
|
|
8
3
|
|
|
9
4
|
export const getConfig = () => {
|
|
10
5
|
// Check to see if there is a config in the root of the project
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const getChangelog = () => (changelog || []) as unknown as ChangelogRecord[];
|
|
16
|
-
|
|
17
|
-
export const getPreview = () => (preview || []) as unknown as PreviewJson;
|
|
6
|
+
return { ...config } as unknown as Config;
|
|
7
|
+
};
|
|
@@ -46,6 +46,19 @@ export interface ComponentSizeMap {
|
|
|
46
46
|
css: string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export interface ExportResult {
|
|
50
|
+
design: {
|
|
51
|
+
color: ColorObject[];
|
|
52
|
+
effect: EffectObject[];
|
|
53
|
+
typography: TypographyObject[];
|
|
54
|
+
};
|
|
55
|
+
components: DocumentComponentsObject;
|
|
56
|
+
assets: {
|
|
57
|
+
icons: AssetObject[];
|
|
58
|
+
logos: AssetObject[];
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
export interface Config {
|
|
50
63
|
title: string;
|
|
51
64
|
client: string;
|
|
@@ -62,16 +75,6 @@ export interface Config {
|
|
|
62
75
|
type_copy: string;
|
|
63
76
|
color_sort: string[];
|
|
64
77
|
component_sort: string[];
|
|
65
|
-
design: {
|
|
66
|
-
color: ColorObject[];
|
|
67
|
-
effect: EffectObject[];
|
|
68
|
-
typography: TypographyObject[];
|
|
69
|
-
};
|
|
70
|
-
components: DocumentComponentsObject;
|
|
71
|
-
assets: {
|
|
72
|
-
icons: AssetObject[];
|
|
73
|
-
logos: AssetObject[];
|
|
74
|
-
};
|
|
75
78
|
/**
|
|
76
79
|
* @default { icons: "/icons.zip", logos: "/logos.zip" }
|
|
77
80
|
*/
|
|
@@ -46,6 +46,19 @@ export interface ComponentSizeMap {
|
|
|
46
46
|
css: string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export interface ExportResult {
|
|
50
|
+
design: {
|
|
51
|
+
color: ColorObject[];
|
|
52
|
+
effect: EffectObject[];
|
|
53
|
+
typography: TypographyObject[];
|
|
54
|
+
};
|
|
55
|
+
components: DocumentComponentsObject;
|
|
56
|
+
assets: {
|
|
57
|
+
icons: AssetObject[];
|
|
58
|
+
logos: AssetObject[];
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
export interface Config {
|
|
50
63
|
title: string;
|
|
51
64
|
client: string;
|
|
@@ -62,16 +75,6 @@ export interface Config {
|
|
|
62
75
|
type_copy: string;
|
|
63
76
|
color_sort: string[];
|
|
64
77
|
component_sort: string[];
|
|
65
|
-
design: {
|
|
66
|
-
color: ColorObject[];
|
|
67
|
-
effect: EffectObject[];
|
|
68
|
-
typography: TypographyObject[];
|
|
69
|
-
};
|
|
70
|
-
components: DocumentComponentsObject;
|
|
71
|
-
assets: {
|
|
72
|
-
icons: AssetObject[];
|
|
73
|
-
logos: AssetObject[];
|
|
74
|
-
};
|
|
75
78
|
/**
|
|
76
79
|
* @default { icons: "/icons.zip", logos: "/logos.zip" }
|
|
77
80
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { ComponentSizeMap } from '../config';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Get Config
|
|
@@ -17,25 +16,4 @@ export const getFetchConfig = () => {
|
|
|
17
16
|
const parsed = { ...config };
|
|
18
17
|
|
|
19
18
|
return parsed;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Map a component size to the right name
|
|
24
|
-
* @param figma
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
export const mapComponentSize = (figma: string, component?: string): string => {
|
|
28
|
-
const config = getFetchConfig();
|
|
29
|
-
if (component) {
|
|
30
|
-
if (config.figma.components[component]?.size) {
|
|
31
|
-
const componentMap = config.components[component]?.size as ComponentSizeMap[];
|
|
32
|
-
const componentSize = componentMap.find((size) => size.figma === figma);
|
|
33
|
-
if (componentSize && componentSize?.css) {
|
|
34
|
-
return componentSize?.css;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const coreMap = config.figma.size as ComponentSizeMap[];
|
|
39
|
-
const size = coreMap.find((size) => size.figma === figma);
|
|
40
|
-
return size?.css ?? figma;
|
|
41
|
-
};
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { buildL2StaticPaths, DocumentationProps, fetchDocPageMarkdown, IParams, reduceSlugToString } from 'components/util';
|
|
2
2
|
import { GetStaticProps } from 'next';
|
|
3
|
-
import { getConfig } from 'config';
|
|
4
3
|
import Head from 'next/head';
|
|
5
4
|
import Header from 'components/Header';
|
|
6
5
|
import CustomNav from 'components/SideNav/Custom';
|
|
@@ -42,8 +41,6 @@ export const getStaticProps: GetStaticProps = async (context) => {
|
|
|
42
41
|
return fetchDocPageMarkdown(`docs/${level1}/`, reduceSlugToString(level2), `/${level1}`);
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
const config = getConfig();
|
|
46
|
-
|
|
47
44
|
/**
|
|
48
45
|
* Render Docs page
|
|
49
46
|
* @param param0
|
package/pages/[level1]/index.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import Header from 'components/Header';
|
|
|
2
2
|
import CustomNav from 'components/SideNav/Custom';
|
|
3
3
|
import { buildL1StaticPaths, DocumentationProps, fetchDocPageMarkdown, IParams, reduceSlugToString } from 'components/util';
|
|
4
4
|
import { MarkdownComponents } from 'components/Markdown/MarkdownComponents';
|
|
5
|
-
import { getConfig } from 'config';
|
|
6
5
|
import { GetStaticProps } from 'next';
|
|
7
6
|
import Head from 'next/head';
|
|
8
7
|
import rehypeRaw from 'rehype-raw';
|
|
@@ -33,8 +32,6 @@ export const getStaticProps: GetStaticProps = async (context) => {
|
|
|
33
32
|
return fetchDocPageMarkdown('docs/', reduceSlugToString(level1), `/${level1}`);
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
const config = getConfig();
|
|
37
|
-
|
|
38
35
|
/**
|
|
39
36
|
* Render Docs page
|
|
40
37
|
* @param param0
|
package/pages/assets/fonts.tsx
CHANGED
|
@@ -2,19 +2,15 @@ import * as React from 'react';
|
|
|
2
2
|
import type { GetStaticProps, NextPage } from 'next';
|
|
3
3
|
import uniq from 'lodash/uniq';
|
|
4
4
|
import * as fs from 'fs-extra';
|
|
5
|
-
import { getConfig } from 'config';
|
|
6
5
|
import Icon from 'components/Icon';
|
|
7
|
-
|
|
8
6
|
import Head from 'next/head';
|
|
9
|
-
import {
|
|
7
|
+
import { fetchDocPageMarkdown, FontDocumentationProps, getTokens } from 'components/util';
|
|
10
8
|
import Header from 'components/Header';
|
|
11
9
|
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
|
|
12
10
|
import CustomNav from 'components/SideNav/Custom';
|
|
13
11
|
import { MarkdownComponents } from 'components/Markdown/MarkdownComponents';
|
|
14
12
|
import rehypeRaw from 'rehype-raw';
|
|
15
13
|
|
|
16
|
-
const config = getConfig();
|
|
17
|
-
const fontFamilies: string[] = uniq(config.design.typography.map((type) => type.values.fontFamily));
|
|
18
14
|
/**
|
|
19
15
|
* This statically renders content from the markdown, creating menu and providing
|
|
20
16
|
* metadata
|
|
@@ -24,11 +20,9 @@ const fontFamilies: string[] = uniq(config.design.typography.map((type) => type.
|
|
|
24
20
|
* @returns
|
|
25
21
|
*/
|
|
26
22
|
export const getStaticProps: GetStaticProps = async (context) => {
|
|
27
|
-
// Read current slug
|
|
28
|
-
const markdown = fetchDocPageMarkdown('docs/assets/', 'fonts', `/assets`);
|
|
29
23
|
const fonts = fs.readdirSync('public/fonts');
|
|
30
24
|
const customFonts: string[] = [];
|
|
31
|
-
|
|
25
|
+
|
|
32
26
|
fonts.map((font) => {
|
|
33
27
|
if (font.endsWith('.zip')) {
|
|
34
28
|
// We have a custom font
|
|
@@ -36,16 +30,18 @@ export const getStaticProps: GetStaticProps = async (context) => {
|
|
|
36
30
|
customFonts.push(name);
|
|
37
31
|
}
|
|
38
32
|
});
|
|
33
|
+
|
|
39
34
|
return {
|
|
40
|
-
props: {
|
|
35
|
+
props: {
|
|
36
|
+
...fetchDocPageMarkdown('docs/assets/', 'fonts', `/assets`).props,
|
|
37
|
+
design: getTokens().design,
|
|
38
|
+
customFonts,
|
|
39
|
+
},
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const FontsPage = ({ content, menu, metadata, current, customFonts }: FontDocProps) => {
|
|
43
|
+
const FontsPage = ({ content, menu, metadata, current, customFonts, design }: FontDocumentationProps) => {
|
|
44
|
+
const fontFamilies: string[] = uniq(design.typography.map((type) => type.values.fontFamily));
|
|
49
45
|
const fontLinks: string[] = fontFamilies.map((fontFamily) => {
|
|
50
46
|
const machine_name = fontFamily.replace(/\s/g, '');
|
|
51
47
|
const custom = customFonts.find((font) => font === machine_name);
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { GetStaticProps
|
|
2
|
+
import type { GetStaticProps } from 'next';
|
|
3
3
|
import { useRouter } from 'next/router';
|
|
4
4
|
import HtmlReactParser from 'html-react-parser';
|
|
5
|
-
import * as fs from 'fs-extra';
|
|
6
5
|
import { AssetObject } from 'figma-exporter/src/types';
|
|
7
6
|
import { getConfig } from 'config';
|
|
8
7
|
import Icon from 'components/Icon';
|
|
9
|
-
|
|
10
8
|
import Head from 'next/head';
|
|
11
9
|
import Header from 'components/Header';
|
|
12
|
-
import {
|
|
13
|
-
import path from 'path';
|
|
10
|
+
import { AssetDocumentationProps, fetchDocPageMarkdown, getTokens } from 'components/util';
|
|
14
11
|
import CustomNav from 'components/SideNav/Custom';
|
|
15
12
|
|
|
16
|
-
const config = getConfig();
|
|
17
|
-
|
|
18
13
|
const DisplayIcon: React.FC<{ icon: AssetObject }> = ({ icon }) => {
|
|
19
14
|
const htmlData = React.useMemo(() => {
|
|
20
15
|
// For SSR
|
|
@@ -36,21 +31,24 @@ const DisplayIcon: React.FC<{ icon: AssetObject }> = ({ icon }) => {
|
|
|
36
31
|
|
|
37
32
|
return <>{HtmlReactParser(htmlData)}</>;
|
|
38
33
|
};
|
|
34
|
+
|
|
39
35
|
/**
|
|
40
36
|
* Render all index pages
|
|
41
37
|
* @returns
|
|
42
38
|
*/
|
|
43
39
|
export async function getStaticPaths() {
|
|
44
|
-
const paths =
|
|
40
|
+
const paths = getTokens().assets.icons.map((icon) => ({
|
|
45
41
|
params: {
|
|
46
42
|
name: icon.name,
|
|
47
43
|
},
|
|
48
44
|
}));
|
|
45
|
+
|
|
49
46
|
return {
|
|
50
47
|
paths,
|
|
51
48
|
fallback: true,
|
|
52
49
|
};
|
|
53
50
|
}
|
|
51
|
+
|
|
54
52
|
/**
|
|
55
53
|
* This statically renders content from the markdown, creating menu and providing
|
|
56
54
|
* metadata
|
|
@@ -60,14 +58,19 @@ export async function getStaticPaths() {
|
|
|
60
58
|
* @returns
|
|
61
59
|
*/
|
|
62
60
|
export const getStaticProps: GetStaticProps = async (context) => {
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
return {
|
|
62
|
+
props: {
|
|
63
|
+
...fetchDocPageMarkdown('docs/assets/', 'icons', `/assets`).props,
|
|
64
|
+
config: getConfig(),
|
|
65
|
+
assets: getTokens().assets,
|
|
66
|
+
}
|
|
67
|
+
};
|
|
65
68
|
};
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
export default function SingleIcon({ content, menu, metadata, current, config, assets }: AssetDocumentationProps) {
|
|
68
71
|
const router = useRouter();
|
|
69
72
|
let { name } = router.query;
|
|
70
|
-
const icon =
|
|
73
|
+
const icon = assets?.icons.find((icon) => icon.icon === name);
|
|
71
74
|
const copySvg = React.useCallback<React.MouseEventHandler>(
|
|
72
75
|
(event) => {
|
|
73
76
|
event.preventDefault();
|
|
@@ -77,16 +80,18 @@ const SingleIcon = ({ content, menu, metadata, current }: DocumentationProps) =>
|
|
|
77
80
|
},
|
|
78
81
|
[icon]
|
|
79
82
|
);
|
|
83
|
+
|
|
80
84
|
if(!menu){
|
|
81
85
|
menu = [];
|
|
82
86
|
}
|
|
87
|
+
|
|
83
88
|
return (
|
|
84
89
|
<div className="c-page">
|
|
85
90
|
<Head>
|
|
86
91
|
{!icon ? (
|
|
87
|
-
<title>{`Icon Not Found | ${config
|
|
92
|
+
<title>{`Icon Not Found | ${config?.client} Design System`}</title>
|
|
88
93
|
) : (
|
|
89
|
-
<title>{`${icon.name} Icon | ${config
|
|
94
|
+
<title>{`${icon.name} Icon | ${config?.client} Design System`}</title>
|
|
90
95
|
)}
|
|
91
96
|
</Head>
|
|
92
97
|
<Header menu={menu} />
|
|
@@ -199,4 +204,3 @@ const SingleIcon = ({ content, menu, metadata, current }: DocumentationProps) =>
|
|
|
199
204
|
</div>
|
|
200
205
|
);
|
|
201
206
|
};
|
|
202
|
-
export default SingleIcon;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { GetStaticProps
|
|
2
|
+
import type { GetStaticProps } from 'next';
|
|
3
3
|
import Link from 'next/link';
|
|
4
|
-
|
|
5
4
|
import type { AssetObject } from 'figma-exporter/src/types';
|
|
6
5
|
import { getConfig } from 'config';
|
|
7
6
|
import Icon from 'components/Icon';
|
|
8
|
-
|
|
9
7
|
import Head from 'next/head';
|
|
10
8
|
import Header from 'components/Header';
|
|
11
|
-
import {
|
|
9
|
+
import { AssetDocumentationProps, fetchDocPageMarkdown, getTokens } from 'components/util';
|
|
12
10
|
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
|
|
13
11
|
import CustomNav from 'components/SideNav/Custom';
|
|
14
12
|
import { MarkdownComponents } from 'components/Markdown/MarkdownComponents';
|
|
15
13
|
import rehypeRaw from 'rehype-raw';
|
|
16
14
|
|
|
17
|
-
const config = getConfig();
|
|
18
|
-
|
|
19
15
|
const DisplayIcon: React.FC<{ icon: AssetObject }> = ({ icon }) => {
|
|
20
16
|
const htmlData = React.useMemo(() => {
|
|
21
17
|
// For SSR
|
|
@@ -57,18 +53,23 @@ const DisplayIcon: React.FC<{ icon: AssetObject }> = ({ icon }) => {
|
|
|
57
53
|
* @returns
|
|
58
54
|
*/
|
|
59
55
|
export const getStaticProps: GetStaticProps = async (context) => {
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
return {
|
|
57
|
+
props: {
|
|
58
|
+
...fetchDocPageMarkdown('docs/assets/', 'icons', `/assets`).props,
|
|
59
|
+
config: getConfig(),
|
|
60
|
+
assets: getTokens().assets,
|
|
61
|
+
}
|
|
62
|
+
};
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
const IconsPage = ({ content, menu, metadata, current }:
|
|
65
|
+
const IconsPage = ({ content, menu, metadata, current, config, assets }: AssetDocumentationProps) => {
|
|
65
66
|
const [search, setSearch] = React.useState('');
|
|
66
67
|
|
|
67
68
|
const icons = search
|
|
68
|
-
?
|
|
69
|
+
? assets.icons.filter((icon) => {
|
|
69
70
|
return icon.index.includes(search);
|
|
70
71
|
})
|
|
71
|
-
:
|
|
72
|
+
: assets.icons;
|
|
72
73
|
|
|
73
74
|
const filterList = React.useCallback<React.ChangeEventHandler<HTMLInputElement>>((event) => {
|
|
74
75
|
setSearch(event.currentTarget.value.toLowerCase().replace(/[\W_]+/g, ' '));
|
package/pages/assets/index.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { GetStaticProps
|
|
2
|
-
|
|
1
|
+
import type { GetStaticProps } from 'next';
|
|
3
2
|
import { getConfig } from 'config';
|
|
4
3
|
import Icon from 'components/Icon';
|
|
5
|
-
|
|
6
4
|
import NavLink from 'components/NavLink';
|
|
7
5
|
import Head from 'next/head';
|
|
8
6
|
import { DocumentationProps, fetchDocPageMarkdown } from 'components/util';
|
|
@@ -12,7 +10,6 @@ import CustomNav from 'components/SideNav/Custom';
|
|
|
12
10
|
import { MarkdownComponents } from 'components/Markdown/MarkdownComponents';
|
|
13
11
|
import rehypeRaw from 'rehype-raw';
|
|
14
12
|
|
|
15
|
-
const config = getConfig();
|
|
16
13
|
/**
|
|
17
14
|
* This statically renders content from the markdown, creating menu and providing
|
|
18
15
|
* metadata
|
|
@@ -22,11 +19,15 @@ const config = getConfig();
|
|
|
22
19
|
* @returns
|
|
23
20
|
*/
|
|
24
21
|
export const getStaticProps: GetStaticProps = async (context) => {
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
return {
|
|
23
|
+
props: {
|
|
24
|
+
...fetchDocPageMarkdown('docs/', 'assets', `/assets`).props,
|
|
25
|
+
config: getConfig(),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
const AssetsPage = ({ content, menu, metadata, current }: DocumentationProps) => {
|
|
30
|
+
const AssetsPage = ({ content, menu, metadata, current, config }: DocumentationProps) => {
|
|
30
31
|
return (
|
|
31
32
|
<div className="c-page">
|
|
32
33
|
<Head>
|
package/pages/assets/logos.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { GetStaticProps
|
|
2
|
-
|
|
1
|
+
import type { GetStaticProps } from 'next';
|
|
3
2
|
import { getConfig } from 'config';
|
|
4
3
|
import Icon from 'components/Icon';
|
|
5
|
-
|
|
6
4
|
import Head from 'next/head';
|
|
7
5
|
import { DocumentationProps, fetchDocPageMarkdown, SectionLink, staticBuildMenu } from 'components/util';
|
|
8
6
|
import Header from 'components/Header';
|
|
@@ -11,7 +9,6 @@ import CustomNav from 'components/SideNav/Custom';
|
|
|
11
9
|
import { MarkdownComponents } from 'components/Markdown/MarkdownComponents';
|
|
12
10
|
import rehypeRaw from 'rehype-raw';
|
|
13
11
|
|
|
14
|
-
const config = getConfig();
|
|
15
12
|
/**
|
|
16
13
|
* This statically renders content from the markdown, creating menu and providing
|
|
17
14
|
* metadata
|
|
@@ -21,11 +18,15 @@ const config = getConfig();
|
|
|
21
18
|
* @returns
|
|
22
19
|
*/
|
|
23
20
|
export const getStaticProps: GetStaticProps = async (context) => {
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return {
|
|
22
|
+
props: {
|
|
23
|
+
...fetchDocPageMarkdown('docs/assets/', 'logos', `/assets`).props,
|
|
24
|
+
config: getConfig(),
|
|
25
|
+
}
|
|
26
|
+
}
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
const AssetsLogosPage = ({ content, menu, metadata, current }: DocumentationProps) => {
|
|
29
|
+
const AssetsLogosPage = ({ content, menu, metadata, current, config }: DocumentationProps) => {
|
|
29
30
|
return (
|
|
30
31
|
<div className="c-page">
|
|
31
32
|
<Head>
|
package/pages/changelog.tsx
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { GetStaticProps
|
|
2
|
+
import type { GetStaticProps } from 'next';
|
|
3
3
|
import { format } from 'date-fns';
|
|
4
|
-
|
|
5
|
-
import { getChangelog, getConfig } from 'config';
|
|
6
4
|
import Icon from 'components/Icon';
|
|
7
5
|
import Head from 'next/head';
|
|
8
|
-
import {
|
|
6
|
+
import { ChangelogDocumentationProps, fetchDocPageMarkdown, getChangelog } from 'components/util';
|
|
9
7
|
import Header from 'components/Header';
|
|
10
8
|
import CustomNav from 'components/SideNav/Custom';
|
|
9
|
+
import { getConfig } from 'config';
|
|
11
10
|
|
|
12
11
|
const getCountLabel = (count: number, singular: string, plural: string) => {
|
|
13
12
|
if (count === 1) {
|
|
@@ -17,10 +16,6 @@ const getCountLabel = (count: number, singular: string, plural: string) => {
|
|
|
17
16
|
return plural;
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const changelog = getChangelog();
|
|
21
|
-
|
|
22
|
-
const config = getConfig();
|
|
23
|
-
|
|
24
19
|
/**
|
|
25
20
|
* This statically renders content from the markdown, creating menu and providing
|
|
26
21
|
* metadata
|
|
@@ -30,11 +25,16 @@ const config = getConfig();
|
|
|
30
25
|
* @returns
|
|
31
26
|
*/
|
|
32
27
|
export const getStaticProps: GetStaticProps = async (context) => {
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
return {
|
|
29
|
+
props: {
|
|
30
|
+
...fetchDocPageMarkdown('docs/', 'changelog', `/changelog`).props,
|
|
31
|
+
config: getConfig(),
|
|
32
|
+
changelog: getChangelog(),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const ChangeLogPage = ({ content, menu, metadata, current }:
|
|
37
|
+
const ChangeLogPage = ({ content, menu, metadata, current, config, changelog }: ChangelogDocumentationProps) => {
|
|
38
38
|
return (
|
|
39
39
|
<div className="c-page">
|
|
40
40
|
<Head>
|