From 5927593fd7e470f79a4490232aabaefa0b71206d Mon Sep 17 00:00:00 2001 From: Gabriel Moncea Date: Tue, 19 Apr 2022 12:11:34 +0300 Subject: [PATCH 1/2] Add absolute path --- babel.config.js | 13 +++++++++++ components/Button/Button.stories.tsx | 2 +- components/Button/Button.tsx | 23 ++----------------- components/Button/index.tsx | 1 + components/index.tsx | 1 + package.json | 5 +++-- styles/index.tsx | 21 ++++++++++++++++++ tsconfig.json | 9 ++++++-- yarn.lock | 33 ++++++++++++++++++++++++++-- 9 files changed, 80 insertions(+), 28 deletions(-) create mode 100644 components/Button/index.tsx create mode 100644 components/index.tsx create mode 100644 styles/index.tsx diff --git a/babel.config.js b/babel.config.js index f842b77..d9e019f 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,16 @@ module.exports = { presets: ['module:metro-react-native-babel-preset'], + plugins: [ + [ + 'module-resolver', + { + root: './', + extensions: ['.js', '.jsx', '.ts', '.tsx', '.ios.js', '.android.js'], + alias: { + '@components': 'components', + '@styles': 'styles', + }, + }, + ], + ], }; diff --git a/components/Button/Button.stories.tsx b/components/Button/Button.stories.tsx index a88c41b..c6a6122 100644 --- a/components/Button/Button.stories.tsx +++ b/components/Button/Button.stories.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {ComponentMeta, ComponentStory} from '@storybook/react'; -import {MyButton} from './Button'; +import {MyButton} from '@components'; export default { title: 'components/MyButton', diff --git a/components/Button/Button.tsx b/components/Button/Button.tsx index 432947b..1768e96 100644 --- a/components/Button/Button.tsx +++ b/components/Button/Button.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'; +import {Text, TouchableOpacity, View} from 'react-native'; +import {styles} from '@styles'; export type ButtonProps = { onPress: () => void; @@ -8,26 +9,6 @@ export type ButtonProps = { textColor?: string; }; -const styles = StyleSheet.create({ - button: { - paddingVertical: 8, - paddingHorizontal: 16, - borderRadius: 4, - alignSelf: 'flex-start', - flexGrow: 0, - backgroundColor: 'purple', - }, - buttonText: { - color: 'white', - fontSize: 16, - fontWeight: 'bold', - }, - buttonContainer: { - alignItems: 'flex-start', - flex: 1, - }, -}); - export const MyButton = ({text, onPress, color, textColor}: ButtonProps) => ( Date: Tue, 19 Apr 2022 13:08:59 +0300 Subject: [PATCH 2/2] Update babel.config.js --- babel.config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/babel.config.js b/babel.config.js index d9e019f..422ae19 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,11 +4,10 @@ module.exports = { [ 'module-resolver', { - root: './', extensions: ['.js', '.jsx', '.ts', '.tsx', '.ios.js', '.android.js'], alias: { - '@components': 'components', - '@styles': 'styles', + '@components': './components', + '@styles': './styles', }, }, ],