From 82462c5c6b00aae69c35cad80d597b8b9d2899ab Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:33:18 -0500 Subject: [PATCH] chore(structure): add component folders (#31) * chore(components): add components within packages for subcomponents * chore(storybook): reorganize subcomponents under package * chore(build): edit glob for css gulp job * chore(lock): update lock file --- .storybook/main.js | 2 +- gulp-tasks/build/modules/css.js | 2 +- .../__stories__/test-input.stories.js | 4 ++-- .../__snapshots__/test-input.test.snap.js | 0 .../__tests__/test-input.test.ts | 2 +- .../test-input/src/test-input.template.ts | 0 .../components}/test-input/src/test-input.ts | 2 +- .../components}/test-input/test-input.ts | 5 +++-- packages/{test-input => chat}/index.ts | 2 +- packages/{test-input => chat}/package.json | 6 +++--- .../services/SearchTypeahead/SearchTypeahead.ts | 0 .../services/SearchTypeahead/index.ts | 0 .../__stories__/extended-button.stories.js | 4 ++-- .../__tests__/extended-button.test.ts | 2 +- .../extended-button}/extended-button.ts | 5 +++-- .../extended-button}/src/extended-button.scss | 2 +- .../src/extended-button.template.ts | 0 packages/extended-button/index.ts | 2 +- pnpm-lock.yaml | 16 ++++++++-------- tools/rollup-plugin-scss-path.js | 2 -- 20 files changed, 29 insertions(+), 29 deletions(-) rename packages/{test-input => chat}/__stories__/test-input.stories.js (86%) rename packages/{test-input => chat}/__tests__/__snapshots__/test-input.test.snap.js (100%) rename packages/{test-input => chat}/__tests__/test-input.test.ts (96%) rename packages/{ => chat/components}/test-input/src/test-input.template.ts (100%) rename packages/{ => chat/components}/test-input/src/test-input.ts (93%) rename packages/{ => chat/components}/test-input/test-input.ts (94%) rename packages/{test-input => chat}/index.ts (79%) rename packages/{test-input => chat}/package.json (81%) rename packages/{test-input => chat}/services/SearchTypeahead/SearchTypeahead.ts (100%) rename packages/{test-input => chat}/services/SearchTypeahead/index.ts (100%) rename packages/extended-button/{ => components/extended-button}/extended-button.ts (93%) rename packages/extended-button/{ => components/extended-button}/src/extended-button.scss (89%) rename packages/extended-button/{ => components/extended-button}/src/extended-button.template.ts (100%) diff --git a/.storybook/main.js b/.storybook/main.js index 3ef42f4e..47618782 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -15,7 +15,7 @@ import sass from 'sass'; const config = { stories: [ - '../packages/**/src/__stories__/*.mdx', + '../packages/**/__stories__/*.mdx', '../packages/**/__stories__/*.stories.@(js|jsx|mjs|ts|tsx)', ], addons: ['@storybook/addon-links', '@storybook/addon-essentials'], diff --git a/gulp-tasks/build/modules/css.js b/gulp-tasks/build/modules/css.js index ed42d138..83efad02 100644 --- a/gulp-tasks/build/modules/css.js +++ b/gulp-tasks/build/modules/css.js @@ -38,7 +38,7 @@ const promisifyStream = promisify(asyncDone); */ const buildModulesCSS = ({ banner }) => gulp - .src([`packages/*/src/*.scss`]) + .src([`packages/**/src/*.scss`]) .pipe( sass({ includePaths: ['node_modules', '../../node_modules'], diff --git a/packages/test-input/__stories__/test-input.stories.js b/packages/chat/__stories__/test-input.stories.js similarity index 86% rename from packages/test-input/__stories__/test-input.stories.js rename to packages/chat/__stories__/test-input.stories.js index 54e31e8c..42f2c8e9 100644 --- a/packages/test-input/__stories__/test-input.stories.js +++ b/packages/chat/__stories__/test-input.stories.js @@ -7,12 +7,12 @@ * LICENSE file in the root directory of this source tree. */ -import '../test-input.ts'; +import '../components/test-input/test-input'; import { html } from 'lit'; // More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction export default { - title: 'Components/Test input', + title: 'Components/Chat/Test input', tags: ['autodocs'], }; diff --git a/packages/test-input/__tests__/__snapshots__/test-input.test.snap.js b/packages/chat/__tests__/__snapshots__/test-input.test.snap.js similarity index 100% rename from packages/test-input/__tests__/__snapshots__/test-input.test.snap.js rename to packages/chat/__tests__/__snapshots__/test-input.test.snap.js diff --git a/packages/test-input/__tests__/test-input.test.ts b/packages/chat/__tests__/test-input.test.ts similarity index 96% rename from packages/test-input/__tests__/test-input.test.ts rename to packages/chat/__tests__/test-input.test.ts index 210e4215..7122809e 100644 --- a/packages/test-input/__tests__/test-input.test.ts +++ b/packages/chat/__tests__/test-input.test.ts @@ -16,7 +16,7 @@ import { } from '@open-wc/testing'; import { stub } from 'sinon'; import '@carbon-labs/ai-test-input/es/test-input.js'; -import C4AITestInput from '../test-input.js'; +import C4AITestInput from '../components/test-input/test-input.js'; describe('c4ai-test-input', function () { it('should render with minimum attributes', async () => { diff --git a/packages/test-input/src/test-input.template.ts b/packages/chat/components/test-input/src/test-input.template.ts similarity index 100% rename from packages/test-input/src/test-input.template.ts rename to packages/chat/components/test-input/src/test-input.template.ts diff --git a/packages/test-input/src/test-input.ts b/packages/chat/components/test-input/src/test-input.ts similarity index 93% rename from packages/test-input/src/test-input.ts rename to packages/chat/components/test-input/src/test-input.ts index 3dd4b71e..f4717207 100644 --- a/packages/test-input/src/test-input.ts +++ b/packages/chat/components/test-input/src/test-input.ts @@ -9,7 +9,7 @@ import { LitElement } from 'lit'; import { property } from 'lit/decorators.js'; -import { SearchTypeaheadAPI } from '../services/SearchTypeahead/index.js'; +import { SearchTypeaheadAPI } from '../../../services/SearchTypeahead/index.js'; /** * Input component using search typeahead api diff --git a/packages/test-input/test-input.ts b/packages/chat/components/test-input/test-input.ts similarity index 94% rename from packages/test-input/test-input.ts rename to packages/chat/components/test-input/test-input.ts index 91c96021..d1b3d36d 100644 --- a/packages/test-input/test-input.ts +++ b/packages/chat/components/test-input/test-input.ts @@ -8,8 +8,9 @@ */ import { customElement } from 'lit/decorators.js'; -// need to set up package to import global files like the one below. Hardcoding the prefixes -// for now +// need to set up package to import global files like the one below. Hardcoding +// the `c4ai` prefixes for now + // import settings from '../../globals/settings.js'; import testInput from './src/test-input.js'; import { testInputTemplate } from './src/test-input.template.js'; diff --git a/packages/test-input/index.ts b/packages/chat/index.ts similarity index 79% rename from packages/test-input/index.ts rename to packages/chat/index.ts index a7caf6c4..46eb89d0 100644 --- a/packages/test-input/index.ts +++ b/packages/chat/index.ts @@ -7,4 +7,4 @@ * LICENSE file in the root directory of this source tree. */ -import './test-input.js'; +import './components/test-input/test-input.js'; diff --git a/packages/test-input/package.json b/packages/chat/package.json similarity index 81% rename from packages/test-input/package.json rename to packages/chat/package.json index dbc64ece..f37d09d3 100644 --- a/packages/test-input/package.json +++ b/packages/chat/package.json @@ -1,15 +1,15 @@ { - "name": "@carbon-labs/ai-test-input", + "name": "@carbon-labs/ai-chat", "version": "0.0.1", "publishConfig": { "access": "public" }, - "description": "Carbon for AI - test-input component", + "description": "Carbon for AI - chat component", "license": "Apache-2.0", "repository": { "type": "git", "url": "https://github.com/carbon-design-system/carbon-for-ai", - "directory": "packages/test-input" + "directory": "packages/chat" }, "main": "./src/index.js", "module": "./src/index.js", diff --git a/packages/test-input/services/SearchTypeahead/SearchTypeahead.ts b/packages/chat/services/SearchTypeahead/SearchTypeahead.ts similarity index 100% rename from packages/test-input/services/SearchTypeahead/SearchTypeahead.ts rename to packages/chat/services/SearchTypeahead/SearchTypeahead.ts diff --git a/packages/test-input/services/SearchTypeahead/index.ts b/packages/chat/services/SearchTypeahead/index.ts similarity index 100% rename from packages/test-input/services/SearchTypeahead/index.ts rename to packages/chat/services/SearchTypeahead/index.ts diff --git a/packages/extended-button/__stories__/extended-button.stories.js b/packages/extended-button/__stories__/extended-button.stories.js index 694e21f7..1ad92ce8 100644 --- a/packages/extended-button/__stories__/extended-button.stories.js +++ b/packages/extended-button/__stories__/extended-button.stories.js @@ -7,7 +7,7 @@ * LICENSE file in the root directory of this source tree. */ -import '../extended-button.ts'; +import '../components/extended-button/extended-button'; import { html } from 'lit'; import ArrowRight16 from '@carbon/web-components/es/icons/arrow--right/16'; @@ -15,7 +15,7 @@ import ArrowRight16 from '@carbon/web-components/es/icons/arrow--right/16'; * More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction */ export default { - title: 'Components/Extended button', + title: 'Components/Extended button/Extended button', tags: ['autodocs'], }; diff --git a/packages/extended-button/__tests__/extended-button.test.ts b/packages/extended-button/__tests__/extended-button.test.ts index 6d7768fd..a6eba410 100644 --- a/packages/extended-button/__tests__/extended-button.test.ts +++ b/packages/extended-button/__tests__/extended-button.test.ts @@ -9,7 +9,7 @@ import { html, fixture, expect } from '@open-wc/testing'; import '@carbon-labs/ai-extended-button/es/extended-button.js'; -import C4AIExtendedButton from '../src/extended-button.template.js'; +import C4AIExtendedButton from '../components/extended-button/src/extended-button.template.js'; describe('c4ai-extended-button', function () { it('should render with cds-button minimum attributes', async () => { diff --git a/packages/extended-button/extended-button.ts b/packages/extended-button/components/extended-button/extended-button.ts similarity index 93% rename from packages/extended-button/extended-button.ts rename to packages/extended-button/components/extended-button/extended-button.ts index 1ce84633..7950fa19 100644 --- a/packages/extended-button/extended-button.ts +++ b/packages/extended-button/components/extended-button/extended-button.ts @@ -8,8 +8,9 @@ */ import { customElement } from 'lit/decorators.js'; -// need to set up package to import global files like the one below. Hardcoding the prefixes -// for now +// need to set up package to import global files like the one below. Hardcoding +//the `c4ai`prefixes for now + // import settings from '../../globals/settings.js'; import extendedButton from './src/extended-button.template.js'; diff --git a/packages/extended-button/src/extended-button.scss b/packages/extended-button/components/extended-button/src/extended-button.scss similarity index 89% rename from packages/extended-button/src/extended-button.scss rename to packages/extended-button/components/extended-button/src/extended-button.scss index f1a08ad7..db09ec2b 100644 --- a/packages/extended-button/src/extended-button.scss +++ b/packages/extended-button/components/extended-button/src/extended-button.scss @@ -7,7 +7,7 @@ $css--plex: true !default; -@use '../../../globals/scss/vars' as *; +@use '../../../../../globals/scss/vars' as *; @use '@carbon/styles/scss/themes' as *; @use '@carbon/web-components/scss/components/button/button'; diff --git a/packages/extended-button/src/extended-button.template.ts b/packages/extended-button/components/extended-button/src/extended-button.template.ts similarity index 100% rename from packages/extended-button/src/extended-button.template.ts rename to packages/extended-button/components/extended-button/src/extended-button.template.ts diff --git a/packages/extended-button/index.ts b/packages/extended-button/index.ts index 617f47a0..9d75334c 100644 --- a/packages/extended-button/index.ts +++ b/packages/extended-button/index.ts @@ -7,4 +7,4 @@ * LICENSE file in the root directory of this source tree. */ -import './extended-button.js'; +import './components/extended-button/extended-button.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a4e9510..a32b1854 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -244,26 +244,26 @@ importers: specifier: ^4.4.5 version: 4.5.0(@types/node@18.18.9)(less@4.2.0)(sass@1.69.5) - packages/extended-button: + packages/chat: dependencies: '@babel/runtime': specifier: ^7.23.2 version: 7.23.2 - '@carbon/styles': - specifier: ^1.39.0 - version: 1.42.0(sass@1.69.5) - '@carbon/web-components': - specifier: 2.0.1-canary.1 - version: 2.0.1-canary.1(sass@1.69.5) lit: specifier: ^3.0.0 version: 3.0.2 - packages/test-input: + packages/extended-button: dependencies: '@babel/runtime': specifier: ^7.23.2 version: 7.23.2 + '@carbon/styles': + specifier: ^1.39.0 + version: 1.42.0(sass@1.69.5) + '@carbon/web-components': + specifier: 2.0.1-canary.1 + version: 2.0.1-canary.1(sass@1.69.5) lit: specifier: ^3.0.0 version: 3.0.2 diff --git a/tools/rollup-plugin-scss-path.js b/tools/rollup-plugin-scss-path.js index 37cb4c75..e7485dd5 100644 --- a/tools/rollup-plugin-scss-path.js +++ b/tools/rollup-plugin-scss-path.js @@ -9,8 +9,6 @@ import path from 'path'; import replace from 'replace-in-file'; -import { promisify } from 'util'; -import * as sass from 'sass'; import { createFilter } from '@rollup/pluginutils'; /**