Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Picker 컴포넌트 구현 #139

Merged
merged 53 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
edd7c5a
chore: day picker 설치
hamo-o Aug 12, 2024
97589ef
feat: LeftArrow 아이콘 추가
hamo-o Aug 12, 2024
06c1f67
feat: DatePicker UI 초기구현
hamo-o Aug 12, 2024
61b98b9
fix: Date Button UI 수정
hamo-o Aug 12, 2024
22cf031
feat: Calendar 아이콘 추가
hamo-o Aug 12, 2024
33f8ef2
feat: Date 전용 DropDown 추가
hamo-o Aug 12, 2024
3f66d47
fix: thead 관련 오류 수정, 필요 없는 import 삭제
hamo-o Aug 12, 2024
857c112
feat: button 클릭 영역 확대
hamo-o Aug 12, 2024
34d7207
feat: single mode로 제한
hamo-o Aug 12, 2024
aac901f
feat: DateDropDown 빌드
hamo-o Aug 12, 2024
9698905
feat: usePickerState 훅 분리
hamo-o Aug 16, 2024
92e0dcf
feat: Picker button style 분리
hamo-o Aug 16, 2024
b487370
feat: TimePicker 초기 UI
hamo-o Aug 16, 2024
fd62548
feat: TimePicker를 usePickerState 훅을 이용해서 동작할 수 있도록 구현
hamo-o Aug 16, 2024
5b13130
chore: TimePicker 내보내기 추가
hamo-o Aug 16, 2024
47615bb
fix: label 스타일 변경 및 TimePicker 라벨 추가
hamo-o Aug 16, 2024
cee99d7
design: 버튼 스타일 변경
hamo-o Aug 16, 2024
c7f97bd
fix: 12시 관련 에러처리
hamo-o Aug 16, 2024
d49c3eb
design: 아이콘 cursor 속성 추가
hamo-o Aug 20, 2024
a3dfea2
fix: 출력 date, time 네이밍 수정 및 isAM 관련 로직 수정
hamo-o Aug 20, 2024
dcd03b9
fix: initialDate 객체가 아니라 바로 받을 수 있도록 수정, 12시 엣지케이스 수정
hamo-o Aug 21, 2024
470884b
feat: Date range도 선택할 수 있도록 수정
hamo-o Aug 21, 2024
cf00d8b
feat: usePickerRangeDateState, usePickerTimeState 훅 분리
hamo-o Aug 21, 2024
622190e
fix: month 관련 오류 수정
hamo-o Aug 21, 2024
8d16c8b
fix: 0시 12시로 변환
hamo-o Aug 21, 2024
af8844c
chore: 추가 컴포넌트 빌드
hamo-o Aug 21, 2024
9cd616f
refactor: Context API 활용
hamo-o Aug 21, 2024
2a959ba
remove: 불필요한 hook 삭제
hamo-o Aug 21, 2024
2972b7f
chore: PickerGroup 빌드
hamo-o Aug 21, 2024
17f6a98
fix: a11y color-contrast 체크 해제
hamo-o Aug 22, 2024
9c39d01
refactor: Date to string 유틸함수 사용하기
hamo-o Aug 22, 2024
a6ae6d0
refactor: pickerClassNames 분리
hamo-o Aug 24, 2024
de41e57
refactor: pickerComponents 분리
hamo-o Aug 24, 2024
1b3b033
rename: 폴더구조 변경
hamo-o Aug 24, 2024
69795f7
chore: 빌드 내용 추가
hamo-o Aug 24, 2024
c851d59
fix: 복잡한 삼항연산자 개선 및 빌드 에러를 해결하기 위한 폴더구조 재변경
hamo-o Aug 24, 2024
516bda5
refactor: 여러번 호출되는 getHours 개선
hamo-o Aug 24, 2024
03bddc5
fix: styled와 className 통일 및 불필요한 styled 삭제
hamo-o Aug 26, 2024
c2985d1
feat: 시작, 끝 날짜 선택 후 재선택 시 초기화
hamo-o Aug 26, 2024
45ecd85
refactor: format~ 으로 함수 네이밍 변경
hamo-o Aug 26, 2024
d9e6f89
refactor: format~ 함수 util로 분리
hamo-o Aug 26, 2024
41c4c14
refactor: useTimeState 훅 분리
hamo-o Aug 26, 2024
ddefb56
refactor: formatDateToString return값 변경
hamo-o Aug 26, 2024
575dae2
fix: 타입 단언 제거
hamo-o Aug 26, 2024
a28105f
chore: pickerComponents 빌드 제외
hamo-o Aug 26, 2024
c2c38fe
chore: package.json 변경 및 rollup config 변경
hamo-o Aug 26, 2024
f79680f
chore: 스토리북 console.log 삭제
hamo-o Aug 26, 2024
3d6be3e
feat: DatePicker 바깥 영역 클릭 시 드롭다운 닫기
hamo-o Aug 26, 2024
f9936b3
chore: changeset 추가
hamo-o Aug 26, 2024
52365aa
design: TimePicker select 및 active 시 디자인 적용
hamo-o Aug 28, 2024
2c6ae10
chore: 불필요한 닫는 태그 삭제
hamo-o Aug 28, 2024
3e3c2fc
refactor: useTimeState 훅 코드리뷰 반영
hamo-o Aug 28, 2024
50a3371
fix: 여러 타입 모두 disabled 상태일 때 이벤트 막기
hamo-o Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lazy-sheep-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wowds-ui": patch
---

