From 7379416aa294729e2bce8a18ce029573c7ff303a Mon Sep 17 00:00:00 2001 From: mym0404 Date: Thu, 14 Mar 2024 15:58:56 +0900 Subject: [PATCH 1/2] docs: change doc --- doc/docs/usage/component.mdx | 2 +- doc/i18n/ko/docusaurus-plugin-content-docs/current.json | 2 +- .../current/usage/component.mdx | 2 +- doc/i18n/ko/docusaurus-theme-classic/footer.json | 8 ++++---- doc/i18n/ko/docusaurus-theme-classic/navbar.json | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/docs/usage/component.mdx b/doc/docs/usage/component.mdx index 16fce242..6523f0d4 100644 --- a/doc/docs/usage/component.mdx +++ b/doc/docs/usage/component.mdx @@ -137,7 +137,7 @@ type StyledScrollViewProps = PropsWithChildren< >; const StyledScrollView = forwardRef((props: StyledScrollViewProps, ref: Ref) => { const { viewStyle, filteredProps } = useSx(props); - const { viewStyle: contentContainerStyle } = useSx(props.contentContainerSx ?? {}); + const { viewStyle: contentContainerStyle } = useSx(props.contentContainerSx); return ( ); diff --git a/doc/i18n/ko/docusaurus-plugin-content-docs/current.json b/doc/i18n/ko/docusaurus-plugin-content-docs/current.json index 5b946c4d..fb308e72 100644 --- a/doc/i18n/ko/docusaurus-plugin-content-docs/current.json +++ b/doc/i18n/ko/docusaurus-plugin-content-docs/current.json @@ -8,7 +8,7 @@ "description": "The label for category Usage in sidebar tutorialSidebar" }, "sidebar.tutorialSidebar.category.Usage.link.generated-index.description": { - "message": "Learn the most important concepts.", + "message": "React Native Styled System의 개념들을 빠르게 배워보세요.", "description": "The generated-index page description for category Usage in sidebar tutorialSidebar" } } diff --git a/doc/i18n/ko/docusaurus-plugin-content-docs/current/usage/component.mdx b/doc/i18n/ko/docusaurus-plugin-content-docs/current/usage/component.mdx index c03d5257..d2c44cf1 100644 --- a/doc/i18n/ko/docusaurus-plugin-content-docs/current/usage/component.mdx +++ b/doc/i18n/ko/docusaurus-plugin-content-docs/current/usage/component.mdx @@ -137,7 +137,7 @@ type StyledScrollViewProps = PropsWithChildren< >; const StyledScrollView = forwardRef((props: StyledScrollViewProps, ref: Ref) => { const { viewStyle, filteredProps } = useSx(props); - const { viewStyle: contentContainerStyle } = useSx(props.contentContainerSx ?? {}); + const { viewStyle: contentContainerStyle } = useSx(props.contentContainerSx); return ( ); diff --git a/doc/i18n/ko/docusaurus-theme-classic/footer.json b/doc/i18n/ko/docusaurus-theme-classic/footer.json index 3742e490..a84d2ba8 100644 --- a/doc/i18n/ko/docusaurus-theme-classic/footer.json +++ b/doc/i18n/ko/docusaurus-theme-classic/footer.json @@ -1,18 +1,18 @@ { "link.title.Docs": { - "message": "Docs", + "message": "문서", "description": "The title of the footer links column with title=Docs in the footer" }, "link.title.More": { - "message": "More", + "message": "더보기", "description": "The title of the footer links column with title=More in the footer" }, "link.item.label.Tutorial": { - "message": "Tutorial", + "message": "튜토리얼", "description": "The label of footer link with label=Tutorial linking to /docs/intro" }, "link.item.label.GitHub": { - "message": "GitHub", + "message": "깃허브", "description": "The label of footer link with label=GitHub linking to https://github.com/mj-studio-library/react-native-styled-system" }, "copyright": { diff --git a/doc/i18n/ko/docusaurus-theme-classic/navbar.json b/doc/i18n/ko/docusaurus-theme-classic/navbar.json index e57d1ad4..a274af75 100644 --- a/doc/i18n/ko/docusaurus-theme-classic/navbar.json +++ b/doc/i18n/ko/docusaurus-theme-classic/navbar.json @@ -4,15 +4,15 @@ "description": "The title in the navbar" }, "logo.alt": { - "message": "My Site Logo", + "message": "로고", "description": "The alt text of navbar logo" }, "item.label.Tutorial": { - "message": "Tutorial", + "message": "튜토리얼", "description": "Navbar item with label Tutorial" }, "item.label.GitHub": { - "message": "GitHub", + "message": "깃허브", "description": "Navbar item with label GitHub" } } From 4dfa1cc8aae9d232440d39065b73e1e223c7ebd9 Mon Sep 17 00:00:00 2001 From: mym0404 Date: Thu, 14 Mar 2024 16:11:44 +0900 Subject: [PATCH 2/2] fix: handle invalid px suffix token values --- src/hook/useSx.test.ts | 7 +++++++ src/util/propsToThemedStyle.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/hook/useSx.test.ts b/src/hook/useSx.test.ts index 9d26e9f6..5aa69843 100644 --- a/src/hook/useSx.test.ts +++ b/src/hook/useSx.test.ts @@ -52,6 +52,13 @@ describe('simple usages', () => { }); describe('edge case', () => { + it('invalid px suffix', () => { + expectResult(baseTheme, { w: 'undefinedpx' as any }, {}); + expectResult(baseTheme, { w: 'nullpx' as any }, {}); + expectResult(baseTheme, { w: '-px' as any }, {}); + expectResult(baseTheme, { w: '-1px' as any }, { width: -1 }); + }); + it('if token is undefined, baseStyle is returned', () => { expectResult(undefined as any, {}, {}); expectResult(undefined as any, { style: { width: 1 } }, { width: 1 }); diff --git a/src/util/propsToThemedStyle.ts b/src/util/propsToThemedStyle.ts index 5f3f881e..16a2da6b 100644 --- a/src/util/propsToThemedStyle.ts +++ b/src/util/propsToThemedStyle.ts @@ -43,6 +43,10 @@ export const propsToThemedStyle = ({ if (is.number(px)) { return px; } + // end with px but not number parsed + if (is.string(token) && token.endsWith('px')) { + return; + } const spaces = theme.space; @@ -121,6 +125,11 @@ export const propsToThemedStyle = ({ return px; } + // end with px but not number parsed + if (is.string(token) && token.endsWith('px')) { + return; + } + const sizes = theme.sizes; if ((is.string(token) || is.number(token)) && token in sizes) {