@linktr.ee/create-link-app 0.3.0-next.2 → 0.3.0-next.20

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 (34) hide show
  1. package/README.md +16 -0
  2. package/dist/commands/build.js +3 -2
  3. package/dist/commands/dev.js +2 -1
  4. package/dist/commands/storybook.js +28 -0
  5. package/dist/lib/create/create-project.js +3 -0
  6. package/dist/lib/deploy/pack-project.js +2 -0
  7. package/dist/lib/schema/compile.js +27 -0
  8. package/dist/postcss/postcss.config.js +20 -0
  9. package/dist/storybook/global.css +53 -0
  10. package/dist/storybook/main.js +62 -0
  11. package/dist/storybook/preview.js +13 -0
  12. package/dist/webpack/webpack.config.js +63 -12
  13. package/html-template/development.html +1 -1
  14. package/html-template/production.html +1 -1
  15. package/oclif.manifest.json +21 -1
  16. package/package.json +26 -3
  17. package/templates/common/README.md +18 -0
  18. package/templates/common/fixtures/props-data.json +1 -2
  19. package/templates/common/gitignore +1 -0
  20. package/templates/common/schema.json +38 -0
  21. package/templates/common/settings.json +11 -23
  22. package/templates/react/package.json +5 -2
  23. package/templates/react/src/index.jsx +4 -13
  24. package/templates/react/src/tailwind.css +5 -0
  25. package/templates/react-ts/package.json +5 -2
  26. package/templates/react-ts/src/components/Layouts.tsx +57 -0
  27. package/templates/react-ts/src/index.tsx +20 -14
  28. package/templates/react-ts/src/stories/LinkApp.stories.tsx +99 -0
  29. package/templates/react-ts/src/stories/tailwind.sb.css +5 -0
  30. package/templates/react-ts/src/tailwind.css +4 -0
  31. package/templates/react-ts/src/types/global.d.ts +8 -5
  32. package/templates/react-ts/src/types/index.ts +34 -6
  33. package/templates/react/src/images/logo.png +0 -0
  34. package/templates/react-ts/src/images/logo.png +0 -0