RangeDatePicker, SingleDatePicker, TimePicker 컴포넌트를 구현합니다.
5 changes: 5 additions & 0 deletions .changeset/sour-swans-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wowds-icons": patch
---

LeftArrow 아이콘을 추가합니다.
1 change: 1 addition & 0 deletions packages/scripts/generateBuildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const excludedComponents = [
"DropDownWrapper",
"CollectionContext",
"DropDownOptionList",
"pickerComponents",
];

const getFilteredComponentFiles = async (directoryPath: string) => {
Expand Down
50 changes: 50 additions & 0 deletions packages/wow-icons/src/component/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { forwardRef } from "react";
import { color } from "wowds-tokens";

import type { IconProps } from "@/types/Icon.ts";

const Calendar = forwardRef<SVGSVGElement, IconProps>(
(
{
className,
width = "24",
height = "24",
viewBox = "0 0 24 24",
stroke = "white",
...rest
},
ref
) => {
return (
<svg
aria-label="calendar icon"
className={className}
fill="none"
height={height}
ref={ref}
viewBox={viewBox}
width={width}
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<path
d="M21.3 4.7V20.3H2.7V4.7L21.3 4.7Z"
stroke={color[stroke]}
strokeWidth="1.4"
/>
<path d="M17 2V7" stroke={color[stroke]} strokeWidth="1.4" />
<path d="M12 2V7" stroke={color[stroke]} strokeWidth="1.4" />
<path d="M7 2V7" stroke={color[stroke]} strokeWidth="1.4" />
<path d="M3 9.5L21 9.5" stroke={color[stroke]} strokeWidth="1.4" />
<path
d="M18.5 15.5C18.5 16.6046 17.6046 17.5 16.5 17.5C15.3954 17.5 14.5 16.6046 14.5 15.5C14.5 14.3954 15.3954 13.5 16.5 13.5C17.6046 13.5 18.5 14.3954 18.5 15.5Z"
stroke={color[stroke]}
strokeWidth="1.4"
/>
</svg>
);
}
);

Calendar.displayName = "Calendar";
export default Calendar;
42 changes: 42 additions & 0 deletions packages/wow-icons/src/component/LeftArrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { forwardRef } from "react";
import { color } from "wowds-tokens";

import type { IconProps } from "@/types/Icon.ts";

const LeftArrow = forwardRef<SVGSVGElement, IconProps>(
(
{
className,
width = "20",
height = "20",
viewBox = "0 0 20 20",
stroke = "white",
...rest
},
ref
) => {
return (
<svg
aria-label="left-arrow icon"
className={className}
fill="none"
height={height}
ref={ref}
viewBox={viewBox}
width={width}
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<path
d="M12.5 16L7.5 10L12.5 4"
stroke={color[stroke]}
strokeLinejoin="bevel"
strokeWidth="1.4"
/>
</svg>
);
}
);

LeftArrow.displayName = "LeftArrow";
export default LeftArrow;
2 changes: 2 additions & 0 deletions packages/wow-icons/src/component/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export { default as Calendar } from "./Calendar.tsx";
export { default as Check } from "./Check.tsx";
export { default as Close } from "./Close.tsx";
export { default as DownArrow } from "./DownArrow.tsx";
export { default as Edit } from "./Edit.tsx";
export { default as Help } from "./Help.tsx";
export { default as LeftArrow } from "./LeftArrow.tsx";
export { default as Link } from "./Link.tsx";
export { default as Plus } from "./Plus.tsx";
export { default as Reload } from "./Reload.tsx";
Expand Down
8 changes: 8 additions & 0 deletions packages/wow-icons/src/svg/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/wow-icons/src/svg/left-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions packages/wow-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,31 @@
"require": "./dist/RadioGroup.cjs",
"import": "./dist/RadioGroup.js"
},
"./DateDropDown": {
"types": "./dist/components/Picker/DateDropDown.d.ts",
"require": "./dist/DateDropDown.cjs",
"import": "./dist/DateDropDown.js"
},
"./PickerGroup": {
"types": "./dist/components/Picker/PickerGroup.d.ts",
"require": "./dist/PickerGroup.cjs",
"import": "./dist/PickerGroup.js"
},
"./RangeDatePicker": {
"types": "./dist/components/Picker/RangeDatePicker.d.ts",
"require": "./dist/RangeDatePicker.cjs",
"import": "./dist/RangeDatePicker.js"
},
"./SingleDatePicker": {
"types": "./dist/components/Picker/SingleDatePicker.d.ts",
"require": "./dist/SingleDatePicker.cjs",
"import": "./dist/SingleDatePicker.js"
},
"./TimePicker": {
"types": "./dist/components/Picker/TimePicker.d.ts",
"require": "./dist/TimePicker.cjs",
"import": "./dist/TimePicker.js"
},
"./MultiGroup": {
"types": "./dist/components/MultiGroup/index.d.ts",
"require": "./dist/MultiGroup.cjs",
Expand Down Expand Up @@ -154,6 +179,7 @@
"dependencies": {
"clsx": "^2.1.1",
"lottie-react": "^2.4.0",
"react-day-picker": "^9.0.8",
"wowds-icons": "workspace:^"
},
"peerDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions packages/wow-ui/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export default {
SearchBar: "./src/components/SearchBar",
RadioButton: "./src/components/RadioGroup/RadioButton",
RadioGroup: "./src/components/RadioGroup/RadioGroup",
DateDropDown: "./src/components/Picker/DateDropDown",
PickerGroup: "./src/components/Picker/PickerGroup",
RangeDatePicker: "./src/components/Picker/RangeDatePicker",
SingleDatePicker: "./src/components/Picker/SingleDatePicker",
TimePicker: "./src/components/Picker/TimePicker",
MultiGroup: "./src/components/MultiGroup",
DropDownOption: "./src/components/DropDown/DropDownOption",
DropDown: "./src/components/DropDown",
Expand Down
4 changes: 2 additions & 2 deletions packages/wow-ui/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const ButtonStyle = cva({
_disabled: {
borderColor: "darkDisabled",
color: "darkDisabled",
cursor: "not-allowed",
pointerEvents: "none",
},
_hover: {
borderColor: "blueHover",
Expand All @@ -152,7 +152,7 @@ const ButtonStyle = cva({

_disabled: {
color: "blueDisabled",
cursor: "not-allowed",
pointerEvents: "none",
},
_hover: {
shadow: "blue",
Expand Down
115 changes: 115 additions & 0 deletions packages/wow-ui/src/components/Picker/DateDropDown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"use client";

import { cva } from "@styled-system/css";
import { Flex, styled } from "@styled-system/jsx";
import { Calendar } from "wowds-icons";

interface DateDropDownPropsBase {
label?: string;
placeholder?: string;
onClick: () => void;
}

interface SingleDateDropDownProps extends DateDropDownPropsBase {
mode: "single";
selectedValue?: string;
}

interface RangeDateDropDownProps extends DateDropDownPropsBase {
mode: "range";
selectedValue?: { start?: string; end?: string };
}

type DateDropDownProps = SingleDateDropDownProps | RangeDateDropDownProps;

const DateDropDown = ({
mode,
placeholder,
label,
selectedValue,
onClick,
}: DateDropDownProps) => {
const formatSelectedValue = () => {
if (!selectedValue) return placeholder;
if (mode === "range" && selectedValue.start) return selectedValue.start;
if (mode === "single") return selectedValue;
};

return (
<Flex direction="column" gap="0.75rem" onClick={onClick}>
{label && (
<styled.span color="sub" textStyle="label2">
{label}
</styled.span>
)}
<button aria-haspopup={true} className={dropdownStyle()}>
<div
className={placeholderStyle({
type: selectedValue ? "selected" : "default",
})}
>
{formatSelectedValue()}
</div>
{mode === "range" && (
<div
className={placeholderStyle({
type: selectedValue ? "selected" : "default",
})}
>
{selectedValue ? `~ ${selectedValue.end}` : placeholder}
eugene028 marked this conversation as resolved.
Show resolved Hide resolved
</div>
)}
<Calendar stroke="outline" />
</button>
</Flex>
);
};

export default DateDropDown;

const dropdownStyle = cva({
base: {
lg: {
maxWidth: "22.375rem",
},
smDown: {
width: "100%",
},
display: "flex",
alignItems: "center",
justifyContent: "space-between",

border: "1px solid",
borderRadius: "sm",
borderColor: "outline",
outline: "none",

paddingY: "xs",
paddingX: "sm",

backgroundColor: "background",
cursor: "pointer",
},
});

const placeholderStyle = cva({
base: {
textStyle: "body1",
},
variants: {
type: {
default: {
color: "outline",
_hover: {
color: "sub",
},
},
focused: {
color: "primary",
},
selected: {
color: "textBlack",
},
},
},
});
Loading
Loading