@ledgerhq/lumen-ui-rnative 0.0.43 → 0.0.45
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.
- package/.storybook/Decorator.tsx +78 -13
- package/.storybook/docs/getting-started/ThemeProvider.mdx +1 -1
- package/.storybook/docs/style-system/lx.mdx +144 -0
- package/.storybook/docs/style-system/useCreate.mdx +95 -0
- package/.storybook/docs/style-system/useTheme.mdx +52 -0
- package/.storybook/preview-head.html +2 -2
- package/.storybook/{preview.ts → preview.tsx} +6 -1
- package/dist/package.json +2 -3
- package/dist/src/lib/Components/AddressInput/AddressInput.js +1 -1
- package/dist/src/lib/Components/AddressInput/AddressInput.stories.d.ts +7 -1
- package/dist/src/lib/Components/AddressInput/AddressInput.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/AddressInput/AddressInput.stories.js +98 -9
- package/dist/src/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
- package/dist/src/lib/Components/AmountInput/AmountInput.js +3 -3
- package/dist/src/lib/Components/AmountInput/AmountInput.stories.d.ts +10 -1
- package/dist/src/lib/Components/AmountInput/AmountInput.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/AmountInput/AmountInput.stories.js +162 -9
- package/dist/src/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/src/lib/Components/BaseInput/BaseInput.js +2 -19
- package/dist/src/lib/Components/BottomSheet/BottomSheet.js +1 -1
- package/dist/src/lib/Components/BottomSheet/BottomSheet.stories.js +8 -8
- package/dist/src/lib/Components/Button/BaseButton.d.ts +3 -3
- package/dist/src/lib/Components/Button/BaseButton.d.ts.map +1 -1
- package/dist/src/lib/Components/Button/BaseButton.js +99 -119
- package/dist/src/lib/Components/Button/Button.d.ts +4 -26
- package/dist/src/lib/Components/Button/Button.d.ts.map +1 -1
- package/dist/src/lib/Components/Button/Button.js +2 -2
- package/dist/src/lib/Components/Button/Button.stories.d.ts +1 -1
- package/dist/src/lib/Components/Button/Button.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/Button/Button.stories.js +25 -48
- package/dist/src/lib/Components/Button/index.d.ts +1 -1
- package/dist/src/lib/Components/Button/index.d.ts.map +1 -1
- package/dist/src/lib/Components/Button/index.js +1 -1
- package/dist/src/lib/Components/Button/{BaseButton.types.d.ts → types.d.ts} +15 -10
- package/dist/src/lib/Components/Button/types.d.ts.map +1 -0
- package/dist/src/lib/Components/CardButton/CardButton.d.ts +4 -3
- package/dist/src/lib/Components/CardButton/CardButton.d.ts.map +1 -1
- package/dist/src/lib/Components/CardButton/CardButton.js +65 -71
- package/dist/src/lib/Components/CardButton/CardButton.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/CardButton/CardButton.stories.js +28 -15
- package/dist/src/lib/Components/CardButton/index.d.ts +1 -1
- package/dist/src/lib/Components/CardButton/index.d.ts.map +1 -1
- package/dist/src/lib/Components/CardButton/index.js +1 -1
- package/dist/src/lib/Components/CardButton/{CardButton.types.d.ts → types.d.ts} +5 -4
- package/dist/src/lib/Components/CardButton/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Icon/Icon.d.ts +6 -3
- package/dist/src/lib/Components/Icon/Icon.d.ts.map +1 -1
- package/dist/src/lib/Components/Icon/Icon.js +24 -25
- package/dist/src/lib/Components/Icon/Icon.stories.d.ts +2 -2
- package/dist/src/lib/Components/Icon/Icon.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/Icon/Icon.stories.js +73 -19
- package/dist/src/lib/Components/Icon/createIcon.d.ts +1 -1
- package/dist/src/lib/Components/Icon/createIcon.d.ts.map +1 -1
- package/dist/src/lib/Components/Icon/createIcon.js +1 -2
- package/dist/src/lib/Components/Icon/index.d.ts +1 -1
- package/dist/src/lib/Components/Icon/index.d.ts.map +1 -1
- package/dist/src/lib/Components/Icon/index.js +1 -1
- package/dist/src/lib/Components/Icon/{Icon.types.d.ts → types.d.ts} +7 -4
- package/dist/src/lib/Components/Icon/types.d.ts.map +1 -0
- package/dist/src/lib/Components/IconButton/IconButton.d.ts +2 -19
- package/dist/src/lib/Components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/src/lib/Components/IconButton/IconButton.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/IconButton/IconButton.stories.js +9 -11
- package/dist/src/lib/Components/IconButton/index.d.ts +1 -0
- package/dist/src/lib/Components/IconButton/index.d.ts.map +1 -1
- package/dist/src/lib/Components/IconButton/index.js +1 -0
- package/dist/src/lib/Components/IconButton/types.d.ts +12 -0
- package/dist/src/lib/Components/IconButton/types.d.ts.map +1 -0
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.d.ts +2 -2
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.d.ts.map +1 -1
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.figma.js +1 -1
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.js +34 -34
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.stories.d.ts +1 -1
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/InteractiveIcon/InteractiveIcon.stories.js +22 -9
- package/dist/src/lib/Components/InteractiveIcon/types.d.ts +3 -7
- package/dist/src/lib/Components/InteractiveIcon/types.d.ts.map +1 -1
- package/dist/src/lib/Components/Link/Link.d.ts +7 -77
- package/dist/src/lib/Components/Link/Link.d.ts.map +1 -1
- package/dist/src/lib/Components/Link/Link.js +59 -75
- package/dist/src/lib/Components/Link/Link.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/Link/Link.stories.js +34 -11
- package/dist/src/lib/Components/Link/index.d.ts +1 -0
- package/dist/src/lib/Components/Link/index.d.ts.map +1 -1
- package/dist/src/lib/Components/Link/index.js +1 -0
- package/dist/src/lib/Components/Link/types.d.ts +43 -0
- package/dist/src/lib/Components/Link/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Link/types.js +1 -0
- package/dist/src/lib/Components/Search/Search.stories.d.ts +6 -1
- package/dist/src/lib/Components/Search/Search.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/Search/Search.stories.js +71 -9
- package/dist/src/lib/Components/Select/Select.d.ts.map +1 -1
- package/dist/src/lib/Components/Select/Select.js +1 -17
- package/dist/src/lib/Components/Spinner/Spinner.d.ts +13 -16
- package/dist/src/lib/Components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/src/lib/Components/Spinner/Spinner.js +33 -5
- package/dist/src/lib/Components/Spinner/Spinner.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/Spinner/Spinner.stories.js +1 -1
- package/dist/src/lib/Components/Spinner/index.d.ts +1 -0
- package/dist/src/lib/Components/Spinner/index.d.ts.map +1 -1
- package/dist/src/lib/Components/Spinner/index.js +1 -0
- package/dist/src/lib/Components/Spinner/types.d.ts +15 -0
- package/dist/src/lib/Components/Spinner/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Spinner/types.js +1 -0
- package/dist/src/lib/Components/Tag/Tag.d.ts +2 -1
- package/dist/src/lib/Components/Tag/Tag.d.ts.map +1 -1
- package/dist/src/lib/Components/Tag/Tag.js +15 -4
- package/dist/src/lib/Components/Tag/Tag.stories.js +1 -1
- package/dist/src/lib/Components/Tag/Tag.types.d.ts +7 -1
- package/dist/src/lib/Components/Tag/Tag.types.d.ts.map +1 -1
- package/dist/src/lib/Components/TextInput/TextInput.stories.d.ts +8 -1
- package/dist/src/lib/Components/TextInput/TextInput.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/TextInput/TextInput.stories.js +104 -9
- package/dist/src/lib/Components/Tile/Tile.d.ts.map +1 -1
- package/dist/src/lib/Components/Tile/Tile.js +54 -8
- package/dist/src/lib/Components/Tile/types.d.ts +14 -1
- package/dist/src/lib/Components/Tile/types.d.ts.map +1 -1
- package/dist/src/lib/Components/Tooltip/Tooltip.stories.js +2 -2
- package/dist/src/lib/Components/Utility/Box/Box.d.ts +39 -0
- package/dist/src/lib/Components/Utility/Box/Box.d.ts.map +1 -0
- package/dist/src/lib/Components/{Box → Utility/Box}/Box.js +10 -11
- package/dist/src/lib/Components/Utility/Box/Box.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/{Box → Utility/Box}/Box.stories.js +13 -12
- package/dist/src/lib/Components/Utility/Box/index.d.ts +2 -0
- package/dist/src/lib/Components/Utility/Box/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Pressable/Pressable.d.ts +34 -0
- package/dist/src/lib/Components/Utility/Pressable/Pressable.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Pressable/Pressable.js +33 -0
- package/dist/src/lib/Components/Utility/Pressable/Pressable.stories.d.ts +7 -0
- package/dist/src/lib/Components/Utility/Pressable/Pressable.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Pressable/Pressable.stories.js +47 -0
- package/dist/src/lib/Components/Utility/Pressable/index.d.ts +3 -0
- package/dist/src/lib/Components/Utility/Pressable/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Pressable/index.js +1 -0
- package/dist/src/lib/Components/Utility/Pressable/types.d.ts +3 -0
- package/dist/src/lib/Components/Utility/Pressable/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Pressable/types.js +1 -0
- package/dist/src/lib/Components/Utility/Text/Text.d.ts +40 -0
- package/dist/src/lib/Components/Utility/Text/Text.d.ts.map +1 -0
- package/dist/src/lib/Components/{Text → Utility/Text}/Text.js +13 -9
- package/dist/src/lib/Components/Utility/Text/Text.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/{Text → Utility/Text}/Text.stories.js +3 -3
- package/dist/src/lib/Components/Utility/Text/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/index.d.ts +4 -0
- package/dist/src/lib/Components/Utility/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/index.js +3 -0
- package/dist/src/lib/Components/index.d.ts +1 -3
- package/dist/src/lib/Components/index.d.ts.map +1 -1
- package/dist/src/lib/Components/index.js +1 -3
- package/dist/src/lib/utils/components/InjectStylesIntoChildren.d.ts +6 -5
- package/dist/src/lib/utils/components/InjectStylesIntoChildren.d.ts.map +1 -1
- package/dist/src/lib/utils/components/InjectStylesIntoChildren.js +6 -6
- package/dist/src/styles/LumenStyleSheet.d.ts +1 -1
- package/dist/src/styles/LumenStyleSheet.d.ts.map +1 -1
- package/dist/src/styles/Provider/createStylesheetTheme.d.ts +0 -1
- package/dist/src/styles/Provider/createStylesheetTheme.d.ts.map +1 -1
- package/dist/src/styles/Provider/createStylesheetTheme.js +0 -1
- package/dist/src/styles/create/useCreate.d.ts +2 -1
- package/dist/src/styles/create/useCreate.d.ts.map +1 -1
- package/dist/src/styles/create/useCreate.js +5 -5
- package/dist/src/styles/factories/areLxPropsEqual.d.ts +3 -0
- package/dist/src/styles/factories/areLxPropsEqual.d.ts.map +1 -0
- package/dist/src/styles/factories/areLxPropsEqual.js +15 -0
- package/dist/src/styles/factories/createStyledPressable.d.ts +26 -0
- package/dist/src/styles/factories/createStyledPressable.d.ts.map +1 -0
- package/dist/src/styles/factories/createStyledPressable.js +61 -0
- package/dist/src/styles/factories/createStyledText.d.ts +15 -26
- package/dist/src/styles/factories/createStyledText.d.ts.map +1 -1
- package/dist/src/styles/factories/createStyledText.js +13 -29
- package/dist/src/styles/factories/createStyledView.d.ts +7 -27
- package/dist/src/styles/factories/createStyledView.d.ts.map +1 -1
- package/dist/src/styles/factories/createStyledView.js +10 -30
- package/dist/src/styles/factories/index.d.ts +4 -0
- package/dist/src/styles/factories/index.d.ts.map +1 -0
- package/dist/src/styles/factories/index.js +3 -0
- package/dist/src/styles/index.d.ts +2 -3
- package/dist/src/styles/index.d.ts.map +1 -1
- package/dist/src/styles/index.js +2 -3
- package/dist/src/styles/resolveStyle/resolveConfig.d.ts +7 -7
- package/dist/src/styles/resolveStyle/resolveConfig.d.ts.map +1 -1
- package/dist/src/styles/resolveStyle/resolveConfig.js +9 -9
- package/dist/src/styles/resolveStyle/resolveStyle.d.ts +6 -20
- package/dist/src/styles/resolveStyle/resolveStyle.d.ts.map +1 -1
- package/dist/src/styles/resolveStyle/resolveStyle.js +4 -29
- package/dist/src/styles/types/create.types.d.ts +1 -1
- package/dist/src/styles/types/create.types.d.ts.map +1 -1
- package/dist/src/styles/types/styled.types.d.ts +72 -50
- package/dist/src/styles/types/styled.types.d.ts.map +1 -1
- package/dist/src/styles/types/utility.types.d.ts.map +1 -1
- package/dist/src/styles/utils/index.d.ts +2 -0
- package/dist/src/styles/utils/index.d.ts.map +1 -0
- package/dist/src/styles/utils/index.js +1 -0
- package/dist/src/styles/utils/mergeStyles.d.ts +16 -0
- package/dist/src/styles/utils/mergeStyles.d.ts.map +1 -0
- package/dist/src/styles/utils/mergeStyles.js +20 -0
- package/package.json +3 -4
- package/src/lib/Components/AddressInput/AddressInput.mdx +15 -4
- package/src/lib/Components/AddressInput/AddressInput.stories.tsx +133 -17
- package/src/lib/Components/AddressInput/AddressInput.tsx +1 -1
- package/src/lib/Components/AmountInput/AmountInput.mdx +20 -1
- package/src/lib/Components/AmountInput/AmountInput.stories.tsx +180 -17
- package/src/lib/Components/AmountInput/AmountInput.tsx +24 -15
- package/src/lib/Components/Banner/Banner.test.tsx +48 -15
- package/src/lib/Components/BaseInput/BaseInput.tsx +6 -35
- package/src/lib/Components/BottomSheet/BottomSheet.stories.tsx +8 -8
- package/src/lib/Components/BottomSheet/BottomSheet.tsx +1 -1
- package/src/lib/Components/Button/BaseButton.test.tsx +149 -0
- package/src/lib/Components/Button/BaseButton.tsx +193 -148
- package/src/lib/Components/Button/Button.mdx +34 -31
- package/src/lib/Components/Button/Button.stories.tsx +37 -58
- package/src/lib/Components/Button/Button.tsx +4 -11
- package/src/lib/Components/Button/index.ts +1 -1
- package/src/lib/Components/Button/{BaseButton.types.ts → types.ts} +14 -8
- package/src/lib/Components/CardButton/CardButton.mdx +15 -25
- package/src/lib/Components/CardButton/CardButton.stories.tsx +48 -22
- package/src/lib/Components/CardButton/CardButton.test.tsx +141 -0
- package/src/lib/Components/CardButton/CardButton.tsx +142 -108
- package/src/lib/Components/CardButton/index.ts +1 -1
- package/src/lib/Components/CardButton/{CardButton.types.ts → types.ts} +4 -3
- package/src/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/src/lib/Components/Checkbox/Checkbox.test.tsx +42 -17
- package/src/lib/Components/Icon/Icon.stories.tsx +143 -73
- package/src/lib/Components/Icon/Icon.test.tsx +84 -0
- package/src/lib/Components/Icon/Icon.tsx +32 -28
- package/src/lib/Components/Icon/createIcon.ts +2 -3
- package/src/lib/Components/Icon/index.ts +1 -1
- package/src/lib/Components/Icon/{Icon.types.ts → types.ts} +4 -3
- package/src/lib/Components/IconButton/IconButton.mdx +13 -10
- package/src/lib/Components/IconButton/IconButton.stories.tsx +12 -14
- package/src/lib/Components/IconButton/IconButton.test.tsx +141 -0
- package/src/lib/Components/IconButton/IconButton.tsx +3 -13
- package/src/lib/Components/IconButton/index.ts +1 -0
- package/src/lib/Components/IconButton/types.ts +12 -0
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.figma.tsx +1 -1
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.mdx +25 -27
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.stories.tsx +82 -43
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.test.tsx +30 -19
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.tsx +78 -45
- package/src/lib/Components/InteractiveIcon/types.ts +4 -7
- package/src/lib/Components/Link/Link.mdx +8 -18
- package/src/lib/Components/Link/Link.stories.tsx +56 -25
- package/src/lib/Components/Link/Link.test.tsx +141 -51
- package/src/lib/Components/Link/Link.tsx +128 -150
- package/src/lib/Components/Link/index.ts +1 -0
- package/src/lib/Components/Link/types.ts +44 -0
- package/src/lib/Components/Search/Search.mdx +14 -1
- package/src/lib/Components/Search/Search.stories.tsx +94 -15
- package/src/lib/Components/Select/Select.test.tsx +8 -4
- package/src/lib/Components/Select/Select.tsx +4 -31
- package/src/lib/Components/Spinner/Spinner.stories.tsx +1 -5
- package/src/lib/Components/Spinner/Spinner.tsx +60 -34
- package/src/lib/Components/Spinner/index.ts +1 -0
- package/src/lib/Components/Spinner/types.ts +15 -0
- package/src/lib/Components/Switch/Switch.mdx +1 -1
- package/src/lib/Components/Tag/Tag.stories.tsx +2 -2
- package/src/lib/Components/Tag/Tag.tsx +22 -6
- package/src/lib/Components/Tag/Tag.types.ts +7 -8
- package/src/lib/Components/TextInput/TextInput.mdx +24 -4
- package/src/lib/Components/TextInput/TextInput.stories.tsx +131 -15
- package/src/lib/Components/Tile/Tile.test.tsx +100 -63
- package/src/lib/Components/Tile/Tile.tsx +64 -13
- package/src/lib/Components/Tile/types.ts +14 -1
- package/src/lib/Components/Tooltip/Tooltip.stories.tsx +2 -2
- package/src/lib/Components/Tooltip/Tooltip.test.tsx +8 -4
- package/src/lib/Components/{Box → Utility/Box}/Box.mdx +15 -13
- package/src/lib/Components/{Box → Utility/Box}/Box.stories.tsx +13 -11
- package/src/lib/Components/{Box → Utility/Box}/Box.tsx +11 -12
- package/src/lib/Components/Utility/Box/index.ts +1 -0
- package/src/lib/Components/Utility/Pressable/Pressable.mdx +103 -0
- package/src/lib/Components/Utility/Pressable/Pressable.stories.tsx +51 -0
- package/src/lib/Components/Utility/Pressable/Pressable.test.tsx +221 -0
- package/src/lib/Components/Utility/Pressable/Pressable.tsx +34 -0
- package/src/lib/Components/Utility/Pressable/index.ts +2 -0
- package/src/lib/Components/Utility/Pressable/types.ts +3 -0
- package/src/lib/Components/{Text → Utility/Text}/Text.mdx +15 -7
- package/src/lib/Components/{Text → Utility/Text}/Text.stories.tsx +3 -3
- package/src/lib/Components/Utility/Text/Text.tsx +39 -0
- package/src/lib/Components/Utility/index.ts +3 -0
- package/src/lib/Components/index.ts +1 -3
- package/src/lib/utils/components/InjectStylesIntoChildren.tsx +23 -14
- package/src/styles/Provider/createStylesheetTheme.ts +0 -1
- package/src/styles/create/useCreate.ts +8 -4
- package/src/styles/factories/areLxPropsEqual.ts +32 -0
- package/src/styles/factories/createStyledPressable.test.tsx +253 -0
- package/src/styles/factories/createStyledPressable.tsx +97 -0
- package/src/styles/factories/createStyledText.test.tsx +28 -20
- package/src/styles/factories/createStyledText.tsx +29 -49
- package/src/styles/factories/createStyledView.test.tsx +22 -16
- package/src/styles/factories/createStyledView.tsx +19 -53
- package/src/styles/factories/index.ts +3 -0
- package/src/styles/index.ts +2 -3
- package/src/styles/resolveStyle/resolveConfig.ts +16 -15
- package/src/styles/resolveStyle/resolveStyle.test.ts +13 -141
- package/src/styles/resolveStyle/resolveStyle.ts +10 -60
- package/src/styles/types/create.types.ts +1 -1
- package/src/styles/types/styled.types.ts +73 -105
- package/src/styles/types/utility.types.ts +1 -0
- package/src/styles/utils/index.ts +1 -0
- package/src/styles/utils/mergeStyles.test.ts +45 -0
- package/src/styles/utils/mergeStyles.ts +25 -0
- package/.storybook/docs/getting-started/StyleSystem.mdx +0 -133
- package/dist/src/lib/Components/Box/Box.d.ts +0 -592
- package/dist/src/lib/Components/Box/Box.d.ts.map +0 -1
- package/dist/src/lib/Components/Box/Box.stories.d.ts.map +0 -1
- package/dist/src/lib/Components/Box/Box.types.d.ts +0 -3
- package/dist/src/lib/Components/Box/Box.types.d.ts.map +0 -1
- package/dist/src/lib/Components/Box/index.d.ts +0 -3
- package/dist/src/lib/Components/Box/index.d.ts.map +0 -1
- package/dist/src/lib/Components/Button/BaseButton.types.d.ts.map +0 -1
- package/dist/src/lib/Components/CardButton/CardButton.types.d.ts.map +0 -1
- package/dist/src/lib/Components/Icon/Icon.types.d.ts.map +0 -1
- package/dist/src/lib/Components/Text/Text.d.ts +0 -602
- package/dist/src/lib/Components/Text/Text.d.ts.map +0 -1
- package/dist/src/lib/Components/Text/Text.stories.d.ts.map +0 -1
- package/dist/src/lib/Components/Text/index.d.ts.map +0 -1
- package/dist/src/lib/Components/_ToRemove/ToRemove.d.ts +0 -9
- package/dist/src/lib/Components/_ToRemove/ToRemove.d.ts.map +0 -1
- package/dist/src/lib/Components/_ToRemove/ToRemove.js +0 -43
- package/dist/src/styles/utils/styleVarianceAuthority.d.ts +0 -30
- package/dist/src/styles/utils/styleVarianceAuthority.d.ts.map +0 -1
- package/dist/src/styles/utils/styleVarianceAuthority.js +0 -97
- package/src/lib/Components/Box/Box.types.ts +0 -3
- package/src/lib/Components/Box/index.ts +0 -2
- package/src/lib/Components/Text/Text.tsx +0 -35
- package/src/lib/Components/_ToRemove/ToRemove.tsx +0 -65
- package/src/styles/utils/styleVarianceAuthority.test.ts +0 -302
- package/src/styles/utils/styleVarianceAuthority.ts +0 -154
- /package/dist/src/lib/Components/{Box/Box.types.js → Button/types.js} +0 -0
- /package/dist/src/lib/Components/{Button/BaseButton.types.js → CardButton/types.js} +0 -0
- /package/dist/src/lib/Components/{CardButton/CardButton.types.js → Icon/types.js} +0 -0
- /package/dist/src/lib/Components/{Icon/Icon.types.js → IconButton/types.js} +0 -0
- /package/dist/src/lib/Components/{Box → Utility/Box}/Box.stories.d.ts +0 -0
- /package/dist/src/lib/Components/{Box → Utility/Box}/index.js +0 -0
- /package/dist/src/lib/Components/{Text → Utility/Text}/Text.stories.d.ts +0 -0
- /package/dist/src/lib/Components/{Text → Utility/Text}/index.d.ts +0 -0
- /package/dist/src/lib/Components/{Text → Utility/Text}/index.js +0 -0
- /package/src/lib/Components/{Text → Utility/Text}/index.ts +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { describe, it, expect, jest } from '@jest/globals';
|
|
2
|
+
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
3
|
+
import { render, screen, fireEvent } from '@testing-library/react-native';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { ViewStyle } from 'react-native';
|
|
6
|
+
|
|
7
|
+
import { Plus, Settings } from '../../Symbols';
|
|
8
|
+
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
9
|
+
import { BaseButton } from './BaseButton';
|
|
10
|
+
|
|
11
|
+
const renderWithProvider = (component: React.ReactElement) => {
|
|
12
|
+
return render(
|
|
13
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
14
|
+
{component}
|
|
15
|
+
</ThemeProvider>,
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe('BaseButton Component', () => {
|
|
20
|
+
describe('Rendering', () => {
|
|
21
|
+
it('should render with text content and correct accessibility role', () => {
|
|
22
|
+
renderWithProvider(<BaseButton testID='button'>Click me</BaseButton>);
|
|
23
|
+
const button = screen.getByTestId('button');
|
|
24
|
+
expect(button).toBeTruthy();
|
|
25
|
+
expect(screen.getByText('Click me')).toBeTruthy();
|
|
26
|
+
expect(button.props.accessibilityRole).toBe('button');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('Appearances', () => {
|
|
31
|
+
it.each([
|
|
32
|
+
'base',
|
|
33
|
+
'accent',
|
|
34
|
+
'gray',
|
|
35
|
+
'transparent',
|
|
36
|
+
'no-background',
|
|
37
|
+
'red',
|
|
38
|
+
] as const)('should render with %s appearance', (appearance) => {
|
|
39
|
+
renderWithProvider(
|
|
40
|
+
<BaseButton testID='button' appearance={appearance}>
|
|
41
|
+
{appearance}
|
|
42
|
+
</BaseButton>,
|
|
43
|
+
);
|
|
44
|
+
expect(screen.getByTestId('button')).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('Sizes', () => {
|
|
49
|
+
it.each(['xs', 'sm', 'md', 'lg'] as const)(
|
|
50
|
+
'should render with %s size',
|
|
51
|
+
(size) => {
|
|
52
|
+
renderWithProvider(
|
|
53
|
+
<BaseButton testID='button' size={size}>
|
|
54
|
+
{size}
|
|
55
|
+
</BaseButton>,
|
|
56
|
+
);
|
|
57
|
+
expect(screen.getByTestId('button')).toBeTruthy();
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('Icons', () => {
|
|
63
|
+
it('should render with icon and text', () => {
|
|
64
|
+
renderWithProvider(
|
|
65
|
+
<BaseButton testID='button' icon={Plus}>
|
|
66
|
+
Add Item
|
|
67
|
+
</BaseButton>,
|
|
68
|
+
);
|
|
69
|
+
expect(screen.getByTestId('button')).toBeTruthy();
|
|
70
|
+
expect(screen.getByText('Add Item')).toBeTruthy();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should render as icon-only when no children provided', () => {
|
|
74
|
+
renderWithProvider(<BaseButton testID='button' icon={Settings} />);
|
|
75
|
+
expect(screen.getByTestId('button')).toBeTruthy();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('States', () => {
|
|
80
|
+
it('should be disabled when disabled prop is true', () => {
|
|
81
|
+
renderWithProvider(
|
|
82
|
+
<BaseButton testID='button' disabled>
|
|
83
|
+
Disabled
|
|
84
|
+
</BaseButton>,
|
|
85
|
+
);
|
|
86
|
+
const button = screen.getByTestId('button');
|
|
87
|
+
expect(button.props.accessibilityState.disabled).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should render loading state with spinner', () => {
|
|
91
|
+
renderWithProvider(
|
|
92
|
+
<BaseButton testID='button' loading>
|
|
93
|
+
Loading
|
|
94
|
+
</BaseButton>,
|
|
95
|
+
);
|
|
96
|
+
expect(screen.getByTestId('button')).toBeTruthy();
|
|
97
|
+
expect(screen.getByText('Loading')).toBeTruthy();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should render correctly with isFull prop', () => {
|
|
101
|
+
renderWithProvider(
|
|
102
|
+
<BaseButton testID='button' isFull>
|
|
103
|
+
Full Width
|
|
104
|
+
</BaseButton>,
|
|
105
|
+
);
|
|
106
|
+
const button = screen.getByTestId('base-button-content');
|
|
107
|
+
expect(button.props.style.width).toBe('100%');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('Interactions', () => {
|
|
112
|
+
it('should call onPress when pressed', () => {
|
|
113
|
+
const handlePress = jest.fn();
|
|
114
|
+
renderWithProvider(
|
|
115
|
+
<BaseButton testID='button' onPress={handlePress}>
|
|
116
|
+
Press me
|
|
117
|
+
</BaseButton>,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
fireEvent.press(screen.getByTestId('button'));
|
|
121
|
+
expect(handlePress).toHaveBeenCalledTimes(1);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should not call onPress when disabled', () => {
|
|
125
|
+
const handlePress = jest.fn();
|
|
126
|
+
renderWithProvider(
|
|
127
|
+
<BaseButton testID='button' onPress={handlePress} disabled>
|
|
128
|
+
Disabled
|
|
129
|
+
</BaseButton>,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
fireEvent.press(screen.getByTestId('button'));
|
|
133
|
+
expect(handlePress).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe('Styling', () => {
|
|
138
|
+
it('should apply custom style and lx props', () => {
|
|
139
|
+
const customStyle: ViewStyle = { marginTop: 16 };
|
|
140
|
+
renderWithProvider(
|
|
141
|
+
<BaseButton testID='button' style={customStyle} lx={{ padding: 's8' }}>
|
|
142
|
+
Styled
|
|
143
|
+
</BaseButton>,
|
|
144
|
+
);
|
|
145
|
+
const button = screen.getByTestId('button');
|
|
146
|
+
expect(button.props.style).toBeDefined();
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -1,118 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { cn } from '../../utils';
|
|
1
|
+
import React, { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { LumenStyleSheet, mergeStyles } from '../../../styles';
|
|
5
4
|
import { IconSize } from '../Icon';
|
|
6
5
|
import { Spinner } from '../Spinner';
|
|
7
|
-
import {
|
|
6
|
+
import { Pressable } from '../Utility';
|
|
7
|
+
import { BaseButtonProps } from './types';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
md: 'px-16 py-12',
|
|
27
|
-
lg: 'p-16',
|
|
28
|
-
},
|
|
29
|
-
isFull: {
|
|
30
|
-
true: 'w-full',
|
|
31
|
-
},
|
|
32
|
-
loading: {
|
|
33
|
-
true: '',
|
|
34
|
-
},
|
|
35
|
-
iconOnly: {
|
|
36
|
-
true: '',
|
|
37
|
-
false: '',
|
|
38
|
-
},
|
|
39
|
-
disabled: {
|
|
40
|
-
true: 'bg-disabled text-disabled active:bg-disabled',
|
|
41
|
-
false: '',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
compoundVariants: [
|
|
45
|
-
{
|
|
46
|
-
size: 'xs',
|
|
47
|
-
iconOnly: true,
|
|
48
|
-
className: 'p-8',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
size: 'sm',
|
|
52
|
-
iconOnly: true,
|
|
53
|
-
className: 'p-12',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
size: 'md',
|
|
57
|
-
iconOnly: true,
|
|
58
|
-
className: 'p-12',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
size: 'lg',
|
|
62
|
-
iconOnly: true,
|
|
63
|
-
className: 'p-16',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
iconOnly: false,
|
|
67
|
-
className: 'gap-8',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
appearance: 'no-background',
|
|
71
|
-
disabled: true,
|
|
72
|
-
className: 'bg-base-transparent',
|
|
9
|
+
type Appearance = NonNullable<BaseButtonProps['appearance']>;
|
|
10
|
+
type Size = NonNullable<BaseButtonProps['size']>;
|
|
11
|
+
|
|
12
|
+
const iconSizeMap: Record<Size, IconSize> = {
|
|
13
|
+
xs: 16,
|
|
14
|
+
sm: 20,
|
|
15
|
+
md: 24,
|
|
16
|
+
lg: 24,
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
const useRootStyles = ({ isFull }: { isFull: boolean }) => {
|
|
20
|
+
return LumenStyleSheet.useCreate(
|
|
21
|
+
(t) => {
|
|
22
|
+
return {
|
|
23
|
+
root: {
|
|
24
|
+
width: isFull ? t.sizes.full : 'auto',
|
|
25
|
+
borderRadius: t.borderRadius.full,
|
|
73
26
|
},
|
|
74
|
-
|
|
75
|
-
defaultVariants: {
|
|
76
|
-
appearance: 'base',
|
|
77
|
-
size: 'md',
|
|
78
|
-
isFull: false,
|
|
79
|
-
iconOnly: false,
|
|
80
|
-
disabled: false,
|
|
81
|
-
},
|
|
27
|
+
};
|
|
82
28
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
variants: {
|
|
86
|
-
appearance: {
|
|
87
|
-
base: 'text-on-interactive',
|
|
88
|
-
accent: 'text-on-accent',
|
|
89
|
-
red: 'text-error',
|
|
90
|
-
gray: 'text-base',
|
|
91
|
-
'no-background': 'text-base',
|
|
92
|
-
transparent: 'text-base',
|
|
93
|
-
},
|
|
94
|
-
disabled: {
|
|
95
|
-
true: 'text-disabled',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
}),
|
|
29
|
+
[isFull],
|
|
30
|
+
);
|
|
99
31
|
};
|
|
100
32
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
33
|
+
const useStyles = ({
|
|
34
|
+
appearance,
|
|
35
|
+
size,
|
|
36
|
+
disabled,
|
|
37
|
+
pressed,
|
|
38
|
+
iconOnly,
|
|
39
|
+
isFull,
|
|
40
|
+
}: {
|
|
41
|
+
appearance: Appearance;
|
|
42
|
+
size: Size;
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
pressed: boolean;
|
|
45
|
+
iconOnly: boolean;
|
|
46
|
+
isFull: boolean;
|
|
47
|
+
}) => {
|
|
48
|
+
return LumenStyleSheet.useCreate(
|
|
49
|
+
(t) => {
|
|
50
|
+
const bgColors: Record<Appearance, string> = {
|
|
51
|
+
base: t.colors.bg.interactive,
|
|
52
|
+
gray: t.colors.bg.muted,
|
|
53
|
+
accent: t.colors.bg.accent,
|
|
54
|
+
transparent: t.colors.bg.mutedTransparent,
|
|
55
|
+
'no-background': 'transparent',
|
|
56
|
+
red: t.colors.bg.error,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const pressedBgColors: Record<Appearance, string> = {
|
|
60
|
+
base: t.colors.bg.interactivePressed,
|
|
61
|
+
gray: t.colors.bg.mutedPressed,
|
|
62
|
+
accent: t.colors.bg.accentPressed,
|
|
63
|
+
transparent: t.colors.bg.mutedTransparentPressed,
|
|
64
|
+
'no-background': t.colors.bg.baseTransparentPressed,
|
|
65
|
+
red: t.colors.bg.errorPressed,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const textColors: Record<Appearance, string> = {
|
|
69
|
+
base: t.colors.text.onInteractive,
|
|
70
|
+
accent: t.colors.text.onAccent,
|
|
71
|
+
red: t.colors.text.error,
|
|
72
|
+
gray: t.colors.text.base,
|
|
73
|
+
'no-background': t.colors.text.base,
|
|
74
|
+
transparent: t.colors.text.base,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const sizeStyles: Record<Size, { paddingH: number; paddingV: number }> = {
|
|
78
|
+
xs: { paddingH: t.spacings.s12, paddingV: t.spacings.s8 },
|
|
79
|
+
sm: { paddingH: t.spacings.s16, paddingV: t.spacings.s10 },
|
|
80
|
+
md: { paddingH: t.spacings.s16, paddingV: t.spacings.s12 },
|
|
81
|
+
lg: { paddingH: t.spacings.s16, paddingV: t.spacings.s16 },
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const iconOnlyPadding: Record<Size, number> = {
|
|
85
|
+
xs: t.spacings.s8,
|
|
86
|
+
sm: t.spacings.s10,
|
|
87
|
+
md: t.spacings.s12,
|
|
88
|
+
lg: t.spacings.s16,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const typography =
|
|
92
|
+
size === 'xs' || size === 'sm'
|
|
93
|
+
? t.typographies.body2SemiBold
|
|
94
|
+
: t.typographies.body1SemiBold;
|
|
95
|
+
|
|
96
|
+
const currentSizeStyle = sizeStyles[size];
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
container: mergeStyles(
|
|
100
|
+
{
|
|
101
|
+
flexDirection: 'row',
|
|
102
|
+
alignItems: 'center',
|
|
103
|
+
justifyContent: 'center',
|
|
104
|
+
backgroundColor: bgColors[appearance],
|
|
105
|
+
},
|
|
106
|
+
iconOnly
|
|
107
|
+
? { padding: iconOnlyPadding[size] }
|
|
108
|
+
: {
|
|
109
|
+
paddingHorizontal: currentSizeStyle.paddingH,
|
|
110
|
+
paddingVertical: currentSizeStyle.paddingV,
|
|
111
|
+
gap: t.spacings.s8,
|
|
112
|
+
},
|
|
113
|
+
isFull && { width: t.sizes.full },
|
|
114
|
+
pressed && { backgroundColor: pressedBgColors[appearance] },
|
|
115
|
+
disabled && { backgroundColor: t.colors.bg.disabled },
|
|
116
|
+
appearance === 'no-background' &&
|
|
117
|
+
disabled && { backgroundColor: 'transparent' },
|
|
118
|
+
),
|
|
119
|
+
label: mergeStyles(typography, {
|
|
120
|
+
color: disabled ? t.colors.text.disabled : textColors[appearance],
|
|
121
|
+
textAlign: 'left',
|
|
122
|
+
}),
|
|
123
|
+
icon: {
|
|
124
|
+
flexShrink: 0,
|
|
125
|
+
color: disabled ? t.colors.text.disabled : textColors[appearance],
|
|
126
|
+
},
|
|
127
|
+
};
|
|
113
128
|
},
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
[appearance, size, disabled, pressed, iconOnly, isFull],
|
|
130
|
+
);
|
|
131
|
+
};
|
|
116
132
|
|
|
117
133
|
/**
|
|
118
134
|
* Base button component
|
|
@@ -125,66 +141,95 @@ export const BaseButton = React.forwardRef<
|
|
|
125
141
|
>(
|
|
126
142
|
(
|
|
127
143
|
{
|
|
128
|
-
|
|
144
|
+
lx,
|
|
145
|
+
style,
|
|
129
146
|
children,
|
|
130
147
|
appearance = 'base',
|
|
131
148
|
size = 'md',
|
|
132
|
-
isFull,
|
|
133
|
-
loading,
|
|
149
|
+
isFull = false,
|
|
150
|
+
loading = false,
|
|
134
151
|
icon: IconProp,
|
|
135
|
-
disabled,
|
|
152
|
+
disabled = false,
|
|
136
153
|
...props
|
|
137
154
|
},
|
|
138
155
|
ref,
|
|
139
156
|
) => {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
const iconSizeMap: { [key: string]: IconSize } = {
|
|
143
|
-
xs: 16,
|
|
144
|
-
sm: 20,
|
|
145
|
-
md: 24,
|
|
146
|
-
lg: 24,
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const calculatedIconSize = size ? iconSizeMap[size] : 24;
|
|
157
|
+
const rootStyles = useRootStyles({ isFull });
|
|
150
158
|
|
|
151
159
|
return (
|
|
152
160
|
<Pressable
|
|
153
161
|
ref={ref}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
isFull,
|
|
160
|
-
loading,
|
|
161
|
-
iconOnly,
|
|
162
|
-
disabled,
|
|
163
|
-
}),
|
|
164
|
-
)}
|
|
165
|
-
disabled={disabled ?? false}
|
|
162
|
+
lx={lx}
|
|
163
|
+
style={[style, rootStyles.root]}
|
|
164
|
+
disabled={disabled}
|
|
165
|
+
accessibilityRole='button'
|
|
166
|
+
accessibilityState={{ disabled }}
|
|
166
167
|
{...props}
|
|
167
168
|
>
|
|
168
|
-
{
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/>
|
|
179
|
-
)}
|
|
180
|
-
{children && (
|
|
181
|
-
<Text className={buttonVariants.label({ appearance, disabled })}>
|
|
169
|
+
{({ pressed }) => (
|
|
170
|
+
<BaseButtonContent
|
|
171
|
+
appearance={appearance}
|
|
172
|
+
size={size}
|
|
173
|
+
disabled={disabled}
|
|
174
|
+
pressed={pressed}
|
|
175
|
+
isFull={isFull}
|
|
176
|
+
loading={loading}
|
|
177
|
+
IconProp={IconProp}
|
|
178
|
+
>
|
|
182
179
|
{children}
|
|
183
|
-
</
|
|
180
|
+
</BaseButtonContent>
|
|
184
181
|
)}
|
|
185
182
|
</Pressable>
|
|
186
183
|
);
|
|
187
184
|
},
|
|
188
185
|
);
|
|
189
186
|
|
|
187
|
+
type BaseButtonContentProps = PropsWithChildren<{
|
|
188
|
+
appearance: Appearance;
|
|
189
|
+
size: Size;
|
|
190
|
+
disabled: boolean;
|
|
191
|
+
pressed: boolean;
|
|
192
|
+
isFull: boolean;
|
|
193
|
+
loading: boolean;
|
|
194
|
+
IconProp?: BaseButtonProps['icon'];
|
|
195
|
+
}>;
|
|
196
|
+
|
|
197
|
+
const BaseButtonContent: FC<BaseButtonContentProps> = ({
|
|
198
|
+
appearance,
|
|
199
|
+
size,
|
|
200
|
+
disabled,
|
|
201
|
+
pressed,
|
|
202
|
+
isFull,
|
|
203
|
+
loading,
|
|
204
|
+
IconProp,
|
|
205
|
+
children,
|
|
206
|
+
}) => {
|
|
207
|
+
const calculatedIconSize = iconSizeMap[size];
|
|
208
|
+
const iconOnly = Boolean(IconProp && !children);
|
|
209
|
+
const styles = useStyles({
|
|
210
|
+
appearance,
|
|
211
|
+
size,
|
|
212
|
+
disabled,
|
|
213
|
+
pressed,
|
|
214
|
+
iconOnly,
|
|
215
|
+
isFull,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<View style={styles.container} testID='base-button-content'>
|
|
220
|
+
{loading && (
|
|
221
|
+
<Spinner size={calculatedIconSize} color={styles.icon.color} />
|
|
222
|
+
)}
|
|
223
|
+
{!loading && IconProp && (
|
|
224
|
+
<IconProp size={calculatedIconSize} style={styles.icon} />
|
|
225
|
+
)}
|
|
226
|
+
{children && (
|
|
227
|
+
<Text style={styles.label} numberOfLines={2}>
|
|
228
|
+
{children}
|
|
229
|
+
</Text>
|
|
230
|
+
)}
|
|
231
|
+
</View>
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
|
|
190
235
|
BaseButton.displayName = 'BaseButton';
|
|
@@ -4,6 +4,7 @@ import { Button } from './Button';
|
|
|
4
4
|
import { CustomTabs, Tab } from '../../../../.storybook/components';
|
|
5
5
|
import { DoVsDontRow, DoBlockItem, DontBlockItem } from '../../../../.storybook/components/DoVsDont';
|
|
6
6
|
import CommonRulesDoAndDont from '../../../../.storybook/docs/CommonRulesDoAndDont.mdx';
|
|
7
|
+
import { Box } from '../Utility';
|
|
7
8
|
|
|
8
9
|
<Meta title='Action/Button' of={ButtonStories} />
|
|
9
10
|
|
|
@@ -60,23 +61,14 @@ Buttons' contents can be of two types:
|
|
|
60
61
|
|
|
61
62
|
Buttons come in four different sizes:
|
|
62
63
|
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
64
|
+
- `sm` (**40px**)
|
|
65
|
+
- `md` (**48px**, default)
|
|
66
|
+
- `lg` (**56px**)
|
|
66
67
|
|
|
67
|
-
> Note: For
|
|
68
|
+
> Note: For `xs` size (32 px), use the [IconButton](/docs/action-iconbutton--docs) component instead.
|
|
68
69
|
|
|
69
70
|
<Canvas of={ButtonStories.SizesShowcase} />
|
|
70
71
|
|
|
71
|
-
> **⚠️ Important**: Icon sizes are automatically managed by the Button component based on the selected size. Never override the icon size using className or style props, as this will break the visual consistency of the design system. The Button component ensures proper scaling and alignment of icons across all sizes.
|
|
72
|
-
>
|
|
73
|
-
> ```tsx
|
|
74
|
-
> // ✅ Correct: Let Button handle icon sizing
|
|
75
|
-
> <Button size="sm" icon={Settings} accessibilityLabel="Settings">Settings</Button>
|
|
76
|
-
>
|
|
77
|
-
> // ❌ Wrong: Don't override icon size [it's not gonna work even if you try]
|
|
78
|
-
> <Button size="sm" icon={Settings} className="w-6 h-6" accessibilityLabel="Settings">Settings</Button>
|
|
79
|
-
> ```
|
|
80
72
|
|
|
81
73
|
### States
|
|
82
74
|
|
|
@@ -90,7 +82,7 @@ Buttons dynamically adapt their width to the size of their content, while keepin
|
|
|
90
82
|
|
|
91
83
|
When a label is too long, it's truncated to 2 lines, with a maximum width of the button's container:
|
|
92
84
|
|
|
93
|
-
<Canvas of={ButtonStories.
|
|
85
|
+
<Canvas of={ButtonStories.LabelTruncate} />
|
|
94
86
|
|
|
95
87
|
> The Button must dynamically resize to its container constraints.
|
|
96
88
|
|
|
@@ -130,13 +122,26 @@ function MyComponent() {
|
|
|
130
122
|
|
|
131
123
|
### Custom Styling
|
|
132
124
|
|
|
133
|
-
While the component comes with predefined styles, you can extend them using
|
|
125
|
+
While the component comes with predefined styles, you can extend them using the `lx` prop for token-based styling:
|
|
134
126
|
|
|
135
127
|
```tsx
|
|
136
128
|
<Button
|
|
137
129
|
size='md'
|
|
138
130
|
appearance='base'
|
|
139
|
-
|
|
131
|
+
lx={{ marginTop: 's4' }} // Custom margin top using design tokens
|
|
132
|
+
onPress={() => {}}
|
|
133
|
+
>
|
|
134
|
+
Custom Button
|
|
135
|
+
</Button>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
You can also use the `style` prop for escape-hatch styling when needed:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<Button
|
|
142
|
+
size='md'
|
|
143
|
+
appearance='base'
|
|
144
|
+
style={{ marginTop: 16 }} // Raw style values
|
|
140
145
|
onPress={() => {}}
|
|
141
146
|
>
|
|
142
147
|
Custom Button
|
|
@@ -207,12 +212,13 @@ The Button component is built on React Native's `Pressable` and accepts all its
|
|
|
207
212
|
|
|
208
213
|
The following guidelines are based on our [Button Component API Design ADR](https://ledgerhq.atlassian.net/wiki/spaces/DLS/pages/6003949581/ADR-001+Button+Component+API+Design). These decisions were made to ensure consistency, maintainability, and proper implementation of our design system principles.
|
|
209
214
|
|
|
210
|
-
<
|
|
215
|
+
<Box lx={{ flexDirection: 'column', gap: 's24' }}>
|
|
211
216
|
<DoVsDontRow>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
<DoBlockItem
|
|
218
|
+
title='Use icon prop'
|
|
219
|
+
description='Pass icon as a component reference for proper sizing and alignment'
|
|
220
|
+
>
|
|
221
|
+
|
|
216
222
|
|
|
217
223
|
{/* prettier-ignore */}
|
|
218
224
|
```tsx
|
|
@@ -291,13 +297,13 @@ import { Settings } from '@ledgerhq/lumen-ui-rnative/symbols';
|
|
|
291
297
|
|
|
292
298
|
</DoBlockItem>
|
|
293
299
|
<DontBlockItem
|
|
294
|
-
title="Don't use
|
|
295
|
-
description='Avoid using
|
|
300
|
+
title="Don't use style for full width"
|
|
301
|
+
description='Avoid using style to control button width'
|
|
296
302
|
>
|
|
297
303
|
|
|
298
304
|
{/* prettier-ignore */}
|
|
299
305
|
```tsx
|
|
300
|
-
<Button
|
|
306
|
+
<Button style={{ width: '100%' }} onPress={() => {}}>
|
|
301
307
|
Full Width
|
|
302
308
|
</Button>
|
|
303
309
|
```
|
|
@@ -331,13 +337,10 @@ import { Settings } from '@ledgerhq/lumen-ui-rnative/symbols';
|
|
|
331
337
|
Clickable Looking Button
|
|
332
338
|
</Button>
|
|
333
339
|
```
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
<CommonRulesDoAndDont />
|
|
340
|
-
</div>
|
|
340
|
+
</DontBlockItem>
|
|
341
|
+
</DoVsDontRow>
|
|
342
|
+
<CommonRulesDoAndDont />
|
|
343
|
+
</Box>
|
|
341
344
|
|
|
342
345
|
## Platform Considerations
|
|
343
346
|
|