@ornikar/kitt-universal 1.0.0-pre

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.
Files changed (146) hide show
  1. package/dist/index-browser-all-dev.es.js +1934 -0
  2. package/dist/index-browser-all-dev.es.js.map +1 -0
  3. package/dist/index-browser-all.es.js +1920 -0
  4. package/dist/index-browser-all.es.js.map +1 -0
  5. package/dist/index-node-12.13-dev.cjs.js +2059 -0
  6. package/dist/index-node-12.13-dev.cjs.js.map +1 -0
  7. package/dist/index-node-12.13.cjs.js +2048 -0
  8. package/dist/index-node-12.13.cjs.js.map +1 -0
  9. package/index.js +7 -0
  10. package/package.json +61 -0
  11. package/src/.eslintrc.json +42 -0
  12. package/src/Avatar/Avatar.stories.tsx +47 -0
  13. package/src/Avatar/Avatar.tsx +60 -0
  14. package/src/Avatar/__snapshots__/Avatar.stories.tsx.snap +1229 -0
  15. package/src/Button/Button.stories.tsx +303 -0
  16. package/src/Button/Button.tsx +60 -0
  17. package/src/Button/ButtonContainer.tsx +32 -0
  18. package/src/Button/ButtonContent.tsx +133 -0
  19. package/src/Button/__snapshots__/Button.stories.tsx.snap +7483 -0
  20. package/src/Button/useButton.ts +14 -0
  21. package/src/Card/Card.stories.tsx +33 -0
  22. package/src/Card/Card.tsx +25 -0
  23. package/src/Card/__snapshots__/Card.stories.tsx.snap +306 -0
  24. package/src/FullScreenModal/Body.tsx +25 -0
  25. package/src/FullScreenModal/FullScreenModal.stories.tsx +65 -0
  26. package/src/FullScreenModal/FullScreenModal.tsx +21 -0
  27. package/src/FullScreenModal/Header.tsx +129 -0
  28. package/src/FullScreenModal/__snapshots__/FullScreenModal.stories.tsx.snap +771 -0
  29. package/src/Icon/Icon.stories.tsx +61 -0
  30. package/src/Icon/Icon.tsx +37 -0
  31. package/src/Icon/SpinningIcon.tsx +38 -0
  32. package/src/Icon/SpinningIcon.web.css +13 -0
  33. package/src/Icon/SpinningIcon.web.tsx +11 -0
  34. package/src/Icon/__snapshots__/Icon.stories.tsx.snap +5648 -0
  35. package/src/KittBreakpoints.ts +44 -0
  36. package/src/KittThemeProvider.tsx +30 -0
  37. package/src/ListItem/ListItem.stories.tsx +124 -0
  38. package/src/ListItem/ListItem.tsx +61 -0
  39. package/src/ListItem/ListItemContent.tsx +17 -0
  40. package/src/ListItem/ListItemSideContent.tsx +41 -0
  41. package/src/ListItem/__snapshots__/ListItem.stories.tsx.snap +1514 -0
  42. package/src/Loader/LargeLoader.tsx +12 -0
  43. package/src/Loader/LargeLoader.web.css +103 -0
  44. package/src/Loader/LargeLoader.web.test.tsx +10 -0
  45. package/src/Loader/LargeLoader.web.tsx +18 -0
  46. package/src/Loader/Loader.stories.tsx +49 -0
  47. package/src/Loader/Loader.tsx +21 -0
  48. package/src/Loader/Loader.web.test.tsx +20 -0
  49. package/src/Loader/Loader.web.tsx +14 -0
  50. package/src/Loader/__snapshots__/LargeLoader.web.test.tsx.snap +33 -0
  51. package/src/Loader/__snapshots__/Loader.stories.tsx.snap +607 -0
  52. package/src/Loader/__snapshots__/Loader.web.test.tsx.snap +103 -0
  53. package/src/Message/Message.stories.tsx +104 -0
  54. package/src/Message/Message.tsx +114 -0
  55. package/src/Message/__snapshots__/Message.stories.tsx.snap +2776 -0
  56. package/src/Modal/Body.tsx +20 -0
  57. package/src/Modal/Footer.tsx +18 -0
  58. package/src/Modal/Header.tsx +66 -0
  59. package/src/Modal/Modal.stories.tsx +183 -0
  60. package/src/Modal/Modal.tsx +66 -0
  61. package/src/Modal/OnCloseContext.ts +3 -0
  62. package/src/Modal/__snapshots__/Modal.stories.tsx.snap +2960 -0
  63. package/src/Notification/Notification.stories.tsx +103 -0
  64. package/src/Notification/Notification.tsx +21 -0
  65. package/src/Notification/__snapshots__/Notification.stories.tsx.snap +2861 -0
  66. package/src/Overlay/Overlay.tsx +22 -0
  67. package/src/Tag/Tag.stories.tsx +19 -0
  68. package/src/Tag/Tag.tsx +31 -0
  69. package/src/Tag/__snapshots__/Tag.stories.tsx.snap +303 -0
  70. package/src/Tooltip/Tooltip.tsx +17 -0
  71. package/src/__mocks__/react-native-safe-area-context.tsx +26 -0
  72. package/src/forms/InputFeedback/InputFeedback.stories.tsx +20 -0
  73. package/src/forms/InputFeedback/InputFeedback.tsx +28 -0
  74. package/src/forms/InputFeedback/__snapshots__/InputFeedback.stories.tsx.snap +252 -0
  75. package/src/forms/InputField/InputField.stories.tsx +21 -0
  76. package/src/forms/InputField/InputField.tsx +45 -0
  77. package/src/forms/InputField/__snapshots__/InputField.stories.tsx.snap +240 -0
  78. package/src/forms/InputFormState.ts +1 -0
  79. package/src/forms/InputText/InputText.stories.tsx +87 -0
  80. package/src/forms/InputText/InputText.tsx +172 -0
  81. package/src/forms/InputText/__snapshots__/InputText.stories.tsx.snap +4274 -0
  82. package/src/forms/InputText/useInputText.ts +19 -0
  83. package/src/forms/Label/Label.stories.tsx +16 -0
  84. package/src/forms/Label/Label.tsx +17 -0
  85. package/src/forms/Label/__snapshots__/Label.stories.tsx.snap +174 -0
  86. package/src/forms/Radio/Radio.stories.tsx +50 -0
  87. package/src/forms/Radio/Radio.tsx +81 -0
  88. package/src/forms/Radio/__snapshots__/Radio.stories.tsx.snap +967 -0
  89. package/src/forms/TextArea/TextArea.stories.tsx +74 -0
  90. package/src/forms/TextArea/TextArea.tsx +12 -0
  91. package/src/forms/TextArea/__snapshots__/TextArea.stories.tsx.snap +2091 -0
  92. package/src/index.ts +43 -0
  93. package/src/stories/Block.tsx +24 -0
  94. package/src/stories/Flex.tsx +16 -0
  95. package/src/stories/color-tokens.stories.tsx +143 -0
  96. package/src/stories-list.tsx +22 -0
  97. package/src/story-components/Section.tsx +56 -0
  98. package/src/story-components/Story.tsx +24 -0
  99. package/src/story-components/StoryDecorator.tsx +8 -0
  100. package/src/story-components/StoryGrid.tsx +80 -0
  101. package/src/story-components/StoryTitle.stories.tsx +12 -0
  102. package/src/story-components/StoryTitle.tsx +69 -0
  103. package/src/story-components/__snapshots__/StoryTitle.stories.tsx.snap +155 -0
  104. package/src/story-components/index.ts +13 -0
  105. package/src/themes/default.ts +34 -0
  106. package/src/themes/late-ocean/avatarLateOceanTheme.ts +12 -0
  107. package/src/themes/late-ocean/buttonLateOceanTheme.ts +37 -0
  108. package/src/themes/late-ocean/cardLateOceanTheme.ts +19 -0
  109. package/src/themes/late-ocean/colorsLateOceanTheme.ts +19 -0
  110. package/src/themes/late-ocean/feedbackMessageLateOceanTheme.ts +10 -0
  111. package/src/themes/late-ocean/formLateOceanTheme.ts +9 -0
  112. package/src/themes/late-ocean/fullScreenModalLateOceanTheme.ts +8 -0
  113. package/src/themes/late-ocean/inputFieldLateOceanTheme.ts +4 -0
  114. package/src/themes/late-ocean/inputLateOceanTheme.ts +55 -0
  115. package/src/themes/late-ocean/listItemLateOceanTheme.ts +8 -0
  116. package/src/themes/late-ocean/radioLateOceanTheme.ts +19 -0
  117. package/src/themes/late-ocean/shadowsLateOceanTheme.ts +3 -0
  118. package/src/themes/late-ocean/tagLateOceanTheme.ts +17 -0
  119. package/src/themes/late-ocean/typographyLateOceanTheme.ts +94 -0
  120. package/src/themes/palettes/lateOceanColorPalette.ts +24 -0
  121. package/src/typings/babel-config.d.ts +6 -0
  122. package/src/typings/metro.d.ts +6 -0
  123. package/src/typography/Typography.stories.tsx +115 -0
  124. package/src/typography/Typography.tsx +165 -0
  125. package/src/typography/TypographyIcon.stories.tsx +32 -0
  126. package/src/typography/TypographyIcon.tsx +35 -0
  127. package/src/typography/TypographyLink.stories.tsx +89 -0
  128. package/src/typography/TypographyLink.tsx +48 -0
  129. package/src/typography/__snapshots__/Typography.stories.tsx.snap +6118 -0
  130. package/src/typography/__snapshots__/TypographyIcon.stories.tsx.snap +334 -0
  131. package/src/typography/__snapshots__/TypographyLink.stories.tsx.snap +10945 -0
  132. package/src/utils/storybook/decorators/KittThemeDecorator.tsx +11 -0
  133. package/src/utils/storybook/decorators/SafeAreaProviderDecorator.tsx +11 -0
  134. package/src/utils/storybook/setup-global-decorators.ts +6 -0
  135. package/src/utils/tests/renderWithProvidersUtils.tsx +17 -0
  136. package/src/utils/typeUtils.ts +6 -0
  137. package/src/utils/windowSize/MatchWindowSize.tsx +14 -0
  138. package/src/utils/windowSize/__snapshots__/windowSize.stories.tsx.snap +1485 -0
  139. package/src/utils/windowSize/createWindowSizeHelper.test.ts +11 -0
  140. package/src/utils/windowSize/createWindowSizeHelper.ts +65 -0
  141. package/src/utils/windowSize/useMatchWindowSize.ts +14 -0
  142. package/src/utils/windowSize/useWindowSize.ts +1 -0
  143. package/src/utils/windowSize/windowSize.stories.tsx +116 -0
  144. package/tsconfig.build.json +30 -0
  145. package/tsconfig.json +13 -0
  146. package/yarn-error.log +22274 -0
