Skip to content

Commit 188b064

Browse files
Mibouvalentinmagrez
authored andcommitted
💄 Fix dialog design according to design review.
1 parent a0fba46 commit 188b064

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

Storybook/components/Dialog/Dialog.stories.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-native';
22
import React from 'react';
33
import { StyleSheet, View } from 'react-native';
44

5-
import { Body, Dialog, useTheme } from 'smartway-react-native-ui';
5+
import { Body, Dialog } from 'smartway-react-native-ui';
66
import { IconsName } from '../config/IconList';
77

88
type DialogPropsAndCustomArgs = React.ComponentProps<typeof Dialog> & {
@@ -70,21 +70,15 @@ export default {
7070
type Story = StoryObj<DialogPropsAndCustomArgs>;
7171

7272
const InsideDialog = ({ variantBody }: { variantBody?: 'left' | 'center' }) => {
73-
const theme = useTheme();
74-
7573
const styles = StyleSheet.create({
7674
content: {
77-
color: theme.sw.color.neutral[600],
7875
textAlign: variantBody,
79-
lineHeight: 22,
80-
marginBottom: 0,
8176
},
8277
});
8378
return (
84-
<Body style={styles.content} size='B2'>
85-
A dialog is a type of modal window that appears in front of app
86-
content to provide critical information. This is a dialog content
87-
example.
79+
<Body style={styles.content} typography={'n2'}>
80+
A dialog is a type of modal window that appears in front of app content to provide
81+
critical information. This is a dialog content example.
8882
</Body>
8983
);
9084
};

src/__tests__/components/__snapshots__/DateSelector.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ exports[`MODULE | DateSelector component renders correctly with prefilled values
8484
"color": "#212b36",
8585
"fontFamily": "PublicSans-Bold",
8686
"fontSize": 20,
87+
"lineHeight": 24,
8788
},
8889
{
8990
"color": "#919eab",
@@ -142,6 +143,7 @@ exports[`MODULE | DateSelector component renders correctly with prefilled values
142143
"color": "#212b36",
143144
"fontFamily": "PublicSans-Bold",
144145
"fontSize": 20,
146+
"lineHeight": 24,
145147
},
146148
{
147149
"color": "#919eab",

src/components/dialogs/Dialog.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ function useStyles({
117117
const commonStyleSheet = StyleSheet.create({
118118
dialog: {
119119
borderRadius: theme.sw.borderRadius.l,
120-
marginTop: 0,
120+
marginVertical: 0,
121121
marginLeft: 'auto',
122122
marginRight: 'auto',
123123
backgroundColor: theme.sw.color.neutral[0],
124124
...style,
125125
},
126126
dialogContent: {
127+
paddingBottom: 0,
127128
paddingHorizontal: 0,
128129
},
129130
title: {
@@ -172,14 +173,15 @@ function useStyles({
172173
paddingVertical: 40,
173174
width: '80%',
174175
maxWidth: 500,
176+
gap: theme.sw.spacing.m,
175177
},
176178
dialogContent: commonStyleSheet.dialogContent,
177179
title: {
178180
...commonStyleSheet.title,
179-
marginBottom: theme.sw.spacing.m,
181+
marginBottom: 0,
180182
},
181183
actions: {
182-
marginTop: theme.sw.spacing.m,
184+
marginBottom: 0,
183185
...commonStyleSheet.actions,
184186
},
185187
leftOption: commonStyleSheet.leftOption,

src/components/dialogs/DialogIcon.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const DialogIcon = (props: DialogIconProps) => {
2424
width: 100,
2525
height: 100,
2626
borderRadius: 50,
27-
marginBottom: theme.sw.spacing.s,
2827
}}
2928
>
3029
<View

src/components/typography/Headline.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,33 @@ import { StyleProp, Text, TextStyle } from 'react-native';
33
import { useTheme } from '../../styles/themes';
44
import type { TextProps } from 'react-native-paper';
55
import { tokens } from '@zerogachis/smartway-design-token';
6-
import { getFont } from './utils';
6+
import { getFont, getLineHeight } from './utils';
7+
import { LineHeight } from '@zerogachis/smartway-design-token/dist/cjs/src/Tokens/TokensType';
78

89
type HeadlineTypography = keyof typeof tokens.typography.headline;
910

1011
export interface HeadlineProps extends TextProps<Text> {
1112
typography: HeadlineTypography;
13+
lineHeight?: keyof LineHeight;
1214
}
1315

14-
export const Headline = ({ typography = 'n5', children, style, ...props }: HeadlineProps) => {
16+
export const Headline = ({
17+
typography = 'n5',
18+
lineHeight = 'normal',
19+
children,
20+
style,
21+
...props
22+
}: HeadlineProps) => {
1523
const theme = useTheme();
1624

1725
const defaultHeadlineStyle: StyleProp<TextStyle> = {
1826
color: theme.sw.color.neutral[800],
1927
fontSize: tokens.typography.headline[typography]?.fontSize,
2028
fontFamily: getFont(tokens.typography.headline[typography]),
29+
lineHeight: getLineHeight(
30+
tokens.lineHeight[lineHeight],
31+
tokens.typography.headline[typography]?.fontSize,
32+
),
2133
};
2234
return (
2335
<Text style={[defaultHeadlineStyle, style]} {...props}>

src/components/typography/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import { Font } from '@zerogachis/smartway-design-token/dist/cjs/src/Tokens/TokensType';
22

3+
export const getLineHeight = (lineHeight: string, fontSize?: number) => {
4+
if (fontSize === undefined) {
5+
return undefined;
6+
}
7+
const lineHeightPercent = parseFloat(lineHeight) / 100;
8+
return fontSize * lineHeightPercent;
9+
};
10+
311
export const getFontWeight = (fontWeight: number | undefined) => {
412
if (fontWeight === 400) {
513
return 'Regular';

0 commit comments

Comments
 (0)