@hero-design/rn 7.13.0 → 7.14.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/.eslintrc.json +3 -1
- package/.turbo/turbo-build.log +3 -2
- package/assets/fonts/hero-icons.ttf +0 -0
- package/babel.config.js +16 -0
- package/es/index.js +26957 -7622
- package/lib/assets/fonts/hero-icons.ttf +0 -0
- package/lib/index.js +26963 -7624
- package/package.json +9 -4
- package/rollup.config.js +1 -0
- package/src/components/Accordion/AccordionItem.tsx +50 -0
- package/src/components/Accordion/StyledAccordion.tsx +29 -0
- package/src/components/Accordion/__tests__/AccordionItem.spec.tsx +56 -0
- package/src/components/Accordion/__tests__/StyledAccordion.spec.tsx +17 -0
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +529 -0
- package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +33 -0
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +822 -0
- package/src/components/Accordion/__tests__/index.spec.tsx +54 -0
- package/src/components/Accordion/index.tsx +82 -0
- package/src/components/Accordion/utils.tsx +11 -0
- package/src/components/Button/IconButton.tsx +1 -1
- package/src/components/Calendar/CalendarRowItem.tsx +54 -0
- package/src/components/Calendar/StyledCalendar.tsx +76 -0
- package/src/components/Calendar/__tests__/CalendarRowItem.spec.tsx +76 -0
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +411 -0
- package/src/components/Calendar/__tests__/helper.spec.ts +50 -0
- package/src/components/Calendar/__tests__/index.spec.tsx +99 -0
- package/src/components/Calendar/helpers.ts +29 -0
- package/src/components/Calendar/index.tsx +217 -0
- package/src/components/Collapse/index.tsx +13 -15
- package/src/components/ContentNavigator/index.tsx +6 -0
- package/src/components/Empty/StyledEmpty.tsx +47 -0
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +66 -0
- package/src/components/Empty/__tests__/index.spec.tsx +17 -0
- package/src/components/Empty/index.tsx +53 -0
- package/src/components/FAB/ActionGroup/ActionItem.tsx +6 -2
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -0
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +7 -1
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +84 -22
- package/src/components/FAB/ActionGroup/index.tsx +8 -1
- package/src/components/Icon/HeroIcon/selection.json +1 -1
- package/src/components/Icon/IconList.ts +13 -0
- package/src/components/List/BasicListItem.tsx +44 -34
- package/src/components/List/ListItem.tsx +67 -58
- package/src/components/List/StyledBasicListItem.tsx +2 -3
- package/src/components/List/StyledListItem.tsx +2 -2
- package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +5 -2
- package/src/components/List/__tests__/StyledListItem.spec.tsx +4 -1
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +15 -10
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +52 -32
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +128 -48
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +132 -52
- package/src/components/RichTextEditor/EditorEvent.ts +7 -0
- package/src/components/RichTextEditor/EditorToolbar.tsx +220 -0
- package/src/components/RichTextEditor/MentionList.tsx +69 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +396 -0
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +20 -0
- package/src/components/RichTextEditor/StyledToolbar.ts +32 -0
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +130 -0
- package/src/components/RichTextEditor/__tests__/MentionList.spec.tsx +109 -0
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +245 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +324 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +45 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +526 -0
- package/src/components/RichTextEditor/constants.ts +20 -0
- package/src/components/RichTextEditor/hero-editor.d.ts +8 -0
- package/src/components/RichTextEditor/index.tsx +8 -0
- package/src/components/RichTextEditor/utils/events.ts +31 -0
- package/src/components/RichTextEditor/utils/rnWebView.ts +19 -0
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +77 -0
- package/src/components/SectionHeading/__tests__/index.spec.tsx +14 -0
- package/src/components/SectionHeading/index.tsx +16 -9
- package/src/components/Tag/StyledTag.tsx +12 -2
- package/src/components/Tag/__tests__/Tag.spec.tsx +35 -8
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +118 -4
- package/src/components/Tag/index.tsx +9 -2
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -0
- package/src/components/Typography/Text/StyledText.tsx +2 -1
- package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
- package/src/components/Typography/Text/index.tsx +2 -1
- package/src/index.ts +8 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +101 -4
- package/src/theme/components/accordion.ts +19 -0
- package/src/theme/components/calendar.ts +34 -0
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/empty.ts +38 -0
- package/src/theme/components/fab.ts +4 -3
- package/src/theme/components/list.ts +1 -0
- package/src/theme/components/pinInput.ts +1 -1
- package/src/theme/components/richTextEditor.ts +34 -0
- package/src/theme/components/tag.ts +8 -2
- package/src/theme/components/typography.ts +1 -0
- package/src/theme/global/borders.ts +6 -6
- package/src/theme/global/colors.ts +4 -1
- package/src/theme/index.ts +12 -0
- package/testUtils/setup.tsx +17 -0
- package/types/components/Accordion/AccordionItem.d.ts +14 -0
- package/types/components/Accordion/StyledAccordion.d.ts +32 -0
- package/types/components/Accordion/__tests__/AccordionItem.spec.d.ts +1 -0
- package/types/components/Accordion/__tests__/StyledAccordion.spec.d.ts +1 -0
- package/types/components/Accordion/__tests__/index.spec.d.ts +1 -0
- package/types/components/Accordion/index.d.ts +38 -0
- package/types/components/Accordion/utils.d.ts +1 -0
- package/types/components/Button/IconButton.d.ts +1 -1
- package/types/components/Calendar/CalendarRowItem.d.ts +10 -0
- package/types/components/Calendar/StyledCalendar.d.ts +54 -0
- package/types/components/Calendar/__tests__/CalendarRowItem.spec.d.ts +1 -0
- package/types/components/Calendar/__tests__/helper.spec.d.ts +1 -0
- package/types/components/Calendar/__tests__/index.spec.d.ts +1 -0
- package/types/components/Calendar/helpers.d.ts +3 -0
- package/types/components/Calendar/index.d.ts +40 -0
- package/types/components/Collapse/index.d.ts +1 -1
- package/types/components/ContentNavigator/index.d.ts +5 -1
- package/types/components/Empty/StyledEmpty.d.ts +31 -0
- package/types/components/Empty/__tests__/index.spec.d.ts +1 -0
- package/types/components/Empty/index.d.ts +26 -0
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +6 -1
- package/types/components/FAB/ActionGroup/index.d.ts +6 -1
- package/types/components/FAB/index.d.ts +1 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/List/StyledBasicListItem.d.ts +3 -3
- package/types/components/List/StyledListItem.d.ts +3 -3
- package/types/components/RichTextEditor/EditorEvent.d.ts +3 -0
- package/types/components/RichTextEditor/EditorToolbar.d.ts +17 -0
- package/types/components/RichTextEditor/MentionList.d.ts +12 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +65 -0
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +16 -0
- package/types/components/RichTextEditor/StyledToolbar.d.ts +21 -0
- package/types/components/RichTextEditor/__tests__/EditorToolbar.spec.d.ts +1 -0
- package/types/components/RichTextEditor/__tests__/MentionList.spec.d.ts +1 -0
- package/types/components/RichTextEditor/__tests__/RichTextEditor.spec.d.ts +1 -0
- package/types/components/RichTextEditor/constants.d.ts +19 -0
- package/types/components/RichTextEditor/index.d.ts +5 -0
- package/types/components/RichTextEditor/utils/events.d.ts +8 -0
- package/types/components/RichTextEditor/utils/rnWebView.d.ts +7 -0
- package/types/components/SectionHeading/index.d.ts +2 -2
- package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
- package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
- package/types/components/Tag/StyledTag.d.ts +1 -1
- package/types/components/Tag/index.d.ts +1 -1
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/index.d.ts +5 -1
- package/types/theme/components/accordion.d.ts +13 -0
- package/types/theme/components/calendar.d.ts +26 -0
- package/types/theme/components/empty.d.ts +28 -0
- package/types/theme/components/fab.d.ts +1 -0
- package/types/theme/components/list.d.ts +1 -0
- package/types/theme/components/richTextEditor.d.ts +26 -0
- package/types/theme/components/tag.d.ts +8 -2
- package/types/theme/components/typography.d.ts +1 -0
- package/types/theme/global/colors.d.ts +4 -1
- package/types/theme/global/index.d.ts +4 -1
- package/types/theme/index.d.ts +8 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import Typography from '../../Typography';
|
|
4
|
+
import Accordion, { AccordionProps } from '..';
|
|
5
|
+
|
|
6
|
+
const AccordionExample = (props: Omit<AccordionProps<string>, 'items'>) => (
|
|
7
|
+
<Accordion
|
|
8
|
+
items={[
|
|
9
|
+
{
|
|
10
|
+
header: 'Accordion header 1',
|
|
11
|
+
content: <Typography.Text>Accordion content 1</Typography.Text>,
|
|
12
|
+
key: 'acc1',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
header: 'Accordion header 2',
|
|
16
|
+
content: <Typography.Text>Accordion content 2</Typography.Text>,
|
|
17
|
+
key: 'acc2',
|
|
18
|
+
},
|
|
19
|
+
]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const ControlledAccordionExample = () => {
|
|
25
|
+
const [activeItem, setActiveItem] = React.useState('acc2');
|
|
26
|
+
return (
|
|
27
|
+
<AccordionExample activeItemKey={activeItem} onItemPress={setActiveItem} />
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe('Accordion', () => {
|
|
32
|
+
it('renders correctly', () => {
|
|
33
|
+
const wrapper = renderWithTheme(<AccordionExample />);
|
|
34
|
+
|
|
35
|
+
expect(wrapper.getAllByText('Accordion header 1')).toHaveLength(1);
|
|
36
|
+
expect(wrapper.getAllByText('Accordion header 2')).toHaveLength(1);
|
|
37
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('allows fully controlled', () => {
|
|
41
|
+
const wrapper = renderWithTheme(<ControlledAccordionExample />);
|
|
42
|
+
|
|
43
|
+
expect(wrapper.getAllByText('Accordion header 1')).toHaveLength(1);
|
|
44
|
+
expect(wrapper.getAllByText('Accordion header 2')).toHaveLength(1);
|
|
45
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('renders correctly when variant is card', () => {
|
|
49
|
+
const wrapper = renderWithTheme(<AccordionExample variant="card" />);
|
|
50
|
+
|
|
51
|
+
expect(wrapper.getAllByTestId('accordion-spacer')).toHaveLength(1);
|
|
52
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { Key, ReactElement, useMemo } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import AccordionItem from './AccordionItem';
|
|
4
|
+
import { Spacer, StyledWrapper } from './StyledAccordion';
|
|
5
|
+
import { usePropsOrInternalState } from './utils';
|
|
6
|
+
|
|
7
|
+
export interface AccordionProps<K extends Key> {
|
|
8
|
+
/**
|
|
9
|
+
* List of accordion items to be rendered. Each item must have an unique key.
|
|
10
|
+
*/
|
|
11
|
+
items: {
|
|
12
|
+
header: string | ReactElement;
|
|
13
|
+
content: ReactElement;
|
|
14
|
+
key: K;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
testID?: string;
|
|
17
|
+
}[];
|
|
18
|
+
/**
|
|
19
|
+
* Key of the active item.
|
|
20
|
+
* When activeItemKey and onItemPress is passed, the component is fully controlled.
|
|
21
|
+
* Otherwise, it would be uncontrolled.
|
|
22
|
+
*/
|
|
23
|
+
activeItemKey?: K;
|
|
24
|
+
/**
|
|
25
|
+
* Callback invoked when an item is pressed.
|
|
26
|
+
*/
|
|
27
|
+
onItemPress?: (key: K) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Item type.
|
|
30
|
+
*/
|
|
31
|
+
variant?: 'default' | 'card';
|
|
32
|
+
/**
|
|
33
|
+
* Additional style.
|
|
34
|
+
*/
|
|
35
|
+
style?: StyleProp<ViewStyle>;
|
|
36
|
+
/**
|
|
37
|
+
* Testing id of the component.
|
|
38
|
+
*/
|
|
39
|
+
testID?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const Accordion = <K extends Key>({
|
|
43
|
+
items,
|
|
44
|
+
activeItemKey,
|
|
45
|
+
onItemPress,
|
|
46
|
+
variant = 'default',
|
|
47
|
+
style,
|
|
48
|
+
testID,
|
|
49
|
+
}: AccordionProps<K>) => {
|
|
50
|
+
const defaultValue = useMemo(
|
|
51
|
+
() => (typeof activeItemKey === 'number' ? NaN : '') as K,
|
|
52
|
+
[activeItemKey]
|
|
53
|
+
);
|
|
54
|
+
const [_activeItemKey, _onItemPress] = usePropsOrInternalState<K>(
|
|
55
|
+
defaultValue,
|
|
56
|
+
activeItemKey,
|
|
57
|
+
onItemPress
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<StyledWrapper style={style} testID={testID}>
|
|
62
|
+
{items.map(({ key, ...props }, index) => {
|
|
63
|
+
const open = _activeItemKey === key;
|
|
64
|
+
return (
|
|
65
|
+
<React.Fragment key={key}>
|
|
66
|
+
{variant === 'card' && index !== 0 && (
|
|
67
|
+
<Spacer testID="accordion-spacer" />
|
|
68
|
+
)}
|
|
69
|
+
<AccordionItem
|
|
70
|
+
{...props}
|
|
71
|
+
open={open}
|
|
72
|
+
onPress={() => _onItemPress(open ? defaultValue : key)}
|
|
73
|
+
variant={variant}
|
|
74
|
+
/>
|
|
75
|
+
</React.Fragment>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</StyledWrapper>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Accordion;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export function usePropsOrInternalState<T>(
|
|
4
|
+
initialState: T,
|
|
5
|
+
state: T | undefined,
|
|
6
|
+
setState: ((val: T) => void) | undefined
|
|
7
|
+
): [T, (val: T) => void] {
|
|
8
|
+
const [internalState, setInternalState] = React.useState<T>(initialState);
|
|
9
|
+
|
|
10
|
+
return [state || internalState, setState || setInternalState];
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Typography from '../Typography';
|
|
3
|
+
import {
|
|
4
|
+
StyledCalendarCell,
|
|
5
|
+
StyledCalendarRowItem,
|
|
6
|
+
StyledMark,
|
|
7
|
+
} from './StyledCalendar';
|
|
8
|
+
|
|
9
|
+
const getCellVariant = (
|
|
10
|
+
isSelected: boolean = false,
|
|
11
|
+
isCurrent: boolean = false
|
|
12
|
+
) => {
|
|
13
|
+
if (isSelected) return 'selected';
|
|
14
|
+
if (isCurrent) return 'current';
|
|
15
|
+
|
|
16
|
+
return 'default';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface CalendarRowItemProps {
|
|
20
|
+
date?: Date;
|
|
21
|
+
onPress?: () => void;
|
|
22
|
+
isCurrent?: boolean;
|
|
23
|
+
isSelected?: boolean;
|
|
24
|
+
textIntent?: 'body' | 'subdued';
|
|
25
|
+
marked?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const CalendarRowItem = ({
|
|
29
|
+
date,
|
|
30
|
+
onPress,
|
|
31
|
+
isCurrent,
|
|
32
|
+
isSelected,
|
|
33
|
+
textIntent = 'body',
|
|
34
|
+
marked = false,
|
|
35
|
+
}: CalendarRowItemProps) => (
|
|
36
|
+
<StyledCalendarRowItem testID="calendar-date-cell">
|
|
37
|
+
<StyledCalendarCell
|
|
38
|
+
variant={getCellVariant(isSelected, isCurrent)}
|
|
39
|
+
onPress={onPress}
|
|
40
|
+
>
|
|
41
|
+
<Typography.Text intent={isSelected ? 'inverted' : textIntent}>
|
|
42
|
+
{date ? date.getDate() : ''}
|
|
43
|
+
</Typography.Text>
|
|
44
|
+
{marked ? (
|
|
45
|
+
<StyledMark
|
|
46
|
+
testID="calendar-date-mark"
|
|
47
|
+
variant={isSelected ? 'inverted' : 'primary'}
|
|
48
|
+
/>
|
|
49
|
+
) : null}
|
|
50
|
+
</StyledCalendarCell>
|
|
51
|
+
</StyledCalendarRowItem>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default CalendarRowItem;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
|
+
import { TouchableOpacity, View, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const StyledContainer = styled(View)(({ theme }) => ({
|
|
5
|
+
backgroundColor: theme.__hd__.calendar.colors.background,
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
const StyledCalendarHeader = styled(View)(({ theme }) => ({
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
paddingHorizontal: theme.__hd__.calendar.space.headerHorizontalPadding,
|
|
11
|
+
paddingVertical: theme.__hd__.calendar.space.headerVerticalPadding,
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const StyledCalendarDayNameCell = styled(View)<ViewProps>(({ theme }) => ({
|
|
15
|
+
width: theme.__hd__.calendar.sizes.cellWidth,
|
|
16
|
+
height: theme.__hd__.calendar.sizes.cellHeight,
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const StyledCalendarCell = styled(TouchableOpacity)<{
|
|
22
|
+
variant?: 'default' | 'current' | 'selected';
|
|
23
|
+
}>(({ theme, variant = 'default' }) => ({
|
|
24
|
+
borderColor: theme.__hd__.calendar.colors.border,
|
|
25
|
+
borderWidth: variant === 'current' ? 1 : 0,
|
|
26
|
+
borderRadius: theme.__hd__.calendar.radii.default,
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
backgroundColor:
|
|
30
|
+
variant === 'selected' ? theme.__hd__.calendar.colors.primary : undefined,
|
|
31
|
+
width: theme.__hd__.calendar.sizes.cellCircleWidth,
|
|
32
|
+
height: theme.__hd__.calendar.sizes.cellCircleHeight,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
const StyledCalendarRow = styled(View)<ViewProps>(({ theme }) => ({
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
paddingHorizontal: theme.__hd__.calendar.space.rowVerticalPadding,
|
|
38
|
+
flexWrap: 'wrap',
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const StyledCalendarRowItem = styled(View)<ViewProps>(({ theme }) => ({
|
|
42
|
+
flexBasis: `${Math.floor(100.0 / 7.0).toString()}%`,
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
width: theme.__hd__.calendar.sizes.cellWidth,
|
|
45
|
+
height: theme.__hd__.calendar.sizes.cellHeight,
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const StyledDisabledCalendarRowItem = styled(View)<ViewProps>(({ theme }) => ({
|
|
50
|
+
flexBasis: `${Math.floor(100.0 / 7.0).toString()}%`,
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
width: theme.__hd__.calendar.sizes.cellWidth,
|
|
53
|
+
height: theme.__hd__.calendar.sizes.cellHeight,
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
const StyledMark = styled(View)<{ variant: 'primary' | 'inverted' }>(
|
|
57
|
+
({ theme, variant = 'primary' }) => ({
|
|
58
|
+
width: theme.__hd__.calendar.sizes.markWidth,
|
|
59
|
+
height: theme.__hd__.calendar.sizes.markHeight,
|
|
60
|
+
borderRadius: theme.__hd__.calendar.radii.default,
|
|
61
|
+
backgroundColor: theme.__hd__.calendar.colors[variant],
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
bottom: '10%',
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
StyledContainer,
|
|
69
|
+
StyledCalendarHeader,
|
|
70
|
+
StyledCalendarRow,
|
|
71
|
+
StyledCalendarRowItem,
|
|
72
|
+
StyledDisabledCalendarRowItem,
|
|
73
|
+
StyledCalendarDayNameCell,
|
|
74
|
+
StyledCalendarCell,
|
|
75
|
+
StyledMark,
|
|
76
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import CalendarRowItem from '../CalendarRowItem';
|
|
4
|
+
|
|
5
|
+
describe('CalendarRowItem', () => {
|
|
6
|
+
it.each`
|
|
7
|
+
textIntent
|
|
8
|
+
${'body'}
|
|
9
|
+
${'subdued'}
|
|
10
|
+
`('renders correctly', ({ textIntent }) => {
|
|
11
|
+
const { toJSON } = renderWithTheme(
|
|
12
|
+
<CalendarRowItem
|
|
13
|
+
date={new Date(2022, 10, 10)}
|
|
14
|
+
onPress={jest.fn()}
|
|
15
|
+
textIntent={textIntent}
|
|
16
|
+
marked
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
expect(toJSON()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it.each`
|
|
24
|
+
isCurrent
|
|
25
|
+
${true}
|
|
26
|
+
${false}
|
|
27
|
+
`(
|
|
28
|
+
'renders correctly when selected, and is current date equal to $current',
|
|
29
|
+
({ isCurrent }) => {
|
|
30
|
+
const { toJSON } = renderWithTheme(
|
|
31
|
+
<CalendarRowItem
|
|
32
|
+
date={new Date(2022, 10, 10)}
|
|
33
|
+
onPress={jest.fn()}
|
|
34
|
+
marked
|
|
35
|
+
isSelected
|
|
36
|
+
isCurrent={isCurrent}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(toJSON()).toMatchSnapshot();
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
it('renders correctly when is current date', () => {
|
|
45
|
+
const { toJSON } = renderWithTheme(
|
|
46
|
+
<CalendarRowItem
|
|
47
|
+
date={new Date(2022, 10, 10)}
|
|
48
|
+
onPress={jest.fn()}
|
|
49
|
+
marked
|
|
50
|
+
isSelected
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(toJSON()).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('renders mark when date is marked', () => {
|
|
58
|
+
const { queryByTestId } = renderWithTheme(
|
|
59
|
+
<CalendarRowItem
|
|
60
|
+
date={new Date(2022, 10, 10)}
|
|
61
|
+
onPress={jest.fn()}
|
|
62
|
+
marked
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(queryByTestId('calendar-date-mark')).toBeTruthy();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('not renders mark when date is not marked', () => {
|
|
70
|
+
const { queryByTestId } = renderWithTheme(
|
|
71
|
+
<CalendarRowItem date={new Date(2022, 10, 10)} onPress={jest.fn()} />
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect(queryByTestId('calendar-date-mark')).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
});
|