Skip to content

Commit

Permalink
feat: alert sub components
Browse files Browse the repository at this point in the history
  • Loading branch information
jordmccord committed Feb 27, 2024
1 parent 9a2a862 commit 89cebde
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 44 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/previews.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Build Native Previews

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'packages/native-ui/**'
- 'apps/native-ui-storybook/**'
- push
# pull_request:
# types: [opened, synchronize, reopened]
# paths:
# - 'packages/native-ui/**'
# - 'apps/native-ui-storybook/**'

env:
CI: true

jobs:
build-for-android:
runs-on: macos-13
runs-on: macos-14-arm64
concurrency:
group: preview-android-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -61,7 +63,7 @@ jobs:
platform: 'android'

build-for-ios:
runs-on: macos-13
runs-on: macos-14-arm64
concurrency:
group: preview-ios-${{ github.ref }}
cancel-in-progress: true
Expand Down
14 changes: 10 additions & 4 deletions apps/native-ui-storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dirname, join } from "path";
const path = require('path');
/** @type{import("@storybook/react-webpack5").StorybookConfig} */
module.exports = {
Expand All @@ -7,12 +8,13 @@ module.exports = {
'../components/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-react-native-web',
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-react-native-web"),
getAbsolutePath("@storybook/addon-mdx-gfm")
],
framework: {
name: '@storybook/react-webpack5',
name: getAbsolutePath("@storybook/react-webpack5"),
options: {},
},
docs: {
Expand All @@ -27,3 +29,7 @@ module.exports = {
return config;
},
};

function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")));
}
21 changes: 15 additions & 6 deletions apps/native-ui-storybook/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,40 @@ import React from 'react';
import {
Alert,
AlertIcon,
AlertChevron,
AlertText,
AlertTitle,
AlertLink,
CheckCircleIcon,
CloseCircleIcon,
AlertCircleIcon,
VStack,
Icon,
AlertLinkText,
AlertLinkChevron,
AlertIconButton,
} from '@utilitywarehouse/native-ui';

import {
InformationMediumContainedIcon,
ChevronRight01MediumIcon,
ChevronRightMediumIcon,
ChevronRightSmallIcon,
} from '@utilitywarehouse/react-native-icons';

const AlertBasic = ({ text = 'Selection successfully moved!', ...props }: any) => {
return (
<Alert {...props} si>
<Alert {...props}>
<AlertIcon as={InformationMediumContainedIcon} />
<VStack flex={1}>
<VStack flex={1} gap={4}>
<AlertTitle>Success</AlertTitle>
<AlertText>{text}</AlertText>
<AlertLink>
<AlertLinkText>View details</AlertLinkText>
<AlertLinkChevron as={ChevronRightSmallIcon} />
</AlertLink>
</VStack>
<AlertChevron as={ChevronRight01MediumIcon} />
<AlertIconButton>
<Icon as={ChevronRightMediumIcon} />
</AlertIconButton>
</Alert>
);
};
Expand All @@ -39,7 +49,6 @@ export {
Alert,
AlertIcon,
AlertText,
AlertChevron,
CheckCircleIcon,
CloseCircleIcon,
AlertCircleIcon,
Expand Down
26 changes: 12 additions & 14 deletions apps/native-ui-storybook/docs/colour-system/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ This is the migration guidelines for mapping
[legacy colour values](https://github.com/utilitywarehouse/customer-web-ui/blob/main/packages/design-tokens/src/colors.ts)
to the new colour system values.

```
| Old value | New value |
| -------------------- | --------------------------------- |
| colors.purple | colorsCommon.brandPrimaryPurple |
| colors.cyan | colors.cyan500 |
| colors.jewel | colors.green700 |
| colors.maroonFlush | colors.red600 |
| colors.apple | colors.apple400 |
| colors.rose | colors.rose400 |
| colors.codGray10 | colors.grey100 |
| colors.blueRibbon | colors.cyan600 |
| colors.whiteOwl | colors.grey75 |
| colors.lightTint | colors.purple100 |
```
| Old value | New value |
| ------------------ | ------------------------------- |
| colors.purple | colorsCommon.brandPrimaryPurple |
| colors.cyan | colors.cyan500 |
| colors.jewel | colors.green700 |
| colors.maroonFlush | colors.red600 |
| colors.apple | colors.apple400 |
| colors.rose | colors.rose400 |
| colors.codGray10 | colors.grey100 |
| colors.blueRibbon | colors.cyan600 |
| colors.whiteOwl | colors.grey75 |
| colors.lightTint | colors.purple100 |
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": { "@gluestack-ui/button": "latest" },
"componentDependencies": ["AsForwarder"],
"componentDependencies": ["Button"],
"keywords": ["components", "core", "Alert"]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Root } from './styled-components';

export const AlertChevron: any = Root;
export const AlertIconButton: any = Root;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { styled, Pressable } from '@gluestack-ui/themed';

const AlertIconButton = styled(
Pressable,
{
width: 24,
height: 24,
display: 'flex',
alignContent: 'center',
justifyContent: 'center',
_icon: {
width: 24,
height: 24,
},
},
{
componentName: 'AlertIconButton',
descendantStyle: ['_icon'],
ancestorStyle: ['_iconButton'],
} as const
) as React.ForwardRefExoticComponent<import('react-native').PressableProps & {}> & {
displayName: string;
};
export default AlertIconButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": { "@gluestack-ui/button": "latest" },
"componentDependencies": ["Text", "Pressable", "Icon"],
"keywords": ["components", "core"]
}
5 changes: 5 additions & 0 deletions packages/native-ui/src/components/custom/AlertLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
Root as AlertLink,
Text as AlertLinkText,
Icon as AlertLinkChevron,
} from './styled-components';
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { styled, AsForwarder } from '@gluestack-ui/themed';

