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

Corregido Storybook del componente Text #18

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ondevice/storybook.requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ global.STORIES = [
directory: "./storybook/stories",
files: "**/*.stories.?(ts|tsx|js|jsx)",
importPathMatcher:
"^\\.[\\\\/](?:storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
"^\\.[\\\\/](?:storybook[\\\\/]stories(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
},
];

Expand Down
55 changes: 35 additions & 20 deletions src/components/StatusChip/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ exports[`StatusChip component render correct a valid component is passed 1`] = `
>
<Text
style={
Object {
"fontFamily": "Roboto",
"fontSize": 16,
}
Array [
Object {
"fontFamily": "Roboto",
"fontSize": 16,
},
undefined,
]
}
>
Custom component
Expand All @@ -48,14 +51,20 @@ exports[`StatusChip component render correct if a background is passed 1`] = `
>
<Text
style={
Object {
"color": "#fff",
"fontFamily": "Roboto",
"fontSize": 15,
"fontWeight": "900",
"lineHeight": 18,
"textAlign": "center",
}
Array [
Object {
"fontFamily": "Roboto",
"fontSize": 16,
},
Object {
"color": "#fff",
"fontFamily": "Roboto",
"fontSize": 15,
"fontWeight": "900",
"lineHeight": 18,
"textAlign": "center",
},
]
}
>
Delivered
Expand All @@ -81,14 +90,20 @@ exports[`StatusChip component render correct text is passed 1`] = `
>
<Text
style={
Object {
"color": "#2979FF",
"fontFamily": "Roboto",
"fontSize": 15,
"fontWeight": "900",
"lineHeight": 18,
"textAlign": "center",
}
Array [
Object {
"fontFamily": "Roboto",
"fontSize": 16,
},
Object {
"color": "#2979FF",
"fontFamily": "Roboto",
"fontSize": 15,
"fontWeight": "900",
"lineHeight": 18,
"textAlign": "center",
},
]
}
>
Partially delivered
Expand Down
3 changes: 2 additions & 1 deletion src/components/StatusChip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {ReactElement, isValidElement} from 'react';
import {StyleSheet, Text, ViewProps, View} from 'react-native';
import {StyleSheet, ViewProps, View} from 'react-native';
import {base, grey, primary} from '../../theme/palette';
import Text from '../Text';

interface StatusChipProps extends ViewProps {
children?: ReactElement | string;
Expand Down
11 changes: 7 additions & 4 deletions src/components/Text/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
exports[`Text component render correct match snapshot 1`] = `
<Text
style={
Object {
"fontFamily": "Roboto",
"fontSize": 16,
}
Array [
Object {
"fontFamily": "Roboto",
"fontSize": 16,
},
undefined,
]
}
>
Janis Picking
Expand Down
26 changes: 16 additions & 10 deletions src/components/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import React, {ReactElement} from 'react';
import {StyleSheet, Text as TextComponent, TextProps as TextComponentProps} from 'react-native';
import {
StyleSheet,
Text as TextComponent,
TextProps as TextComponentProps,
TextStyle,
} from 'react-native';

interface TextProps extends TextComponentProps {
children?: ReactElement | string;
style?: TextStyle;
}

const Text = ({children, ...props}: TextProps) => {
const Text = ({children, style, ...props}: TextProps) => {
if (!children) {
return null;
}

const styles = StyleSheet.create({
TextStyles: {
fontSize: 16,
fontFamily: 'Roboto',
},
});

return (
<TextComponent style={styles.TextStyles} {...props}>
<TextComponent style={[styles.TextStyles, style]} {...props}>
{children}
</TextComponent>
);
};

const styles = StyleSheet.create({
TextStyles: {
fontSize: 16,
fontFamily: 'Roboto',
},
});

export default Text;
2 changes: 1 addition & 1 deletion storybook/stories/StatusChip/StatusChip.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import StatusChip from '../../../src/components/StatusChip';
import Text from '../Text';
import Text from '../../../src/components/Text';
import React from 'react';

export default {
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/Text/Text.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Text from './index';
import Text from '../../../src/components/Text';

const fontFamilies = [
'normal',
Expand Down
15 changes: 0 additions & 15 deletions storybook/stories/Text/index.js

This file was deleted.