package/README.md CHANGED
@@ -27,6 +27,7 @@ yarn create @linktr.ee/create-link-app my-link-app
27
27
  * [`create-link-app help [COMMANDS]`](#create-link-app-help-commands)
28
28
  * [`create-link-app login`](#create-link-app-login)
29
29
  * [`create-link-app logout`](#create-link-app-logout)
30
+ * [`create-link-app storybook`](#create-link-app-storybook)
30
31
 
31
32
  ## `create-link-app build`
32
33
 
@@ -168,4 +169,19 @@ USAGE
168
169
  DESCRIPTION
169
170
  Logout and clear browser session
170
171
  ```
172
+
173
+ ## `create-link-app storybook`
174
+
175
+ Start the Stortybook development server
176
+
177
+ ```
178
+ USAGE
179
+ $ create-link-app storybook [-p <value>]
180
+
181
+ FLAGS
182
+ -p, --port=<value> [default: 6006] Port to run the Storybook server on
183
+
184
+ DESCRIPTION
185
+ Start the Stortybook development server
186
+ ```
171
187
  <!-- commandsstop -->
@@ -10,9 +10,10 @@ const webpack_config_1 = __importDefault(require("../webpack/webpack.config"));
10
10
  class Build extends base_1.default {
11
11
  async run() {
12
12
  const { flags } = await this.parse(Build);
13
- (0, webpack_1.default)((0, webpack_config_1.default)('production', {
13
+ const config = await (0, webpack_config_1.default)('production', {
14
14
  allowAnyOrigin: flags['allow-any-origin'],
15
- }), (err, stats) => {
15
+ });
16
+ (0, webpack_1.default)(config, (err, stats) => {
16
17
  if (err) {
17
18
  this.error(err);
18
19
  }
@@ -11,6 +11,7 @@ const webpack_config_1 = __importDefault(require("../webpack/webpack.config"));
11
11
  class Dev extends base_1.default {
12
12
  async run() {
13
13
  const { flags } = await this.parse(Dev);
14
+ const config = await (0, webpack_config_1.default)('development');
14
15
  const devServer = new webpack_dev_server_1.default({
15
16
  client: {
16
17
  overlay: false,
@@ -18,7 +19,7 @@ class Dev extends base_1.default {
18
19
  hot: false,
19
20
  https: flags.https,
20
21
  port: flags.port,
21
- }, (0, webpack_1.default)((0, webpack_config_1.default)('development')));
22
+ }, (0, webpack_1.default)(config));
22
23
  await devServer.start();
23
24
  }
24
25
  }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const child_process_1 = require("child_process");
8
+ const base_1 = __importDefault(require("../base"));
9
+ const path_1 = __importDefault(require("path"));
10
+ class Storybook extends base_1.default {
11
+ async run() {
12
+ const configPath = path_1.default.resolve(__dirname, '..', 'storybook');
13
+ const { flags } = await this.parse(Storybook);
14
+ const storybook = (0, child_process_1.spawn)(`start-storybook -p ${flags.port} -c ${configPath}`, { shell: true, stdio: 'inherit' });
15
+ storybook.on('error', (err) => {
16
+ throw err;
17
+ });
18
+ }
19
+ }
20
+ exports.default = Storybook;
21
+ Storybook.description = 'Start the Stortybook development server';
22
+ Storybook.flags = {
23
+ port: core_1.Flags.integer({
24
+ char: 'p',
25
+ description: 'Port to run the Storybook server on',
26
+ default: 6006,
27
+ }),
28
+ };
@@ -14,6 +14,9 @@ const createProject = async (template, targetDir) => {
14
14
  await fs_extra_1.default.copy(templateDir, targetDir);
15
15
  await fs_extra_1.default.copy(templateCommonDir, targetDir);
16
16
  await fs_extra_1.default.move(`${targetDir}/gitignore`, `${targetDir}/.gitignore`);
17
+ if (await fs_extra_1.default.existsSync(`${targetDir}/src/types/global.d.ts`)) {
18
+ await fs_extra_1.default.unlink(`${targetDir}/src/types/global.d.ts`);
19
+ }
17
20
  // update `name` field in project manifest
18
21
  const manifest = await fs_extra_1.default.readJson(`${targetDir}/manifest.json`);
19
22
  manifest.name = (0, project_name_to_title_1.default)(path_1.default.basename(targetDir));
@@ -9,6 +9,7 @@ const path_1 = __importDefault(require("path"));
9
9
  /**
10
10
  * Pack the Link App source files into `package.tgz`. This includes the following:
11
11
  * - `src/`
12
+ * - `schema.json`
12
13
  * - `package.json`
13
14
  * - `package-lock.json` - *optional*
14
15
  * - `yarn.lock` - *optional*
@@ -43,6 +44,7 @@ async function packProject() {
43
44
  handleFailure(err);
44
45
  });
45
46
  archive.pipe(outputWriteStream);
47
+ archive.file(resolveProjPath('schema.json'), { name: 'schema.json' });
46
48
  archive.file(resolveProjPath('package.json'), { name: 'package.json' });
47
49
  archive.file(resolveProjPath('package-lock.json'), { name: 'package-lock.json' });
48
50
  archive.file(resolveProjPath('yarn.lock'), { name: 'yarn.lock' });
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_extra_1 = __importDefault(require("fs-extra"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const jtd_js_1 = __importDefault(require("ajv/dist/jtd.js"));
9
+ const index_js_1 = __importDefault(require("ajv/dist/standalone/index.js"));
10
+ const defaultSchemaPath = path_1.default.join(process.cwd(), './schema.json');
11
+ async function compileSchema(inputSchemaPath = defaultSchemaPath) {
12
+ try {
13
+ const schema = await fs_extra_1.default.readJSON(inputSchemaPath);
14
+ const ajv = new jtd_js_1.default({
15
+ // @ts-expect-error: In JTD mode some options are not typed correctly.
16
+ strict: false,
17
+ code: { source: true, esm: true },
18
+ });
19
+ const compiled = ajv.compile(schema);
20
+ const moduleCode = (0, index_js_1.default)(ajv, compiled);
21
+ return moduleCode;
22
+ }
23
+ catch (e) {
24
+ console.error(e);
25
+ }
26
+ }
27
+ exports.default = compileSchema;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = __importDefault(require("path"));
7
+ const tailwindcss_1 = __importDefault(require("tailwindcss"));
8
+ const autoprefixer_1 = __importDefault(require("autoprefixer"));
9
+ const componentLibraryContentPath = path_1.default.join(require.resolve('@linktr.ee/component-library/tailwind.config').split('/').slice(0, -1).join('/'), 'dist', '**', '*.js');
10
+ const config = {
11
+ plugins: [
12
+ (0, tailwindcss_1.default)({
13
+ content: [`${process.cwd()}/src/**/*.{js,jsx,ts,tsx}`, componentLibraryContentPath],
14
+ presets: [require('@linktr.ee/component-library/tailwind.config')],
15
+ plugins: [],
16
+ }),
17
+ (0, autoprefixer_1.default)(),
18
+ ],
19
+ };
20
+ module.exports = config;
@@ -0,0 +1,53 @@
1
+ :root {
2
+ --lt-color-primary: #849589;
3
+ --lt-color-on-primary: #ffffff;
4
+ --lt-color-on-primary-alpha: #ffffffb2;
5
+
6
+ --lt-color-secondary: #67776b;
7
+ --lt-color-on-secondary: #ffffffb3;
8
+
9
+ --lt-color-background: #3a463c;
10
+ --lt-color-on-background: #f7fdf9;
11
+
12
+ --lt-color0: #ffffff;
13
+ --lt-color1: #f7fdf9;
14
+ --lt-color2: #eef6ed;
15
+ --lt-color3: #e0ece2;
16
+ --lt-color4: #c9d5cb;
17
+ --lt-color5: #b6c5b7;
18
+ --lt-color6: #849589;
19
+ --lt-color7: #67776b;
20
+ --lt-color8: #4d5e52;
21
+ --lt-color9: #3a463c;
22
+ --lt-color10: #29382d;
23
+ --lt-color11: #151e16;
24
+ --lt-color12: #0b140c;
25
+ --lt-color13: #000501;
26
+ --lt-color14: #000000;
27
+ --lt-color15: #000000;
28
+
29
+ --lt-treetop-radius-mobile: 2.5rem;
30
+
31
+ --lt-cover-radius: 6rem;
32
+ --lt-cover-radius-mobile: 4rem;
33
+
34
+ --lt-feature-container-radius: 2rem;
35
+ --lt-feature-thumbnail-radius: 1.5rem;
36
+
37
+ --lt-carousel-container-radius: 1.5rem;
38
+ --lt-carousel-thumbnail-radius: 1rem;
39
+
40
+ --lt-grid-container-radius: 1.25rem;
41
+ --lt-grid-thumbnail-radius: 0.75rem;
42
+
43
+ --lt-stack-container-radius: 1rem;
44
+ --lt-stack-thumbnail-radius: 0.65rem;
45
+
46
+ --lt-font-family: INTER;
47
+ --lt-text-2xl: 1.5rem;
48
+ --lt-text-xl: 1.25rem;
49
+ --lt-text-lg: 1.125rem;
50
+ --lt-text-md: 1rem;
51
+ --lt-text-sm: 0.875rem;
52
+ --lt-text-xs: 0.75rem;
53
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const postcss_1 = __importDefault(require("postcss"));
30
+ const postcssOptions = __importStar(require("../postcss/postcss.config"));
31
+ const config = {
32
+ stories: [`${process.cwd()}/src/**/*.stories.@(js|jsx|ts|tsx)`],
33
+ addons: [
34
+ '@storybook/addon-links',
35
+ '@storybook/addon-essentials',
36
+ {
37
+ name: 'storybook-addon-turbo-build',
38
+ options: {
39
+ optimizationLevel: 2,
40
+ },
41
+ },
42
+ {
43
+ /**
44
+ * Fix Storybook issue with PostCSS@8
45
+ * @see https://github.com/storybookjs/storybook/issues/12668#issuecomment-773958085
46
+ */
47
+ name: '@storybook/addon-postcss',
48
+ options: {
49
+ cssLoaderOptions: { importLoaders: 1 },
50
+ postcssLoaderOptions: {
51
+ implementation: postcss_1.default,
52
+ postcssOptions: { ...postcssOptions },
53
+ },
54
+ },
55
+ },
56
+ ],
57
+ framework: '@storybook/react',
58
+ core: {
59
+ builder: 'webpack5',
60
+ },
61
+ };
62
+ module.exports = config;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parameters = void 0;
4
+ require("./global.css");
5
+ exports.parameters = {
6
+ actions: { argTypesRegex: '^on[A-Z].*' },
7
+ controls: {
8
+ matchers: {
9
+ color: /(background|color)$/i,
10
+ date: /Date$/,
11
+ },
12
+ },
13
+ };
@@ -1,5 +1,28 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
3
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
28
  };
@@ -8,25 +31,33 @@ const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checke
8
31
  const fs_1 = __importDefault(require("fs"));
9
32
  const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
10
33
  const inject_body_webpack_plugin_1 = __importDefault(require("inject-body-webpack-plugin"));
34
+ const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
11
35
  const path_1 = __importDefault(require("path"));
12
36
  const webpack_1 = require("webpack");
13
37
  const camelcase_1 = __importDefault(require("camelcase"));
14
38
  const slugify_1 = __importDefault(require("slugify"));
39
+ const compile_1 = __importDefault(require("../lib/schema/compile"));
40
+ const postcssOptions = __importStar(require("../postcss/postcss.config"));
15
41
  const { ModuleFederationPlugin } = webpack_1.container;
16
- function default_1(env, options) {
42
+ function toVirtualModule(code) {
43
+ const base64 = Buffer.from(code).toString('base64');
44
+ return `data:text/javascript;base64,${base64}`;
45
+ }
46
+ async function default_1(env, options) {
17
47
  const appDir = process.cwd();
18
48
  const entryFile = path_1.default.resolve(__dirname, `${env}.entry`);
19
49
  const htmlTemplateFile = path_1.default.resolve(__dirname, '..', '..', 'html-template', `${env}.html`);
20
50
  const manifestJson = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(appDir, 'manifest.json'), 'utf8'));
21
51
  const linkTypeName = manifestJson.name.replace(/[^A-Za-z0-9 ]/g, '');
22
- const linkTypeId = (0, camelcase_1.default)((0, slugify_1.default)(linkTypeName, { lower: true }), { pascalCase: true });
52
+ const linkTypeSlug = (0, slugify_1.default)(linkTypeName, { lower: true });
53
+ const linkTypeId = (0, camelcase_1.default)(linkTypeSlug, { pascalCase: true });
23
54
  const hasTsconfig = fileExists(path_1.default.resolve(appDir, 'tsconfig.json'));
24
55
  const config = {
25
56
  target: 'web',
26
57
  mode: env,
27
58
  entry: entryFile,
28
59
  output: {
29
- publicPath: '',
60
+ publicPath: 'auto',
30
61
  path: path_1.default.resolve(appDir, 'dist'),
31
62
  assetModuleFilename: 'images/[hash][ext][query]',
32
63
  },
@@ -49,6 +80,19 @@ function default_1(env, options) {
49
80
  test: /\.(png|jpe?g|gif|svg)$/i,
50
81
  type: 'asset/inline',
51
82
  },
83
+ {
84
+ test: /\.css$/,
85
+ use: [
86
+ mini_css_extract_plugin_1.default.loader,
87
+ 'css-loader',
88
+ {
89
+ loader: 'postcss-loader',
90
+ options: {
91
+ postcssOptions: { ...postcssOptions },
92
+ },
93
+ },
94
+ ],
95
+ },
52
96
  ],
53
97
  },
54
98
  resolve: {
@@ -77,13 +121,16 @@ function default_1(env, options) {
77
121
  ...config.resolve.alias,
78
122
  '@linktr.ee/extension-dev-data': path_1.default.resolve(appDir, 'fixtures', 'props-data.json'),
79
123
  };
124
+ config.plugins.push(new mini_css_extract_plugin_1.default());
80
125
  }
81
126
  if (env === 'production') {
82
- config.externals = {
83
- react: 'React',
84
- 'react-dom': 'ReactDOM',
85
- 'styled-components': 'styled',
86
- };
127
+ // TODO: Figure out how to manage externals with Module Federation
128
+ // Possibly make the index.html a host app, via separate webpack config
129
+ // config.externals = {
130
+ // react: 'React',
131
+ // 'react-dom': 'ReactDOM',
132
+ // 'styled-components': 'styled',
133
+ // }
87
134
  config.performance = {
88
135
  maxEntrypointSize: 1048576,
89
136
  maxAssetSize: 350000,
@@ -102,6 +149,7 @@ function default_1(env, options) {
102
149
  filename: 'remoteEntry.js',
103
150
  exposes: {
104
151
  ['./App']: path_1.default.resolve(appDir, 'src'),
152
+ ['./validate']: toVirtualModule((await (0, compile_1.default)())),
105
153
  },
106
154
  shared: {
107
155
  react: {
@@ -112,11 +160,14 @@ function default_1(env, options) {
112
160
  singleton: true,
113
161
  requiredVersion: '17 || 18',
114
162
  },
115
- 'styled-components': {
116
- singleton: true,
117
- requiredVersion: '5',
118
- },
163
+ // 'styled-components': {
164
+ // singleton: true,
165
+ // requiredVersion: '5',
166
+ // },
119
167
  },
168
+ }), new mini_css_extract_plugin_1.default({
169
+ filename: '[name].[contenthash].css',
170
+ chunkFilename: '[id].[contenthash].css',
120
171
  }));
121
172
  }
122
173
  return config;
@@ -13,4 +13,4 @@
13
13
  <div id="root"></div>
14
14
  </body>
15
15
 
16
- </html>
16
+ </html>
@@ -17,4 +17,4 @@
17
17
  <div id="root"></div>
18
18
  </body>
19
19
 
20
- </html>
20
+ </html>
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.0-next.2",
2
+ "version": "0.3.0-next.20",
3
3
  "commands": {
4
4
  "build": {
5
5
  "id": "build",
@@ -216,6 +216,26 @@
216
216
  }
217
217
  },
218
218
  "args": {}
219
+ },
220
+ "storybook": {
221
+ "id": "storybook",
222
+ "description": "Start the Stortybook development server",
223
+ "strict": true,
224
+ "pluginName": "@linktr.ee/create-link-app",
225
+ "pluginAlias": "@linktr.ee/create-link-app",
226
+ "pluginType": "core",
227
+ "aliases": [],
228
+ "flags": {
229
+ "port": {
230
+ "name": "port",
231
+ "type": "option",
232
+ "char": "p",
233
+ "description": "Port to run the Storybook server on",
234
+ "multiple": false,
235
+ "default": 6006
236
+ }
237
+ },
238
+ "args": {}
219
239
  }
220
240
  }
221
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/create-link-app",
3
- "version": "0.3.0-next.2",
3
+ "version": "0.3.0-next.20",
4
4
  "description": "Create a Link App on Linktr.ee.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Linktree",
@@ -19,13 +19,14 @@
19
19
  "/templates"
20
20
  ],
21
21
  "scripts": {
22
- "build": "shx rm -rf dist && tsc -b",
22
+ "build": "shx rm -rf dist && tsc -b && yarn copy-storybook-global-css",
23
23
  "postpack": "shx rm -f oclif.manifest.json",
24
24
  "prepack": "yarn build && oclif manifest && oclif readme",
25
25
  "test": "jest --watch",
26
26
  "test:ci": "jest",
27
27
  "test:cov": "jest --coverage",
28
- "version": "oclif readme && git add README.md"
28
+ "version": "oclif readme && git add README.md",
29
+ "copy-storybook-global-css": "cp ./src/storybook/global.css ./dist/storybook/global.css"
29
30
  },
30
31
  "dependencies": {
31
32
  "@babel/core": "^7.18.2",
@@ -34,24 +35,46 @@
34
35
  "@babel/preset-react": "^7.17.12",
35
36
  "@babel/preset-typescript": "^7.17.12",
36
37
  "@babel/runtime": "^7.18.3",
38
+ "@linktr.ee/component-library": "^7.0.17",
37
39
  "@oclif/core": "^1.9.0",
38
40
  "@oclif/plugin-help": "^5.1.12",
41
+ "@storybook/addon-actions": "^6.5.9",
42
+ "@storybook/addon-essentials": "^6.5.9",
43
+ "@storybook/addon-interactions": "^6.5.9",
44
+ "@storybook/addon-links": "^6.5.9",
45
+ "@storybook/addon-postcss": "^2.0.0",
46
+ "@storybook/builder-webpack5": "^6.5.9",
47
+ "@storybook/manager-webpack5": "^6.5.9",
48
+ "@storybook/react": "^6.5.9",
49
+ "@testing-library/react": "^12.1.4",
50
+ "@testing-library/user-event": "14",
51
+ "ajv": "^8.12.0",
39
52
  "archiver": "^5.3.1",
53
+ "autoprefixer": "^10.4.14",
40
54
  "axios": "^0.27.2",
41
55
  "babel-loader": "^8.2.5",
42
56
  "camelcase": "^6.3.0",
57
+ "css-loader": "^6.7.3",
43
58
  "fork-ts-checker-webpack-plugin": "^7.2.11",
44
59
  "form-data": "^4.0.0",
45
60
  "fs-extra": "^10.1.0",
46
61
  "html-webpack-plugin": "^5.5.0",
47
62
  "inject-body-webpack-plugin": "^1.3.0",
48
63
  "jsonwebtoken": "^8.5.1",
64
+ "mini-css-extract-plugin": "^2.7.5",
49
65
  "netrc-parser": "^3.1.6",
50
66
  "openid-client": "^5.1.6",
67
+ "postcss": "^8.4.21",
68
+ "postcss-loader": "^4.3.0",
69
+ "prop-types": "^15.8.1",
51
70
  "react": "^17.0.2",
52
71
  "react-dom": "^17.0.2",
53
72
  "slugify": "^1.6.6",
73
+ "storybook-addon-designs": "^6.3.1",
74
+ "storybook-addon-turbo-build": "^1.1.0",
75
+ "style-loader": "^3.3.2",
54
76
  "styled-components": "^5.3.5",
77
+ "tailwindcss": "^3.3.1",
55
78
  "typescript": "^4.7.3",
56
79
  "webpack": "^5.75.0",
57
80
  "webpack-dev-server": "^4.11.1"
@@ -21,6 +21,24 @@ Several files were created during the bootstrapping of this project. Some of the
21
21
  | `settings.json` | Defines the settings made available to Linktree users when configuring the Link App via [Linktree Admin](https://linktr.ee/admin) |
22
22
  | `fixtures/props-data.json` | Used during development, this file acts as mock data for the `settings.json` output, it is injected as props to the entry point component |
23
23
  | `url-match-rules.json` | Defines the URL pattern to match against when users add a link on Linktree via URL, its structure follows the [URL Pattern API](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) |
24
+ | `schema.json` | Defines the schema a Link App will use for generating types shared between client and server. The format for the schema adheres to the [JSON Type Definition](https://jsontypedef.com/), aka [RFC 8927](https://datatracker.ietf.org/doc/html/rfc8927), standard. |
25
+
26
+ ## Generating types from `schema.json`
27
+
28
+ To generate the appropriate Typescript types from your schema run one of the following commands:
29
+
30
+ `npm run generate:types` or `yarn generate:types`
31
+
32
+ Please note that under the hood we use the `jtd-codegen` package which must first be installed on your system.
33
+
34
+ This can be installed with the following command:
35
+
36
+ ```sh
37
+ brew install jsontypedef/jsontypedef/jtd-codegen
38
+ ```
39
+
40
+ For more information on using `jtd-codegen` to generate code see the [official documentation](https://jsontypedef.com/docs/jtd-codegen/), or for specifics on generating Typescript code [here](https://jsontypedef.com/docs/typescript-codegen/).
41
+
24
42
 
25
43
  ## UI Components
26
44
 
@@ -1,4 +1,3 @@
1
1
  {
2
- "toggle": true,
3
- "your_name": "World"
2
+ "title": "Link App Title"
4
3
  }
@@ -1,3 +1,4 @@
1
1
  node_modules
2
2
  dist
3
3
  .DS_Store
4
+ package.tgz
@@ -0,0 +1,38 @@
1
+ {
2
+ "definitions": {
3
+ "publicData": {
4
+ "metadata": {
5
+ "description": "This represents the types derived from settings.json, and is editable from the client"
6
+ },
7
+ "properties": {
8
+ "thumbnailUrl": { "type": "string" },
9
+ "title": { "type": "string" },
10
+ "url": { "type": "string" }
11
+ }
12
+ },
13
+ "protectedData": {
14
+ "metadata": {
15
+ "description": "This represents the types derived from the linktree-backend context service, and is read only from the client"
16
+ },
17
+ "properties": {}
18
+ },
19
+ "privateData": {
20
+ "metadata": {
21
+ "description": "This represents the types for backend only data, it should never be sent to the client"
22
+ },
23
+ "properties": {}
24
+ }
25
+ },
26
+ "properties": {
27
+ "publicData": { "ref": "publicData" },
28
+ "protectedData": { "ref": "protectedData" }
29
+ },
30
+ "optionalProperties": {
31
+ "privateData": {
32
+ "metadata": {
33
+ "description": "This should never be sent to the client"
34
+ },
35
+ "ref": "privateData"
36
+ }
37
+ }
38
+ }
@@ -1,33 +1,21 @@
1
1
  {
2
- "title": "Link Type",
3
- "overview": {
4
- "title": "You can have a heading",
5
- "description": "as well as a description to inform users on what the link does."
6
- },
2
+ "title": "Link App",
7
3
  "elements": [
8
4
  {
9
- "inputType": "linkBehavior",
10
- "id": "how_link_behaves",
11
- "title": "How would you like the link to behave?",
12
- "description": "When a user interacts with this link:",
13
- "linkBehaviorLabels": {
14
- "embedLabel": "Embed content on the profile",
15
- "linkOffLabel": "Go directly to URL"
16
- },
17
- "defaultValue": "embedLabel"
5
+ "id": "thumbnailUrl",
6
+ "title": "Thumbnail",
7
+ "inputType": "file",
8
+ "accept": ["image/*"]
18
9
  },
19
10
  {
20
- "inputType": "switch",
21
- "id": "toggle",
22
- "title": "Use another title/description to break up content",
23
- "description": "and describe what the next section of inputs will do",
24
- "label": "Is feature enabled?",
25
- "defaultValue": true
11
+ "id": "title",
12
+ "title": "Title",
13
+ "inputType": "text"
26
14
  },
27
15
  {
28
- "inputType": "text",
29
- "id": "your_name",
30
- "label": "elements that only have a label will stick close the element above"
16
+ "id": "url",
17
+ "title": "URL",
18
+ "inputType": "text"
31
19
  }
32
20
  ]
33
21
  }
@@ -3,10 +3,13 @@
3
3
  "scripts": {
4
4
  "build": "create-link-app build",
5
5
  "deploy": "create-link-app deploy",
6
- "dev": "create-link-app dev"
6
+ "storybook": "create-link-app storybook",
7
+ "dev": "create-link-app dev",
8
+ "generate:types": "jtd-codegen ./schema.json --typescript-out src/types --root-name=LinkAppData"
7
9
  },
8
10
  "devDependencies": {
9
- "@linktr.ee/create-link-app": "latest",
11
+ "@linktr.ee/component-library": "latest",
12
+ "@linktr.ee/create-link-app": "next",
10
13
  "@linktr.ee/ui-link-kit": "latest"
11
14
  }
12
15
  }
@@ -1,18 +1,9 @@
1
- import { Container, Description, Header } from '@linktr.ee/ui-link-kit'
1
+ import P from '@linktr.ee/component-library/P'
2
2
 
3
- import logo from './images/logo.png'
3
+ import './tailwind.css'
4
4
 
5
- function App({ toggle, your_name, __linkUrl }) {
6
- return (
7
- <Container
8
- primaryCta={toggle ? { label: 'Visit our UI docs for more info', href: 'https://blstrco.github.io/ui-link-kit/' } : null}
9
- secondaryCta={toggle ? { label: 'Original url for your Linktree link', href: __linkUrl } : null}
10
- logo={logo}
11
- >
12
- <Header heading={`Hello ${your_name}!`} secondaryHeading="Congratulations, you now have a Linktree link!" layout="hero" />
13
- <Description>{your_name}</Description>
14
- </Container>
15
- )
5
+ function App({ title }) {
6
+ return <P>{title}</P>
16
7
  }
17
8
 
18
9
  export default App
@@ -0,0 +1,5 @@
1
+ /* tailwind.css */
2
+
3
+ @tailwind base;
4
+ @tailwind components;
5
+ @tailwind utilities;
@@ -3,10 +3,13 @@
3
3
  "scripts": {
4
4
  "build": "create-link-app build",
5
5
  "deploy": "create-link-app deploy",
6
- "dev": "create-link-app dev"
6
+ "storybook": "create-link-app storybook",
7
+ "dev": "create-link-app dev",
8
+ "generate:types": "jtd-codegen ./schema.json --typescript-out src/types --root-name=LinkAppData"
7
9
  },
8
10
  "devDependencies": {
9
- "@linktr.ee/create-link-app": "latest",
11
+ "@linktr.ee/component-library": "latest",
12
+ "@linktr.ee/create-link-app": "next",
10
13
  "@linktr.ee/ui-link-kit": "latest",
11
14
  "@types/react": "^17.0.0",
12
15
  "@types/react-dom": "^17.0.0"
@@ -0,0 +1,57 @@
1
+ import { SettingsData } from '../types'
2
+
3
+ const baseStyle = {
4
+ backgroundColor: 'var(--lt-color-primary)',
5
+ color: 'var(--lt-color-on-primary)',
6
+ } as React.CSSProperties
7
+
8
+ const Featured = (props: SettingsData) => {
9
+ return (
10
+ <div
11
+ className="px-6 pt-12 pb-11 h-full"
12
+ style={{
13
+ ...baseStyle,
14
+ borderRadius: 'var(--lt-feature-container-radius)',
15
+ }}
16
+ >
17
+ Featured
18
+ </div>
19
+ )
20
+ }
21
+
22
+ const Carousel = (props: SettingsData) => {
23
+ return (
24
+ <div
25
+ className="px-4 pt-16 pb-10 h-full"
26
+ style={{
27
+ ...baseStyle,
28
+ borderRadius: 'var(--lt-carousel-container-radius)',
29
+ }}
30
+ >
31
+ Carousel
32
+ </div>
33
+ )
34
+ }
35
+
36
+ const Grid = (props: SettingsData) => {
37
+ return (
38
+ <div className="px-3 py-10 h-full" style={{ ...baseStyle, borderRadius: 'var(--lt-grid-container-radius)' }}>
39
+ Grid
40
+ </div>
41
+ )
42
+ }
43
+
44
+ const Stack = (props: SettingsData) => {
45
+ return (
46
+ <div className="flex p-2 h-full gap-4 w-full" style={{ ...baseStyle, borderRadius: 'var(--lt-stack-container-radius)' }}>
47
+ <div className="w-16 aspect-square"></div>
48
+ <h2 className="mr-20">Stack</h2>
49
+ </div>
50
+ )
51
+ }
52
+
53
+ const SheetBody = () => {
54
+ return <div>sheet body</div>
55
+ }
56
+
57
+ export { Featured, Carousel, Grid, Stack, SheetBody }
@@ -1,19 +1,25 @@
1
- import { Container, Description, Header } from '@linktr.ee/ui-link-kit'
2
- import { SettingsData } from './types'
1
+ import { Featured, Carousel, Grid, Stack, SheetBody } from './components/Layouts'
2
+ import { SettingsData, Layout } from './types'
3
3
 
4
- import logo from './images/logo.png'
4
+ import './tailwind.css'
5
5
 
6
- function App({ toggle, your_name, __linkUrl }: SettingsData) {
7
- return (
8
- <Container
9
- primaryCta={toggle ? { label: 'Visit our UI docs for more info', href: 'https://blstrco.github.io/ui-link-kit/' } : null}
10
- secondaryCta={toggle ? { label: 'Original url for your Linktree link', href: __linkUrl } : null}
11
- logo={logo}
12
- >
13
- <Header heading={`Hello ${your_name}!`} secondaryHeading="Congratulations, you now have a Linktree link!" layout="hero" />
14
- <Description>{your_name}</Description>
15
- </Container>
16
- )
6
+ function App(props: SettingsData) {
7
+ const { layout } = props
8
+
9
+ switch (layout) {
10
+ case Layout.stack:
11
+ return <Stack {...props} />
12
+ case Layout.grid:
13
+ return <Grid {...props} />
14
+ case Layout.carousel:
15
+ return <Carousel {...props} />
16
+ case Layout.featured:
17
+ return <Featured {...props} />
18
+ case Layout.sheetBody:
19
+ return <SheetBody />
20
+ default:
21
+ return <div>Unknown layout: {props.layout}</div>
22
+ }
17
23
  }
18
24
 
19
25
  export default App
@@ -0,0 +1,99 @@
1
+ import React from 'react'
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react'
3
+ import manifest from '../../manifest.json'
4
+ import fixture from '../../fixtures/props-data.json'
5
+
6
+ import { Layout } from '../types'
7
+
8
+ import LinkApp from '..'
9
+
10
+ import './tailwind.sb.css'
11
+
12
+ export default {
13
+ title: `Link App/${manifest.name}`,
14
+ component: LinkApp,
15
+ tags: ['autodocs'],
16
+ parameters: {
17
+ layout: 'fullscreen',
18
+ },
19
+ args: {
20
+ ...fixture,
21
+ editing: false,
22
+ },
23
+ argTypes: {
24
+ layout: {
25
+ table: {
26
+ disable: true,
27
+ },
28
+ },
29
+ },
30
+ } as ComponentMeta<typeof LinkApp>
31
+
32
+ export const Stack: ComponentStory<typeof LinkApp> = (args) => (
33
+ <div
34
+ className="m-2"
35
+ style={{
36
+ width: 374,
37
+ height: 80,
38
+ }}
39
+ >
40
+ <LinkApp {...args} />
41
+ </div>
42
+ )
43
+ Stack.args = {
44
+ layout: Layout.stack,
45
+ }
46
+
47
+ export const Grid: ComponentStory<typeof LinkApp> = (args) => (
48
+ <div
49
+ className="m-2"
50
+ style={{
51
+ width: 183,
52
+ height: 240,
53
+ }}
54
+ >
55
+ <LinkApp {...args} />
56
+ </div>
57
+ )
58
+ Grid.args = {
59
+ layout: Layout.grid,
60
+ }
61
+
62
+ export const Carousel: ComponentStory<typeof LinkApp> = (args) => (
63
+ <div
64
+ className="m-2"
65
+ style={{
66
+ width: 224,
67
+ height: 296,
68
+ }}
69
+ >
70
+ <LinkApp {...args} />
71
+ </div>
72
+ )
73
+ Carousel.args = {
74
+ layout: Layout.carousel,
75
+ }
76
+
77
+ export const Featured: ComponentStory<typeof LinkApp> = (args) => (
78
+ <div
79
+ className="m-2"
80
+ style={{
81
+ width: 374,
82
+ height: 374,
83
+ }}
84
+ >
85
+ <LinkApp {...args} />
86
+ </div>
87
+ )
88
+ Featured.args = {
89
+ layout: Layout.featured,
90
+ }
91
+
92
+ export const SheetBody: ComponentStory<typeof LinkApp> = (args) => (
93
+ <div className="m-2">
94
+ <LinkApp {...args} />
95
+ </div>
96
+ )
97
+ SheetBody.args = {
98
+ layout: Layout.sheetBody,
99
+ }
@@ -0,0 +1,5 @@
1
+ /* tailwind.sb.css */
2
+
3
+ @tailwind base;
4
+ @tailwind components;
5
+ @tailwind utilities;
@@ -0,0 +1,4 @@
1
+ /* tailwind.css */
2
+
3
+ @tailwind components;
4
+ @tailwind utilities;
@@ -1,5 +1,8 @@
1
- declare module '*.jpg'
2
- declare module '*.png'
3
- declare module '*.jpeg'
4
- declare module '*.gif'
5
- declare module '*.svg'
1
+ // @HACK: These files are removed at build time, but we need it for type checking
2
+ declare module '*manifest.json' {
3
+ export const name: string
4
+ }
5
+
6
+ declare module '*props-data.json' {
7
+ export const name: string
8
+ }
@@ -1,7 +1,35 @@
1
- type LinktreeLinkContext = {
2
- __linkUrl: string
1
+ // Code generated by jtd-codegen for TypeScript v0.2.1
2
+
3
+ export interface LinkAppData {
4
+ protectedData: ProtectedData;
5
+ publicData: PublicData;
6
+
7
+ /**
8
+ * This should never be sent to the client
9
+ */
10
+ privateData?: PrivateData;
11
+ }
12
+
13
+ /**
14
+ * This represents the types for backend only data, it should never be sent to
15
+ * the client
16
+ */
17
+ export interface PrivateData {
18
+ }
19
+
20
+ /**
21
+ * This represents the types derived from the linktree-backend context service,
22
+ * and is read only from the client
23
+ */
24
+ export interface ProtectedData {
25
+ }
26
+
27
+ /**
28
+ * This represents the types derived from settings.json, and is editable from
29
+ * the client
30
+ */
31
+ export interface PublicData {
32
+ thumbnailUrl: string;
33
+ title: string;
34
+ url: string;
3
35
  }
4
- export type SettingsData = {
5
- toggle: boolean
6
- your_name: string
7
- } & LinktreeLinkContext
Binary file