From 0e487c31f74cd67181cc550c79cdb39e2d213d47 Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sat, 16 Mar 2024 01:55:18 +0900 Subject: [PATCH 1/2] docs: useSxToken --- doc/docs/advanced/get-token-value.mdx | 30 +++++++++++++++++++ doc/docs/advanced/global-theme-value.mdx | 2 +- .../current/advanced/get-token-value.mdx | 30 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 doc/docs/advanced/get-token-value.mdx create mode 100644 doc/i18n/ko/docusaurus-plugin-content-docs/current/advanced/get-token-value.mdx diff --git a/doc/docs/advanced/get-token-value.mdx b/doc/docs/advanced/get-token-value.mdx new file mode 100644 index 00000000..ac27879f --- /dev/null +++ b/doc/docs/advanced/get-token-value.mdx @@ -0,0 +1,30 @@ +--- +sidebar_position: 1 +--- + +# Get token value with useSxToken + +To get individual token values for a theme, you can use the `useSxToken` hook. + +This is useful when it is cumbersome to get the style by passing `SxProps` to the `useSx` hook or when individual token values are needed. + +```tsx +const MyView = ( + { + disabled, + readonly + }:{ + disabled?: boolean; + readonly?: boolean; + }) => { + const backgroundColor = useSxToken('colors', readonly || disabled ? 'gray500' : 'gray200'); +g + return +} +``` + +:::info +To operate properly, you must use it in the Context inside `StyledSystemProvider` or pass the theme object as an option. + +Additionally, `undefined` is returned when attempting to reference a key that does not exist. +::: \ No newline at end of file diff --git a/doc/docs/advanced/global-theme-value.mdx b/doc/docs/advanced/global-theme-value.mdx index 60a52e6a..11797110 100644 --- a/doc/docs/advanced/global-theme-value.mdx +++ b/doc/docs/advanced/global-theme-value.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 1 +sidebar_position: 2 title: Get Theme value in global --- diff --git a/doc/i18n/ko/docusaurus-plugin-content-docs/current/advanced/get-token-value.mdx b/doc/i18n/ko/docusaurus-plugin-content-docs/current/advanced/get-token-value.mdx new file mode 100644 index 00000000..4ad5f37c --- /dev/null +++ b/doc/i18n/ko/docusaurus-plugin-content-docs/current/advanced/get-token-value.mdx @@ -0,0 +1,30 @@ +--- +sidebar_position: 1 +--- + +# useSxToken를 이용해 토큰값 얻기 + +테마의 개별적인 토큰 값을 얻으려면 `useSxToken` 훅을 사용할 수 있습니다. + +이는 `SxProps`를 `useSx` 훅에 전달해 style을 얻기 번거롭거나 개별적인 토큰 값이 필요할 때 유용합니다. + +```tsx +const MyView = ( + { + disabled, + readonly + }:{ + disabled?: boolean; + readonly?: boolean; + }) => { + const backgroundColor = useSxToken('colors', readonly || disabled ? 'gray500' : 'gray200'); + + return +} +``` + +:::info +`StyledSystemProvider`내부의 Context에서 사용하거나 옵션으로 테마 객체를 전달해야 정상적으로 동작합니다. + +또한, 존재하지 않는 키를 참조하려고 할 시에도 `undefined`가 반환됩니다. +::: \ No newline at end of file From fed800b3804cc0b57e46dd01319dc7fd56c18d2d Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sat, 16 Mar 2024 02:09:32 +0900 Subject: [PATCH 2/2] build: exclude redundant build outputs --- package.json | 4 +++- tsconfig.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6da8792b..073ed4d8 100644 --- a/package.json +++ b/package.json @@ -67,13 +67,15 @@ "source": "src/index.ts", "module": "lib/module/index.js", "react-native-builder-bob": { + "declarationMap": false, "source": "src", "output": "lib", "targets": [ "commonjs", "module", "typescript" - ] + ], + "exclude": ["**/{__tests__,__fixtures__,__mocks__}/**", "**/*.test.*"] }, "config": { "commitizen": { diff --git a/tsconfig.json b/tsconfig.json index bad2d311..a11f240e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,5 +15,6 @@ "rootDir": "src", "skipLibCheck": true }, - "include": ["src/**/*.ts", "src/**/*.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["**/*.test.*", "node_modules"] }