handoff-app 1.1.0-0 → 1.1.0-1

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.
@@ -5,26 +5,3 @@ image: component-alert
5
5
  metaTitle: 'Alerts | Handoff Design System'
6
6
  metaDescription: 'Alerts are used to communicate a state that affects a system, feature or page. They are used to provide feedback about an action that has taken place.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this alert does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with alerts
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with alerts
26
-
27
- </div>
28
- </div>
29
-
30
- ---
@@ -5,30 +5,3 @@ image: component-button
5
5
  metaTitle: 'Buttons | Handoff Design System'
6
6
  metaDescription: 'Buttons allow users to take actions and make choices, with a single click.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this button does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - Make it clear what this button does for the user.
19
- - Use at most two buttons in one group.
20
- - Attribute indicating if the element should be.
21
-
22
- </div>
23
- <div className="c-do-dont__dont">
24
-
25
- <X /> DON&apos;T
26
-
27
- - Use more than two words for call to action.
28
- - First letter of each sentence defaults to a capital letter.
29
- - Attribute indicating if the element should be.
30
-
31
- </div>
32
- </div>
33
-
34
- ---
@@ -5,26 +5,3 @@ image: component-checkbox
5
5
  metaTitle: 'Checkboxes | Handoff Design System'
6
6
  metaDescription: 'Checkboxes create an on/off boolean switch that can be built into array.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this checkboxes does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with checkboxes
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with checkboxes
26
-
27
- </div>
28
- </div>
29
-
30
- ---
@@ -6,26 +6,3 @@ image: component-input
6
6
  metaTitle: 'Inputs | Handoff Design System'
7
7
  metaDescription: 'Form input controls like <input> and <textarea>.'
8
8
  ---
9
-
10
- ### Accessibility
11
-
12
- Make it clear what this input does for the user.
13
-
14
- <div className="c-do-dont">
15
- <div className="c-do-dont__do">
16
-
17
- <Check /> DO
18
-
19
- - What to do with inputs
20
-
21
- </div>
22
- <div className="c-do-dont__dont">
23
-
24
- <X /> DON&apos;T
25
-
26
- - What not to do with inputs
27
-
28
- </div>
29
- </div>
30
-
31
- ---
@@ -7,26 +7,3 @@ metaTitle: 'Modal dialogs | Handoff Design System'
7
7
  metaDescription: 'Modal dialogs present popup information to inform users of important information
8
8
  and sometimes allow the user to take action.'
9
9
  ---
10
-
11
- ### Accessibility
12
-
13
- Make it clear what this modal does for the user.
14
-
15
- <div className="c-do-dont">
16
- <div className="c-do-dont__do">
17
-
18
- <Check /> DO
19
-
20
- - What to do with modals
21
-
22
- </div>
23
- <div className="c-do-dont__dont">
24
-
25
- <X /> DON&apos;T
26
-
27
- - What not to do with modals
28
-
29
- </div>
30
- </div>
31
-
32
- ---
@@ -5,26 +5,3 @@ image: component-pagination
5
5
  metaTitle: 'Pagination | Handoff Design System'
6
6
  metaDescription: 'Pagination provides swift access to all pages, while indicating that more pages exist.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this pagination widget does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with pagination
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with pagination
26
-
27
- </div>
28
- </div>
29
-
30
- ---
@@ -5,26 +5,3 @@ image: component-radio
5
5
  metaTitle: 'Radios | Handoff Design System'
6
6
  metaDescription: 'Radios create an on/off boolean switch that can be built into array.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this radio widget does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with radio
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with radio
26
-
27
- </div>
28
- </div>
29
-
30
- ---
@@ -5,26 +5,3 @@ image: component-select
5
5
  metaTitle: 'Selects | Handoff Design System'
6
6
  metaDescription: 'Selects create dropdowns for selecting a single entry from a list.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this select widget does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with select
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with select
26
-
27
- </div>
28
- </div>
29
-
30
- ---
@@ -2,29 +2,6 @@
2
2
  title: Switches
3
3
  description: Switches render a single boolean toggle that has an off state and an on state.
4
4
  image: component-switch