const AlertChevron = styled(
const AlertLinkChevron = styled(
AsForwarder,
{
width: 24,
height: 24,
width: 16,
height: 16,
},
{
componentName: 'AlertChevron',
componentName: 'AlertLinkChevron',
descendantStyle: [],
ancestorStyle: ['_chevron'],
} as const
);

export default AlertChevron;
export default AlertLinkChevron;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { styled, Pressable } from '@gluestack-ui/themed';

const AlertLink = styled(
Pressable,
{
display: 'flex',
alignItems: 'center',
flexDirection: 'row',
gap: 4,
},
{
componentName: 'AlertLink',
descendantStyle: ['_text', '_chevron'],
ancestorStyle: ['_link'],
} as const
) as React.ForwardRefExoticComponent<import('react-native').PressableProps & {}> & {
displayName: string;
};

export default AlertLink;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { styled } from '@gluestack-ui/themed';
import { Text } from 'react-native';

const AlertLinkText = styled(
Text,
{
fontSize: 16,
lineHeight: 24,
fontFamily: 'WorkSans-SemiBold',
},
{
componentName: 'AlertLinkText',
descendantStyle: [],
ancestorStyle: ['_text'],
} as const
);

export default AlertLinkText;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as Root } from './Root';
export { default as Icon } from './Icon';
export { default as Text } from './Text';
3 changes: 2 additions & 1 deletion packages/native-ui/src/components/custom/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './IconButton';
export * from './AlertLink';
export * from './AlertTitle';
export * from './AlertChevron';
export * from './AlertIconButton';
15 changes: 15 additions & 0 deletions packages/native-ui/src/config/theme/Alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ export const Alert = createStyle({
_chevron: {
alignSelf: 'center',
},
_button: {
width: 24,
height: 24,
padding: 0,
_icon: {
width: 24,
height: 24,
minWidth: 24,
},
},
variants: {
colorScheme: {
error: {
Expand All @@ -27,6 +37,11 @@ export const Alert = createStyle({
_chevron: {
color: '$red700',
},
_button: {
_icon: {
color: '$red700',
},
},
_dark: {
bg: '$darkRed50',
borderColor: '$darkRed500',
Expand Down
2 changes: 2 additions & 0 deletions packages/native-ui/src/config/theme/AlertIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export const AlertIcon = createStyle({
alignSelf: 'flex-start',
width: 24,
height: 24,
minWidth: 24,
minHeight: 24,
});
6 changes: 1 addition & 5 deletions packages/native-ui/src/config/theme/IconButton.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { createStyle } from '@gluestack-style/react';

export const IconButton = createStyle({
bg: '$primary500',
p: '$2',
rounded: '$full',
});
export const IconButton = createStyle({});

0 comments on commit 89cebde

Please sign in to comment.