Skip to content

Commit 5dbacf2

Browse files
committed
feat : business
1 parent 7c30eb0 commit 5dbacf2

File tree

19 files changed

+314
-33
lines changed

19 files changed

+314
-33
lines changed

package/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
dist
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
# lock
26+
yarn.lock
27+
package-lock.json

package/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
],
4040
"license": "MIT",
4141
"scripts": {
42-
"watch": "concurrently \"npm run clean\" \"npm run watch:esm\" \"npm run watch:cjs\" \"npm run copy-styles\"",
42+
"watch": "concurrently \"npm run clean\" \"npm run copy-assets\" \"npm run watch:esm\" \"npm run watch:cjs\" \"npm run copy-styles\"",
4343
"watch:esm": "tsc --project tsconfig.json --outDir dist/esm --module esnext --watch",
4444
"watch:cjs": "tsc --project tsconfig.json --outDir dist/cjs --module commonjs --watch",
4545
"clean": "rm -rf dist",
46+
"copy-assets": "cpy \"src/assets/**/*.*\" dist/assets",
4647
"copy-styles": "node ./devops/copyStyles.js"
4748
},
4849
"browserslist": {

package/src/ReactDatepicker.css

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.react-datepicker__wrapper {
2+
position: relative;
3+
background: #fff;
4+
}
5+
6+
.react-datepicker__datepicker-container {
7+
position: absolute;
8+
width: 360px;
9+
top: 50px;
10+
left: 0;
11+
background-color: #fff;
12+
}
13+
14+
/* controller */
15+
.react-datepicker__controller {
16+
display: flex;
17+
}
18+
.react-datepicker__label {
19+
height: 36px;
20+
flex-grow: 1;
21+
border: none;
22+
background-color: transparent;
23+
}
24+
.react-datepicker__controller-arrow {
25+
width: 36px;
26+
height: 36px;
27+
font-size: 0;
28+
background-repeat: no-repeat;
29+
background-position: center;
30+
border: none;
31+
background-color: transparent;
32+
}
33+
.react-datepicker__controller-extra-prev {
34+
background-image: url(./extra-prev.svg);
35+
}
36+
.react-datepicker__controller-extra-next {
37+
background-image: url(./extra-next.svg);
38+
}
39+
.react-datepicker__controller-prev {
40+
background-image: url(./prev.svg);
41+
}
42+
.react-datepicker__controller-next {
43+
background-image: url(./next.svg);
44+
}

package/src/assets/extra-next.svg

Lines changed: 1 addition & 0 deletions
Loading

package/src/assets/extra-prev.svg

Lines changed: 1 addition & 0 deletions
Loading

package/src/assets/next.svg

Lines changed: 1 addition & 0 deletions
Loading

package/src/assets/prev.svg

Lines changed: 1 addition & 0 deletions
Loading

package/src/components/DatepickerContainer.tsx renamed to package/src/components/Container.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import * as React from 'react';
44
import { useState, useMemo } from 'react';
55
import { getFormatDatetime } from '../utils/datetime';
6-
import DevController from './dev/Controller';
76
import {
87
setCenturyPage,
98
setDecadePage,
@@ -14,8 +13,10 @@ import ViewCentury from './view/Century';
1413
import { NAME_SPACE } from './constants/core';
1514
import Controller from './Controller';
1615
import ViewDecade from './view/Decade';
16+
import ViewYear from './view/Year';
17+
import ViewMonth from './view/Month';
1718

18-
function DatepickerContainer() {
19+
function Container() {
1920
// 인수가 없을 땐 LOCAL 기준 현재 시간을 반환한다.
2021
const NEW_DATE = new Date();
2122
const [activeDate, setActiveDate] = useState<Date>(NEW_DATE);
@@ -31,7 +32,10 @@ function DatepickerContainer() {
3132
const yearPage = useMemo(() => setYearPage(viewDate), [viewDate]);
3233
const monthPage = useMemo(() => setMonthPage(viewDate), [viewDate]);
3334

34-
const setViewDateType = (value: string, type: 'year' | 'month' | 'date') => {
35+
const setViewDateByType = (
36+
value: string,
37+
type: 'year' | 'month' | 'date'
38+
) => {
3539
const split = viewDate.split('-');
3640

3741
if (type === 'year') split[0] = value;
@@ -55,51 +59,57 @@ function DatepickerContainer() {
5559
console.log(NEW_DATE);
5660

5761
return (
58-
<>
62+
<div className={`${NAME_SPACE}__wrapper`}>
5963
<div className={`${NAME_SPACE}__input-container`}>
60-
<input type="text" />
64+
<input
65+
type="text"
66+
value={getFormatDatetime(activeDate, 'YYYY-MM-DD')}
67+
readOnly
68+
/>
6169
{activeDate.toString()}
6270
<br />
6371
{viewDate}
6472
</div>
65-
<div className={`${NAME_SPACE}__wrapper`}>
73+
<div className={`${NAME_SPACE}__datepicker-container`}>
6674
<Controller
6775
viewType={viewType}
6876
setViewType={setViewType}
6977
viewDate={viewDate}
7078
/>
71-
<div className={`${NAME_SPACE}__container`}>
79+
<div className={`${NAME_SPACE}__datepicker`}>
7280
{viewType === 'month' && (
73-
<div className={`${NAME_SPACE}__month-view`}>month</div>
81+
<ViewMonth monthPage={monthPage} setActiveDate={setActiveDate} />
7482
)}
7583
{viewType === 'year' && (
76-
<div className={`${NAME_SPACE}__year-view`}>year</div>
84+
<ViewYear
85+
setViewDateByType={setViewDateByType}
86+
setViewType={setViewType}
87+
/>
7788
)}
7889
{viewType === 'decade' && (
7990
<ViewDecade
8091
decadePage={decadePage}
81-
setViewDateType={setViewDateType}
92+
setViewDateByType={setViewDateByType}
8293
setViewType={setViewType}
8394
/>
8495
)}
8596
{viewType === 'century' && (
8697
<ViewCentury
8798
centuryPage={centuryPage}
88-
setViewDateType={setViewDateType}
99+
setViewDateByType={setViewDateByType}
89100
setViewType={setViewType}
90101
/>
91102
)}
92103
</div>
93104
</div>
94-
<DevController setViewDate={setViewDate} />
95105
<div className="dashboard">
96106
<div>Century : {centuryPage}</div>
97107
<div>Decade : {decadePage}</div>
98108
<div>Year : {yearPage}</div>
99109
<div>Month : {monthPage}</div>
100110
</div>
101-
</>
111+
</div>
102112
);
103113
}
104114

105-
export default DatepickerContainer;
115+
export default Container;

package/src/components/Controller.tsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
'use client';
22

33
import * as React from 'react';
4-
import { useMemo, useState } from 'react';
4+
import { useMemo } from 'react';
55
import { NAME_SPACE } from './constants/core';
6-
import { setCenturyPage, setDecadePage, setYearPage } from '../utils/page';
6+
import {
7+
setCenturyPage,
8+
setDecadePage,
9+
setMonthPage,
10+
setYearPage,
11+
} from '../utils/page';
12+
import { addLeadingZero } from '../utils/string';
713

814
type TviewType = 'century' | 'decade' | 'year' | 'month';
915

@@ -34,6 +40,13 @@ function Controller({ viewDate, viewType, setViewType }: IProps) {
3440

3541
return `${yearPage}`;
3642
}
43+
if (type === 'month') {
44+
const monthPage = setMonthPage(date);
45+
const year = Math.ceil(monthPage / 12);
46+
const month = addLeadingZero(monthPage % 12 || 12);
47+
48+
return `${year}-${month}`;
49+
}
3750
return '';
3851
};
3952

@@ -56,14 +69,34 @@ function Controller({ viewDate, viewType, setViewType }: IProps) {
5669

5770
return (
5871
<div className={`${NAME_SPACE}__controller`}>
72+
<button
73+
className={`${NAME_SPACE}__controller-arrow ${NAME_SPACE}__controller-extra-prev`}
74+
>
75+
Extra Previous
76+
</button>
77+
<button
78+
className={`${NAME_SPACE}__controller-arrow ${NAME_SPACE}__controller-prev`}
79+
>
80+
Previous
81+
</button>
5982
<button
6083
type="button"
61-
className={`${NAME_SPACE}__controller-label`}
84+
className={`${NAME_SPACE}__label`}
6285
onClick={handleLabelClick}
6386
disabled={viewType === 'century'}
6487
>
6588
{label}
6689
</button>
90+
<button
91+
className={`${NAME_SPACE}__controller-arrow ${NAME_SPACE}__controller-next`}
92+
>
93+
Extra Next
94+
</button>
95+
<button
96+
className={`${NAME_SPACE}__controller-arrow ${NAME_SPACE}__controller-extra-next`}
97+
>
98+
Next
99+
</button>
67100
</div>
68101
);
69102
}

0 commit comments

Comments
 (0)