@cdek-it/react-native-ui-kit 0.2.0
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/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/components/Accordion/Accordion.d.ts +39 -0
- package/dist/components/Accordion/Accordion.js +103 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/Avatar/Avatar.d.ts +96 -0
- package/dist/components/Avatar/Avatar.js +121 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.d.ts +35 -0
- package/dist/components/Badge/Badge.js +74 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Button/BaseButton.d.ts +5 -0
- package/dist/components/Button/BaseButton.js +62 -0
- package/dist/components/Button/Button.d.ts +16 -0
- package/dist/components/Button/Button.js +21 -0
- package/dist/components/Button/ButtonBadge.d.ts +21 -0
- package/dist/components/Button/ButtonBadge.js +53 -0
- package/dist/components/Button/ButtonSeverity.d.ts +17 -0
- package/dist/components/Button/ButtonSeverity.js +22 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.js +3 -0
- package/dist/components/Button/styles/index.d.ts +2 -0
- package/dist/components/Button/styles/index.js +2 -0
- package/dist/components/Button/styles/useBasicButtonStyles.d.ts +98 -0
- package/dist/components/Button/styles/useBasicButtonStyles.js +81 -0
- package/dist/components/Button/styles/useDangerButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useDangerButtonStyles.js +57 -0
- package/dist/components/Button/styles/useInfoButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useInfoButtonStyles.js +56 -0
- package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +64 -0
- package/dist/components/Button/styles/useSeverityButtonStyles.js +29 -0
- package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useSuccessButtonStyles.js +61 -0
- package/dist/components/Button/styles/useWarningButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useWarningButtonStyles.js +61 -0
- package/dist/components/Button/types.d.ts +107 -0
- package/dist/components/Button/types.js +0 -0
- package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -0
- package/dist/components/Button/utils/ButtonActivityIndicator.js +17 -0
- package/dist/components/Button/utils/ButtonContainer.d.ts +7 -0
- package/dist/components/Button/utils/ButtonContainer.js +10 -0
- package/dist/components/Button/utils/ButtonIcon.d.ts +4 -0
- package/dist/components/Button/utils/ButtonIcon.js +11 -0
- package/dist/components/Button/utils/ButtonLabel.d.ts +4 -0
- package/dist/components/Button/utils/ButtonLabel.js +13 -0
- package/dist/components/Button/utils/ButtonLeftArea.d.ts +4 -0
- package/dist/components/Button/utils/ButtonLeftArea.js +13 -0
- package/dist/components/Button/utils/ButtonRightArea.d.ts +3 -0
- package/dist/components/Button/utils/ButtonRightArea.js +13 -0
- package/dist/components/Button/utils/index.d.ts +4 -0
- package/dist/components/Button/utils/index.js +4 -0
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +3 -0
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +141 -0
- package/dist/components/Button/utils/useButtonLabelStyle.d.ts +3 -0
- package/dist/components/Button/utils/useButtonLabelStyle.js +40 -0
- package/dist/components/Button/utils/useIconStyle.d.ts +7 -0
- package/dist/components/Button/utils/useIconStyle.js +35 -0
- package/dist/components/Button/utils/useTypeBasedStyle.d.ts +2 -0
- package/dist/components/Button/utils/useTypeBasedStyle.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +31 -0
- package/dist/components/Checkbox/Checkbox.js +55 -0
- package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +15 -0
- package/dist/components/Checkbox/hooks/usePressableStyles.js +91 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/Chip/Chip.d.ts +30 -0
- package/dist/components/Chip/Chip.js +70 -0
- package/dist/components/Chip/index.d.ts +1 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Dialog/Dialog.d.ts +14 -0
- package/dist/components/Dialog/Dialog.js +96 -0
- package/dist/components/Dialog/DialogComponent.d.ts +7 -0
- package/dist/components/Dialog/DialogComponent.js +34 -0
- package/dist/components/Dialog/DialogHeader.d.ts +12 -0
- package/dist/components/Dialog/DialogHeader.js +68 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.js +3 -0
- package/dist/components/Divider/Divider.d.ts +42 -0
- package/dist/components/Divider/Divider.js +95 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/Input/FloatLabel.d.ts +22 -0
- package/dist/components/Input/FloatLabel.js +19 -0
- package/dist/components/Input/InputGroup.d.ts +21 -0
- package/dist/components/Input/InputGroup.js +52 -0
- package/dist/components/Input/InputGroupAddon.d.ts +17 -0
- package/dist/components/Input/InputGroupAddon.js +57 -0
- package/dist/components/Input/InputSwitch/InputSwitch.d.ts +8 -0
- package/dist/components/Input/InputSwitch/InputSwitch.js +16 -0
- package/dist/components/Input/InputSwitch/index.d.ts +1 -0
- package/dist/components/Input/InputSwitch/index.js +1 -0
- package/dist/components/Input/InputSwitch/styles/index.d.ts +2 -0
- package/dist/components/Input/InputSwitch/styles/index.js +2 -0
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.d.ts +13 -0
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +47 -0
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +17 -0
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +95 -0
- package/dist/components/Input/InputText.d.ts +13 -0
- package/dist/components/Input/InputText.js +14 -0
- package/dist/components/Input/InputTextBase/InputTextBase.d.ts +13 -0
- package/dist/components/Input/InputTextBase/InputTextBase.js +124 -0
- package/dist/components/Input/InputTextBase/testIds.d.ts +11 -0
- package/dist/components/Input/InputTextBase/testIds.js +11 -0
- package/dist/components/Input/InputTextBase/types.d.ts +41 -0
- package/dist/components/Input/InputTextBase/types.js +0 -0
- package/dist/components/Input/InputTextBase/useStyles.d.ts +86 -0
- package/dist/components/Input/InputTextBase/useStyles.js +78 -0
- package/dist/components/Input/index.d.ts +5 -0
- package/dist/components/Input/index.js +4 -0
- package/dist/components/List/Base/ListBase.d.ts +32 -0
- package/dist/components/List/Base/ListBase.js +88 -0
- package/dist/components/List/Base/index.d.ts +1 -0
- package/dist/components/List/Base/index.js +1 -0
- package/dist/components/MenuItem/MenuItemAccessory.d.ts +11 -0
- package/dist/components/MenuItem/MenuItemAccessory.js +23 -0
- package/dist/components/MenuItem/MenuItemIcon.d.ts +36 -0
- package/dist/components/MenuItem/MenuItemIcon.js +33 -0
- package/dist/components/MenuItem/Template/MenuItemTemplate.d.ts +42 -0
- package/dist/components/MenuItem/Template/MenuItemTemplate.js +79 -0
- package/dist/components/MenuItem/index.d.ts +1 -0
- package/dist/components/MenuItem/index.js +1 -0
- package/dist/components/Message/Message.d.ts +65 -0
- package/dist/components/Message/Message.js +126 -0
- package/dist/components/Message/index.d.ts +1 -0
- package/dist/components/Message/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +33 -0
- package/dist/components/ProgressBar/ProgressBar.js +62 -0
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressSpinner/ProgressSpinner.d.ts +17 -0
- package/dist/components/ProgressSpinner/ProgressSpinner.js +68 -0
- package/dist/components/ProgressSpinner/index.d.ts +1 -0
- package/dist/components/ProgressSpinner/index.js +1 -0
- package/dist/components/RadioButton/RadioButton.d.ts +18 -0
- package/dist/components/RadioButton/RadioButton.js +134 -0
- package/dist/components/RadioButton/index.d.ts +1 -0
- package/dist/components/RadioButton/index.js +1 -0
- package/dist/components/Rating/Rating.d.ts +48 -0
- package/dist/components/Rating/Rating.js +37 -0
- package/dist/components/Rating/RatingClear.d.ts +14 -0
- package/dist/components/Rating/RatingClear.js +28 -0
- package/dist/components/Rating/RatingItem.d.ts +19 -0
- package/dist/components/Rating/RatingItem.js +44 -0
- package/dist/components/Rating/RatingItemContainer.d.ts +37 -0
- package/dist/components/Rating/RatingItemContainer.js +30 -0
- package/dist/components/Rating/index.d.ts +1 -0
- package/dist/components/Rating/index.js +1 -0
- package/dist/components/SelectButton/SelectButton.d.ts +32 -0
- package/dist/components/SelectButton/SelectButton.js +75 -0
- package/dist/components/SelectButton/SelectButtonItem.d.ts +35 -0
- package/dist/components/SelectButton/SelectButtonItem.js +133 -0
- package/dist/components/SelectButton/index.d.ts +1 -0
- package/dist/components/SelectButton/index.js +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +15 -0
- package/dist/components/Skeleton/Skeleton.js +53 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Slider/Slider.d.ts +36 -0
- package/dist/components/Slider/Slider.js +153 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Tabs/TabItem/TabItem.d.ts +24 -0
- package/dist/components/Tabs/TabItem/TabItem.js +82 -0
- package/dist/components/Tabs/TabItem/index.d.ts +1 -0
- package/dist/components/Tabs/TabItem/index.js +1 -0
- package/dist/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
- package/dist/components/Tabs/TabPanel/TabPanel.js +11 -0
- package/dist/components/Tabs/TabPanel/index.d.ts +1 -0
- package/dist/components/Tabs/TabPanel/index.js +1 -0
- package/dist/components/Tabs/Tabs.d.ts +15 -0
- package/dist/components/Tabs/Tabs.js +48 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tag/Tag.d.ts +33 -0
- package/dist/components/Tag/Tag.js +71 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/Tag/index.js +1 -0
- package/dist/components/Timer/Timer.d.ts +18 -0
- package/dist/components/Timer/Timer.js +74 -0
- package/dist/components/Timer/TimerFlip.d.ts +7 -0
- package/dist/components/Timer/TimerFlip.js +69 -0
- package/dist/components/Timer/constants.d.ts +1 -0
- package/dist/components/Timer/constants.js +1 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +45 -0
- package/dist/components/ToggleButton/ToggleButton.js +85 -0
- package/dist/components/ToggleButton/hooks/useIconSize.d.ts +14 -0
- package/dist/components/ToggleButton/hooks/useIconSize.js +26 -0
- package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +8 -0
- package/dist/components/ToggleButton/hooks/useLabelSize.js +19 -0
- package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +11 -0
- package/dist/components/ToggleButton/hooks/useStateStyles.js +92 -0
- package/dist/components/ToggleButton/index.d.ts +1 -0
- package/dist/components/ToggleButton/index.js +1 -0
- package/dist/components/Typography/Anchor.d.ts +31 -0
- package/dist/components/Typography/Anchor.js +75 -0
- package/dist/components/Typography/Body.d.ts +9 -0
- package/dist/components/Typography/Body.js +32 -0
- package/dist/components/Typography/Caption.d.ts +9 -0
- package/dist/components/Typography/Caption.js +38 -0
- package/dist/components/Typography/Service.d.ts +25 -0
- package/dist/components/Typography/Service.js +63 -0
- package/dist/components/Typography/Subtitle.d.ts +18 -0
- package/dist/components/Typography/Subtitle.js +23 -0
- package/dist/components/Typography/Title.d.ts +5 -0
- package/dist/components/Typography/Title.js +24 -0
- package/dist/components/Typography/index.d.ts +6 -0
- package/dist/components/Typography/index.js +6 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.js +23 -0
- package/dist/hooks/useChangeTheme.d.ts +1 -0
- package/dist/hooks/useChangeTheme.js +5 -0
- package/dist/hooks/useFonts.d.ts +1 -0
- package/dist/hooks/useFonts.js +5 -0
- package/dist/hooks/useLoadingRotationAnimation.d.ts +5 -0
- package/dist/hooks/useLoadingRotationAnimation.js +19 -0
- package/dist/hooks/useMakeTestId.d.ts +3 -0
- package/dist/hooks/useMakeTestId.js +7 -0
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useTheme.js +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/theme/ThemeContext.d.ts +15 -0
- package/dist/theme/ThemeContext.js +20 -0
- package/dist/theme/assets/background.json +149 -0
- package/dist/theme/assets/border.json +103 -0
- package/dist/theme/assets/customCommon.d.ts +4 -0
- package/dist/theme/assets/customCommon.js +4 -0
- package/dist/theme/assets/customDark.d.ts +5 -0
- package/dist/theme/assets/customDark.js +15 -0
- package/dist/theme/assets/customLight.d.ts +15 -0
- package/dist/theme/assets/customLight.js +15 -0
- package/dist/theme/assets/effects.json +15 -0
- package/dist/theme/assets/global.json +114 -0
- package/dist/theme/assets/primaryColors.json +14 -0
- package/dist/theme/assets/shadow.d.ts +6 -0
- package/dist/theme/assets/shadow.js +6 -0
- package/dist/theme/assets/sizing.json +78 -0
- package/dist/theme/assets/spacing.json +48 -0
- package/dist/theme/assets/themeDark.json +1141 -0
- package/dist/theme/assets/themeLight.json +1141 -0
- package/dist/theme/assets/typography.json +45 -0
- package/dist/theme/commonTheme.d.ts +582 -0
- package/dist/theme/commonTheme.js +22 -0
- package/dist/theme/darkTheme.d.ts +2 -0
- package/dist/theme/darkTheme.js +7 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/lightTheme.d.ts +2 -0
- package/dist/theme/lightTheme.js +7 -0
- package/dist/theme/types.d.ts +40 -0
- package/dist/theme/types.js +5 -0
- package/dist/utils/SvgUniversal.d.ts +29 -0
- package/dist/utils/SvgUniversal.js +28 -0
- package/dist/utils/genericMemo.d.ts +1 -0
- package/dist/utils/genericMemo.js +2 -0
- package/dist/utils/makeStyles.d.ts +11 -0
- package/dist/utils/makeStyles.js +19 -0
- package/package.json +159 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Fragment, memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { Pressable, Text, View, } from 'react-native';
|
|
3
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
4
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
5
|
+
const WORD_JOINER = '\u2060'; // символ невидимого пробела, чтобы избежать разрыва строки между текстом и иконкой
|
|
6
|
+
/**
|
|
7
|
+
* Используется для ссылок и якорей
|
|
8
|
+
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS--DS-?node-id=1-271
|
|
9
|
+
*/
|
|
10
|
+
export const Anchor = memo(({ onPress, base, visited, children, noWrapper, LeftIcon, RightIcon, testID, style, ...other }) => {
|
|
11
|
+
const styles = useStyles();
|
|
12
|
+
const [pressed, setPressed] = useState(false);
|
|
13
|
+
const onPressIn = useCallback(() => setPressed(true), []);
|
|
14
|
+
const onPressOut = useCallback(() => setPressed(false), []);
|
|
15
|
+
const Wrapper = noWrapper ? Fragment : View;
|
|
16
|
+
const containerProps = useMemo(() => {
|
|
17
|
+
if (noWrapper) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
return { style: styles.container, testID: testID || AnchorTestId.root };
|
|
21
|
+
}, [noWrapper, styles.container, testID]);
|
|
22
|
+
const iconColor = useMemo(() => (visited ? styles.visited.color : styles.text.color), [styles.text.color, styles.visited.color, visited]);
|
|
23
|
+
return (<Wrapper {...containerProps}>
|
|
24
|
+
{LeftIcon ? (<Pressable style={styles.leftIconContainer} testID={AnchorTestId.leftPressable} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut}>
|
|
25
|
+
<SvgUniversal source={LeftIcon} testID={AnchorTestId.leftIcon} {...styles.icon} {...(base ? styles.iconBase : {})} color={iconColor}/>
|
|
26
|
+
</Pressable>) : null}
|
|
27
|
+
<Text suppressHighlighting style={[
|
|
28
|
+
styles.text,
|
|
29
|
+
pressed && styles.underlined,
|
|
30
|
+
base && styles.base,
|
|
31
|
+
visited && styles.visited,
|
|
32
|
+
style,
|
|
33
|
+
]} testID={AnchorTestId.text} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut} {...other}>
|
|
34
|
+
{LeftIcon ? WORD_JOINER : null}
|
|
35
|
+
{children}
|
|
36
|
+
{RightIcon ? WORD_JOINER : null}
|
|
37
|
+
</Text>
|
|
38
|
+
|
|
39
|
+
{RightIcon ? (<Pressable style={styles.rightIconContainer} testID={AnchorTestId.rightPressable} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut}>
|
|
40
|
+
<SvgUniversal source={RightIcon} {...styles.icon} {...(base ? styles.iconBase : {})} color={iconColor} testID={AnchorTestId.rightIcon}/>
|
|
41
|
+
</Pressable>) : null}
|
|
42
|
+
</Wrapper>);
|
|
43
|
+
});
|
|
44
|
+
const useStyles = makeStyles(({ spacing, typography, fonts }) => ({
|
|
45
|
+
container: { flexDirection: 'row', alignItems: 'center' },
|
|
46
|
+
text: {
|
|
47
|
+
flexShrink: 1,
|
|
48
|
+
fontSize: typography.Size['text-sm'],
|
|
49
|
+
includeFontPadding: false,
|
|
50
|
+
verticalAlign: 'middle',
|
|
51
|
+
color: typography.Color.Service['text-info'],
|
|
52
|
+
fontFamily: fonts.primary,
|
|
53
|
+
},
|
|
54
|
+
underlined: { textDecorationLine: 'underline' },
|
|
55
|
+
base: { fontSize: typography.Size['text-base'], fontFamily: fonts.secondary },
|
|
56
|
+
visited: { color: typography.Color.Service['text-help'] },
|
|
57
|
+
icon: {
|
|
58
|
+
width: typography.Size['text-base'],
|
|
59
|
+
height: typography.Size['text-base'],
|
|
60
|
+
},
|
|
61
|
+
iconBase: {
|
|
62
|
+
width: typography.Size['text-xl'],
|
|
63
|
+
height: typography.Size['text-xl'],
|
|
64
|
+
},
|
|
65
|
+
leftIconContainer: { paddingRight: spacing.Padding['p-2'] },
|
|
66
|
+
rightIconContainer: { paddingLeft: spacing.Padding['p-2'] },
|
|
67
|
+
}));
|
|
68
|
+
export const AnchorTestId = {
|
|
69
|
+
root: 'Anchor',
|
|
70
|
+
leftPressable: 'AnchorLeftPressable',
|
|
71
|
+
rightPressable: 'AnchorRightPressable',
|
|
72
|
+
leftIcon: 'LeftIcon',
|
|
73
|
+
rightIcon: 'RightIcon',
|
|
74
|
+
text: 'AnchorText',
|
|
75
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TextProps } from 'react-native';
|
|
2
|
+
export interface BodyProps extends TextProps {
|
|
3
|
+
readonly base?: boolean;
|
|
4
|
+
readonly color?: 'default' | 'secondary' | 'primary';
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
readonly paragraph?: boolean;
|
|
7
|
+
readonly weight?: 'regular' | 'medium' | 'bold';
|
|
8
|
+
}
|
|
9
|
+
export declare const Body: ({ base, color, disabled, paragraph, weight, style, ...other }: BodyProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
3
|
+
export const Body = ({ base, color = 'default', disabled, paragraph, weight = 'regular', style, ...other }) => {
|
|
4
|
+
const styles = useStyles();
|
|
5
|
+
return (<Text style={[
|
|
6
|
+
styles.text,
|
|
7
|
+
styles[weight],
|
|
8
|
+
styles[color],
|
|
9
|
+
base && styles.base,
|
|
10
|
+
paragraph && (base ? styles.paragraphBase : styles.paragraph),
|
|
11
|
+
disabled && styles.disabled,
|
|
12
|
+
style,
|
|
13
|
+
]} {...other}/>);
|
|
14
|
+
};
|
|
15
|
+
const useStyles = makeStyles(({ theme, typography, fonts }) => ({
|
|
16
|
+
text: {
|
|
17
|
+
fontSize: typography.Size['text-lg'],
|
|
18
|
+
includeFontPadding: false,
|
|
19
|
+
verticalAlign: 'middle',
|
|
20
|
+
fontFamily: fonts.secondary,
|
|
21
|
+
},
|
|
22
|
+
regular: { fontWeight: 400 },
|
|
23
|
+
medium: { fontWeight: 500 },
|
|
24
|
+
bold: { fontWeight: 700 },
|
|
25
|
+
default: { color: theme.General.textColor },
|
|
26
|
+
primary: { color: theme.General.primaryColor },
|
|
27
|
+
secondary: { color: theme.General.textSecondaryColor },
|
|
28
|
+
base: { fontSize: typography.Size['text-base'] },
|
|
29
|
+
paragraph: { fontSize: typography.Size['text-lg'] },
|
|
30
|
+
paragraphBase: { fontSize: typography.Size['text-base'] },
|
|
31
|
+
disabled: { opacity: 0.6 },
|
|
32
|
+
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TextProps } from 'react-native';
|
|
2
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
3
|
+
export interface CaptionProps extends TextProps {
|
|
4
|
+
readonly color?: 'default' | 'secondary' | 'primary';
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
/** SVG-иконка */
|
|
7
|
+
readonly Icon?: SvgSource;
|
|
8
|
+
}
|
|
9
|
+
export declare const Caption: ({ color, disabled, style, Icon, ...other }: CaptionProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Text, View } from 'react-native';
|
|
2
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
3
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
4
|
+
export const Caption = ({ color = 'default', disabled, style, Icon, ...other }) => {
|
|
5
|
+
const styles = useStyles();
|
|
6
|
+
const text = (<Text style={[
|
|
7
|
+
styles.text,
|
|
8
|
+
styles[color],
|
|
9
|
+
disabled && styles.disabled,
|
|
10
|
+
Icon && styles.textWithIcon,
|
|
11
|
+
style,
|
|
12
|
+
]} {...other}/>);
|
|
13
|
+
if (Icon) {
|
|
14
|
+
return (<View style={styles.withIconContainer}>
|
|
15
|
+
<SvgUniversal source={Icon} {...styles[color]} {...styles.icon}/>
|
|
16
|
+
{text}
|
|
17
|
+
</View>);
|
|
18
|
+
}
|
|
19
|
+
return text;
|
|
20
|
+
};
|
|
21
|
+
const useStyles = makeStyles(({ theme, spacing, typography, fonts }) => ({
|
|
22
|
+
text: {
|
|
23
|
+
fontSize: typography.Size['text-sm'],
|
|
24
|
+
includeFontPadding: false,
|
|
25
|
+
verticalAlign: 'middle',
|
|
26
|
+
fontFamily: fonts.primary,
|
|
27
|
+
},
|
|
28
|
+
textWithIcon: { flexShrink: 1 },
|
|
29
|
+
default: { color: theme.General.textColor },
|
|
30
|
+
primary: { color: theme.General.primaryColor },
|
|
31
|
+
secondary: { color: theme.General.textSecondaryColor },
|
|
32
|
+
disabled: { opacity: 0.6 },
|
|
33
|
+
withIconContainer: { flexDirection: 'row', gap: spacing.Gap['gap-1'] },
|
|
34
|
+
icon: {
|
|
35
|
+
width: typography.Size['text-base'],
|
|
36
|
+
height: typography.Size['text-base'],
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type TextProps } from 'react-native';
|
|
2
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
3
|
+
export interface ServiceProps extends TextProps {
|
|
4
|
+
/**
|
|
5
|
+
* Вариант отображения
|
|
6
|
+
* @default success
|
|
7
|
+
*/
|
|
8
|
+
readonly variant?: 'danger' | 'warning' | 'success' | 'info' | 'help';
|
|
9
|
+
/**
|
|
10
|
+
* true, если необходимо показать иконку
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
readonly showIcon?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* true, если необходим компонент в базовом стиле
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
readonly base?: boolean;
|
|
19
|
+
/** SVG-иконка */
|
|
20
|
+
readonly Icon?: SvgSource;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=1-284&m=dev
|
|
24
|
+
*/
|
|
25
|
+
export declare const Service: ({ variant, showIcon, base, Icon: IconFromProps, ...other }: ServiceProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { IconAlertTriangle, IconCircleCheck, IconCircleX, IconHelpCircle, IconInfoCircle, } from '@tabler/icons-react-native';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Text, View } from 'react-native';
|
|
4
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
5
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
6
|
+
/**
|
|
7
|
+
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=1-284&m=dev
|
|
8
|
+
*/
|
|
9
|
+
export const Service = ({ variant = 'success', showIcon = true, base = true, Icon: IconFromProps, ...other }) => {
|
|
10
|
+
const styles = useStyles();
|
|
11
|
+
const { Icon, variantStyle, iconSize, textStyles, containerStyle } = useMemo(() => {
|
|
12
|
+
const iconMap = {
|
|
13
|
+
danger: { Icon: IconCircleX, style: styles.danger },
|
|
14
|
+
warning: { Icon: IconAlertTriangle, style: styles.warning },
|
|
15
|
+
success: { Icon: IconCircleCheck, style: styles.success },
|
|
16
|
+
info: { Icon: IconInfoCircle, style: styles.info },
|
|
17
|
+
help: { Icon: IconHelpCircle, style: styles.help },
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
Icon: IconFromProps || iconMap[variant]?.Icon || IconInfoCircle,
|
|
21
|
+
variantStyle: iconMap[variant]?.style || styles.info,
|
|
22
|
+
iconSize: base ? styles.iconBase : styles.icon,
|
|
23
|
+
textStyles: [
|
|
24
|
+
styles.textCommon,
|
|
25
|
+
base ? styles.textBase : styles.text,
|
|
26
|
+
iconMap[variant]?.style || styles.info,
|
|
27
|
+
],
|
|
28
|
+
containerStyle: base ? styles.containerBase : styles.container,
|
|
29
|
+
};
|
|
30
|
+
}, [variant, base, styles, IconFromProps]);
|
|
31
|
+
return (<View style={containerStyle}>
|
|
32
|
+
{showIcon ? (<SvgUniversal color={variantStyle.color} height={iconSize.height} source={Icon} width={iconSize.width}/>) : null}
|
|
33
|
+
<Text style={textStyles} {...other}/>
|
|
34
|
+
</View>);
|
|
35
|
+
};
|
|
36
|
+
const useStyles = makeStyles(({ typography, spacing, fonts }) => ({
|
|
37
|
+
iconBase: {
|
|
38
|
+
width: typography.Size['text-xl'],
|
|
39
|
+
height: typography.Size['text-xl'],
|
|
40
|
+
},
|
|
41
|
+
icon: {
|
|
42
|
+
width: typography.Size['text-base'],
|
|
43
|
+
height: typography.Size['text-base'],
|
|
44
|
+
},
|
|
45
|
+
containerBase: { flexDirection: 'row', gap: spacing.Gap['gap-2'] },
|
|
46
|
+
container: { flexDirection: 'row', gap: spacing.Gap['gap-1'] },
|
|
47
|
+
textCommon: {
|
|
48
|
+
includeFontPadding: false,
|
|
49
|
+
verticalAlign: 'middle',
|
|
50
|
+
flexShrink: 1,
|
|
51
|
+
fontWeight: 400,
|
|
52
|
+
},
|
|
53
|
+
textBase: {
|
|
54
|
+
fontSize: typography.Size['text-base'],
|
|
55
|
+
fontFamily: fonts.secondary,
|
|
56
|
+
},
|
|
57
|
+
text: { fontSize: typography.Size['text-sm'], fontFamily: fonts.primary },
|
|
58
|
+
warning: { color: typography.Color.Service['text-warning'] },
|
|
59
|
+
success: { color: typography.Color.Service['text-success'] },
|
|
60
|
+
info: { color: typography.Color.Service['text-info'] },
|
|
61
|
+
help: { color: typography.Color.Service['text-help'] },
|
|
62
|
+
danger: { color: typography.Color.Service['text-danger'] },
|
|
63
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type TextProps } from 'react-native';
|
|
2
|
+
export interface SubtitleProps extends TextProps {
|
|
3
|
+
/**
|
|
4
|
+
* true, если необходим базовый размер текста подзаголовка
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
base?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Выбор цвета подзаголовка
|
|
10
|
+
* @default 'default'
|
|
11
|
+
*/
|
|
12
|
+
color?: 'default' | 'primary' | 'secondary';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Используется для подзаголовков
|
|
16
|
+
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=1-245
|
|
17
|
+
*/
|
|
18
|
+
export declare const Subtitle: import("react").NamedExoticComponent<SubtitleProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
4
|
+
/**
|
|
5
|
+
* Используется для подзаголовков
|
|
6
|
+
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=1-245
|
|
7
|
+
*/
|
|
8
|
+
export const Subtitle = memo(({ base = false, color = 'default', style, ...other }) => {
|
|
9
|
+
const styles = useStyles();
|
|
10
|
+
return (<Text style={[styles.text, styles[color], base && styles.base, style]} {...other}/>);
|
|
11
|
+
});
|
|
12
|
+
const useStyles = makeStyles(({ theme, typography, fonts }) => ({
|
|
13
|
+
text: {
|
|
14
|
+
fontSize: typography.Size['text-sm'],
|
|
15
|
+
fontWeight: 700,
|
|
16
|
+
textTransform: 'uppercase',
|
|
17
|
+
fontFamily: fonts.primary,
|
|
18
|
+
},
|
|
19
|
+
base: { fontSize: typography.Size['text-base'], fontFamily: fonts.secondary },
|
|
20
|
+
default: { color: theme.General.textColor },
|
|
21
|
+
primary: { color: theme.General.primaryColor },
|
|
22
|
+
secondary: { color: theme.General.textSecondaryColor },
|
|
23
|
+
}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TextProps } from 'react-native';
|
|
2
|
+
export interface TitleProps extends TextProps {
|
|
3
|
+
readonly level: 'd1' | 'd2' | 'd3' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
4
|
+
}
|
|
5
|
+
export declare const Title: ({ level, style, ...other }: TitleProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
3
|
+
export const Title = ({ level, style, ...other }) => {
|
|
4
|
+
const styles = useStyles();
|
|
5
|
+
return <Text style={[styles.text, styles[level], style]} {...other}/>;
|
|
6
|
+
};
|
|
7
|
+
const useStyles = makeStyles(({ theme, typography, fonts }) => ({
|
|
8
|
+
text: {
|
|
9
|
+
color: theme.General.textColor,
|
|
10
|
+
fontFamily: fonts.primary,
|
|
11
|
+
fontWeight: 700,
|
|
12
|
+
includeFontPadding: false,
|
|
13
|
+
verticalAlign: 'middle',
|
|
14
|
+
},
|
|
15
|
+
d1: { fontSize: typography.Size['text-6xl'] },
|
|
16
|
+
d2: { fontSize: typography.Size['text-5xl'] },
|
|
17
|
+
d3: { fontSize: typography.Size['text-4xl'] },
|
|
18
|
+
h1: { fontSize: typography.Size['text-3xl'] },
|
|
19
|
+
h2: { fontSize: typography.Size['text-2xl'] },
|
|
20
|
+
h3: { fontSize: typography.Size['text-xl'] },
|
|
21
|
+
h4: { fontSize: typography.Size['text-lg'] },
|
|
22
|
+
h5: { fontSize: typography.Size['text-base'] },
|
|
23
|
+
h6: { fontSize: typography.Size['text-sm'] },
|
|
24
|
+
}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Body, type BodyProps } from './Body';
|
|
2
|
+
export { Caption, type CaptionProps } from './Caption';
|
|
3
|
+
export { Title, type TitleProps } from './Title';
|
|
4
|
+
export { Subtitle, type SubtitleProps } from './Subtitle';
|
|
5
|
+
export { Service, type ServiceProps } from './Service';
|
|
6
|
+
export { Anchor, type AnchorProps } from './Anchor';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './Button';
|
|
2
|
+
export * from './Typography';
|
|
3
|
+
export * from './Avatar';
|
|
4
|
+
export * from './Badge';
|
|
5
|
+
export * from './Checkbox';
|
|
6
|
+
export * from './Input';
|
|
7
|
+
export * from './MenuItem';
|
|
8
|
+
export * from './ToggleButton';
|
|
9
|
+
export * from './Tag';
|
|
10
|
+
export * from './Divider';
|
|
11
|
+
export * from './SelectButton';
|
|
12
|
+
export * from './RadioButton';
|
|
13
|
+
export * from './Skeleton';
|
|
14
|
+
export * from './Message';
|
|
15
|
+
export * from './Slider';
|
|
16
|
+
export * from './Chip';
|
|
17
|
+
export * from './ProgressSpinner';
|
|
18
|
+
export * from './ProgressBar';
|
|
19
|
+
export * from './Rating';
|
|
20
|
+
export * from './Tabs';
|
|
21
|
+
export * from './List/Base';
|
|
22
|
+
export * from './Accordion';
|
|
23
|
+
export * from './Dialog';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './Button';
|
|
2
|
+
export * from './Typography';
|
|
3
|
+
export * from './Avatar';
|
|
4
|
+
export * from './Badge';
|
|
5
|
+
export * from './Checkbox';
|
|
6
|
+
export * from './Input';
|
|
7
|
+
export * from './MenuItem';
|
|
8
|
+
export * from './ToggleButton';
|
|
9
|
+
export * from './Tag';
|
|
10
|
+
export * from './Divider';
|
|
11
|
+
export * from './SelectButton';
|
|
12
|
+
export * from './RadioButton';
|
|
13
|
+
export * from './Skeleton';
|
|
14
|
+
export * from './Message';
|
|
15
|
+
export * from './Slider';
|
|
16
|
+
export * from './Chip';
|
|
17
|
+
export * from './ProgressSpinner';
|
|
18
|
+
export * from './ProgressBar';
|
|
19
|
+
export * from './Rating';
|
|
20
|
+
export * from './Tabs';
|
|
21
|
+
export * from './List/Base';
|
|
22
|
+
export * from './Accordion';
|
|
23
|
+
export * from './Dialog';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useChangeTheme: () => (theme: import("..").ThemeVariant) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useFonts: () => import("../theme").FontsConfig;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { Easing, interpolate, useAnimatedStyle, useSharedValue, withRepeat, withTiming, } from 'react-native-reanimated';
|
|
3
|
+
const DURATION = 1000; // ms
|
|
4
|
+
export const useLoadingRotationAnimation = (loading) => {
|
|
5
|
+
const loadingAnimation = useSharedValue(0);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
loadingAnimation.value = loading
|
|
8
|
+
? withRepeat(withTiming(1, {
|
|
9
|
+
duration: DURATION,
|
|
10
|
+
easing: Easing.inOut(Easing.ease),
|
|
11
|
+
}), -1)
|
|
12
|
+
: 0;
|
|
13
|
+
}, [loading, loadingAnimation]);
|
|
14
|
+
return useAnimatedStyle(() => ({
|
|
15
|
+
transform: [
|
|
16
|
+
{ rotate: `${interpolate(loadingAnimation.value, [0, 1], [0, 360])}deg` },
|
|
17
|
+
],
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTheme: () => import("..").ThemeVariant;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './components';
|
|
2
|
+
export { useChangeTheme } from './hooks/useChangeTheme';
|
|
3
|
+
export { ThemeContext, ThemeContextProvider, ThemeVariant, darkTheme, lightTheme, } from './theme';
|
|
4
|
+
export { makeStyles } from './utils/makeStyles';
|
|
5
|
+
export { useTheme } from './hooks/useTheme';
|
|
6
|
+
export { SvgUniversal, type SvgSource } from './utils/SvgUniversal';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './components';
|
|
2
|
+
export { useChangeTheme } from './hooks/useChangeTheme';
|
|
3
|
+
export { ThemeContext, ThemeContextProvider, ThemeVariant, darkTheme, lightTheme, } from './theme';
|
|
4
|
+
export { makeStyles } from './utils/makeStyles';
|
|
5
|
+
export { useTheme } from './hooks/useTheme';
|
|
6
|
+
export { SvgUniversal } from './utils/SvgUniversal';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { ThemeVariant, type FontsConfig } from './types';
|
|
3
|
+
interface ThemeContextType {
|
|
4
|
+
theme: ThemeVariant;
|
|
5
|
+
fonts: FontsConfig;
|
|
6
|
+
changeTheme: (theme: ThemeVariant) => void;
|
|
7
|
+
}
|
|
8
|
+
interface ThemeContextProviderProps {
|
|
9
|
+
readonly initialTheme?: ThemeVariant;
|
|
10
|
+
readonly fonts?: FontsConfig;
|
|
11
|
+
readonly children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const ThemeContext: import("react").Context<ThemeContextType>;
|
|
14
|
+
export declare const ThemeContextProvider: ({ children, initialTheme, fonts, }: ThemeContextProviderProps) => import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useCallback, useMemo, useState, } from 'react';
|
|
2
|
+
import { ThemeVariant } from './types';
|
|
3
|
+
const defaultThemeContext = {
|
|
4
|
+
theme: ThemeVariant.Light,
|
|
5
|
+
fonts: { primary: 'TT Fellows', secondary: 'PT Sans' },
|
|
6
|
+
changeTheme: () => {
|
|
7
|
+
/* do nothing */
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export const ThemeContext = createContext(defaultThemeContext);
|
|
11
|
+
export const ThemeContextProvider = ({ children, initialTheme = defaultThemeContext.theme, fonts = defaultThemeContext.fonts, }) => {
|
|
12
|
+
const [theme, setTheme] = useState(initialTheme);
|
|
13
|
+
const changeTheme = useCallback((nextTheme) => {
|
|
14
|
+
setTheme(nextTheme);
|
|
15
|
+
}, []);
|
|
16
|
+
const contextValue = useMemo(() => ({ theme, fonts, changeTheme }), [theme, fonts, changeTheme]);
|
|
17
|
+
return (<ThemeContext.Provider value={contextValue}>
|
|
18
|
+
{children}
|
|
19
|
+
</ThemeContext.Provider>);
|
|
20
|
+
};
|