Skip to content

Commit

Permalink
#77 feat: add lookbook base components (#92)
Browse files Browse the repository at this point in the history
* #77 feat: add lookbook button component

* #77 feat: add lookbook addButton component

* #77 feat: add toggle component

* fix: set patch package to solve deprecated prop types error
  • Loading branch information
eujin-shin authored Jul 9, 2024
1 parent 48a8547 commit ac85b71
Show file tree
Hide file tree
Showing 7 changed files with 1,068 additions and 137 deletions.
759 changes: 759 additions & 0 deletions node_modules/react-native/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/assets/lookbook/plusSquare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions src/common/Toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Dispatch, SetStateAction, useEffect, useRef } from 'react';
import {
Animated,
StyleSheet,
Touchable,
TouchableOpacity,
TouchableWithoutFeedback,
View,
} from 'react-native';
import { PURPLE, PURPLE2 } from '../styles/GlobalColor';

const Toggle = ({
isOn,
setIsOn,
}: {
isOn: boolean;
setIsOn: Dispatch<SetStateAction<boolean>>;
}) => {
const X_COORD_OFF = 0;
const X_COORD_ON = 24;
const ANIMATION_DURATION = 500;

const animationXTrans = useRef(new Animated.Value(0)).current;

const handlePress = () => {
setIsOn(prev => !prev);
};

useEffect(() => {
console.log('animation on');
Animated.timing(animationXTrans, {
toValue: isOn ? X_COORD_ON : X_COORD_OFF,
duration: ANIMATION_DURATION,
useNativeDriver: true,
}).start();
}, [animationXTrans, isOn]);

return (
<View>
<TouchableWithoutFeedback onPress={handlePress}>
<View
style={{
backgroundColor: isOn ? PURPLE : PURPLE2,
...Styles.container,
}}>
<Animated.View
style={{
transform: [{ translateX: animationXTrans }],
...Styles.button,
}}
/>
</View>
</TouchableWithoutFeedback>
</View>
);
};

const Styles = StyleSheet.create({
container: {
width: 50,
height: 26,
borderRadius: 100,
margin: 5,
justifyContent: 'center',
paddingHorizontal: 3,
},
button: {
width: 20,
height: 20,
borderRadius: 100,
backgroundColor: 'white',
},
});

export default Toggle;
28 changes: 28 additions & 0 deletions src/components/Lookbook/LookbookAddButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { StyleSheet, TouchableOpacity, View } from 'react-native';
import PlusSquare from '../../assets/lookbook/plusSquare.svg';

const LookbookAddButton = ({ onPress }: { onPress: () => void }) => {
return (
<View>
<TouchableOpacity onPress={onPress}>
<View style={Styles.container}>
<PlusSquare />
</View>
</TouchableOpacity>
</View>
);
};

const Styles = StyleSheet.create({
container: {
width: 54,
height: 54,
backgroundColor: 'black',
borderRadius: 100,
alignItems: 'center',
justifyContent: 'center',
margin: 5,
},
});

export default LookbookAddButton;
27 changes: 27 additions & 0 deletions src/components/Lookbook/LookbookButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { StyleSheet, View, ViewStyle } from 'react-native';
import { GREEN, PURPLE } from '../../styles/GlobalColor';
import { Upcymall12M } from '../../styles/GlobalText';

const LookbookButton = ({ positioning }: { positioning?: ViewStyle }) => {
return (
<View style={{ ...positioning }}>
<View style={Styles.container}>
<Upcymall12M style={{ color: GREEN }}>UPCYMALL</Upcymall12M>
</View>
</View>
);
};

const Styles = StyleSheet.create({
container: {
backgroundColor: PURPLE,
paddingHorizontal: 8,
paddingVertical: 6,
borderRadius: 5,
width: 'auto',
alignSelf: 'flex-start',
margin: 5,
},
});

export default LookbookButton;
21 changes: 15 additions & 6 deletions src/pages/ComponentsTest.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { SafeAreaView, TouchableOpacity, View } from 'react-native';
import Dropdown from '../common/Dropdown';
import { useState } from 'react';
import { Body16M } from '../styles/GlobalText';
import { Body16M, Title20B } from '../styles/GlobalText';
import LookbookButton from '../components/Lookbook/LookbookButton';
import LookbookAddButton from '../components/Lookbook/LookbookAddButton';
import TextToggle from '../common/TextToggle';
import Toggle from '../common/Toggle';

const TestDropdown = ({ index }: { index: number }) => {
const [value, setValue] = useState<string | undefined>(undefined);
Expand All @@ -19,14 +23,19 @@ const TestDropdown = ({ index }: { index: number }) => {
);
};

const TestToggle = () => {
const [isOn, setIsOn] = useState(true);
return <Toggle isOn={isOn} setIsOn={setIsOn} />;
};

export default function ComponentsTest() {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<Body16M>테스트용 페이지</Body16M>
<TestDropdown index={4} />
<Body16M>테스트용 페이지</Body16M>
<TestDropdown index={3} />
<View style={{ flex: 1, padding: 20 }}>
<Title20B>룩북 컴포넌트</Title20B>
<LookbookButton />
<LookbookAddButton onPress={() => {}} />
<TestToggle />
</View>
</SafeAreaView>
);
Expand Down
Loading

0 comments on commit ac85b71

Please sign in to comment.