Skip to content

Feat/hide calendar header #1046

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 9 additions & 6 deletions packages/calendar/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ describe('Calendar', () => {
).toMatchSnapshot();
});

it.each(['month-only', 'full'])('should match selectorView="%s" snapshot', view => {
expect(
render(<Calendar value={defaultValue} selectorView={view as SelectorView} />)
.container,
).toMatchSnapshot();
});
it.each(['month-only', 'full', 'empty'])(
'should match selectorView="%s" snapshot',
view => {
expect(
render(<Calendar value={defaultValue} selectorView={view as SelectorView} />)
.container,
).toMatchSnapshot();
},
);
});

it('should set `data-test-id` attribute', () => {
Expand Down
46 changes: 24 additions & 22 deletions packages/calendar/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type CalendarProps = {
defaultView?: View;

/**
* Вид шапки — месяц и год или только месяц
* Вид шапки — месяц и год или только месяц или без шапки
*/
selectorView?: SelectorView;

Expand Down Expand Up @@ -253,27 +253,29 @@ export const Calendar = forwardRef<HTMLDivElement, CalendarProps>(
})}
data-test-id={dataTestId}
>
<Header view={selectorView} withShadow={scrolled}>
{selectorView === 'month-only' ? (
<PeriodSlider
className={styles.period}
value={activeMonth}
periodType='month'
prevArrowDisabled={!canSetPrevMonth}
nextArrowDisabled={!canSetNextMonth}
hideDisabledArrows={true}
onPrevArrowClick={handlePrevArrowClick}
onNextArrowClick={handleNextArrowClick}
/>
) : (
<MonthYearHeader
className={styles.monthYear}
value={activeMonth}
onMonthClick={handleMonthClick}
onYearClick={handleYearClick}
/>
)}
</Header>
{selectorView !== 'empty' && (
<Header view={selectorView} withShadow={scrolled}>
{selectorView === 'month-only' ? (
<PeriodSlider
className={styles.period}
value={activeMonth}
periodType='month'
prevArrowDisabled={!canSetPrevMonth}
nextArrowDisabled={!canSetNextMonth}
hideDisabledArrows={true}
onPrevArrowClick={handlePrevArrowClick}
onNextArrowClick={handleNextArrowClick}
/>
) : (
<MonthYearHeader
className={styles.monthYear}
value={activeMonth}
onMonthClick={handleMonthClick}
onYearClick={handleYearClick}
/>
)}
</Header>
)}

<div className={cn(styles.container, styles[view])}>
{view === 'days' && (
Expand Down
Loading