Skip to content

Commit d51b86e

Browse files
committed
2 parents 143fb91 + 67c0184 commit d51b86e

File tree

13 files changed

+134
-2657
lines changed

13 files changed

+134
-2657
lines changed

.changeset/shaggy-cows-jam.md

-5
This file was deleted.

.changeset/tasty-melons-provide.md

-5
This file was deleted.

apps/native-ui-storybook/components/Alert/Alert.docs.mdx

+18-15
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,18 @@ const MyComponent = () => {
7979

8080
## Props
8181

82-
| Property | Type | Description | Default |
83-
| ------------------- | -------------------------------------- | ------------------------------------------------------------------ | ------- |
84-
| `colorScheme` | `'cyan' \| 'green' \| 'gold' \| 'red'` | The colour scheme of the alert. Mapped to an icon. | 'info' |
85-
| `title` | `string` | The title of the alert. | |
86-
| `text` | `string` | The text of the alert. | |
87-
| `link` | `string` | The text of the link. | |
88-
| `onPressLink` | `() => void` | A callback function to be called when the link is clicked. | |
89-
| `onPressIconButton` | `() => void` | A callback function to be called when the icon button is clicked. | |
90-
| `onClose` | `() => void` | A callback function to be called when the close button is clicked. | |
82+
| Property | Type | Description | Default |
83+
| ------------------- | -------------------------------------- | ----------------------------------------------------------------- | ------- |
84+
| `colorScheme` | `'cyan' \| 'green' \| 'gold' \| 'red'` | The colour scheme of the alert. Mapped to an icon. | 'info' |
85+
| `title` | `string` | The title of the alert. | |
86+
| `text` | `string` | The text of the alert. | |
87+
| `link` | `string` | The text of the link. | |
88+
| `linkTestID` | `string` | The testID of the link. | |
89+
| `iconButtonTestID` | `string` | The testID of the icon button. | |
90+
| `onPress` | `() => void` | A callback function to be called when the alert is tapped. | |
91+
| `onPressLink` | `() => void` | A callback function to be called when the link is tapped. | |
92+
| `onPressIconButton` | `() => void` | A callback function to be called when the icon button is tapped. | |
93+
| `onClose` | `() => void` | A callback function to be called when the close button is tapped. | |
9194

9295
## Variants
9396

@@ -106,15 +109,15 @@ If you need to use the Alert component in a more advanced way, you can use the p
106109
<VStack space="lg" style={{flex: 1}}>
107110
<AlertTitle>Information</AlertTitle>
108111
<AlertText>Unlock the power of knowledge with the following information.</AlertText>
109-
<AlertLink onPress={() => console.log('Link clicked')}>
112+
<AlertLink onPress={() => console.log('Link tapped')}>
110113
<AlertLinkText>Learn more</AlertLinkText>
111114
<AlertLinkChevron />
112115
</AlertLink>
113116
</VStack>
114-
<AlertIconButton onPress={() => console.log('Icon button clicked')}>
117+
<AlertIconButton onPress={() => console.log('Icon button tapped')}>
115118
<AlertIconButtonChevron />
116119
</AlertIconButton>
117-
<AlertCloseButton onClose={() => console.log('Close button clicked')}>
120+
<AlertCloseButton onClose={() => console.log('Close button tapped')}>
118121
<AlertCloseButtonIcon />
119122
</AlertCloseButton>
120123
</Alert>
@@ -146,17 +149,17 @@ const MyComponent = () => {
146149
<AlertTitle>Information</AlertTitle>
147150
<AlertText>Unlock the power of knowledge with the following information.</AlertText>
148151

149-
<AlertLink onPress={() => console.log('Link clicked')}>
152+
<AlertLink onPress={() => console.log('Link tapped')}>
150153
<AlertLinkText>Learn more</AlertLinkText>
151154
<AlertLinkChevron />
152155
</AlertLink>
153156
</VStack>
154157
{/* Note: AlertIconButton should not be used with the AlertLink component */}
155-
<AlertIconButton onPress={() => console.log('Icon button clicked')}>
158+
<AlertIconButton onPress={() => console.log('Icon button tapped')}>
156159
<AlertIconButtonChevron />
157160
</AlertIconButton>
158161

159-
<AlertCloseButton onClose={() => console.log('Close button clicked')}>
162+
<AlertCloseButton onClose={() => console.log('Close button tapped')}>
160163
<AlertCloseButtonIcon />
161164
</AlertCloseButton>
162165
</Alert>

apps/native-ui-storybook/components/Icon/Icon.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from 'react';
1+
import React, { ComponentType } from 'react';
22

33
import { Icon, createIcon, HStack } from '@utilitywarehouse/native-ui';
44
import * as Icons from '@utilitywarehouse/react-native-icons';
5-
import { Path, Rect } from 'react-native-svg';
5+
import Svg, { Path, Rect } from 'react-native-svg';
66
import { colors } from '@utilitywarehouse/colour-system';
77
import { StoryFn } from '@storybook/react';
88

@@ -38,6 +38,7 @@ IconBasic.args = {
3838
};
3939

4040
export const GluestackIcon = createIcon({
41+
Root: Svg,
4142
viewBox: '0 0 32 32',
4243
path: (
4344
<>

apps/native-ui-storybook/docs/components/BackToTopButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, ButtonIcon, ButtonText, NativeUIProvider } from '@utilitywarehouse/native-ui';
1+
import { Button, ButtonIcon, ButtonText } from '@utilitywarehouse/native-ui';
22
import { ChevronUpSmallIcon } from '@utilitywarehouse/react-native-icons';
33
import React, { useState } from 'react';
44
import { Platform } from 'react-native';

apps/native-ui-storybook/docs/components/ViewFigmaButton.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { Button, ButtonIcon, ButtonText, createIcon } from '@utilitywarehouse/na
22
import { ChevronRightSmallIcon } from '@utilitywarehouse/react-native-icons';
33
import React from 'react';
44
import { Platform } from 'react-native';
5-
import { Path } from 'react-native-svg';
5+
import Svg, { Path } from 'react-native-svg';
66

77
interface Props {
88
url: string;
99
}
1010

1111
const FigmaIcon = createIcon({
12+
Root: Svg,
1213
viewBox: '0 0 24 24',
14+
1315
path: (
1416
<Path d="M15.852 8.981h-4.588V0h4.588c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.491-4.49 4.491zM12.735 7.51h3.117c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-3.117V7.51zm0 1.471H8.148c-2.476 0-4.49-2.014-4.49-4.49S5.672 0 8.148 0h4.588v8.981zm-4.587-7.51c-1.665 0-3.019 1.355-3.019 3.019s1.354 3.02 3.019 3.02h3.117V1.471H8.148zm4.587 15.019H8.148c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h4.588v8.98zM8.148 8.981c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h3.117V8.981H8.148zM8.172 24c-2.489 0-4.515-2.014-4.515-4.49s2.014-4.49 4.49-4.49h4.588v4.441c0 2.503-2.047 4.539-4.563 4.539zm-.024-7.51a3.023 3.023 0 0 0-3.019 3.019c0 1.665 1.365 3.019 3.044 3.019 1.705 0 3.093-1.376 3.093-3.068v-2.97H8.148zm7.704 0h-.098c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h.098c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.49-4.49 4.49zm-.097-7.509c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h.098c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-.098z" />
1517
),
@@ -30,7 +32,7 @@ const ViewFigmaButton: React.FC<Props> = ({ url }) => (
3032
}}
3133
onPress={() => window.open(url)}
3234
>
33-
<ButtonIcon as={FigmaIcon} />
35+
<ButtonIcon as={FigmaIcon} width={24} height={24} />
3436
<ButtonText>View in Figma</ButtonText>
3537
<ButtonIcon as={ChevronRightSmallIcon} />
3638
</Button>

packages/native-ui/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @utilitywarehouse/native-ui
22

3+
## 0.11.0
4+
5+
### Minor Changes
6+
7+
- [#665](https://github.com/utilitywarehouse/design-systems/pull/665) [`e46c3b0`](https://github.com/utilitywarehouse/design-systems/commit/e46c3b0b80316c3411b89eea4a651d547513ee1f) Thanks [@jordmccord](https://github.com/jordmccord)! - Adds `onPress` prop to `Alert`
8+
9+
- [#654](https://github.com/utilitywarehouse/design-systems/pull/654) [`de2fe90`](https://github.com/utilitywarehouse/design-systems/commit/de2fe9082e78eb354511af7df9da3e682536daeb) Thanks [@jordmccord](https://github.com/jordmccord)! - Removes `gluestack-style` dependency
10+
11+
- [#654](https://github.com/utilitywarehouse/design-systems/pull/654) [`de2fe90`](https://github.com/utilitywarehouse/design-systems/commit/de2fe9082e78eb354511af7df9da3e682536daeb) Thanks [@jordmccord](https://github.com/jordmccord)! - Removes unstyled components
12+
313
## 0.10.1
414

515
### Patch Changes

packages/native-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@utilitywarehouse/native-ui",
3-
"version": "0.10.2",
3+
"version": "0.11.0",
44
"description": "Utility Warehouse React Native UI library",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/native-ui/src/components/Alert/Alert.props.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { ViewProps } from 'react-native';
1+
import type { PressableProps } from 'react-native';
22

33
/**
44
* Props for the Alert component.
55
*/
6-
interface AlertWithoutChildrenProps extends ViewProps {
6+
interface AlertWithoutChildrenProps extends PressableProps {
77
/**
88
* The text content of the alert.
99
*/
@@ -19,6 +19,16 @@ interface AlertWithoutChildrenProps extends ViewProps {
1919
*/
2020
link?: string;
2121

22+
/**
23+
* The test ID for the link.
24+
*/
25+
linkTestID?: string;
26+
27+
/**
28+
* The test ID for the icon button.
29+
*/
30+
iconButtonTestID?: string;
31+
2232
/**
2333
* The color scheme of the alert.
2434
* Possible values: 'cyan', 'green', 'gold', 'red'.
@@ -44,7 +54,7 @@ interface AlertWithoutChildrenProps extends ViewProps {
4454
}
4555

4656
interface AlertWithChildrenProps
47-
extends ViewProps,
57+
extends PressableProps,
4858
Omit<AlertWithoutChildrenProps, 'text' | 'children'> {
4959
text?: never;
5060
onPressLink?: never;

packages/native-ui/src/components/Alert/Alert.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import AlertCloseButton, { AlertCloseButtonIcon } from './AlertCloseButton';
66
import type { AlertProps } from './Alert.props';
77
import { AlertContext } from './Alert.context';
88
import { createStyleSheet, useStyles } from 'react-native-unistyles';
9-
import { View } from 'react-native';
9+
import { View, Pressable, ViewStyle } from 'react-native';
1010
import AlertText from './AlertText';
1111
import AlertIcon from './AlertIcon';
1212

@@ -21,6 +21,9 @@ const Alert = forwardRef<View, AlertProps>(
2121
onPressIconButton,
2222
onClose,
2323
children,
24+
onPress,
25+
iconButtonTestID,
26+
linkTestID,
2427
style,
2528
...props
2629
},
@@ -42,7 +45,13 @@ const Alert = forwardRef<View, AlertProps>(
4245

4346
return (
4447
<AlertContext.Provider value={value}>
45-
<View ref={ref} {...props} style={[styles.container, style]}>
48+
<Pressable
49+
ref={ref}
50+
{...props}
51+
style={[styles.container, style as ViewStyle]}
52+
onPress={onPress}
53+
disabled={!onPress}
54+
>
4655
{children ? (
4756
children
4857
) : (
@@ -52,14 +61,14 @@ const Alert = forwardRef<View, AlertProps>(
5261
{!!title && <AlertTitle>{title}</AlertTitle>}
5362
<AlertText>{text}</AlertText>
5463
{!!link && (
55-
<AlertLink onPress={onPressLink}>
64+
<AlertLink onPress={onPressLink} testID={linkTestID}>
5665
<AlertLinkText>{link}</AlertLinkText>
5766
<AlertLinkChevron />
5867
</AlertLink>
5968
)}
6069
</View>
61-
{!!onPressIconButton && !link && (
62-
<AlertIconButton onPress={onPressIconButton}>
70+
{(!!onPressIconButton || !!onPress) && !link && (
71+
<AlertIconButton onPress={onPressIconButton || onPress} testID={iconButtonTestID}>
6372
<AlertIconButtonChevron />
6473
</AlertIconButton>
6574
)}
@@ -70,7 +79,7 @@ const Alert = forwardRef<View, AlertProps>(
7079
)}
7180
</>
7281
)}
73-
</View>
82+
</Pressable>
7483
</AlertContext.Provider>
7584
);
7685
}

packages/native-ui/src/lab/Carousel/CarouselItems.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React, {
1111
} from 'react';
1212
import { AccessibilityActionEvent, FlatList, ViewToken, ViewStyle } from 'react-native';
1313

14-
import { Box } from '../';
14+
import { Box } from '../../components';
1515
import CarouselContext from './Carousel.context';
1616
import { CarouselItemProps, CarouselItemsProps, CarouselRef } from './Carousel.props';
1717

packages/native-ui/src/lab/Carousel/CarouselPagination.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { nanoid } from 'nanoid/non-secure';
22
import React, { FC, useContext, useEffect, useMemo } from 'react';
33
import { createStyleSheet, useStyles } from 'react-native-unistyles';
4-
5-
import { Text } from '../../components/Text';
6-
import { Box } from '../';
4+
import { Box, Text } from '../../components';
75
import { CarouselPaginationProps, CarouselPaginationItemProps } from './Carousel.props';
86
import CarouselContext from './Carousel.context';
97

0 commit comments

Comments
 (0)