Skip to content

Commit 82d18b3

Browse files
committed
feat: ✨ calendar
1 parent 3006470 commit 82d18b3

7 files changed

Lines changed: 88 additions & 20 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { Meta } from "@storybook/react";
2+
import type { DateCalendarProps } from "node_modules/@mui/x-date-pickers";
3+
4+
import { DateCalendar, LocalizationProvider } from "@mui/x-date-pickers";
5+
import { AdapterLuxon } from "@mui/x-date-pickers/AdapterLuxon";
6+
7+
const meta: Meta<typeof DateCalendar> = {
8+
title: "KRDS/Calendar",
9+
component: DateCalendar,
10+
parameters: {
11+
design: {
12+
type: "figma",
13+
url: "https://www.figma.com/design/FQZqKPOEJVqFCFglsC5VUt/KRDS_v1.0.0--Community-?node-id=5131-24401&t=Aqswq9fC3JfS3oxl-4",
14+
},
15+
layout: "centered",
16+
},
17+
tags: ["autodocs"],
18+
argTypes: {
19+
showDaysOutsideCurrentMonth: {
20+
control: { type: "boolean" },
21+
},
22+
},
23+
};
24+
25+
export default meta;
26+
27+
export const ExampleCalendar = {
28+
args: {
29+
showDaysOutsideCurrentMonth: true,
30+
},
31+
render: (args: DateCalendarProps) => (
32+
<LocalizationProvider dateAdapter={AdapterLuxon} adapterLocale="ko">
33+
<DateCalendar {...args} />
34+
</LocalizationProvider>
35+
),
36+
};

apps/storybook/stories/date-input.stories.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const meta: Meta<typeof DatePicker> = {
2323
type: "boolean",
2424
},
2525
},
26+
showDaysOutsideCurrentMonth: {
27+
control: {
28+
type: "boolean",
29+
},
30+
},
2631
},
2732
};
2833

