Skip to content

Commit 73571fb

Browse files
committed
feat: show value and selected dates for examples
1 parent e139ded commit 73571fb

5 files changed

Lines changed: 30 additions & 10 deletions

File tree

packages/react-use-calendar-component/src/app/components/CalendarCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export default function CalendarCell({
2020
onClick={() => selectThisDate()}
2121
type='button'
2222
title={title}>
23-
<div className='flex items-center justify-center'>
24-
<span>{dayOfMonth}</span>
25-
</div>
23+
{dayOfMonth}
2624
</button>
2725
);
2826
}

packages/react-use-calendar-component/src/app/components/Examples/Multiple.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { useState } from 'react';
22

33
import useCalendarComponent from '../../../lib';
44
import Calendar from '../Calendar';
5-
import SelectedDates from '../SelectedDates';
5+
import StateInfo from '../StateInfo';
66

77
export function Multiple() {
88
const [value, setValue] = useState([new Date()]);
9-
console.log(value);
109
const calendarControl = useCalendarComponent({
1110
selectType: 'multiple',
1211
value,
@@ -17,7 +16,7 @@ export function Multiple() {
1716
return (
1817
<div>
1918
<Calendar calendarControl={calendarControl} />
20-
<SelectedDates selectedDates={selectedDates} />
19+
<StateInfo value={value} selectedDates={selectedDates} />
2120
</div>
2221
);
2322
}

packages/react-use-calendar-component/src/app/components/Examples/Single.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react';
22

33
import useCalendarComponent from '../../../lib';
44
import Calendar from '../Calendar';
5-
import SelectedDates from '../SelectedDates';
5+
import StateInfo from '../StateInfo';
66

77
export function Single() {
88
const [value, setValue] = useState(new Date());
@@ -12,7 +12,7 @@ export function Single() {
1212
return (
1313
<div>
1414
<Calendar calendarControl={calendarControl} />
15-
<SelectedDates selectedDates={selectedDates} />
15+
<StateInfo value={[value]} selectedDates={selectedDates} />
1616
</div>
1717
);
1818
}

packages/react-use-calendar-component/src/app/components/SelectedDates.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ interface Props {
44

55
export default function SelectedDates({ selectedDates }: Props) {
66
return (
7-
<p className='text-center mt-10 text-white flex flex-col'>
7+
<div className='flex flex-col'>
88
{selectedDates.map(date => {
99
return <span key={date.toString()}>{date.toLocaleDateString()}</span>;
1010
})}
11-
</p>
11+
</div>
1212
);
1313
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
interface Props {
2+
value: Date[];
3+
selectedDates: Date[];
4+
}
5+
6+
export default function StateInfo({ value, selectedDates }: Props) {
7+
return (
8+
<div className='text-white flex justify-between mt-5'>
9+
<div className='flex flex-col'>
10+
<div className='text-lg text-rose-300'>value:</div>
11+
{value.map((v, index) => (
12+
<span key={index}>{v.toLocaleDateString()}</span>
13+
))}
14+
</div>
15+
<div className='flex flex-col'>
16+
<div className='text-lg text-rose-300'>selected dates:</div>
17+
{selectedDates.map((date, index) => {
18+
return <span key={index}>{date.toLocaleDateString()}</span>;
19+
})}
20+
</div>
21+
</div>
22+
);
23+
}

0 commit comments

Comments
 (0)