handoff-app 1.1.0-experimental.2 → 1.1.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.
- package/Changelog.md +0 -5
- package/config/docs/system.md +0 -2
- package/dist/app/components/Component/Cards.jsx +32 -0
- package/dist/app-builder/build.d.ts +1 -6
- package/dist/app-builder/build.js +14 -43
- package/dist/app-builder/index.d.ts +0 -1
- package/dist/app-builder/index.js +1 -9
- package/dist/app-builder/watchers.d.ts +1 -5
- package/dist/app-builder/watchers.js +1 -59
- package/dist/cli.js +1 -1
- package/dist/commands/index.js +2 -16
- package/dist/config/runtime.d.ts +0 -5
- package/dist/config/runtime.js +4 -67
- package/dist/index.d.ts +1 -4
- package/dist/index.js +2 -2
- package/dist/pipeline/index.d.ts +0 -1
- package/dist/pipeline/index.js +1 -3
- package/dist/transformers/plugins/csf-render.js +1 -18
- package/dist/transformers/plugins/ssr-render.js +0 -14
- package/dist/transformers/utils/build.d.ts +0 -18
- package/dist/transformers/utils/build.js +0 -108
- package/dist/types/config.d.ts +0 -19
- package/docs/api.md +279 -0
- package/docs/api_spec.yml +0 -0
- package/docs/cli.md +52 -66
- package/docs/props.md +34 -0
- package/handoff.config.js +1 -1
- package/package.json +6 -10
- package/src/app/components/util/index.ts +11 -64
- package/src/app/next.config.mjs +10 -2
- package/src/app/pages/system/component/[component]/index.tsx +14 -7
- package/src/app/pages/system/component/index.tsx +10 -87
- package/src/app/pages/system/index.tsx +5 -24
- package/src/app/pages/system/tokens/components/[component]/index.tsx +14 -1
- package/src/app/pages/system/tokens/index.tsx +10 -85
- package/src/app/tsconfig.json +1 -1
- package/src/app-builder/README.md +1 -1
- package/src/app-builder/build.ts +16 -59
- package/src/app-builder/index.ts +0 -9
- package/src/app-builder/watchers.ts +0 -59
- package/src/cache/README.md +2 -2
- package/src/cli.ts +1 -1
- package/src/commands/index.ts +0 -14
- package/src/config/runtime.ts +0 -76
- package/src/index.ts +3 -3
- package/src/pipeline/README.md +1 -0
- package/src/pipeline/index.ts +0 -1
- package/src/transformers/README.md +3 -2
- package/src/transformers/plugins/csf-render.ts +0 -17
- package/src/transformers/plugins/ssr-render.ts +8 -17
- package/src/transformers/utils/build.ts +0 -112
- package/src/types/README.md +2 -1
- package/src/types/config.ts +0 -21
- package/tsconfig.json +1 -1
- package/config/docs/playground.md +0 -14
- package/config/docs/system/alert.md +0 -30
- package/config/docs/system/button.md +0 -34
- package/config/docs/system/checkbox.md +0 -30
- package/config/docs/system/input.md +0 -31
- package/config/docs/system/modal.md +0 -32
- package/config/docs/system/pagination.md +0 -30
- package/config/docs/system/radio.md +0 -30
- package/config/docs/system/select.md +0 -30
- package/config/docs/system/switch.md +0 -30
- package/config/docs/system/tooltip.md +0 -30
- package/dist/app/components/Component/Cards.js +0 -17
- package/dist/app-builder/isr-paths.d.ts +0 -44
- package/dist/app-builder/isr-paths.js +0 -213
- package/dist/commands/isr/component.d.ts +0 -10
- package/dist/commands/isr/component.js +0 -63
- package/dist/commands/isr/pages.d.ts +0 -11
- package/dist/commands/isr/pages.js +0 -64
- package/dist/commands/platform/init.d.ts +0 -6
- package/dist/commands/platform/init.js +0 -231
- package/dist/commands/platform/login.d.ts +0 -6
- package/dist/commands/platform/login.js +0 -108
- package/dist/commands/platform/logout.d.ts +0 -6
- package/dist/commands/platform/logout.js +0 -88
- package/dist/commands/platform/pull.d.ts +0 -8
- package/dist/commands/platform/pull.js +0 -112
- package/dist/commands/platform/push.d.ts +0 -8
- package/dist/commands/platform/push.js +0 -428
- package/dist/pipeline/pages.d.ts +0 -6
- package/dist/pipeline/pages.js +0 -21
- package/dist/platform/client.d.ts +0 -122
- package/dist/platform/client.js +0 -228
- package/dist/platform/credentials.d.ts +0 -40
- package/dist/platform/credentials.js +0 -91
- package/dist/platform/sync.d.ts +0 -68
- package/dist/platform/sync.js +0 -349
- package/dist/transformers/preview/page/api.d.ts +0 -8
- package/dist/transformers/preview/page/api.js +0 -74
- package/dist/transformers/preview/page/builder.d.ts +0 -7
- package/dist/transformers/preview/page/builder.js +0 -173
- package/dist/transformers/preview/page/types.d.ts +0 -38
- package/dist/transformers/preview/page/types.js +0 -2
- package/docs/components.md +0 -107
- package/docs/isr.md +0 -113
- package/docs/pages.md +0 -152
- package/docs/rest.yml +0 -590
- package/docs/rest_api.md +0 -78
- package/eslint.config.mjs +0 -18
- package/src/app/components/Page/PageLists.tsx +0 -218
- package/src/app/components/Page/types.ts +0 -19
- package/src/app/components/Playground/ComponentCard.tsx +0 -78
- package/src/app/components/Playground/ComponentLibrary.tsx +0 -99
- package/src/app/components/Playground/EditContext.tsx +0 -159
- package/src/app/components/Playground/EditSheet.tsx +0 -80
- package/src/app/components/Playground/MediaBrowser.tsx +0 -56
- package/src/app/components/Playground/PlaygroundBuilder.tsx +0 -160
- package/src/app/components/Playground/PlaygroundContext.tsx +0 -276
- package/src/app/components/Playground/Preview.tsx +0 -174
- package/src/app/components/Playground/SortableItem.tsx +0 -45
- package/src/app/components/Playground/TemplateManager.tsx +0 -81
- package/src/app/components/Playground/Wizard/ApiKeySettings.tsx +0 -125
- package/src/app/components/Playground/Wizard/WizardDialog.tsx +0 -228
- package/src/app/components/Playground/Wizard/llm-client.ts +0 -87
- package/src/app/components/Playground/Wizard/prompt-builder.ts +0 -78
- package/src/app/components/Playground/Wizard/response-parser.ts +0 -81
- package/src/app/components/Playground/fields/ButtonField.tsx +0 -24
- package/src/app/components/Playground/fields/Field.tsx +0 -112
- package/src/app/components/Playground/fields/FieldLabel.tsx +0 -20
- package/src/app/components/Playground/fields/ImageField.tsx +0 -92
- package/src/app/components/Playground/fields/LinkField.tsx +0 -24
- package/src/app/components/Playground/fields/RichTextField.tsx +0 -34
- package/src/app/components/Playground/fields/TextField.tsx +0 -13
- package/src/app/components/Playground/types.ts +0 -30
- package/src/app/components/ui/dialog.tsx +0 -80
- package/src/app/components/ui/textarea.tsx +0 -19
- package/src/app/pages/playground/index.tsx +0 -30
- package/src/app/pages/system/page/[page]/index.tsx +0 -300
- package/src/app/pages/system/page/index.tsx +0 -124
- package/src/app-builder/isr-paths.ts +0 -209
- package/src/commands/isr/component.ts +0 -68
- package/src/commands/isr/pages.ts +0 -68
- package/src/commands/platform/init.ts +0 -229
- package/src/commands/platform/login.ts +0 -96
- package/src/commands/platform/logout.ts +0 -63
- package/src/commands/platform/pull.ts +0 -98
- package/src/commands/platform/push.ts +0 -469
- package/src/pipeline/pages.ts +0 -10
- package/src/platform/client.ts +0 -335
- package/src/platform/credentials.ts +0 -106
- package/src/platform/sync.ts +0 -428
- package/src/transformers/preview/page/api.ts +0 -65
- package/src/transformers/preview/page/builder.ts +0 -200
- package/src/transformers/preview/page/types.ts +0 -37
- package/test_components/example/example.js +0 -110
- package/test_components/example/style.scss +0 -56
- package/test_components/example/template.hbs +0 -19
- package/test_components/example-csf/example-csf.js +0 -16
- package/test_components/example-csf/style.scss +0 -52
- package/test_components/example-csf/template.stories.tsx +0 -97
- package/test_components/example-react/example-react.js +0 -69
- package/test_components/example-react/style.scss +0 -56
- package/test_components/example-react/template.tsx +0 -49
- package/test_pages/boilerplate/boilerplate.json +0 -73
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,12 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.DEFAULT_CLIENT_BUILD_CONFIG = exports.DEFAULT_SSR_BUILD_CONFIG = void 0;
|
|
16
7
|
exports.resolveModule = resolveModule;
|
|
17
8
|
exports.createReactResolvePlugin = createReactResolvePlugin;
|
|
18
|
-
exports.generateClientComponentSource = generateClientComponentSource;
|
|
19
|
-
exports.generateCsfClientComponentSource = generateCsfClientComponentSource;
|
|
20
|
-
exports.buildClientModule = buildClientModule;
|
|
21
|
-
const esbuild_1 = __importDefault(require("esbuild"));
|
|
22
9
|
const path_1 = __importDefault(require("path"));
|
|
23
|
-
const logger_1 = require("../../utils/logger");
|
|
24
10
|
/**
|
|
25
11
|
* Default esbuild configuration for SSR builds
|
|
26
12
|
*/
|
|
@@ -88,97 +74,3 @@ function createReactResolvePlugin(workingPath, handoffModulePath) {
|
|
|
88
74
|
},
|
|
89
75
|
};
|
|
90
76
|
}
|
|
91
|
-
function toForwardSlash(p) {
|
|
92
|
-
return p.replace(/\\/g, '/');
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Generates the entry source for a standalone client-side React component module.
|
|
96
|
-
* The resulting module exports `render(container, props)` and `update(props)`
|
|
97
|
-
* so the Playground can dynamically load and re-render it in an iframe.
|
|
98
|
-
*/
|
|
99
|
-
function generateClientComponentSource(componentPath) {
|
|
100
|
-
return `
|
|
101
|
-
import React from 'react';
|
|
102
|
-
import { createRoot } from 'react-dom/client';
|
|
103
|
-
import Component from '${toForwardSlash(componentPath)}';
|
|
104
|
-
|
|
105
|
-
let root = null;
|
|
106
|
-
|
|
107
|
-
export function render(container, props) {
|
|
108
|
-
root = createRoot(container);
|
|
109
|
-
root.render(React.createElement(Component, props));
|
|
110
|
-
return root;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function update(props) {
|
|
114
|
-
if (root) {
|
|
115
|
-
root.render(React.createElement(Component, props));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
`;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Generates the entry source for a standalone CSF component module.
|
|
122
|
-
* Replicates the story rendering logic (meta.render / story.render / meta.component)
|
|
123
|
-
* so the Playground can render CSF components client-side.
|
|
124
|
-
*/
|
|
125
|
-
function generateCsfClientComponentSource(componentPath, storyKey) {
|
|
126
|
-
return `
|
|
127
|
-
import React from 'react';
|
|
128
|
-
import { createRoot } from 'react-dom/client';
|
|
129
|
-
import * as stories from '${toForwardSlash(componentPath)}';
|
|
130
|
-
|
|
131
|
-
const meta = stories.default || {};
|
|
132
|
-
const story = stories['${storyKey}'];
|
|
133
|
-
|
|
134
|
-
let root = null;
|
|
135
|
-
|
|
136
|
-
function renderElement(props) {
|
|
137
|
-
const storyRender = typeof story === 'function' ? story : (story && story.render);
|
|
138
|
-
const renderFn = storyRender || meta.render;
|
|
139
|
-
if (renderFn) {
|
|
140
|
-
const result = renderFn(props);
|
|
141
|
-
return React.isValidElement(result) ? result : React.createElement(meta.component, props);
|
|
142
|
-
}
|
|
143
|
-
if (meta.component) {
|
|
144
|
-
return React.createElement(meta.component, props);
|
|
145
|
-
}
|
|
146
|
-
return React.createElement('pre', null, JSON.stringify(props, null, 2));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function render(container, props) {
|
|
150
|
-
root = createRoot(container);
|
|
151
|
-
root.render(renderElement(props));
|
|
152
|
-
return root;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function update(props) {
|
|
156
|
-
if (root) {
|
|
157
|
-
root.render(renderElement(props));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
`;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Builds a self-contained browser ESM module from the given source code.
|
|
164
|
-
* React and ReactDOM are bundled into the output so the module works standalone.
|
|
165
|
-
*/
|
|
166
|
-
function buildClientModule(sourceCode, handoff) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
var _a, _b;
|
|
169
|
-
const config = Object.assign(Object.assign({}, exports.DEFAULT_CLIENT_BUILD_CONFIG), { logLevel: 'silent', stdin: {
|
|
170
|
-
contents: sourceCode,
|
|
171
|
-
resolveDir: process.cwd(),
|
|
172
|
-
loader: 'tsx',
|
|
173
|
-
}, plugins: [createReactResolvePlugin(handoff.workingPath, handoff.modulePath)] });
|
|
174
|
-
const finalConfig = ((_b = (_a = handoff.config) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.clientBuildConfig)
|
|
175
|
-
? handoff.config.hooks.clientBuildConfig(config)
|
|
176
|
-
: config;
|
|
177
|
-
const result = yield esbuild_1.default.build(finalConfig);
|
|
178
|
-
if (result.warnings.length > 0) {
|
|
179
|
-
const messages = yield esbuild_1.default.formatMessages(result.warnings, { kind: 'warning', color: true });
|
|
180
|
-
messages.forEach((msg) => logger_1.Logger.warn(msg));
|
|
181
|
-
}
|
|
182
|
-
return result.outputFiles[0].text;
|
|
183
|
-
});
|
|
184
|
-
}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Types as HandoffTypes } from 'handoff-core';
|
|
|
3
3
|
import { InlineConfig } from 'vite';
|
|
4
4
|
import { SlotMetadata } from '../transformers/preview/component';
|
|
5
5
|
import { ComponentListObject, TransformComponentTokensResult } from '../transformers/preview/types';
|
|
6
|
-
import { PageListObject } from '../transformers/preview/page/types';
|
|
7
6
|
import { ValidationResult } from './preview';
|
|
8
7
|
export interface ImageStyle {
|
|
9
8
|
name: string;
|
|
@@ -114,11 +113,6 @@ export interface Config {
|
|
|
114
113
|
* @example ["components/button", "components/input"]
|
|
115
114
|
*/
|
|
116
115
|
components?: string[];
|
|
117
|
-
/**
|
|
118
|
-
* Array of page paths to be included in the build
|
|
119
|
-
* @example ["pages/homepage", "pages/about"]
|
|
120
|
-
*/
|
|
121
|
-
pages?: string[];
|
|
122
116
|
};
|
|
123
117
|
/**
|
|
124
118
|
* Configuration for asset zip file download links
|
|
@@ -136,16 +130,6 @@ export interface Config {
|
|
|
136
130
|
*/
|
|
137
131
|
logos?: string;
|
|
138
132
|
};
|
|
139
|
-
/**
|
|
140
|
-
* Platform project ID (UUID). Set by `platform:init` to link this
|
|
141
|
-
* local project with a remote handoff-service project.
|
|
142
|
-
*/
|
|
143
|
-
platformProjectId?: string;
|
|
144
|
-
/**
|
|
145
|
-
* Platform base URL (e.g. "http://localhost:3000" or "https://handoff.example.com").
|
|
146
|
-
* Set by `platform:init` so subsequent sync commands know where to connect.
|
|
147
|
-
*/
|
|
148
|
-
platformUrl?: string;
|
|
149
133
|
/**
|
|
150
134
|
* Configuration hooks for extending functionality
|
|
151
135
|
*/
|
|
@@ -277,9 +261,6 @@ export interface RuntimeConfig {
|
|
|
277
261
|
components: {
|
|
278
262
|
[id: string]: ComponentListObject;
|
|
279
263
|
};
|
|
280
|
-
pages: {
|
|
281
|
-
[id: string]: PageListObject;
|
|
282
|
-
};
|
|
283
264
|
};
|
|
284
265
|
options: {
|
|
285
266
|
[key: string]: RuntimeConfigComponentOptions;
|
package/docs/api.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# Handoff API
|
|
2
|
+
|
|
3
|
+
Handoff exposes two APIs - A Javascript API for interacting with the pipeline
|
|
4
|
+
Handoff exposes a Javascript API allowing you to easily integrate Handoff into
|
|
5
|
+
existing Node based applications, CI/CD, and command line tools. This API also
|
|
6
|
+
allows you to hook into the pipeline execution and generate new build artifacts
|
|
7
|
+
during the execution.
|
|
8
|
+
|
|
9
|
+
## Example Project
|
|
10
|
+
|
|
11
|
+
Here's a demo project you can check out to get started fast
|
|
12
|
+
https://github.com/Convertiv/handoff-0-6-0/
|
|
13
|
+
|
|
14
|
+
## Get Started
|
|
15
|
+
|
|
16
|
+
1. Run `npm install --save handoff-app`
|
|
17
|
+
2. Add handoff to your code. Create `handoff.ts`
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import Handoff from 'handoff-app';
|
|
21
|
+
|
|
22
|
+
const handoff = new Handoff({
|
|
23
|
+
// You can customize the configuration here
|
|
24
|
+
});
|
|
25
|
+
handoff.fetch();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Build your typescript `tsc`
|
|
29
|
+
4. Run your project `node handoff.js`
|
|
30
|
+
|
|
31
|
+
## Methods
|
|
32
|
+
|
|
33
|
+
Methods of the handoff class can be called to run actions in the
|
|
34
|
+
|
|
35
|
+
### init
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
handoff.init();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Init will check and build the local state, including the configuration. You
|
|
42
|
+
probably don't need to call this method since it is executed as part of the
|
|
43
|
+
class constructor
|
|
44
|
+
|
|
45
|
+
### fetch
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
handoff.fetch();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Fetch will connect to the defined Figma file id provided in the
|
|
52
|
+
`env`. If no env or file is found, it will interactively request one. Then it
|
|
53
|
+
will export all of the tokens and generated data into an `exported` directory
|
|
54
|
+
in the local working root.
|
|
55
|
+
|
|
56
|
+
### build
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
handoff.build();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Build will take the exported artifacts and build a react documentation site from
|
|
63
|
+
those artifacts. The build html site will be exported to the `out` directory
|
|
64
|
+
in the current working root
|
|
65
|
+
|
|
66
|
+
This method will throw an error if the `exported` directory or the `tokens.json`
|
|
67
|
+
files do not exist
|
|
68
|
+
|
|
69
|
+
### integration
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
handoff.integration();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The integration method will run just the preview and integration generation.
|
|
76
|
+
This step is done as part of the build step, but its often useful to be able
|
|
77
|
+
to generate only the integration code.
|
|
78
|
+
|
|
79
|
+
## Hooks
|
|
80
|
+
|
|
81
|
+
Hooks allow a typescript or javascript app to interact with the pipeline.
|
|
82
|
+
This is especially useful for modifying or extending the output of the pipeline.
|
|
83
|
+
To use a hook in your project, once you've instantiated the handoff object, you
|
|
84
|
+
can call one of the hook methods and pass a function to the method. The hook
|
|
85
|
+
function will be called at the appropriate point in the pipeline.
|
|
86
|
+
|
|
87
|
+
For example if you want to alter the integration output, you can do this -
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
import Handoff from 'handoff-app';
|
|
91
|
+
|
|
92
|
+
const handoff = new Handoff({
|
|
93
|
+
// You can customize the configuration here
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
handoff.postIntegration((documentationObject: DocumentationObject, data: HookReturn[]) => {
|
|
97
|
+
const colors = documentationObject.design.color.map((color) => {
|
|
98
|
+
return {
|
|
99
|
+
name: color.name,
|
|
100
|
+
value: color.value,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
data.push({
|
|
104
|
+
filename: 'colors.json',
|
|
105
|
+
data: JSON.stringify(colors, null, 2),
|
|
106
|
+
});
|
|
107
|
+
return data;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
handoff.fetch();
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### postIntegration
|
|
114
|
+
|
|
115
|
+
The Post integration hook will allow you to add a function that will be executed
|
|
116
|
+
after the integration build is complete. The function accepts two arguments -
|
|
117
|
+
|
|
118
|
+
**arguments**
|
|
119
|
+
|
|
120
|
+
- `tokens: DocumentationObject` This is an instance of the exported
|
|
121
|
+
DocumentationObject containing all of the tokens.
|
|
122
|
+
- `data: HookReturn[]` This an array of HookReturns, consisting of `filename`
|
|
123
|
+
and `data`. Each object in this array will be written out to
|
|
124
|
+
`exported/{integration}-tokens`
|
|
125
|
+
|
|
126
|
+
**return**
|
|
127
|
+
The hook must return an array of `HookReturn` objects, or an empty array
|
|
128
|
+
|
|
129
|
+
#### Example
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
handoff.postIntegration((documentationObject: DocumentationObject, data: HookReturn[]) => {
|
|
133
|
+
const colors = documentationObject.design.color.map((color) => {
|
|
134
|
+
return {
|
|
135
|
+
name: color.name,
|
|
136
|
+
value: color.value,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
data.push({
|
|
140
|
+
filename: 'colors.json',
|
|
141
|
+
data: JSON.stringify(colors, null, 2),
|
|
142
|
+
});
|
|
143
|
+
return data;
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### postBuild
|
|
148
|
+
|
|
149
|
+
This function is called after the app build is complete.
|
|
150
|
+
|
|
151
|
+
**arguments**
|
|
152
|
+
|
|
153
|
+
- `tokens: DocumentationObject` This is an instance of the exported
|
|
154
|
+
DocumentationObject containing all of the tokens.
|
|
155
|
+
|
|
156
|
+
**returns**
|
|
157
|
+
Nothing is returned from the postBuild hook
|
|
158
|
+
|
|
159
|
+
### postCssTransformer
|
|
160
|
+
|
|
161
|
+
This function is called after the css generation is complete. It allows an
|
|
162
|
+
application to alter the css generation in transit
|
|
163
|
+
|
|
164
|
+
**arguments**
|
|
165
|
+
|
|
166
|
+
- `tokens: DocumentationObject` This is an instance of the exported
|
|
167
|
+
DocumentationObject containing all of the tokens.
|
|
168
|
+
- `css: CssTransformerOutput` This is an object containing all of the
|
|
169
|
+
tokens for components and foundations, formatted as CSS variables
|
|
170
|
+
|
|
171
|
+
**returns**
|
|
172
|
+
|
|
173
|
+
- `css: CssTransformerOutput` This is an object containing all of the
|
|
174
|
+
tokens for components and foundations, formatted as CSS variables.
|
|
175
|
+
Any changes you return here will be written to the css files
|
|
176
|
+
|
|
177
|
+
### postCssTransformer
|
|
178
|
+
|
|
179
|
+
This function is called after the css generation is complete. It allows an
|
|
180
|
+
application to alter the css generation in transit. It will allow you to alter
|
|
181
|
+
the transformed output prior to being written to disk.
|
|
182
|
+
|
|
183
|
+
**arguments**
|
|
184
|
+
|
|
185
|
+
- `tokens: DocumentationObject` This is an instance of the exported
|
|
186
|
+
DocumentationObject containing all of the tokens.
|
|
187
|
+
- `css: CssTransformerOutput` This is an object containing all of the
|
|
188
|
+
tokens for components and foundations, formatted as CSS variables
|
|
189
|
+
|
|
190
|
+
**returns**
|
|
191
|
+
|
|
192
|
+
- `css: CssTransformerOutput` This is an object containing all of the
|
|
193
|
+
tokens for components and foundations, formatted as CSS variables.
|
|
194
|
+
Any changes you return here will be written to the css files.
|
|
195
|
+
|
|
196
|
+
### postScssTransformer
|
|
197
|
+
|
|
198
|
+
This function is called after the scss generation is complete. It allows an
|
|
199
|
+
application to alter the scss generation in transit. It will allow you to alter
|
|
200
|
+
the transformed output prior to being written to disk.
|
|
201
|
+
|
|
202
|
+
**arguments**
|
|
203
|
+
|
|
204
|
+
- `tokens: DocumentationObject` This is an instance of the exported
|
|
205
|
+
DocumentationObject containing all of the tokens.
|
|
206
|
+
- `scss: CssTransformerOutput` This is an object containing all of the
|
|
207
|
+
tokens for components and foundations, formatted as SCSS variables
|
|
208
|
+
|
|
209
|
+
**returns**
|
|
210
|
+
|
|
211
|
+
- `css: CssTransformerOutput` This is an object containing all of the
|
|
212
|
+
tokens for components and foundations, formatted as SCSS variables.
|
|
213
|
+
Any changes you return here will be written to the scss files.
|
|
214
|
+
|
|
215
|
+
### postTypeTransformer
|
|
216
|
+
|
|
217
|
+
Handoff generates a set of scss files that list all the possible types of
|
|
218
|
+
a component (type, state, activity, size, theme, etc.). This allows frontend
|
|
219
|
+
engineers to iterate over the types and build scss maps with the variables.
|
|
220
|
+
|
|
221
|
+
This function is called after the type generation is complete. It allows an
|
|
222
|
+
application to alter the type generation in transit. It will allow you to alter
|
|
223
|
+
the transformed output prior to being written to disk.
|
|
224
|
+
|
|
225
|
+
**arguments**
|
|
226
|
+
|
|
227
|
+
- `tokens: DocumentationObject` This is an instance of the exported
|
|
228
|
+
DocumentationObject containing all of the tokens.
|
|
229
|
+
- `scss: CssTransformerOutput` This is an object containing all of the
|
|
230
|
+
type arrays for components and foundations, formatted as SCSS variables
|
|
231
|
+
|
|
232
|
+
**returns**
|
|
233
|
+
|
|
234
|
+
- `css: CssTransformerOutput` This is an object containing all of the
|
|
235
|
+
tokens for components and foundations, formatted as type variables.
|
|
236
|
+
Any changes you return here will be written to the scss type files.
|
|
237
|
+
|
|
238
|
+
### modifyWebpackConfig
|
|
239
|
+
|
|
240
|
+
When the application is built, Handoff uses webpack to compile css, scss,
|
|
241
|
+
and javascript in the entry point to build a little live preview of the
|
|
242
|
+
components. This hook accepts a webpack.Configuration as the first argument
|
|
243
|
+
and allows you to alter and return that configuration.
|
|
244
|
+
|
|
245
|
+
**arguments**
|
|
246
|
+
|
|
247
|
+
- `webpackConfig: webpack.Configuration` This is a full webpack configuration.
|
|
248
|
+
|
|
249
|
+
**returns**
|
|
250
|
+
|
|
251
|
+
- `webpackConfig: webpack.Configuration` Return the webpack configuration that
|
|
252
|
+
you have altered to fit your needs.
|
|
253
|
+
|
|
254
|
+
**Example**
|
|
255
|
+
|
|
256
|
+
```js
|
|
257
|
+
export const modifyWebpackConfigForTailwind = (webpackConfig: webpack.Configuration): webpack.Configuration => {
|
|
258
|
+
// Enable webpack dev mode
|
|
259
|
+
webpackConfig.mode = 'development';
|
|
260
|
+
return webpackConfig;
|
|
261
|
+
};
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### configureExportables
|
|
265
|
+
|
|
266
|
+
This hook allows you to alter the exportable list. You could do this by ejecting
|
|
267
|
+
the handoff configuration and modifying the list, but this hook allows you to
|
|
268
|
+
alter the exportable list with just a couple of lines of code rather than
|
|
269
|
+
exporting the whole list
|
|
270
|
+
|
|
271
|
+
**arguments**
|
|
272
|
+
|
|
273
|
+
- `exportables: string[]` The current list of exportables
|
|
274
|
+
|
|
275
|
+
**returns**
|
|
276
|
+
|
|
277
|
+
- `exportables: string[]` Return the list with whatever additions and subtractions
|
|
278
|
+
you need for your application.
|
|
279
|
+
|
|
File without changes
|
package/docs/cli.md
CHANGED
|
@@ -1,86 +1,72 @@
|
|
|
1
|
-
# CLI
|
|
1
|
+
# Handoff CLI
|
|
2
2
|
|
|
3
|
-
The Handoff
|
|
3
|
+
The Handoff cli allows you to interact with your Figma file and Handoff app
|
|
4
|
+
via the command line. It allows you to run handoff in any folder with
|
|
5
|
+
no other configuration or setup.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
## Interacting with Figma
|
|
8
|
+
The CLI will allow you to fetch all data from Figma, build the documentation
|
|
9
|
+
app and run a local dev site. For these use the build, fetch, and serve commands
|
|
10
|
+
documented below.
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## Configuring a handoff project
|
|
13
|
+
The CLI will allow you to build the various kinds of configurations that you
|
|
14
|
+
will need for interacting with Figma. Handoff has sane configuration defaults
|
|
15
|
+
but the various kinds of configurations can be tailored or extended.
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
Handoff has 4 configuration files -
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
`handoff.config.json` - Defines the general handoff configuration.
|
|
20
|
+
`pages` - Markdown files that will create or customize pages in the documentation
|
|
21
|
+
app
|
|
22
|
+
`exportables` - JSON schemas for each component in your figma file that you
|
|
23
|
+
want to pull into handoff.
|
|
24
|
+
`integration` - scss mappings and html templates for making it easy to map
|
|
25
|
+
handoff tokens to your frontend framework.
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
The CLI exposes two ways to manage the config - `make` and `eject`.
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
__Eject__ commands will take the default configuration and eject them into
|
|
30
|
+
the current working directory. If you customize these configurations, then run
|
|
31
|
+
handoff commands in that directory, these configs will be executed.
|
|
32
|
+
__Make__ commands will generate a boilerplate configuration in the current
|
|
33
|
+
working directory. This is useful for extending handoff for different components
|
|
34
|
+
or integrations.
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| `build:app` | Build the documentation application | `--skip-components` — skip building components before building the app |
|
|
26
|
-
| `build:components [component]` | Build project components | Optional positional: component name to build a specific component |
|
|
36
|
+
## Requirements
|
|
37
|
+
Node 16+
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
## Install the CLI
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|---------|-------------|
|
|
32
|
-
| `dev` | Start the design system in development mode (custom dev server with watchers) |
|
|
33
|
-
| `start` | Start the design system in development mode (same as dev) |
|
|
41
|
+
`npm install -g handoff-app`
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
## Run the CLI
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|---------|-------------|
|
|
39
|
-
| `eject:config` | Eject the default configuration to the current working directory |
|
|
40
|
-
| `eject:pages` | Eject the default pages to the current working directory |
|
|
41
|
-
| `eject:theme` | Eject the currently selected theme |
|
|
45
|
+
`handoff-app --help`
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
## Commands and Flags
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|---------|-------------|
|
|
47
|
-
| `fetch` | Fetch the design tokens |
|
|
48
|
-
| `init` | Initialize a new Handoff project with interactive wizard |
|
|
49
|
+
Usage: handoff-app <cmd> <opts>
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
Commands:
|
|
52
|
+
fetch [opts] - Fetches the design tokens from the design system
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
| `make:page <name> [parent]` | Create a new page | `name` — page name; optional `parent` |
|
|
55
|
-
| `make:component <name>` | Create a new HTML code component for documentation | `name` — component name |
|
|
56
|
-
| `make:template <component> [state]` | Create a new template | `component` — component; optional `state` |
|
|
54
|
+
build - Using the current tokens, build various outputs
|
|
55
|
+
build:app [opts] - Builds the design system static application
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
start [opts] - Starts the design system in development mode
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
| `platform:init` | Link this directory to a Handoff platform project | `--url` — platform URL |
|
|
64
|
-
| `platform:pull` | Pull project files from the Handoff platform | `--url`, `--force`, `--debug` |
|
|
65
|
-
| `platform:push` | Push local changes to the Handoff platform | `--url`, `--force`, `--debug` |
|
|
66
|
-
| `platform:logout` | Log out from the Handoff platform | `--url` — platform URL |
|
|
59
|
+
make
|
|
60
|
+
make:template <component> <state> [opts] - Creates a new template
|
|
61
|
+
make:page <component> <state> [opts] - Creates a new page
|
|
67
62
|
|
|
68
|
-
|
|
63
|
+
eject - Ejects the default entire configuration to the current directory
|
|
64
|
+
eject:config [opts] - Ejects the default configuration to the current directory
|
|
65
|
+
eject:integration [opts] - Ejects the default integration to the current directory
|
|
66
|
+
eject:pages [opts] - Ejects the default pages to the current directory
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
For detailed ISR behavior and options, see [ISR](./isr.md).
|
|
76
|
-
|
|
77
|
-
### Other
|
|
78
|
-
|
|
79
|
-
| Command | Description | Main options |
|
|
80
|
-
|---------|-------------|--------------|
|
|
81
|
-
| `scaffold` | Scaffold component stubs for fetched Figma components | |
|
|
82
|
-
| `validate:components` | Validate components in the design system | `--skip-build` — skip build step before validating |
|
|
83
|
-
|
|
84
|
-
## Config
|
|
85
|
-
|
|
86
|
-
The CLI reads config from `handoff.config.js`, `handoff.config.cjs`, or `handoff.config.json` in the current working directory. Use `-c` or `--config` to point to a different file.
|
|
68
|
+
Options:
|
|
69
|
+
-c, --config [file] Define the path to the config file
|
|
70
|
+
-d, --debug Show debug logs
|
|
71
|
+
-h, --help Show this help message
|
|
72
|
+
-v, --version Show the handoff version number
|
package/docs/props.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Here are the property types and rules
|
|
2
|
+
|
|
3
|
+
## Types
|
|
4
|
+
- string
|
|
5
|
+
- image
|
|
6
|
+
- array of
|
|
7
|
+
- src
|
|
8
|
+
- alt
|
|
9
|
+
- breadcrumb
|
|
10
|
+
- array of
|
|
11
|
+
- label
|
|
12
|
+
- url
|
|
13
|
+
- active (boolean)
|
|
14
|
+
- button
|
|
15
|
+
- label
|
|
16
|
+
- url
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- required
|
|
20
|
+
- content
|
|
21
|
+
- min
|
|
22
|
+
- max
|
|
23
|
+
- pattern (regex)
|
|
24
|
+
- dimensions
|
|
25
|
+
- min
|
|
26
|
+
- width
|
|
27
|
+
- height
|
|
28
|
+
- max
|
|
29
|
+
- width
|
|
30
|
+
- height
|
|
31
|
+
- recommend
|
|
32
|
+
- width
|
|
33
|
+
- height
|
|
34
|
+
- filesize
|
package/handoff.config.js
CHANGED