@@ -31,6 +36,7 @@ export default meta;
3136
export const ExampleDateInput = {
3237
args: {
3338
disabled: false,
39+
showDaysOutsideCurrentMonth: true,
3440
slotProps: {
3541
textField: {
3642
size: "medium",
@@ -40,7 +46,7 @@ export const ExampleDateInput = {
4046
},
4147
render: (args: DatePickerProps) => {
4248
return (
43-
<LocalizationProvider dateAdapter={AdapterLuxon}>
49+
<LocalizationProvider dateAdapter={AdapterLuxon} adapterLocale="ko">
4450
<DatePicker {...args} />
4551
</LocalizationProvider>
4652
);
File renamed without changes.

packages/krds/src/components/base/mui-table-pagination.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { Components } from "@mui/material";
22
import type { TablePaginationActionsProps } from "@mui/material/TablePagination/TablePaginationActions";
33
import type { ChangeEvent } from "react";
44

5-
import { Box, Button, TextField, Typography } from "@mui/material";
5+
import { Button, TextField } from "@mui/material";
66
import { useState } from "react";
7-
import { getPalette } from "#/design-tokens/palettes";
7+
import * as S from "#/components/base/mui/table-pagination.styles";
88

99
declare module "@mui/material/TablePagination" {}
1010

@@ -39,8 +39,8 @@ function TablePaginationActions(props: TablePaginationActionsProps) {
3939
};
4040

4141
return (
42-
<Box sx={{ display: "flex", gap: "16px" }}>
43-
<Box sx={{ display: "flex", alignItems: "center" }}>
42+
<S.PaginationContainer>
43+
<S.PaginationTextFieldContainer>
4444
<TextField
4545
size="small"
4646
value={pageInput}
@@ -52,13 +52,10 @@ function TablePaginationActions(props: TablePaginationActionsProps) {
5252
}}
5353
error={!isValidPage}
5454
/>
55-
<Typography
56-
variant="body-small"
57-
sx={{ marginLeft: "9px", color: getPalette("text.subtle") }}
58-
>
55+
<S.TotalPageTypography variant="body-small">
5956
/{totalPages}
60-
</Typography>
61-
</Box>
57+
</S.TotalPageTypography>
58+
</S.PaginationTextFieldContainer>
6259
<Button
6360
variant="outlined"
6461
color="secondary"
@@ -68,7 +65,7 @@ function TablePaginationActions(props: TablePaginationActionsProps) {
6865
>
6966
이동
7067
</Button>
71-
</Box>
68+
</S.PaginationContainer>
7269
);
7370
}
7471

packages/krds/src/components/base/mui-x-date-pickers.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
usePickerActionsContext,
2929
yearCalendarClasses,
3030
} from "@mui/x-date-pickers";
31-
import * as S from "#/components/base/mui-x/date-picker.styles";
31+
import * as S from "#/components/base/mui-x/date-pickers.styles";
3232
import { getPalette } from "#/design-tokens/palettes";
3333
import { getRadius } from "#/design-tokens/radius";
3434
import { getTypography } from "#/design-tokens/typography";
@@ -50,7 +50,7 @@ export const MuiLocalizationProvider: Components["MuiLocalizationProvider"] = {
5050
},
5151
};
5252

53-
export function DatePickerHeader(props: PickersCalendarHeaderProps) {
53+
function DatePickerHeader(props: PickersCalendarHeaderProps) {
5454
const { currentMonth, onMonthChange, onViewChange } = props;
5555

5656
const handleNextMonth = () =>
@@ -109,7 +109,7 @@ export function DatePickerHeader(props: PickersCalendarHeaderProps) {
109109
);
110110
}
111111

112-
export function DatePickerActionBar(props: PickersActionBarProps) {
112+
function DatePickerActionBar(props: PickersActionBarProps) {
113113
const { actions, className } = props;
114114
const { setValueToToday, acceptValueChanges, cancelValueChanges } =
115115
usePickerActionsContext();
@@ -165,8 +165,6 @@ export const MuiDatePicker: Components["MuiDatePicker"] = {
165165
slots: {
166166
// * https://mui.com/x/react-date-pickers/custom-components/#component
167167
actionBar: DatePickerActionBar,
168-
// * https://mui.com/x/react-date-pickers/custom-components/#calendar-header
169-
calendarHeader: DatePickerHeader,
170168
},
171169
views: ["year", "month", "day"],
172170
},
@@ -338,10 +336,7 @@ export const MuiPickersOutlinedInput: Components["MuiPickersOutlinedInput"] = {
338336
export const MuiPickerPopper: Components["MuiPickerPopper"] = {
339337
styleOverrides: {
340338
paper: {
341-
backgroundColor: getPalette("surface.secondary-subtler"),
342-
borderRadius: getRadius("xlarge2"),
343339
boxShadow: "none",
344-
outline: `1px solid ${getPalette("border.secondary-light")}`,
345340
},
346341
},
347342
};
@@ -423,11 +418,21 @@ export const MuiDayCalendar: Components["MuiDayCalendar"] = {
423418
};
424419

425420
export const MuiDateCalendar: Components["MuiDateCalendar"] = {
421+
defaultProps: {
422+
showDaysOutsideCurrentMonth: true,
423+
slots: {
424+
// * https://mui.com/x/react-date-pickers/custom-components/#calendar-header
425+
calendarHeader: DatePickerHeader,
426+
},
427+
},
426428
styleOverrides: {
427429
root: {
430+
backgroundColor: getPalette("surface.secondary-subtler"),
431+
borderRadius: getRadius("xlarge2"),
428432
height: "auto",
429433
// * 6줄이 보이기 위한 처리
430434
minHeight: "400px",
435+
outline: `1px solid ${getPalette("border.secondary-light")}`,
431436
paddingTop: "16px",
432437
width: "384px",
433438
},

packages/krds/src/components/base/mui-x/date-picker.styles.tsx renamed to packages/krds/src/components/base/mui-x/date-pickers.styles.tsx

File renamed without changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { BoxProps, TypographyProps } from "@mui/material";
2+
import type { ComponentType } from "react";
3+
4+
import { Box, Typography, styled } from "@mui/material";
5+
import { getPalette } from "#/design-tokens/palettes";
6+
7+
export const PaginationContainer: ComponentType<BoxProps> = styled(Box)({
8+
display: "flex",
9+
gap: "16px",
10+
});
11+
12+
export const PaginationTextFieldContainer: ComponentType<BoxProps> = styled(
13+
Box,
14+
)({
15+
display: "flex",
16+
alignItems: "center",
17+
});
18+
19+
export const TotalPageTypography: ComponentType<TypographyProps> = styled(
20+
Typography,
21+
)({
22+
color: getPalette("text.subtle"),
23+
marginLeft: "9px",
24+
});

0 commit comments

Comments
 (0)