@@ -0,0 +1,165 @@
1
+ import type { FC, ReactElement, ReactNode } from 'react';
2
+ import React, { createContext, useContext } from 'react';
3
+ import type { TextProps } from 'react-native';
4
+ import styled from 'styled-components/native';
5
+ import type { Except, SetOptional } from 'type-fest';
6
+
7
+ type TypographyHeaderType = `header${'1' | '2' | '3' | '4' | '5'}`;
8
+ type TypographyBodyType = 'body' | `body-${'large' | 'medium' | 'small' | 'xsmall'}`;
9
+ type TypographyType = TypographyHeaderType | TypographyBodyType;
10
+ type TypographyVariant = 'regular' | 'bold' | 'italic';
11
+ export type TypographyColor =
12
+ | 'black'
13
+ | 'black-light'
14
+ | 'white'
15
+ | 'white-light'
16
+ | 'grey'
17
+ | 'grey-light'
18
+ | 'primary'
19
+ | 'primary-light'
20
+ | 'accent'
21
+ | 'success'
22
+ | 'danger';
23
+
24
+ const TypographyTypeContext = createContext<TypographyType | undefined>(undefined);
25
+ const TypographyColorContext = createContext<TypographyColor>('black');
26
+
27
+ export function useTypographyColor(): TypographyColor {
28
+ return useContext(TypographyColorContext);
29
+ }
30
+
31
+ interface StyledTypographyProps {
32
+ isHeader: boolean;
33
+ type?: TypographyType;
34
+ variant: TypographyVariant;
35
+ color?: TypographyColor;
36
+ }
37
+
38
+ const StyledTypography = styled.Text<StyledTypographyProps>`
39
+ /* font */
40
+ ${({ theme, isHeader, type, variant }) => {
41
+ const { headers, bodies } = theme.kitt.typography.types;
42
+
43
+ return `
44
+ /* type */
45
+ ${
46
+ !type
47
+ ? ''
48
+ : `
49
+ font-family: ${isHeader ? headers.fontFamily[variant] : bodies.fontFamily[variant]};
50
+ font-size: ${
51
+ isHeader
52
+ ? headers.configs[type as TypographyHeaderType].baseAndSmall.fontSize
53
+ : bodies.configs[type as TypographyBodyType].baseAndSmall.fontSize
54
+ };
55
+ line-height: ${
56
+ isHeader
57
+ ? headers.configs[type as TypographyHeaderType].baseAndSmall.lineHeight
58
+ : bodies.configs[type as TypographyBodyType].baseAndSmall.lineHeight
59
+ };
60
+ `
61
+ }
62
+
63
+ /* variant */
64
+ font-weight: ${isHeader ? headers.fontWeight : bodies.fontWeight[variant]};
65
+ font-style: ${isHeader ? headers.fontStyle : bodies.fontStyle[variant]};
66
+ `;
67
+ }}
68
+
69
+ /* color */
70
+ ${({ theme, color }) =>
71
+ !color
72
+ ? ''
73
+ : `
74
+ color: ${theme.kitt.typography.colors[color]};
75
+ text-decoration-color: ${theme.kitt.typography.colors[color]};
76
+ `}
77
+ `;
78
+
79
+ export interface TypographyProps extends Except<TextProps, 'accessibilityRole'> {
80
+ // Find mapping for web here: https://www.w3.org/TR/html-aria/
81
+ accessibilityRole: NonNullable<TextProps['accessibilityRole']> | null;
82
+ /** base type. Inherited from parent Typography if not specified */
83
+ base?: TypographyType;
84
+ small?: TypographyType;
85
+ medium?: TypographyType;
86
+ large?: TypographyType;
87
+ /** Default to regular for bodies and bold of headers. Is not inherited. */
88
+ variant?: TypographyVariant;
89
+ /** Inherited from parent Typography if not specified, or black if no Typography parent found. */
90
+ color?: TypographyColor;
91
+ children: ReactNode;
92
+ }
93
+ export type TypographyPropsWithoutRole = Except<TypographyProps, 'accessibilityRole'>;
94
+
95
+ const isTypeHeader = (type: TypographyType): boolean => type.startsWith('header');
96
+ const isTypographyHeader = (base: TypographyType | undefined, typeInContext: TypographyType | undefined): boolean => {
97
+ if (base) return isTypeHeader(base);
98
+ if (typeInContext) return isTypeHeader(typeInContext);
99
+
100
+ throw new Error('You must set a "base" prop or wrap this Typography in one that does.');
101
+ };
102
+
103
+ export function Typography({
104
+ accessibilityRole,
105
+ base,
106
+ variant,
107
+ color,
108
+ ...otherProps
109
+ }: TypographyProps): ReactElement | null {
110
+ const typeInContext = useContext(TypographyTypeContext);
111
+ const isHeader = isTypographyHeader(base, typeInContext);
112
+ const nonNullableVariant: TypographyVariant = variant ?? (isHeader ? 'bold' : 'regular');
113
+ const colorWithDefaultToBlack: TypographyColor | undefined = color ?? (typeInContext ? undefined : 'black');
114
+
115
+ const content = base ? (
116
+ // use the type and pass the type to the context for children
117
+ <TypographyTypeContext.Provider value={base}>
118
+ <StyledTypography
119
+ color={colorWithDefaultToBlack}
120
+ isHeader={isHeader}
121
+ type={base}
122
+ variant={nonNullableVariant}
123
+ {...otherProps}
124
+ />
125
+ </TypographyTypeContext.Provider>
126
+ ) : (
127
+ <StyledTypography
128
+ color={colorWithDefaultToBlack}
129
+ isHeader={isHeader}
130
+ variant={nonNullableVariant}
131
+ {...otherProps}
132
+ />
133
+ );
134
+
135
+ return color ? <TypographyColorContext.Provider value={color}>{content}</TypographyColorContext.Provider> : content;
136
+ }
137
+
138
+ export type TypographyTextProps = SetOptional<TypographyProps, 'accessibilityRole'>;
139
+ function TypographyText(props: TypographyTextProps): ReactElement {
140
+ return <Typography accessibilityRole={null} {...props} />;
141
+ }
142
+
143
+ function TypographyParagraph(props: TypographyTextProps): ReactElement {
144
+ // @ts-expect-error paragraph is not allowed in react-native but exists in react-native-web
145
+ return <Typography accessibilityRole="paragraph" {...props} />;
146
+ }
147
+
148
+ export type TypographyHeadingProps = TypographyPropsWithoutRole;
149
+
150
+ const createHeading = (level: string): FC<TypographyHeadingProps> => {
151
+ // https://github.com/necolas/react-native-web/issues/401
152
+ function TypographyHeading(props: TypographyHeadingProps): ReactElement {
153
+ return <Typography accessibilityRole="header" {...props} aria-level={level} />;
154
+ }
155
+ TypographyHeading.displayName = `TypographyHeading${level}`;
156
+ return TypographyHeading;
157
+ };
158
+
159
+ Typography.Text = TypographyText;
160
+ Typography.Paragraph = TypographyParagraph;
161
+ Typography.h1 = createHeading('1');
162
+ Typography.h2 = createHeading('2');
163
+ Typography.h3 = createHeading('3');
164
+ Typography.h4 = createHeading('4');
165
+ Typography.h5 = createHeading('5');
@@ -0,0 +1,32 @@
1
+ import { AlertCircleIcon } from '@ornikar/kitt-icons';
2
+ import { storiesOf } from '@storybook/react-native';
3
+ import React from 'react';
4
+ import { StoryComponents } from '../story-components';
5
+ import { Typography } from './Typography';
6
+ import { TypographyIcon } from './TypographyIcon';
7
+
8
+ const { Section, Story } = StoryComponents;
9
+ storiesOf('kitt/Typography', module).add('Icon', () => (
10
+ <Story title="Icons">
11
+ <Section.DemoSection>
12
+ <TypographyIcon color="black" icon={<AlertCircleIcon />} />
13
+ </Section.DemoSection>
14
+
15
+ <Section title="Icons inside text">
16
+ <Typography.Text base="body-large" color="black">
17
+ <TypographyIcon icon={<AlertCircleIcon />} /> The future is in our{' '}
18
+ <Typography.Text color="primary">
19
+ hands <TypographyIcon icon={<AlertCircleIcon />} />
20
+ </Typography.Text>{' '}
21
+ to shape.
22
+ </Typography.Text>
23
+ <Typography.Text base="header1" color="black">
24
+ <TypographyIcon icon={<AlertCircleIcon />} /> The future is in our{' '}
25
+ <Typography.Text color="primary">
26
+ hands <TypographyIcon icon={<AlertCircleIcon />} />
27
+ </Typography.Text>{' '}
28
+ to shape.
29
+ </Typography.Text>
30
+ </Section>
31
+ </Story>
32
+ ));
@@ -0,0 +1,35 @@
1
+ import type { ReactElement } from 'react';
2
+ import React from 'react';
3
+ import { useTheme } from 'styled-components/native';
4
+ import type { Except } from 'type-fest';
5
+ import type { IconProps } from '../Icon/Icon';
6
+ import { Icon } from '../Icon/Icon';
7
+ import type { SetNonNullable } from '../utils/typeUtils';
8
+ import type { TypographyProps } from './Typography';
9
+ import { useTypographyColor } from './Typography';
10
+
11
+ export interface TypographyIconProps extends Except<IconProps, 'color'> {
12
+ color?: TypographyProps['color'];
13
+ }
14
+
15
+ function TypographyIconInheritColor(props: TypographyIconProps): ReactElement {
16
+ const color = useTypographyColor();
17
+ const theme = useTheme();
18
+ return <Icon {...props} color={theme.kitt.typography.colors[color]} />;
19
+ }
20
+
21
+ function TypographyIconSpecifiedColor({
22
+ color,
23
+ ...otherProps
24
+ }: SetNonNullable<TypographyIconProps, 'color'>): ReactElement {
25
+ const theme = useTheme();
26
+ return <Icon {...otherProps} color={theme.kitt.typography.colors[color]} />;
27
+ }
28
+
29
+ export function TypographyIcon({ color, ...otherProps }: TypographyIconProps): ReactElement {
30
+ if (color) {
31
+ return <TypographyIconSpecifiedColor color={color} {...otherProps} />;
32
+ }
33
+
34
+ return <TypographyIconInheritColor {...otherProps} />;
35
+ }
@@ -0,0 +1,89 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import { storiesOf } from '@storybook/react-native';
3
+ import React from 'react';
4
+ import styled from 'styled-components/native';
5
+ import type { BlockProps } from '../stories/Block';
6
+ import { BlockWithPadding } from '../stories/Block';
7
+ import { StoryComponents } from '../story-components';
8
+ import type { TypographyProps } from './Typography';
9
+ import { Typography } from './Typography';
10
+ import { TypographyLink } from './TypographyLink';
11
+
12
+ const { Story, StoryGrid, StoryTitle } = StoryComponents;
13
+ const groups: {
14
+ background: BlockProps['color'];
15
+ colors: [TypographyProps['color'], TypographyProps['color']];
16
+ }[] = [
17
+ { background: 'transparent', colors: ['black', 'black-light'] },
18
+ { background: 'dark', colors: ['white', 'white-light'] },
19
+ ];
20
+
21
+ const variants: NonNullable<TypographyProps['variant']>[] = ['bold', 'regular', 'italic'];
22
+ const typographyTypes: TypographyProps['base'][] = ['body-large', 'body-medium', 'body', 'body-small', 'body-xsmall'];
23
+
24
+ const ucFirst = (string: string): string => string[0].toUpperCase() + string.slice(1);
25
+ const formatColorName = (colorName = 'black'): string => colorName.split('-').map(ucFirst).join('\u00A0');
26
+
27
+ const ViewWithMarginBottom = styled.View`
28
+ overflow: hidden;
29
+ margin-bottom: 10px;
30
+ `;
31
+
32
+ storiesOf('kitt/Typography', module).add('Link', () => (
33
+ <Story title="Link">
34
+ {groups.map(({ background, colors }, index) => (
35
+ <BlockWithPadding
36
+ /* eslint-disable-next-line react/no-array-index-key */
37
+ key={index}
38
+ color={background}
39
+ >
40
+ <StoryGrid.Row breakpoint="medium">
41
+ {colors.filter(Boolean).map((color) =>
42
+ variants.map((variant) => (
43
+ <StoryGrid.Col key={variant}>
44
+ <StoryTitle.Level2 color={color}>
45
+ {formatColorName(color)} {ucFirst(variant)}
46
+ </StoryTitle.Level2>
47
+
48
+ {typographyTypes.map((base) => {
49
+ return (
50
+ <ViewWithMarginBottom key={base}>
51
+ {[false, true].map((noUnderline) => (
52
+ <Typography.Paragraph
53
+ key={noUnderline ? 'no-underline' : 'underline'}
54
+ variant={variant}
55
+ base={base}
56
+ color={color}
57
+ >
58
+ This is a paragraph and inside it{' '}
59
+ <TypographyLink
60
+ base={base}
61
+ noUnderline={noUnderline}
62
+ href="#"
63
+ onPress={action('Link pressed')}
64
+ >
65
+ there is a link
66
+ </TypographyLink>{' '}
67
+ that leads home.{' '}
68
+ <TypographyLink
69
+ noUnderline={noUnderline}
70
+ variant="bold"
71
+ href="#"
72
+ onPress={action('Link pressed')}
73
+ >
74
+ Here a bold link
75
+ </TypographyLink>
76
+ .
77
+ </Typography.Paragraph>
78
+ ))}
79
+ </ViewWithMarginBottom>
80
+ );
81
+ })}
82
+ </StoryGrid.Col>
83
+ )),
84
+ )}
85
+ </StoryGrid.Row>
86
+ </BlockWithPadding>
87
+ ))}
88
+ </Story>
89
+ ));
@@ -0,0 +1,48 @@
1
+ import type { ReactElement } from 'react';
2
+ import React from 'react';
3
+ import { Platform } from 'react-native';
4
+ import styled from 'styled-components/native';
5
+ import type { SetRequired } from 'type-fest';
6
+ import type { TypographyProps, TypographyPropsWithoutRole } from './Typography';
7
+ import { Typography } from './Typography';
8
+
9
+ interface StyledTypographyLinkProps extends TypographyPropsWithoutRole {
10
+ disabled?: boolean;
11
+ noUnderline?: boolean;
12
+ }
13
+
14
+ const StyledLink = styled(Typography).withConfig({
15
+ shouldForwardProp: (prop, defaultValidatorFn) => !['disabled', 'noUnderline'].includes(prop),
16
+ })<TypographyLinkProps & TypographyProps>`
17
+ text-decoration: ${({ noUnderline }) => (noUnderline ? 'none' : 'underline')};
18
+ ${({ disabled }) =>
19
+ Platform.OS === 'web'
20
+ ? `
21
+ text-decoration-color: inherit;
22
+ transition: color 0.2s ease-in-out;
23
+ cursor: ${disabled ? 'not-allowed' : 'pointer'};
24
+ `
25
+ : null};
26
+ margin: 0;
27
+ `;
28
+
29
+ interface TypographyLinkProps extends SetRequired<StyledTypographyLinkProps, 'onPress'> {
30
+ href?: string;
31
+ }
32
+
33
+ export function TypographyLink({
34
+ disabled,
35
+ noUnderline,
36
+ variant = 'bold',
37
+ ...otherProps
38
+ }: TypographyLinkProps): ReactElement {
39
+ return (
40
+ <StyledLink
41
+ disabled={disabled}
42
+ noUnderline={noUnderline}
43
+ variant={variant}
44
+ accessibilityRole="link"
45
+ {...otherProps}
46
+ />
47
+ );
48
+ }