Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 feat: small quality of life for tags #920

Merged
merged 4 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions frontend/mobile/app/(app)/(tabs)/discover.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Box, Text } from '@/app/(design-system)';
import { Box, Tag, Text } from '@/app/(design-system)';

Check failure on line 1 in frontend/mobile/app/(app)/(tabs)/discover.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Text' is defined but never used

Check notice

Code scanning / CodeQL

Unused variable, import, function or class

Unused import Text.

const DiscoverPage = () => {
return (
<Box flex={1} alignItems="center" justifyContent="center" padding="m">
<Text color="aqua" variant="text-1">
DiscoverAA
</Text>
<Tag variant="darkRed">Discover</Tag>
</Box>
);
};
Expand Down
37 changes: 37 additions & 0 deletions frontend/mobile/app/(design-system)/Tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';

import {
BoxProps,
VariantProps,
createBox,
createRestyleComponent,
createVariant
} from '@shopify/restyle';

import { Text } from '../Text/Text';
import { Theme } from '../theme';

const Box = createBox<Theme>();

const tagVariant = createVariant<Theme, 'tagVariants'>({
themeKey: 'tagVariants'
});

type TagProps = VariantProps<Theme, 'tagVariants'> &
BoxProps<Theme> & {
children?: React.ReactNode;
};

const TagBase = createRestyleComponent<TagProps, Theme>([tagVariant], Box);

export const Tag: React.FC<TagProps> = ({ variant, children, ...rest }) => {
return (
<TagBase variant={variant} {...rest}>
{typeof children === 'string' ? (
<Text variant="body-1">{children}</Text>
) : (
children
)}
</TagBase>
);
};
42 changes: 42 additions & 0 deletions frontend/mobile/app/(design-system)/Tag/TagVariants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const TagColorVariants = {
darkBlue: {
backgroundColor: 'darkBlue'
},
darkRed: {
backgroundColor: 'darkRed'
},
green: {
backgroundColor: 'green'
},
blue: {
backgroundColor: 'blue'
},
aqua: {
backgroundColor: 'aqua'
},
purple: {
backgroundColor: 'purple'
},
red: {
backgroundColor: 'red'
},
orange: {
backgroundColor: 'orange'
},
yellow: {
backgroundColor: 'yellow'
}
} as const;

export const TagVariants = {
defaults: {
flex: '1',
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 'l',
paddingVertical: 'xs',
backgroundColor: 'aqua',
borderRadius: 105
},
...TagColorVariants
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createText } from '@shopify/restyle';

import { Theme } from './theme';
import { Theme } from '../theme';

export const Text = createText<Theme>();
43 changes: 43 additions & 0 deletions frontend/mobile/app/(design-system)/Text/TextVariants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const Texts = {
'header-1': {
fontFamily: 'DMSans-Bold',
fontSize: 32,
fontStyle: 'normal',
fontWeight: '700',
lineHeight: 'normal'
},
'subheader-1': {
fontFamily: 'DMSans-Medium',
fontSize: 24,
fontStyle: 'normal',
fontWeight: '500',
lineHeight: 'normal',
color: '#000'
},
'body-1': {
fontFamily: 'DMSans-Regular',
fontSize: 16,
fontStyle: 'normal',
fontWeight: '400',
lineHeight: 'normal'
},
'caption-1': {
fontFamily: 'DMSans-Regular',
fontSize: 12,
fontStyle: 'normal',
fontWeight: '400',
lineHeight: 'normal'
},
'caption-2': {
fontFamily: 'DMSans-Regular',
fontSize: 10,
fontStyle: 'normal',
fontWeight: '400',
lineHeight: 'normal'
}
} as const;

export const TextVariants = {
defaults: Texts['body-1'],
...Texts
};
20 changes: 0 additions & 20 deletions frontend/mobile/app/(design-system)/TextVariants.ts

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion frontend/mobile/app/(design-system)/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './Text';
export * from './Text/Text';
export * from './Box';
export * from './theme';
export * from './Colors';
export * from './Spacing';
export * from './Tag/Tag';
6 changes: 4 additions & 2 deletions frontend/mobile/app/(design-system)/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { createTheme } from '@shopify/restyle';

import { Colors } from './Colors';
import { Spacing } from './Spacing';
import { TextVariants } from './TextVariants';
import { TagVariants } from './Tag/TagVariants';
import { TextVariants } from './Text/TextVariants';

export const theme = createTheme({
colors: Colors,
spacing: Spacing,
textVariants: TextVariants
textVariants: TextVariants,
tagVariants: TagVariants
});

export type Theme = typeof theme;
Loading