@jobber/components-native 0.75.3-POC-fixing-d44fac2.136 → 0.75.3-POC-fixing-ffcd368.137
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/dist/package.json +4 -3
- package/dist/src/ActionItem/ActionItem.js +2 -1
- package/dist/src/ActionItem/ActionItem.style.js +23 -22
- package/dist/src/ActionItem/ActionItemGroup.js +2 -1
- package/dist/src/ActionItem/components/ActionItemContainer.js +4 -2
- package/dist/src/ActionItem/components/ActionItemContainer.style.js +12 -11
- package/dist/src/ActivityIndicator/ActivityIndicator.js +2 -1
- package/dist/src/AtlantisThemeContext/AtlantisThemeContext.js +32 -0
- package/dist/src/AtlantisThemeContext/buildThemedStyles.js +38 -0
- package/dist/src/AtlantisThemeContext/index.js +2 -0
- package/dist/src/AtlantisThemeContext/types.js +1 -0
- package/dist/src/AutoLink/AutoLink.js +2 -1
- package/dist/src/Banner/Banner.js +4 -3
- package/dist/src/Banner/Banner.style.js +34 -33
- package/dist/src/Banner/components/BannerIcon/BannerIcon.js +2 -1
- package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +17 -16
- package/dist/src/BottomSheet/BottomSheet.js +8 -7
- package/dist/src/BottomSheet/BottomSheet.style.js +27 -25
- package/dist/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.js +2 -1
- package/dist/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.js +18 -17
- package/dist/src/Button/Button.js +13 -8
- package/dist/src/Button/Button.style.js +97 -95
- package/dist/src/ButtonGroup/ButtonGroup.js +2 -1
- package/dist/src/ButtonGroup/ButtonGroup.style.js +18 -17
- package/dist/src/Card/Card.js +4 -3
- package/dist/src/Card/Card.style.js +31 -30
- package/dist/src/Card/components/InternalCardHeader.js +2 -1
- package/dist/src/Card/components/InternalCardHeader.style.js +16 -15
- package/dist/src/Checkbox/Checkbox.js +4 -2
- package/dist/src/Checkbox/Checkbox.style.js +30 -29
- package/dist/src/Checkbox/CheckboxGroup.js +2 -1
- package/dist/src/Checkbox/CheckboxGroup.style.js +14 -13
- package/dist/src/Chip/Chip.js +6 -4
- package/dist/src/Chip/Chip.style.js +32 -31
- package/dist/src/Content/Content.js +14 -9
- package/dist/src/Content/ContentHorizontal.style.js +30 -29
- package/dist/src/Content/ContentSpaceAround.style.js +22 -21
- package/dist/src/Content/ContentVertical.style.js +30 -29
- package/dist/src/ContentOverlay/ContentOverlay.js +4 -2
- package/dist/src/ContentOverlay/ContentOverlay.style.js +55 -54
- package/dist/src/Disclosure/Disclosure.js +10 -7
- package/dist/src/Disclosure/Disclosure.style.js +21 -20
- package/dist/src/Divider/Divider.js +4 -2
- package/dist/src/Divider/DividerHorizontal.style.js +23 -22
- package/dist/src/Divider/DividerVertical.style.js +26 -25
- package/dist/src/EmptyState/EmptyState.js +2 -1
- package/dist/src/EmptyState/EmptyState.style.js +8 -7
- package/dist/src/ErrorMessageWrapper/ErrorMessageWrapper.js +6 -5
- package/dist/src/ErrorMessageWrapper/ErrorMessageWrapper.style.js +31 -30
- package/dist/src/Flex/Flex.styles.js +2 -2
- package/dist/src/Form/Form.js +2 -1
- package/dist/src/Form/Form.style.js +33 -32
- package/dist/src/Form/components/FormActionBar/FormActionBar.js +2 -1
- package/dist/src/Form/components/FormActionBar/FormActionBar.style.js +5 -4
- package/dist/src/Form/components/FormBody/FormBody.js +2 -1
- package/dist/src/Form/components/FormBody/FormBody.style.js +26 -25
- package/dist/src/Form/components/FormMask/FormMask.js +2 -1
- package/dist/src/Form/components/FormMask/FormMask.style.js +15 -14
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +2 -1
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.js +17 -16
- package/dist/src/FormatFile/FormatFile.js +2 -1
- package/dist/src/FormatFile/FormatFile.style.js +18 -15
- package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.js +2 -1
- package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.style.js +10 -9
- package/dist/src/FormatFile/components/FileView/FileView.js +2 -1
- package/dist/src/FormatFile/components/FileView/FileView.style.js +64 -63
- package/dist/src/FormatFile/components/MediaView/MediaView.js +8 -7
- package/dist/src/FormatFile/components/MediaView/MediaView.style.js +27 -26
- package/dist/src/FormatFile/components/ProgressBar/ProgressBar.js +2 -1
- package/dist/src/FormatFile/components/ProgressBar/ProgressBar.style.js +15 -14
- package/dist/src/Glimmer/Glimmer.js +6 -3
- package/dist/src/Glimmer/Glimmer.shape.style.js +16 -15
- package/dist/src/Glimmer/Glimmer.size.style.js +9 -8
- package/dist/src/Glimmer/Glimmer.style.js +21 -19
- package/dist/src/IconButton/IconButton.js +2 -1
- package/dist/src/IconButton/IconButton.style.js +10 -9
- package/dist/src/InputFieldWrapper/CommonInputStyles.style.js +47 -33
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +4 -2
- package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +121 -116
- package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.js +2 -1
- package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.style.js +25 -24
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +7 -3
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +7 -3
- package/dist/src/InputFieldWrapper/index.js +1 -1
- package/dist/src/InputPressable/InputPressable.js +4 -2
- package/dist/src/InputPressable/InputPressable.style.js +24 -22
- package/dist/src/InputText/InputText.js +4 -2
- package/dist/src/InputText/InputText.style.js +23 -22
- package/dist/src/InputText/context/InputAccessoriesProvider.js +2 -1
- package/dist/src/InputText/context/InputAccessoriesProvider.style.js +21 -19
- package/dist/src/Menu/Menu.js +6 -4
- package/dist/src/Menu/Menu.style.js +5 -4
- package/dist/src/Menu/components/MenuOption/MenuOption.js +4 -2
- package/dist/src/Menu/components/MenuOption/MenuOption.style.js +10 -9
- package/dist/src/Menu/components/Overlay/Overlay.js +2 -1
- package/dist/src/Menu/components/Overlay/Overlay.style.js +5 -3
- package/dist/src/Menu/utils.js +1 -2
- package/dist/src/ProgressBar/ProgressBar.js +6 -4
- package/dist/src/ProgressBar/ProgressBar.style.js +36 -35
- package/dist/src/ProgressBar/ProgressBarInner.js +2 -1
- package/dist/src/ProgressBar/ProgressBarStepped.js +7 -2
- package/dist/src/Select/Select.js +2 -1
- package/dist/src/Select/Select.style.js +48 -45
- package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.js +2 -1
- package/dist/src/Select/components/SelectPressable/SelectPressable.js +2 -1
- package/dist/src/Select/components/SelectPressable/SelectPressable.style.js +7 -6
- package/dist/src/StatusLabel/StatusLabel.js +6 -4
- package/dist/src/StatusLabel/StatusLabel.style.js +28 -28
- package/dist/src/Switch/Switch.js +2 -1
- package/dist/src/Switch/Switch.styles.js +20 -19
- package/dist/src/Switch/components/BaseSwitch/BaseSwitch.js +5 -4
- package/dist/src/Text/Text.js +2 -2
- package/dist/src/TextList/TextList.js +2 -1
- package/dist/src/TextList/TextList.style.js +16 -15
- package/dist/src/ThumbnailList/ThumbnailList.js +2 -1
- package/dist/src/ThumbnailList/ThumbnailList.style.js +49 -48
- package/dist/src/Toast/Toast.js +9 -6
- package/dist/src/Toast/Toast.styles.js +30 -29
- package/dist/src/Typography/Typography.js +18 -13
- package/dist/src/Typography/Typography.style.js +16 -21
- package/dist/src/Typography/index.js +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/utils/design/index.js +5 -0
- package/dist/src/utils/meta/meta.json +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/ActionItem/ActionItem.style.d.ts +1 -1
- package/dist/types/src/ActionItem/components/ActionItemContainer.style.d.ts +1 -1
- package/dist/types/src/AtlantisThemeContext/AtlantisThemeContext.d.ts +4 -0
- package/dist/types/src/AtlantisThemeContext/buildThemedStyles.d.ts +32 -0
- package/dist/types/src/AtlantisThemeContext/index.d.ts +3 -0
- package/dist/types/src/AtlantisThemeContext/types.d.ts +27 -0
- package/dist/types/src/Banner/Banner.style.d.ts +1 -1
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.style.d.ts +1 -1
- package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +1 -1
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.d.ts +1 -1
- package/dist/types/src/Button/Button.d.ts +14 -1
- package/dist/types/src/Button/Button.style.d.ts +1 -1
- package/dist/types/src/ButtonGroup/ButtonGroup.style.d.ts +1 -1
- package/dist/types/src/Card/Card.style.d.ts +1 -1
- package/dist/types/src/Card/components/InternalCardHeader.style.d.ts +1 -1
- package/dist/types/src/Checkbox/Checkbox.style.d.ts +1 -1
- package/dist/types/src/Checkbox/CheckboxGroup.style.d.ts +1 -1
- package/dist/types/src/Chip/Chip.style.d.ts +1 -1
- package/dist/types/src/Content/Content.d.ts +12 -1
- package/dist/types/src/Content/ContentHorizontal.style.d.ts +1 -1
- package/dist/types/src/Content/ContentSpaceAround.style.d.ts +1 -1
- package/dist/types/src/Content/ContentVertical.style.d.ts +1 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.style.d.ts +1 -1
- package/dist/types/src/Disclosure/Disclosure.style.d.ts +1 -1
- package/dist/types/src/Divider/DividerHorizontal.style.d.ts +1 -1
- package/dist/types/src/Divider/DividerVertical.style.d.ts +1 -1
- package/dist/types/src/EmptyState/EmptyState.style.d.ts +1 -1
- package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.style.d.ts +1 -1
- package/dist/types/src/Flex/Flex.styles.d.ts +1 -1
- package/dist/types/src/Form/Form.style.d.ts +1 -1
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.style.d.ts +1 -1
- package/dist/types/src/Form/components/FormBody/FormBody.style.d.ts +1 -1
- package/dist/types/src/Form/components/FormMask/FormMask.style.d.ts +1 -1
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.d.ts +1 -1
- package/dist/types/src/FormatFile/FormatFile.style.d.ts +2 -1
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.style.d.ts +1 -1
- package/dist/types/src/FormatFile/components/FileView/FileView.style.d.ts +1 -1
- package/dist/types/src/FormatFile/components/MediaView/MediaView.style.d.ts +1 -1
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.style.d.ts +1 -1
- package/dist/types/src/Glimmer/Glimmer.d.ts +6 -5
- package/dist/types/src/Glimmer/Glimmer.shape.style.d.ts +1 -1
- package/dist/types/src/Glimmer/Glimmer.size.style.d.ts +1 -1
- package/dist/types/src/Glimmer/Glimmer.style.d.ts +1 -1
- package/dist/types/src/IconButton/IconButton.style.d.ts +1 -1
- package/dist/types/src/InputFieldWrapper/CommonInputStyles.style.d.ts +10 -32
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +2 -16
- package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.style.d.ts +1 -1
- package/dist/types/src/InputFieldWrapper/index.d.ts +1 -1
- package/dist/types/src/InputPressable/InputPressable.d.ts +12 -4
- package/dist/types/src/InputPressable/InputPressable.style.d.ts +1 -1
- package/dist/types/src/InputText/InputText.style.d.ts +1 -1
- package/dist/types/src/InputText/context/InputAccessoriesProvider.style.d.ts +1 -1
- package/dist/types/src/Menu/Menu.style.d.ts +1 -1
- package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +1 -1
- package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +1 -1
- package/dist/types/src/Menu/utils.d.ts +2 -1
- package/dist/types/src/ProgressBar/ProgressBar.style.d.ts +1 -1
- package/dist/types/src/ProgressBar/ProgressBarStepped.d.ts +2 -1
- package/dist/types/src/Select/Select.style.d.ts +3 -38
- package/dist/types/src/Select/components/SelectPressable/SelectPressable.style.d.ts +1 -1
- package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +1 -1
- package/dist/types/src/Switch/Switch.styles.d.ts +1 -1
- package/dist/types/src/Text/Text.d.ts +9 -3
- package/dist/types/src/TextList/TextList.style.d.ts +1 -1
- package/dist/types/src/ThumbnailList/ThumbnailList.style.d.ts +1 -1
- package/dist/types/src/ThumbnailList/types.d.ts +1 -1
- package/dist/types/src/Toast/Toast.styles.d.ts +1 -1
- package/dist/types/src/Typography/Typography.d.ts +6 -2
- package/dist/types/src/Typography/Typography.style.d.ts +7 -11
- package/dist/types/src/Typography/index.d.ts +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/utils/design/index.d.ts +5 -0
- package/jestSetup.js +2 -1
- package/package.json +4 -3
- package/src/ActionItem/ActionItem.style.ts +23 -22
- package/src/ActionItem/ActionItem.tsx +3 -1
- package/src/ActionItem/ActionItemGroup.tsx +2 -1
- package/src/ActionItem/components/ActionItemContainer.style.ts +12 -11
- package/src/ActionItem/components/ActionItemContainer.tsx +5 -2
- package/src/ActivityIndicator/ActivityIndicator.tsx +3 -1
- package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +106 -0
- package/src/AtlantisThemeContext/AtlantisThemeContext.tsx +56 -0
- package/src/AtlantisThemeContext/buildThemedStyles.test.tsx +57 -0
- package/src/AtlantisThemeContext/buildThemedStyles.ts +43 -0
- package/src/AtlantisThemeContext/index.ts +10 -0
- package/src/AtlantisThemeContext/types.ts +33 -0
- package/src/AutoLink/AutoLink.tsx +2 -1
- package/src/Banner/Banner.style.ts +34 -33
- package/src/Banner/Banner.tsx +6 -2
- package/src/Banner/components/BannerIcon/BannerIcon.style.ts +17 -16
- package/src/Banner/components/BannerIcon/BannerIcon.tsx +3 -1
- package/src/BottomSheet/BottomSheet.style.ts +32 -29
- package/src/BottomSheet/BottomSheet.tsx +21 -5
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.ts +18 -17
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +2 -1
- package/src/Button/Button.style.ts +119 -120
- package/src/Button/Button.test.tsx +88 -1
- package/src/Button/Button.tsx +38 -7
- package/src/ButtonGroup/ButtonGroup.style.ts +18 -17
- package/src/ButtonGroup/ButtonGroup.tsx +2 -1
- package/src/Card/Card.style.ts +46 -45
- package/src/Card/Card.tsx +8 -3
- package/src/Card/components/InternalCardHeader.style.ts +16 -15
- package/src/Card/components/InternalCardHeader.tsx +3 -1
- package/src/Checkbox/Checkbox.style.ts +30 -29
- package/src/Checkbox/Checkbox.tsx +6 -2
- package/src/Checkbox/CheckboxGroup.style.ts +14 -13
- package/src/Checkbox/CheckboxGroup.tsx +3 -1
- package/src/Chip/Chip.style.ts +32 -31
- package/src/Chip/Chip.test.tsx +1 -1
- package/src/Chip/Chip.tsx +7 -5
- package/src/Content/Content.test.tsx +93 -5
- package/src/Content/Content.tsx +33 -9
- package/src/Content/ContentHorizontal.style.ts +38 -37
- package/src/Content/ContentSpaceAround.style.ts +22 -21
- package/src/Content/ContentVertical.style.ts +38 -37
- package/src/ContentOverlay/ContentOverlay.style.ts +57 -56
- package/src/ContentOverlay/ContentOverlay.tsx +5 -2
- package/src/Disclosure/Disclosure.style.ts +21 -20
- package/src/Disclosure/Disclosure.test.tsx +102 -44
- package/src/Disclosure/Disclosure.tsx +18 -7
- package/src/Divider/Divider.test.tsx +11 -3
- package/src/Divider/Divider.tsx +5 -2
- package/src/Divider/DividerHorizontal.style.ts +23 -22
- package/src/Divider/DividerVertical.style.ts +26 -25
- package/src/EmptyState/EmptyState.style.ts +8 -7
- package/src/EmptyState/EmptyState.tsx +3 -1
- package/src/ErrorMessageWrapper/ErrorMessageWrapper.style.ts +31 -30
- package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +7 -6
- package/src/Flex/Flex.styles.tsx +2 -2
- package/src/Form/Form.style.ts +33 -32
- package/src/Form/Form.test.tsx +1 -1
- package/src/Form/Form.tsx +3 -1
- package/src/Form/components/FormActionBar/FormActionBar.style.ts +10 -9
- package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -1
- package/src/Form/components/FormBody/FormBody.style.ts +26 -25
- package/src/Form/components/FormBody/FormBody.tsx +2 -1
- package/src/Form/components/FormMask/FormMask.style.tsx +15 -14
- package/src/Form/components/FormMask/FormMask.tsx +2 -1
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.ts +17 -16
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +2 -1
- package/src/FormatFile/FormatFile.style.ts +18 -15
- package/src/FormatFile/FormatFile.tsx +3 -1
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.style.ts +10 -9
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +3 -1
- package/src/FormatFile/components/FileView/FileView.style.ts +64 -63
- package/src/FormatFile/components/FileView/FileView.tsx +3 -1
- package/src/FormatFile/components/MediaView/MediaView.style.ts +27 -26
- package/src/FormatFile/components/MediaView/MediaView.tsx +15 -3
- package/src/FormatFile/components/ProgressBar/ProgressBar.style.tsx +15 -14
- package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +3 -1
- package/src/Glimmer/Glimmer.shape.style.ts +16 -15
- package/src/Glimmer/Glimmer.size.style.ts +9 -8
- package/src/Glimmer/Glimmer.style.ts +21 -19
- package/src/Glimmer/Glimmer.test.tsx +16 -5
- package/src/Glimmer/Glimmer.tsx +9 -5
- package/src/Heading/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/IconButton/IconButton.style.ts +10 -9
- package/src/IconButton/IconButton.tsx +3 -1
- package/src/InputFieldWrapper/CommonInputStyles.style.ts +65 -38
- package/src/InputFieldWrapper/InputFieldWrapper.style.ts +144 -138
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +24 -5
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +5 -2
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.style.ts +25 -24
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +2 -1
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +14 -3
- package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +9 -3
- package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +9 -2
- package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +9 -3
- package/src/InputFieldWrapper/index.ts +4 -1
- package/src/InputPressable/InputPressable.style.ts +26 -23
- package/src/InputPressable/InputPressable.tsx +19 -6
- package/src/InputText/InputText.style.ts +26 -24
- package/src/InputText/InputText.test.tsx +11 -1
- package/src/InputText/InputText.tsx +5 -2
- package/src/InputText/context/InputAccessoriesProvider.style.tsx +21 -19
- package/src/InputText/context/InputAccessoriesProvider.tsx +3 -1
- package/src/Menu/Menu.style.ts +13 -12
- package/src/Menu/Menu.test.tsx +1 -1
- package/src/Menu/Menu.tsx +9 -4
- package/src/Menu/components/MenuOption/MenuOption.style.tsx +10 -9
- package/src/Menu/components/MenuOption/MenuOption.tsx +4 -2
- package/src/Menu/components/Overlay/Overlay.style.ts +10 -8
- package/src/Menu/components/Overlay/Overlay.tsx +3 -1
- package/src/Menu/utils.ts +2 -1
- package/src/ProgressBar/ProgressBar.style.ts +36 -35
- package/src/ProgressBar/ProgressBar.test.tsx +6 -20
- package/src/ProgressBar/ProgressBar.tsx +8 -4
- package/src/ProgressBar/ProgressBarInner.tsx +2 -1
- package/src/ProgressBar/ProgressBarStepped.tsx +10 -2
- package/src/ProgressBar/__snapshots__/ProgressBar.test.tsx.snap +2 -2
- package/src/Select/Select.style.ts +52 -48
- package/src/Select/Select.tsx +2 -1
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +2 -1
- package/src/Select/components/SelectPressable/SelectPressable.style.ts +7 -6
- package/src/Select/components/SelectPressable/SelectPressable.tsx +2 -2
- package/src/StatusLabel/StatusLabel.style.ts +29 -29
- package/src/StatusLabel/StatusLabel.tsx +9 -4
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +7 -7
- package/src/Switch/Switch.styles.ts +20 -19
- package/src/Switch/Switch.tsx +2 -1
- package/src/Switch/components/BaseSwitch/BaseSwitch.test.tsx +75 -50
- package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +6 -4
- package/src/Text/Text.test.tsx +20 -0
- package/src/Text/Text.tsx +11 -1
- package/src/Text/__snapshots__/Text.test.tsx.snap +2 -2
- package/src/TextList/TextList.style.ts +16 -15
- package/src/TextList/TextList.tsx +3 -1
- package/src/TextList/__snapshots__/TextList.test.tsx.snap +3 -0
- package/src/ThumbnailList/ThumbnailList.style.ts +49 -48
- package/src/ThumbnailList/ThumbnailList.tsx +2 -1
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +1 -0
- package/src/ThumbnailList/types.ts +1 -1
- package/src/Toast/Toast.styles.ts +30 -29
- package/src/Toast/Toast.tsx +10 -6
- package/src/Typography/Typography.style.ts +26 -23
- package/src/Typography/Typography.test.tsx +14 -0
- package/src/Typography/Typography.tsx +34 -10
- package/src/Typography/__snapshots__/Typography.test.tsx.snap +29 -29
- package/src/Typography/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/utils/design/index.ts +5 -0
- package/src/utils/meta/meta.json +1 -0
- package/dist/src/InputText/context/InputAccessory.style.js +0 -16
- package/dist/types/src/InputText/context/InputAccessory.style.d.ts +0 -14
- package/src/Disclosure/__snapshots__/Disclosure.test.tsx.snap +0 -482
- package/src/InputText/context/InputAccessory.style.ts +0 -17
- package/src/Switch/components/BaseSwitch/__snapshots__/BaseSwitch.test.tsx.snap +0 -217
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
container:
|
|
3
|
-
|
|
4
|
-
marginVertical: number;
|
|
5
|
-
backgroundColor: string;
|
|
6
|
-
minHeight: number;
|
|
7
|
-
flexDirection: "row";
|
|
8
|
-
justifyContent: "space-between";
|
|
9
|
-
width: "100%";
|
|
10
|
-
borderColor: string;
|
|
11
|
-
borderStyle: "solid";
|
|
12
|
-
borderWidth: number;
|
|
13
|
-
borderRadius: number;
|
|
14
|
-
} | {
|
|
15
|
-
flexDirection: "column";
|
|
16
|
-
justifyContent: "center";
|
|
17
|
-
minHeight: number;
|
|
18
|
-
marginVertical: number;
|
|
19
|
-
borderWidth: number;
|
|
20
|
-
};
|
|
21
|
-
input: {
|
|
22
|
-
width: "100%";
|
|
23
|
-
flexShrink: number;
|
|
24
|
-
flexGrow: number;
|
|
25
|
-
color: string;
|
|
26
|
-
fontFamily: string | undefined;
|
|
27
|
-
fontSize: number | undefined;
|
|
28
|
-
letterSpacing: number | undefined;
|
|
29
|
-
minHeight: number;
|
|
30
|
-
padding: number;
|
|
31
|
-
} | {
|
|
32
|
-
flexDirection: "row";
|
|
33
|
-
flexGrow: number;
|
|
34
|
-
paddingTop: number;
|
|
35
|
-
minHeight: number;
|
|
36
|
-
minWidth: "100%";
|
|
37
|
-
paddingRight: number;
|
|
38
|
-
};
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
container: import("react-native").ViewStyle;
|
|
3
|
+
input: import("react-native").ViewStyle;
|
|
39
4
|
value: {
|
|
40
5
|
flexGrow: number;
|
|
41
6
|
flexShrink: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TextAlign, TextVariation, TruncateLength, TypographyProps } from "../Typography";
|
|
2
|
-
|
|
2
|
+
import { TypographyUnsafeStyle } from "../Typography/Typography";
|
|
3
|
+
export interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "selectable"> {
|
|
3
4
|
/**
|
|
4
5
|
* Visual hierarchy of the text
|
|
5
6
|
*/
|
|
@@ -59,8 +60,13 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
|
|
|
59
60
|
* of the TextInput
|
|
60
61
|
*/
|
|
61
62
|
readonly hideFromScreenReader?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* **Use at your own risk:** Custom style for specific elements. This should only be used as a
|
|
65
|
+
* **last resort**. Using this may result in unexpected side effects.
|
|
66
|
+
* More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).
|
|
67
|
+
*/
|
|
68
|
+
readonly UNSAFE_style?: TypographyUnsafeStyle;
|
|
62
69
|
}
|
|
63
70
|
export type TextLevel = "text" | "textSupporting";
|
|
64
71
|
export declare const TEXT_MAX_SCALED_FONT_SIZES: Record<TextLevel, number>;
|
|
65
|
-
export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, italic, hideFromScreenReader, maxFontScaleSize, underline, selectable, }: TextProps): JSX.Element;
|
|
66
|
-
export {};
|
|
72
|
+
export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, italic, hideFromScreenReader, maxFontScaleSize, UNSAFE_style, underline, selectable, }: TextProps): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TextProps } from "react-native";
|
|
2
|
+
import { StyleProp, TextProps, TextStyle } from "react-native";
|
|
3
3
|
export interface TypographyProps<T extends FontFamily> extends Pick<TextProps, "selectable"> {
|
|
4
4
|
/**
|
|
5
5
|
* Text capitalization
|
|
@@ -85,9 +85,13 @@ export interface TypographyProps<T extends FontFamily> extends Pick<TextProps, "
|
|
|
85
85
|
* Have text styled with strike through
|
|
86
86
|
*/
|
|
87
87
|
readonly strikeThrough?: boolean;
|
|
88
|
+
readonly UNSAFE_style?: TypographyUnsafeStyle;
|
|
89
|
+
}
|
|
90
|
+
export interface TypographyUnsafeStyle {
|
|
91
|
+
textStyle?: StyleProp<TextStyle>;
|
|
88
92
|
}
|
|
89
93
|
export declare const Typography: React.MemoExoticComponent<typeof InternalTypography>;
|
|
90
|
-
declare function InternalTypography<T extends FontFamily = "base">({ fontFamily, fontStyle, fontWeight, transform, color, align, size, children, maxLines, allowFontScaling, maxFontScaleSize, adjustsFontSizeToFit, lineHeight, letterSpacing, reverseTheme, hideFromScreenReader, accessibilityRole, strikeThrough, underline, selectable, }: TypographyProps<T>): JSX.Element;
|
|
94
|
+
declare function InternalTypography<T extends FontFamily = "base">({ fontFamily, fontStyle, fontWeight, transform, color, align, size, children, maxLines, allowFontScaling, maxFontScaleSize, adjustsFontSizeToFit, lineHeight, letterSpacing, reverseTheme, hideFromScreenReader, accessibilityRole, strikeThrough, underline, UNSAFE_style, selectable, }: TypographyProps<T>): JSX.Element;
|
|
91
95
|
export type FontFamily = "base" | "display";
|
|
92
96
|
export type FontStyle = "regular" | "italic";
|
|
93
97
|
export type FontWeight = "regular" | "medium" | "bold" | "semiBold" | "extraBold" | "black";
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { TextStyle } from "react-native";
|
|
2
|
+
import { tokens as staticTokens } from "../utils/design";
|
|
3
|
+
import { AtlantisThemeContextValue } from "../AtlantisThemeContext";
|
|
2
4
|
/**
|
|
3
|
-
* Reusable typography
|
|
5
|
+
* Reusable typography styles to ensure consistency for any client facing texts.
|
|
4
6
|
*/
|
|
5
|
-
export declare const
|
|
7
|
+
export declare const getTypographyStyles: (tokens: AtlantisThemeContextValue["tokens"] | typeof staticTokens) => {
|
|
6
8
|
[index: string]: TextStyle;
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* If you find yourself needing to use what's inside this object on files other
|
|
12
|
-
* than `<Typography />`, please import from `@jobber/components-native` instead.
|
|
13
|
-
*
|
|
14
|
-
* ```
|
|
15
|
-
* import { typographyStyles } from "@jobber/components-native"
|
|
16
|
-
* ```
|
|
11
|
+
* @deprecated Use useTypographyStyles instead
|
|
17
12
|
*/
|
|
18
|
-
export declare const typographyStyles:
|
|
13
|
+
export declare const typographyStyles: Record<string, TextStyle>;
|
|
14
|
+
export declare const useTypographyStyles: () => {
|
|
19
15
|
[index: string]: TextStyle;
|
|
20
16
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Typography } from "./Typography";
|
|
2
2
|
export type { FontFamily, FontStyle, FontWeight, BaseWeight, DisplayWeight, BaseStyle, DisplayStyle, TextColor, TextTransform, TextSize, TextAlign, LineHeight, LetterSpacing, TextAccessibilityRole, TextVariation, TypographyProps, TruncateLength, } from "./Typography";
|
|
3
|
+
export { getTypographyStyles, useTypographyStyles } from "./Typography.style";
|
|
3
4
|
export { typographyStyles } from "./Typography.style";
|
|
4
5
|
export { TypographyGestureDetector } from "./TypographyGestureDetector";
|
|
@@ -2,6 +2,7 @@ export * from "./ActionItem";
|
|
|
2
2
|
export * from "./ActionLabel";
|
|
3
3
|
export * from "./ActivityIndicator";
|
|
4
4
|
export * from "./AtlantisContext";
|
|
5
|
+
export * from "./AtlantisThemeContext";
|
|
5
6
|
export * from "./AutoLink";
|
|
6
7
|
export * from "./Banner";
|
|
7
8
|
export * from "./BottomSheet";
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { iosTokens } from "@jobber/design";
|
|
2
|
+
/**
|
|
3
|
+
* These design tokens don't react to theme changes. Only use these if you need to access
|
|
4
|
+
* tokens that are not affected by the current theme, otherwise you should be using our
|
|
5
|
+
* useAtlantisTheme() hook to access the current theme's tokens.
|
|
6
|
+
*/
|
|
2
7
|
export declare const tokens: typeof iosTokens;
|
package/jestSetup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
// Mock the useIsScreenReaderEnabled hook
|
|
3
3
|
jest.mock("./dist/src/hooks", () => {
|
|
4
4
|
const actualHooks = jest.requireActual("./dist/src/hooks");
|
|
5
5
|
|
|
@@ -33,5 +33,6 @@ jest.mock("react-native-reanimated", () => {
|
|
|
33
33
|
FadeIn: {
|
|
34
34
|
duration: () => undefined,
|
|
35
35
|
},
|
|
36
|
+
useEvent: () => ({ listeners: [] }),
|
|
36
37
|
};
|
|
37
38
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.75.3-POC-fixing-
|
|
3
|
+
"version": "0.75.3-POC-fixing-ffcd368.137+ffcd3687",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -64,12 +64,13 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@babel/core": "^7.4.5",
|
|
67
|
+
"@jobber/design": "*",
|
|
67
68
|
"@react-native-community/datetimepicker": ">=6.7.0",
|
|
68
69
|
"date-fns": "^2.30.0",
|
|
69
70
|
"date-fns-tz": "^2.0.0",
|
|
70
71
|
"react": "^18.2.0",
|
|
71
72
|
"react-intl": "^6.4.2",
|
|
72
|
-
"react-native": ">=0.
|
|
73
|
+
"react-native": ">=0.76.0",
|
|
73
74
|
"react-native-gesture-handler": ">=2.10.0",
|
|
74
75
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
75
76
|
"react-native-modal-datetime-picker": " >=13.0.0",
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"react-native-safe-area-context": "^4.5.2",
|
|
80
81
|
"react-native-svg": ">=12.0.0"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "ffcd3687552f344f0e63002680a3a1e161f560a8"
|
|
83
84
|
}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { tokens } from "../utils/design";
|
|
1
|
+
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
4
|
+
return {
|
|
5
|
+
actionItemHorizontalOffset: {
|
|
6
|
+
paddingHorizontal: tokens["space-base"],
|
|
7
|
+
},
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
icon: {
|
|
10
|
+
justifyContent: "flex-start",
|
|
11
|
+
paddingRight: tokens["space-small"],
|
|
12
|
+
},
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
titlePadding: {
|
|
15
|
+
paddingBottom: tokens["space-smaller"],
|
|
16
|
+
},
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
content: {
|
|
19
|
+
flex: 1,
|
|
20
|
+
},
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
offsetForIcons: {
|
|
23
|
+
paddingTop: tokens["space-smallest"],
|
|
24
|
+
},
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
actionIcon: {
|
|
27
|
+
paddingLeft: tokens["space-small"],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
29
30
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { IconColorNames, IconNames } from "@jobber/design";
|
|
4
|
-
import {
|
|
4
|
+
import { useStyles } from "./ActionItem.style";
|
|
5
5
|
import { ActionItemContainer } from "./components/ActionItemContainer";
|
|
6
6
|
import { Typography } from "../Typography";
|
|
7
7
|
import { Icon } from "../Icon";
|
|
@@ -65,6 +65,8 @@ export function ActionItem({
|
|
|
65
65
|
justifyContent: actionIconAlignment,
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
const styles = useStyles();
|
|
69
|
+
|
|
68
70
|
const addIconOffset = icon || onPress ? styles.offsetForIcons : undefined;
|
|
69
71
|
const titlePadding = children ? styles.titlePadding : undefined;
|
|
70
72
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { ActionItem, ActionItemProps } from "./ActionItem";
|
|
4
|
-
import {
|
|
4
|
+
import { useStyles } from "./ActionItem.style";
|
|
5
5
|
import { Divider } from "../Divider";
|
|
6
6
|
|
|
7
7
|
export type ActionItemElement =
|
|
@@ -24,6 +24,7 @@ export function ActionItemGroup({
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function renderChildren(children: ActionItemElement | ActionItemElement[]) {
|
|
27
|
+
const styles = useStyles();
|
|
27
28
|
const childArray = React.Children.toArray(children);
|
|
28
29
|
if (childArray.length === 1) return children;
|
|
29
30
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { tokens } from "../../utils/design";
|
|
1
|
+
import { buildThemedStyles } from "../../AtlantisThemeContext";
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
4
|
+
return {
|
|
5
|
+
container: {
|
|
6
|
+
width: "100%",
|
|
7
|
+
flexDirection: "row",
|
|
8
|
+
paddingVertical: tokens["space-base"],
|
|
9
|
+
},
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
pressed: {
|
|
12
|
+
opacity: tokens["opacity-pressed"],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
14
15
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { Pressable, View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useStyles } from "./ActionItemContainer.style";
|
|
4
|
+
import { useStyles as useActionItemStyles } from "../ActionItem.style";
|
|
5
5
|
|
|
6
6
|
interface ActionItemContainerProps {
|
|
7
7
|
readonly children: ReactNode;
|
|
@@ -16,6 +16,9 @@ export function ActionItemContainer({
|
|
|
16
16
|
children,
|
|
17
17
|
testID,
|
|
18
18
|
}: ActionItemContainerProps): JSX.Element {
|
|
19
|
+
const styles = useStyles();
|
|
20
|
+
const actionItemStyles = useActionItemStyles();
|
|
21
|
+
|
|
19
22
|
if (onPress) {
|
|
20
23
|
return (
|
|
21
24
|
<Pressable
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ActivityIndicator, ActivityIndicatorProps } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { useAtlantisTheme } from "../AtlantisThemeContext";
|
|
4
4
|
|
|
5
5
|
export function JobberActivityIndicator(
|
|
6
6
|
props: ActivityIndicatorProps,
|
|
7
7
|
): JSX.Element {
|
|
8
|
+
const { tokens } = useAtlantisTheme();
|
|
9
|
+
|
|
8
10
|
return (
|
|
9
11
|
<ActivityIndicator
|
|
10
12
|
{...props}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { act, renderHook } from "@testing-library/react-native";
|
|
3
|
+
import { darkTokens, iosTokens } from "@jobber/design";
|
|
4
|
+
import merge from "lodash/merge";
|
|
5
|
+
import {
|
|
6
|
+
AtlantisThemeContextProvider,
|
|
7
|
+
useAtlantisTheme,
|
|
8
|
+
} from "./AtlantisThemeContext";
|
|
9
|
+
import { AtlantisThemeContextProviderProps, Theme } from "./types";
|
|
10
|
+
|
|
11
|
+
const expectedDarkTokens = merge({}, iosTokens, darkTokens);
|
|
12
|
+
const expectedLightTokens = iosTokens;
|
|
13
|
+
|
|
14
|
+
function Wrapper({
|
|
15
|
+
children,
|
|
16
|
+
dangerouslyOverrideTheme,
|
|
17
|
+
}: AtlantisThemeContextProviderProps) {
|
|
18
|
+
return (
|
|
19
|
+
<AtlantisThemeContextProvider
|
|
20
|
+
dangerouslyOverrideTheme={dangerouslyOverrideTheme}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</AtlantisThemeContextProvider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function WrapperWithOverride({
|
|
28
|
+
children,
|
|
29
|
+
dangerouslyOverrideTheme,
|
|
30
|
+
}: AtlantisThemeContextProviderProps) {
|
|
31
|
+
return (
|
|
32
|
+
<Wrapper>
|
|
33
|
+
<AtlantisThemeContextProvider
|
|
34
|
+
dangerouslyOverrideTheme={dangerouslyOverrideTheme}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</AtlantisThemeContextProvider>
|
|
38
|
+
</Wrapper>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe("ThemeContext", () => {
|
|
43
|
+
it("defaults to the light theme", () => {
|
|
44
|
+
const { result } = renderHook(useAtlantisTheme, {
|
|
45
|
+
wrapper: (props: AtlantisThemeContextProviderProps) => (
|
|
46
|
+
<Wrapper {...props} />
|
|
47
|
+
),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(result.current.theme).toBe("light");
|
|
51
|
+
expect(result.current.tokens).toEqual(expectedLightTokens);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("updates the theme and tokens", () => {
|
|
55
|
+
const { result } = renderHook(useAtlantisTheme, {
|
|
56
|
+
wrapper: (props: AtlantisThemeContextProviderProps) => (
|
|
57
|
+
<Wrapper {...props} />
|
|
58
|
+
),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
act(() => result.current.setTheme("dark"));
|
|
62
|
+
expect(result.current.theme).toBe("dark");
|
|
63
|
+
expect(result.current.tokens).toEqual(expectedDarkTokens);
|
|
64
|
+
|
|
65
|
+
act(() => result.current.setTheme("light"));
|
|
66
|
+
expect(result.current.theme).toBe("light");
|
|
67
|
+
expect(result.current.tokens).toEqual(expectedLightTokens);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("when theme is forced for provider", () => {
|
|
71
|
+
it("ignores updates to the global theme", () => {
|
|
72
|
+
const { result } = renderHook(useAtlantisTheme, {
|
|
73
|
+
wrapper: (props: AtlantisThemeContextProviderProps) => (
|
|
74
|
+
<WrapperWithOverride {...props} dangerouslyOverrideTheme="light" />
|
|
75
|
+
),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Update the global theme
|
|
79
|
+
act(() => result.current.setTheme("dark"));
|
|
80
|
+
|
|
81
|
+
// This hook shouldn't be affected by it because it's set to the light theme
|
|
82
|
+
expect(result.current.theme).toBe("light");
|
|
83
|
+
expect(result.current.tokens).toEqual(expectedLightTokens);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it.each([
|
|
87
|
+
{ defaultTheme: "light", expectedTokens: expectedLightTokens },
|
|
88
|
+
{ defaultTheme: "dark", expectedTokens: expectedDarkTokens },
|
|
89
|
+
] as { defaultTheme: Theme; expectedTokens: typeof iosTokens }[])(
|
|
90
|
+
"provides the dangerouslyOverrideTheme $defaultTheme tokens",
|
|
91
|
+
({ defaultTheme, expectedTokens }) => {
|
|
92
|
+
const { result } = renderHook(useAtlantisTheme, {
|
|
93
|
+
wrapper: (props: AtlantisThemeContextProviderProps) => (
|
|
94
|
+
<WrapperWithOverride
|
|
95
|
+
{...props}
|
|
96
|
+
dangerouslyOverrideTheme={defaultTheme}
|
|
97
|
+
/>
|
|
98
|
+
),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(result.current.theme).toBe(defaultTheme);
|
|
102
|
+
expect(result.current.tokens).toEqual(expectedTokens);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { androidTokens, darkTokens, iosTokens } from "@jobber/design";
|
|
2
|
+
import React, { createContext, useContext, useState } from "react";
|
|
3
|
+
import merge from "lodash/merge";
|
|
4
|
+
import { Platform } from "react-native";
|
|
5
|
+
import {
|
|
6
|
+
AtlantisThemeContextProviderProps,
|
|
7
|
+
AtlantisThemeContextValue,
|
|
8
|
+
Theme,
|
|
9
|
+
} from "./types";
|
|
10
|
+
|
|
11
|
+
const lightTokens = Platform.select({
|
|
12
|
+
ios: () => iosTokens,
|
|
13
|
+
android: () => androidTokens,
|
|
14
|
+
default: () => androidTokens,
|
|
15
|
+
})();
|
|
16
|
+
|
|
17
|
+
const completeDarkTokens = merge({}, lightTokens, darkTokens);
|
|
18
|
+
|
|
19
|
+
const AtlantisThemeContext = createContext<AtlantisThemeContextValue>({
|
|
20
|
+
theme: "light",
|
|
21
|
+
tokens: lightTokens,
|
|
22
|
+
setTheme: () => {
|
|
23
|
+
console.error(
|
|
24
|
+
"useAtlantisTheme accessed outside of AtlantisThemeContextProvider",
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function AtlantisThemeContextProvider({
|
|
30
|
+
children,
|
|
31
|
+
dangerouslyOverrideTheme,
|
|
32
|
+
}: AtlantisThemeContextProviderProps) {
|
|
33
|
+
// TODO: check last saved theme from local/device storage
|
|
34
|
+
const initialTheme: Theme = "light";
|
|
35
|
+
const [globalTheme, setGlobalTheme] = useState<Theme>(initialTheme);
|
|
36
|
+
|
|
37
|
+
const currentTheme = dangerouslyOverrideTheme ?? globalTheme;
|
|
38
|
+
const currentTokens =
|
|
39
|
+
currentTheme === "dark" ? completeDarkTokens : lightTokens;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<AtlantisThemeContext.Provider
|
|
43
|
+
value={{
|
|
44
|
+
theme: currentTheme,
|
|
45
|
+
tokens: currentTokens,
|
|
46
|
+
setTheme: setGlobalTheme,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</AtlantisThemeContext.Provider>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function useAtlantisTheme() {
|
|
55
|
+
return useContext(AtlantisThemeContext);
|
|
56
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { renderHook } from "@testing-library/react-native";
|
|
3
|
+
import { buildThemedStyles } from "./buildThemedStyles";
|
|
4
|
+
import { AtlantisThemeContextProvider } from "./AtlantisThemeContext";
|
|
5
|
+
|
|
6
|
+
describe("buildThemedStyles", () => {
|
|
7
|
+
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
8
|
+
<AtlantisThemeContextProvider>{children}</AtlantisThemeContextProvider>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
it("creates styles using theme tokens", () => {
|
|
12
|
+
const useTestStyles = buildThemedStyles(tokens => ({
|
|
13
|
+
container: {
|
|
14
|
+
backgroundColor: tokens["color-surface"],
|
|
15
|
+
padding: tokens["space-base"],
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const { result } = renderHook(() => useTestStyles(), { wrapper });
|
|
20
|
+
|
|
21
|
+
expect(result.current).toEqual({
|
|
22
|
+
container: {
|
|
23
|
+
backgroundColor: expect.any(String),
|
|
24
|
+
padding: expect.any(Number),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("memoizes styles and only updates when tokens change", () => {
|
|
30
|
+
const styleFactory = jest.fn(tokens => ({
|
|
31
|
+
container: {
|
|
32
|
+
backgroundColor: tokens["color-surface"],
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const useTestStyles = buildThemedStyles(styleFactory);
|
|
37
|
+
|
|
38
|
+
const { result, rerender } = renderHook(() => useTestStyles(), { wrapper });
|
|
39
|
+
|
|
40
|
+
// Initial render should call styleFactory
|
|
41
|
+
expect(styleFactory).toHaveBeenCalledTimes(1);
|
|
42
|
+
const initialResult = result.current;
|
|
43
|
+
|
|
44
|
+
// Rerender without token changes should not call styleFactory again
|
|
45
|
+
rerender({ wrapper });
|
|
46
|
+
expect(styleFactory).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(result.current).toBe(initialResult);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("handles empty style objects", () => {
|
|
51
|
+
const useTestStyles = buildThemedStyles(() => ({}));
|
|
52
|
+
|
|
53
|
+
const { result } = renderHook(() => useTestStyles(), { wrapper });
|
|
54
|
+
|
|
55
|
+
expect(result.current).toEqual({});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { AtlantisThemeContextValue } from "./types";
|
|
4
|
+
import { useAtlantisTheme } from "./AtlantisThemeContext";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a hook that generates themed styles using the current theme tokens.
|
|
8
|
+
* The hook will automatically update the styles when the theme changes.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const useStyles = buildThemedStyles(tokens => ({
|
|
13
|
+
* container: {
|
|
14
|
+
* backgroundColor: tokens["color-surface"],
|
|
15
|
+
* padding: tokens["space-base"],
|
|
16
|
+
* },
|
|
17
|
+
* }));
|
|
18
|
+
*
|
|
19
|
+
* function MyComponent() {
|
|
20
|
+
* const styles = useStyles();
|
|
21
|
+
* return <View style={styles.container} />;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param styleFactory - A function that receives theme tokens and returns a style object
|
|
26
|
+
* @returns A hook function that returns the created styles
|
|
27
|
+
*
|
|
28
|
+
* @note
|
|
29
|
+
* - Styles are memoized and only recalculated when tokens change
|
|
30
|
+
* - Use this for components that need to respond to theme changes
|
|
31
|
+
* - The returned styles are created using StyleSheet.create()
|
|
32
|
+
*
|
|
33
|
+
* @see Related functions: {@link useAtlantisTheme}
|
|
34
|
+
*/
|
|
35
|
+
export function buildThemedStyles<
|
|
36
|
+
T extends Parameters<typeof StyleSheet.create>[0],
|
|
37
|
+
>(styleFactory: (tokens: AtlantisThemeContextValue["tokens"]) => T) {
|
|
38
|
+
return function useStyles() {
|
|
39
|
+
const { tokens } = useAtlantisTheme();
|
|
40
|
+
|
|
41
|
+
return useMemo(() => StyleSheet.create(styleFactory(tokens)), [tokens]);
|
|
42
|
+
};
|
|
43
|
+
}
|