Skip to content

Commit

Permalink
feat: slideBar를 추가합니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zero-1016 committed Sep 26, 2024
1 parent e0a0710 commit e5411cc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/components/common/slide-bar/SlideBar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Meta, StoryObj } from '@storybook/react';
import { View } from 'react-native';

import SlideBar from './';

const SlideBarMeta: Meta<typeof SlideBar> = {
title: 'common/SlideBar',
component: SlideBar,
argTypes: {
max_value: {
control: {
type: 'number',
},
description: '최대값을 설정합니다.',
},
current_value: {
control: {
type: 'number',
},
description: '현재값을 설정합니다.',
},
},
parameters: {
layout: 'centered',
},
decorators: [
(Story) => {
return (
<View style={{ width: 300 }}>
<Story />
</View>
);
},
],
};

export default SlideBarMeta;

export const Primary: StoryObj<typeof SlideBar> = {
args: {
current_value: 2,
max_value: 5,
},
};
29 changes: 29 additions & 0 deletions src/components/common/slide-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Animated, { useAnimatedStyle, withTiming } from 'react-native-reanimated';

import { color } from '@/styles/theme';

import * as S from './style';

type Props = {
max_value: number;
current_value: number;
};

function SlideBar({ max_value, current_value }: Props) {
const slideBarStyle = useAnimatedStyle(() => {
return {
position: 'absolute',
width: withTiming(`${(current_value / max_value) * 100}%`),
height: '100%',
backgroundColor: color.Primary.Normal,
};
});

return (
<S.Container>
<Animated.View style={slideBarStyle} />
</S.Container>
);
}

export default SlideBar;
10 changes: 10 additions & 0 deletions src/components/common/slide-bar/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from '@emotion/native';

export const Container = styled.View`
position: relative;
width: 100%;
height: 4px;
overflow: hidden;
background: ${({ theme }) => theme.color.Background.Alternative};
border-radius: 30px;
`;

0 comments on commit e5411cc

Please sign in to comment.