From dfc3204af2ae87acb2e44c956fcd6fa757007438 Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:10:07 -0500 Subject: [PATCH 1/3] chore: add tsconfig to generate d.ts files --- .../ExampleButton/components/ExampleButton.tsx | 2 +- .../src/components/ExampleButton/package.json | 3 +++ .../src/components/ExampleButton/tsconfig.json | 8 ++++++++ packages/react/tasks/build.js | 2 +- packages/utilities/package.json | 4 ++++ packages/utilities/src/index.js | 1 + packages/utilities/src/usePrefix.js | 18 ++++++++++++++++++ yarn.lock | 4 ++++ 8 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 packages/react/src/components/ExampleButton/tsconfig.json create mode 100644 packages/utilities/src/usePrefix.js diff --git a/packages/react/src/components/ExampleButton/components/ExampleButton.tsx b/packages/react/src/components/ExampleButton/components/ExampleButton.tsx index 861269af..1473cf4a 100644 --- a/packages/react/src/components/ExampleButton/components/ExampleButton.tsx +++ b/packages/react/src/components/ExampleButton/components/ExampleButton.tsx @@ -8,7 +8,7 @@ */ import React from 'react'; import { Button, ButtonProps } from '@carbon/react'; -import { usePrefix } from '../../../internal/usePrefix'; +import { usePrefix } from '@carbon-labs/utilities/es/index.js'; /** Primary UI component for user interaction */ diff --git a/packages/react/src/components/ExampleButton/package.json b/packages/react/src/components/ExampleButton/package.json index 6972b4a5..284ed9c2 100644 --- a/packages/react/src/components/ExampleButton/package.json +++ b/packages/react/src/components/ExampleButton/package.json @@ -23,5 +23,8 @@ "scripts": { "build": "node ../../../tasks/build.js", "clean": "rm -rf {es,lib,scss}" + }, + "devDependencies": { + "@carbon-labs/utilities": "0.14.0" } } diff --git a/packages/react/src/components/ExampleButton/tsconfig.json b/packages/react/src/components/ExampleButton/tsconfig.json new file mode 100644 index 00000000..1a834217 --- /dev/null +++ b/packages/react/src/components/ExampleButton/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "typescript-config-carbon/tsconfig.base.json", + "compilerOptions": { + // TODO: Turn back on once stricter typings for internal utitlies are complete + "noImplicitAny": false + }, + "exclude": ["**/__stories__/*.stories.js", "**/__tests__/*"] +} diff --git a/packages/react/tasks/build.js b/packages/react/tasks/build.js index 8305159d..f685150e 100644 --- a/packages/react/tasks/build.js +++ b/packages/react/tasks/build.js @@ -31,7 +31,7 @@ const packageJSON = JSON.parse( async function build() { const reactEntrypoint = { filepath: path.resolve(process.cwd(), 'index.ts'), - rootDir: 'src', + rootDir: path.resolve(process.cwd()), outputDirectory: path.resolve(process.cwd()), }; diff --git a/packages/utilities/package.json b/packages/utilities/package.json index 3e944808..dd7a541f 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -29,6 +29,10 @@ "es/**/*.js", "es/index.js" ], + "dependencies": { + "react": "^18.3.1", + "react-dom": "^18.3.1" + }, "devDependencies": { "@rollup/plugin-babel": "^6.0.4", "babel-cli": "^6.26.0" diff --git a/packages/utilities/src/index.js b/packages/utilities/src/index.js index f1146913..8e0a8d3a 100644 --- a/packages/utilities/src/index.js +++ b/packages/utilities/src/index.js @@ -8,3 +8,4 @@ */ export * from './settings/index.js'; +export * from './usePrefix.js'; diff --git a/packages/utilities/src/usePrefix.js b/packages/utilities/src/usePrefix.js new file mode 100644 index 00000000..095d9cab --- /dev/null +++ b/packages/utilities/src/usePrefix.js @@ -0,0 +1,18 @@ +/** + * Copyright IBM Corp. 2016, 2023 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; + +export const PrefixContext = React.createContext('clabs'); + +/** + * Sets the prefix context + * @returns context value + */ +export function usePrefix() { + return React.useContext(PrefixContext); +} diff --git a/yarn.lock b/yarn.lock index 5082642c..8e1120b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2585,6 +2585,8 @@ __metadata: "@carbon-labs/react-example-button@workspace:packages/react/src/components/ExampleButton": version: 0.0.0-use.local resolution: "@carbon-labs/react-example-button@workspace:packages/react/src/components/ExampleButton" + dependencies: + "@carbon-labs/utilities": "npm:0.14.0" languageName: unknown linkType: soft @@ -2594,6 +2596,8 @@ __metadata: dependencies: "@rollup/plugin-babel": "npm:^6.0.4" babel-cli: "npm:^6.26.0" + react: "npm:^18.3.1" + react-dom: "npm:^18.3.1" languageName: unknown linkType: soft From bd9beee00fabe2a81408ce5f45642309a0b59e38 Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:11:44 -0500 Subject: [PATCH 2/3] docs: adjust stackblitz link position in mdx docs --- .../ExampleButton/__stories__/ExampleButton.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx b/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx index d15f19af..c3c9d769 100644 --- a/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx +++ b/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx @@ -3,17 +3,17 @@ import * as ExampleButtonStories from './ExampleButton.stories'; +# ExampleButton + +{/* */} +{/* */} + > 💡 Check our > [Stackblitz](https://stackblitz.com/github/carbon-design-system/carbon-labs/tree/main/examples/react/example-button) > example implementation. [![Edit carbon-labs](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/carbon-design-system/carbon-labs/tree/main/examples/react/example-button) -# ExampleButton - -{/* */} -{/* */} - ## Table of Contents - [Overview](#overview) From d27f66be36f7d32dd16e589ca18459d1843cb4b5 Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:46:04 -0500 Subject: [PATCH 3/3] chore: set utilities to canary --- .../react/src/components/ExampleButton/package.json | 2 +- yarn.lock | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/react/src/components/ExampleButton/package.json b/packages/react/src/components/ExampleButton/package.json index 284ed9c2..ad7b1148 100644 --- a/packages/react/src/components/ExampleButton/package.json +++ b/packages/react/src/components/ExampleButton/package.json @@ -25,6 +25,6 @@ "clean": "rm -rf {es,lib,scss}" }, "devDependencies": { - "@carbon-labs/utilities": "0.14.0" + "@carbon-labs/utilities": "canary" } } diff --git a/yarn.lock b/yarn.lock index dcdac8d5..6a9da5a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2586,7 +2586,7 @@ __metadata: version: 0.0.0-use.local resolution: "@carbon-labs/react-example-button@workspace:packages/react/src/components/ExampleButton" dependencies: - "@carbon-labs/utilities": "npm:0.14.0" + "@carbon-labs/utilities": "npm:canary" languageName: unknown linkType: soft @@ -2608,6 +2608,16 @@ __metadata: languageName: node linkType: hard +"@carbon-labs/utilities@npm:canary": + version: 0.14.1-canary.387 + resolution: "@carbon-labs/utilities@npm:0.14.1-canary.387" + dependencies: + react: "npm:^18.3.1" + react-dom: "npm:^18.3.1" + checksum: 10c0/17f791a40f4f55689924b355fdecbfb254abd99325e1aee86ef96b7adb95e57d5be0b0eb928083137a6bad8a667d1bdfe33af2946502fa48434a133fb43756a3 + languageName: node + linkType: hard + "@carbon-labs/web-components-example-button@workspace:packages/web-components/src/components/example-button": version: 0.0.0-use.local resolution: "@carbon-labs/web-components-example-button@workspace:packages/web-components/src/components/example-button"