5
- metaTitle: 'Selects | Handoff Design System'
5
+ metaTitle: 'Switches | Handoff Design System'
6
6
  metaDescription: 'Switches render a single boolean toggle that has an off state and an on state.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this switch widget does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with switches
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with switches
26
-
27
- </div>
28
- </div>
29
-
30
- ---
@@ -5,26 +5,3 @@ image: component-tooltip
5
5
  metaTitle: 'Tooltips | Handoff Design System'
6
6
  metaDescription: 'Tooltips are informative message that appears when a user interacts with an element.'
7
7
  ---
8
-
9
- ### Accessibility
10
-
11
- Make it clear what this tooltip widget does for the user.
12
-
13
- <div className="c-do-dont">
14
- <div className="c-do-dont__do">
15
-
16
- <Check /> DO
17
-
18
- - What to do with tooltips
19
-
20
- </div>
21
- <div className="c-do-dont__dont">
22
-
23
- <X /> DON&apos;T
24
-
25
- - What not to do with tooltips
26
-
27
- </div>
28
- </div>
29
-
30
- ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handoff-app",
3
- "version": "1.1.0-0",
3
+ "version": "1.1.0-1",
4
4
  "description": "Automated documentation toolchain for building client side documentation from figma",
5
5
  "author ": {
6
6
  "name": "Convertiv",
@@ -308,7 +308,7 @@ const staticBuildComponentMenu = (type?: boolean | string) => {
308
308
  Object.keys(groupedComponents).forEach((group) => {
309
309
  const menuGroup = { title: group || 'Uncategorized', menu: [] };
310
310
  groupedComponents[group].forEach((component) => {
311
- const docs = fetchDocPageMetadataAndContent('docs/components/', component.id);
311
+ const docs = fetchDocPageMetadataAndContent('docs/system/', component.id);
312
312
  let title = startCase(component.id);
313
313
  if (docs.metadata.title) {
314
314
  title = docs.metadata.title;
@@ -357,7 +357,7 @@ const staticBuildTokensMenu = () => {
357
357
  const groupedComponents = groupBy(components, (e) => e.group ?? '');
358
358
  Object.keys(groupedComponents).forEach((group) => {
359
359
  groupedComponents[group].forEach((component) => {
360
- const docs = fetchDocPageMetadataAndContent('docs/components/', component.id);
360
+ const docs = fetchDocPageMetadataAndContent('docs/system/', component.id);
361
361
  let title = startCase(component.id);
362
362
  if (docs.metadata.title) {
363
363
  title = docs.metadata.title;
@@ -677,7 +677,7 @@ export const filterOutUndefined = <T>(value: T): value is NonNullable<T> => valu
677
677
  export const titleString = (prefix: string | null): string => {
678
678
  const config = getClientRuntimeConfig();
679
679
  const prepend = prefix ? `${prefix} | ` : '';
680
- return `${prefix}${config?.app?.client} Design System`;
680
+ return `${prepend}${config?.app?.client} Design System`;
681
681
  };
682
682
 
683
683
  /**
@@ -2,6 +2,7 @@
2
2
  import { OptionalPreviewRender } from '@handoff/transformers/preview/types';
3
3
  import { PreviewObject } from '@handoff/types/preview';
4
4
  import { evaluateFilter, type Filter } from '@handoff/utils/filter';
5
+ import { startCase } from 'lodash';
5
6
  import React, { useEffect, useState } from 'react';
6
7
  import ReactMarkdown from 'react-markdown';
7
8
  import rehypeRaw from 'rehype-raw';
@@ -16,7 +17,7 @@ import HeadersType from '../../../../components/Typography/Headers';
16
17
  import { Button } from '../../../../components/ui/button';
17
18
  import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from '../../../../components/ui/drawer';
18
19
  import { JsonTreeView } from '../../../../components/ui/json-tree-view';
19
- import { fetchComponents, getClientRuntimeConfig, getCurrentSection, IParams, staticBuildMenu } from '../../../../components/util';
20
+ import { fetchComponents, fetchDocPageMetadataAndContent, getClientRuntimeConfig, getCurrentSection, IParams, staticBuildMenu } from '../../../../components/util';
20
21
 
21
22
  /**
22
23
  * Render all index pages
@@ -73,13 +74,17 @@ export const getStaticProps = async (context) => {
73
74
  const components = fetchComponents()!;
74
75
  const menu = staticBuildMenu();
75
76
  const config = getClientRuntimeConfig();
76
- const metadata = components.find((c) => c.id === component);
77
+ const componentData = components.find((c) => c.id === component);
78
+ const docs = fetchDocPageMetadataAndContent('docs/system/', component as string);
77
79
  const componentHotReloadIsAvailable = process.env.NODE_ENV === 'development';
78
- const sameGroupComponents = components.filter((c) => c.group === metadata?.group);
80
+ const sameGroupComponents = components.filter((c) => c.group === componentData?.group);
79
81
  const groupIndex = sameGroupComponents.findIndex((c) => c.id === component);
80
82
  const previousComponent = sameGroupComponents[groupIndex - 1] ?? null;
81
83
  const nextComponent = sameGroupComponents[groupIndex + 1] ?? null;
82
84
 
85
+ const fallbackTitle = componentData.name || startCase(component as string);
86
+ const fallbackMetaTitle = `${fallbackTitle}${config?.app?.client ? ` | ${config.app.client} Design System` : ''}`;
87
+
83
88
  return {
84
89
  props: {
85
90
  id: component,
@@ -89,10 +94,12 @@ export const getStaticProps = async (context) => {
89
94
  config,
90
95
  current: getCurrentSection(menu, '/system') ?? [],
91
96
  metadata: {
92
- ...metadata,
93
- title: metadata.name,
94
- description: metadata.description,
95
- image: 'hero-brand-assets',
97
+ ...componentData,
98
+ title: componentData.name || docs.metadata.title || startCase(component as string),
99
+ description: componentData.description,
100
+ metaTitle: docs.metadata.metaTitle || fallbackMetaTitle,
101
+ metaDescription: docs.metadata.metaDescription || componentData.description,
102
+ image: docs.metadata.image || 'hero-brand-assets',
96
103
  },
97
104
  componentHotReloadIsAvailable,
98
105
  previousComponent,
@@ -1,92 +1,15 @@
1
- import type { GetStaticProps } from 'next';
2
- import Head from 'next/head';
3
- import ReactMarkdown from 'react-markdown';
4
- import rehypeRaw from 'rehype-raw';
5
- import ComponentSearch from '../../../components/ComponentSearch';
6
- import Footer from '../../../components/Footer';
7
- import { MarkdownComponents } from '../../../components/Markdown/MarkdownComponents';
8
- import Header from '../../../components/old/Header';
9
- import {
10
- DocumentationProps,
11
- fetchComponents,
12
- fetchDocPageMarkdown,
13
- fetchDocPageMetadataAndContent,
14
- getClientRuntimeConfig,
15
- Metadata,
16
- } from '../../../components/util';
1
+ import { useEffect } from 'react';
2
+ import { useRouter } from 'next/router';
17
3
 
18
- type ComponentPageDocumentationProps = DocumentationProps & {
19
- components: { [id: string]: Metadata };
20
- };
21
-
22
- /**
23
- * This statically renders content from the markdown, creating menu and providing
24
- * metadata
25
- *
26
- * This is all done statically at build time
27
- * @param context GetStaticProps
28
- * @returns
29
- */
30
- export const getStaticProps: GetStaticProps = async (context) => {
31
- // Read current slug
32
- const components = fetchComponents()?.map((c) => c.id) ?? [];
33
- const config = getClientRuntimeConfig();
34
- return {
35
- ...{
36
- props: {
37
- config,
38
- ...fetchDocPageMarkdown('docs/', 'components', `/components`).props,
39
- components: components.reduce(
40
- (acc, component) => ({
41
- ...acc,
42
- ...{
43
- [component]: fetchDocPageMetadataAndContent('docs/components/', component).metadata,
44
- },
45
- }),
46
- {}
47
- ),
48
- } as ComponentPageDocumentationProps,
49
- },
50
- };
51
- };
4
+ const ComponentIndexRedirect = () => {
5
+ const router = useRouter();
6
+ const basePath = process.env.HANDOFF_APP_BASE_PATH ?? '';
52
7
 
53
- /**
54
- * Define the components page
55
- * @param param0
56
- * @returns
57
- */
58
- const ComponentsListPage = ({ content, menu, metadata, current, components, config }: ComponentPageDocumentationProps) => {
59
- return (
60
- <div className="c-page">
61
- <Head>
62
- <title>{metadata.metaTitle}</title>
63
- <meta name="description" content={metadata.metaDescription} />
64
- </Head>
65
- <Header menu={menu} config={config} />
66
- <section className="c-content">
67
- <div className="o-container-fluid">
68
- <div className="c-hero c-hero--boxed c-hero--bg-blue">
69
- <div>
70
- <h1 className="c-title--extra-large">{metadata.title}</h1>
71
- <p>{metadata.description}</p>
72
- </div>
73
- </div>
8
+ useEffect(() => {
9
+ router.replace(`${basePath}/system`);
10
+ }, [router, basePath]);
74
11
 
75
- <div className="o-row">
76
- <div className="o-col-12@md">
77
- <ComponentSearch />
78
- </div>
79
- </div>
80
- <div className="prose">
81
- <ReactMarkdown components={MarkdownComponents} rehypePlugins={[rehypeRaw]}>
82
- {content}
83
- </ReactMarkdown>
84
- </div>
85
- </div>
86
- </section>
87
- <Footer config={config} />
88
- </div>
89
- );
12
+ return null;
90
13
  };
91
14
 
92
- export default ComponentsListPage;
15
+ export default ComponentIndexRedirect;
@@ -15,16 +15,11 @@ import { JsonTreeView } from '../../components/ui/json-tree-view';
15
15
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../components/ui/tooltip';
16
16
  import {
17
17
  DocumentationProps,
18
- fetchComponents,
19
18
  fetchDocPageMarkdown,
20
- fetchDocPageMetadataAndContent,
21
19
  getClientRuntimeConfig,
22
- Metadata,
23
20
  } from '../../components/util';
24
21
 
25
- type ComponentPageDocumentationProps = DocumentationProps & {
26
- components: { [id: string]: Metadata };
27
- };
22
+ type ComponentPageDocumentationProps = DocumentationProps;
28
23
 
29
24
  /**
30
25
  * This statically renders content from the markdown, creating menu and providing
@@ -36,26 +31,12 @@ type ComponentPageDocumentationProps = DocumentationProps & {
36
31
  */
37
32
  export const getStaticProps: GetStaticProps = async (context) => {
38
33
  // Read current slug
39
- const components = fetchComponents()?.map((c) => c.id);
40
34
  const config = getClientRuntimeConfig();
41
35
  return {
42
- ...{
43
- props: {
44
- config,
45
- ...fetchDocPageMarkdown('docs/', 'system', `/system`).props,
46
- components: components
47
- ? components.reduce(
48
- (acc, component) => ({
49
- ...acc,
50
- ...{
51
- [component]: fetchDocPageMetadataAndContent('docs/components/', component).metadata,
52
- },
53
- }),
54
- {}
55
- )
56
- : null,
57
- } as ComponentPageDocumentationProps,
58
- },
36
+ props: {
37
+ config,
38
+ ...fetchDocPageMarkdown('docs/', 'system', `/system`).props,
39
+ } as ComponentPageDocumentationProps,
59
40
  };
60
41
  };
61
42
  /**
@@ -38,6 +38,19 @@ export const getStaticProps = async (context) => {
38
38
  const componentSlug = reduceSlugToString(component);
39
39
  const tokens = getTokens();
40
40
  const componentObject = tokens?.components?.[componentSlug!] ?? null;
41
+ const markdownProps = fetchCompDocPageMarkdown('docs/', `/system/${componentSlug}`, `/system`).props;
42
+ const componentData = fetchComponents()?.find((c) => c.id === componentSlug);
43
+
44
+ const fallbackTitle = componentData?.name || startCase(componentSlug);
45
+ const fallbackMetaTitle = `${fallbackTitle}${config?.app?.client ? ` | ${config.app.client} Design System` : ''}`;
46
+
47
+ markdownProps.metadata = {
48
+ ...markdownProps.metadata,
49
+ title: componentData?.name || markdownProps.metadata.title || startCase(componentSlug),
50
+ description: markdownProps.metadata.description || componentData?.description || '',
51
+ metaTitle: markdownProps.metadata.metaTitle || fallbackMetaTitle,
52
+ metaDescription: markdownProps.metadata.metaDescription || componentData?.description || '',
53
+ };
41
54
 
42
55
  return {
43
56
  props: {
@@ -45,7 +58,7 @@ export const getStaticProps = async (context) => {
45
58
  component: componentObject ?? {},
46
59
  menu,
47
60
  config,
48
- ...fetchCompDocPageMarkdown('docs/', `/system/${componentSlug}`, `/system`).props,
61
+ ...markdownProps,
49
62
  },
50
63
  };
51
64
  };
@@ -1,90 +1,15 @@
1
- import { PreviewObject } from '@handoff/types/preview';
2
- import type { GetStaticProps } from 'next';
3
- import { useEffect, useState } from 'react';
4
- import ReactMarkdown from 'react-markdown';
5
- import rehypeRaw from 'rehype-raw';
6
- import { APIComponentList } from '../../../components/Component/ComponentLists';
7
- import Layout from '../../../components/Layout/Main';
8
- import { MarkdownComponents } from '../../../components/Markdown/MarkdownComponents';
9
- import HeadersType from '../../../components/Typography/Headers';
10
- import {
11
- DocumentationProps,
12
- fetchComponents,
13
- fetchDocPageMarkdown,
14
- fetchDocPageMetadataAndContent,
15
- getClientRuntimeConfig,
16
- Metadata,
17
- } from '../../../components/util';
1
+ import { useEffect } from 'react';
2
+ import { useRouter } from 'next/router';
18
3
 
19
- type ComponentPageDocumentationProps = DocumentationProps & {
20
- components: { [id: string]: Metadata };
21
- };
4
+ const TokensIndexRedirect = () => {
5
+ const router = useRouter();
6
+ const basePath = process.env.HANDOFF_APP_BASE_PATH ?? '';
22
7
 
23
- /**
24
- * This statically renders content from the markdown, creating menu and providing
25
- * metadata
26
- *
27
- * This is all done statically at build time
28
- * @param context GetStaticProps
29
- * @returns
30
- */
31
- export const getStaticProps: GetStaticProps = async (context) => {
32
- // Read current slug
33
- const components = fetchComponents()?.map((c) => c.id);
34
- const config = getClientRuntimeConfig();
35
- return {
36
- ...{
37
- props: {
38
- config,
39
- ...fetchDocPageMarkdown('docs/', 'system', `/system`).props,
40
- components: components
41
- ? components.reduce(
42
- (acc, component) => ({
43
- ...acc,
44
- ...{
45
- [component]: fetchDocPageMetadataAndContent('docs/components/', component).metadata,
46
- },
47
- }),
48
- {}
49
- )
50
- : null,
51
- } as ComponentPageDocumentationProps,
52
- },
53
- };
54
- };
55
- /**
56
- * Define the components page
57
- * @param param0
58
- * @returns
59
- */
60
- const ComponentsPage = ({ content, menu, metadata, current, config }: ComponentPageDocumentationProps) => {
61
- // Fetch components from api
62
- const [components, setComponents] = useState<PreviewObject[]>(undefined);
63
- const fetchComponents = async () => {
64
- let data = await fetch(`${process.env.HANDOFF_APP_BASE_PATH ?? ''}/api/components.json`).then((res) => res.json());
65
- setComponents(data as PreviewObject[]);
66
- };
67
8
  useEffect(() => {
68
- fetchComponents();
69
- }, []);
70
- if (!components) return <p>Loading...</p>;
71
- const apiUrl = (window.location.origin && window.location.origin) + `${process.env.HANDOFF_APP_BASE_PATH ?? ''}/api/components.json`;
72
- return (
73
- <Layout config={config} menu={menu} current={current} metadata={metadata}>
74
- <div className="flex flex-col gap-2 pb-7">
75
- <HeadersType.H1>{metadata.title}</HeadersType.H1>
76
- <p className="text-lg leading-relaxed text-gray-600 dark:text-gray-300">{metadata.description}</p>
77
- </div>
78
- <div>
79
- <div className="prose mb-10">
80
- <ReactMarkdown components={MarkdownComponents} rehypePlugins={[rehypeRaw]}>
81
- {content}
82
- </ReactMarkdown>
83
- </div>
84
- <APIComponentList components={components} />
85
- </div>
86
- </Layout>
87
- );
9
+ router.replace(`${basePath}/system`);
10
+ }, [router, basePath]);
11
+
12
+ return null;
88
13
  };
89
14
 
90
- export default ComponentsPage;
15
+ export default TokensIndexRedirect;