-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : ์ฃผ์ฐจ๋ฅผ ๊ตฌํ๋ util ์์ฑ * feat : title ์์ฑ * chore : title ์์ * feat : api ํธ์ถ param ์ถ๊ฐ * env : rechart ์ค์น * fix : ์ ๋๊ฒฝ๋ก๋ฅผ ์คํ ๋ถ์ด ์ธ์ง ๋ชปํ๋ ์ค๋ฅ ์์ * env : storybook ์๋ฌ ์์ * feat : chart ์ปดํฌ๋ํธ * refactor : ์ฌ์ฌ์ฉ์ฑ์ ์ํด INFO ์ปดํฌ๋ํธ๋ก ๋ถ๋ฆฌ * feat : ์ฌ์ฉ์์ ํ์ฌ ์ฃผ์ฐจ๋ฅผ ๊ตฌํ๋ ์ ํธ * chore : ๊ฒฝ๋ก ๋ณ๊ฒฝ ๋ฐ ์ฝ๋ ์์น ๋ณ๊ฒฝ * feat : ํ๊ท ๊ฐ์ ์ ๋ถ๋ฌ์ค๋ hook ์์ฑ * feat : api๋ฅผ ๋ถ๋ฌ์ ์ฐ๊ฒฐ * env : date-fns ์์กด์ฑ ์ถ๊ฐ * feat : char ํํฐ๋ง ๊ตฌํ * chore : ์คํ ๋ฆฌ๋ถ ๊ฒฝ๋ก ์์ * env : ์์กด์ฑ ์๋ฌ ์ ๊ฑฐ * chore : ์ฐจํธ ์คํ์ผ๋ง ์์
- Loading branch information
Showing
41 changed files
with
994 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Preview } from '@storybook/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import React from 'react'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i | ||
} | ||
} | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<QueryClientProvider client={queryClient}> | ||
<Story /> | ||
</QueryClientProvider> | ||
) | ||
] | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// ์ฃผ์ฐจ๋ฅผ ๊ณ์ฐํ๋ ์ ํธ ํจ์ | ||
export const calculateWeekOfYear = (date: Date): number => { | ||
const startOfYear = new Date(date.getFullYear(), 0, 1); | ||
const pastDaysOfYear = | ||
(date.getTime() - startOfYear.getTime()) / (24 * 60 * 60 * 1000); | ||
return Math.ceil((pastDaysOfYear + startOfYear.getDay() + 1) / 7); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { | ||
DailyEmotionType, | ||
WeeklyEmotionSummaryType | ||
} from '@/shared/model/moodTypes'; | ||
|
||
const isDailyEmotion = ( | ||
data: DailyEmotionType[] | WeeklyEmotionSummaryType[] | ||
): data is DailyEmotionType[] => { | ||
return (data as DailyEmotionType[])[0]?.day !== undefined; | ||
}; | ||
|
||
export default isDailyEmotion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import Chart from './Chart'; | ||
|
||
const meta: Meta<typeof Chart> = { | ||
component: Chart, | ||
title: 'entities/UI/CHART', | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Chart>; | ||
|
||
const dailyEmotionData = [ | ||
{ day: 'Mon' as const, mood: null }, | ||
{ day: 'Tue' as const, mood: '๋์จ' }, | ||
{ day: 'Wed' as const, mood: '๋์จ' }, | ||
{ day: 'Thu' as const, mood: null }, | ||
{ day: 'Fri' as const, mood: null }, | ||
{ day: 'Sat' as const, mood: null }, | ||
{ day: 'Sun' as const, mood: null }, | ||
]; | ||
|
||
|
||
export const Default: Story = { | ||
args: { | ||
data: dailyEmotionData, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from 'react'; | ||
import { | ||
DailyEmotionType, | ||
WeeklyEmotionSummaryType | ||
} from '@/shared/model/moodTypes'; | ||
|
||
import { | ||
LineChart, | ||
Line, | ||
XAxis, | ||
YAxis, | ||
CartesianGrid, | ||
Tooltip, | ||
ResponsiveContainer | ||
} from 'recharts'; | ||
import isDailyEmotion from '../lib/isDailyEmotion'; | ||
|
||
const emotions = ['๋งค์ฐ ๋์จ', '๋์จ', '๋ณดํต', '์ข์', '๋งค์ฐ ์ข์']; | ||
|
||
interface ChartProps { | ||
data: DailyEmotionType[] | WeeklyEmotionSummaryType[]; | ||
} | ||
|
||
const Chart = ({ data }: ChartProps) => { | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<LineChart | ||
data={data} | ||
margin={{ top: 20, right: 10, left: 10, bottom: 20 }} | ||
> | ||
<CartesianGrid vertical={false} /> | ||
{isDailyEmotion(data) ? ( | ||
<> | ||
<XAxis | ||
dataKey="day" | ||
angle={0} | ||
dy={10} | ||
height={50} | ||
axisLine={false} | ||
/> | ||
<YAxis | ||
type="category" | ||
dataKey="mood" | ||
tickLine={false} | ||
axisLine={false} | ||
domain={emotions} | ||
ticks={emotions} | ||
allowDuplicatedCategory={false} | ||
/> | ||
<Line | ||
type="monotone" | ||
dataKey="mood" | ||
stroke="#FF480E" | ||
activeDot={{ r: 8 }} | ||
connectNulls | ||
/> | ||
</> | ||
) : ( | ||
<> | ||
<XAxis | ||
dataKey="week" | ||
angle={0} | ||
dy={10} | ||
height={50} | ||
axisLine={false} | ||
/> | ||
<YAxis | ||
type="category" | ||
dataKey="mostFrequentEmotion" | ||
tickLine={false} | ||
axisLine={false} | ||
domain={emotions} | ||
ticks={emotions} | ||
allowDuplicatedCategory={false} | ||
/> | ||
<Line | ||
type="monotone" | ||
dataKey="mostFrequentEmotion" | ||
stroke="#FF480E" | ||
activeDot={{ r: 8 }} | ||
connectNulls | ||
/> | ||
</> | ||
)} | ||
<Tooltip | ||
formatter={(value) => | ||
value === '์ ๋ณด ์์' || value === null | ||
? '์ ๋ณด ์์' | ||
: value | ||
} | ||
/> | ||
</LineChart> | ||
</ResponsiveContainer> | ||
); | ||
}; | ||
|
||
export default Chart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Storybook configuration for DateSlider | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import DateSlider from "./DateSlider" | ||
const meta: Meta<typeof DateSlider> = { | ||
component: DateSlider, | ||
title: 'entities/ui/DateSlider', | ||
tags: ['autodocs'], | ||
argTypes: { | ||
year: { control: 'number', defaultValue: 2023 }, | ||
month: { control: 'number', defaultValue: 10 }, | ||
week: { control: 'number', defaultValue: 1 }, | ||
viewMode: { control: 'radio', options: ['week', 'month'], defaultValue: 'week' }, | ||
onDateChange: { action: 'dateChanged' }, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof DateSlider>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
year: 2023, | ||
month: 10, | ||
week: 1, | ||
viewMode: 'week', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const MonthWeekSelectorWrapper = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 20px; | ||
`; | ||
|
||
export const ArrowButton = styled.button` | ||
background: none; | ||
border: none; | ||
font-size: 24px; | ||
cursor: pointer; | ||
&:focus { | ||
outline: none; | ||
} | ||
`; | ||
|
||
export const Display = styled.span` | ||
margin: 0 140px; | ||
font-size: 20px; | ||
`; | ||
|
||
export const SliderInfoContainer = styled.div` | ||
margin-bottom: 100px; | ||
`; |
Oops, something went wrong.