From 202ffdb6ce935f3b1c40a8594d77e84ca66b6933 Mon Sep 17 00:00:00 2001 From: u_m1by6 Date: Mon, 28 Mar 2022 13:03:05 +0500 Subject: [PATCH 1/2] feat(calendar): added hide header --- packages/calendar/src/Component.test.tsx | 15 +- packages/calendar/src/Component.tsx | 46 +- .../src/__snapshots__/Component.test.tsx.snap | 593 ++++++++++++++++++ .../src/component.screenshots.test.tsx | 2 +- .../src/components/header/Component.tsx | 2 +- packages/calendar/src/typings.ts | 2 +- 6 files changed, 629 insertions(+), 31 deletions(-) diff --git a/packages/calendar/src/Component.test.tsx b/packages/calendar/src/Component.test.tsx index 65e6bddfca..d89e3f205e 100644 --- a/packages/calendar/src/Component.test.tsx +++ b/packages/calendar/src/Component.test.tsx @@ -41,12 +41,15 @@ describe('Calendar', () => { ).toMatchSnapshot(); }); - it.each(['month-only', 'full'])('should match selectorView="%s" snapshot', view => { - expect( - render() - .container, - ).toMatchSnapshot(); - }); + it.each(['month-only', 'full', 'empty'])( + 'should match selectorView="%s" snapshot', + view => { + expect( + render() + .container, + ).toMatchSnapshot(); + }, + ); }); it('should set `data-test-id` attribute', () => { diff --git a/packages/calendar/src/Component.tsx b/packages/calendar/src/Component.tsx index b171f99a56..4499904428 100644 --- a/packages/calendar/src/Component.tsx +++ b/packages/calendar/src/Component.tsx @@ -28,7 +28,7 @@ export type CalendarProps = { defaultView?: View; /** - * Вид шапки — месяц и год или только месяц + * Вид шапки — месяц и год, только месяц или пустой */ selectorView?: SelectorView; @@ -253,27 +253,29 @@ export const Calendar = forwardRef( })} data-test-id={dataTestId} > -
- {selectorView === 'month-only' ? ( - - ) : ( - - )} -
+ {selectorView !== 'empty' && ( +
+ {selectorView === 'month-only' ? ( + + ) : ( + + )} +
+ )}
{view === 'days' && ( diff --git a/packages/calendar/src/__snapshots__/Component.test.tsx.snap b/packages/calendar/src/__snapshots__/Component.test.tsx.snap index ea04050bc7..c6cb8e3090 100644 --- a/packages/calendar/src/__snapshots__/Component.test.tsx.snap +++ b/packages/calendar/src/__snapshots__/Component.test.tsx.snap @@ -2280,6 +2280,599 @@ exports[`Calendar Display tests should match defaultView="years" snapshot 1`] =
`; +exports[`Calendar Display tests should match selectorView="empty" snapshot 1`] = ` +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Пн + + Вт + + Ср + + Чт + + Пт + + Сб + + Вс +
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + +
+
+
+
+`; + exports[`Calendar Display tests should match selectorView="full" snapshot 1`] = `
Date: Mon, 28 Mar 2022 15:04:09 +0500 Subject: [PATCH 2/2] fix(calendar): fix comments --- packages/calendar/src/Component.tsx | 2 +- packages/calendar/src/components/header/Component.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/calendar/src/Component.tsx b/packages/calendar/src/Component.tsx index 4499904428..30356b8398 100644 --- a/packages/calendar/src/Component.tsx +++ b/packages/calendar/src/Component.tsx @@ -28,7 +28,7 @@ export type CalendarProps = { defaultView?: View; /** - * Вид шапки — месяц и год, только месяц или пустой + * Вид шапки — месяц и год или только месяц или без шапки */ selectorView?: SelectorView; diff --git a/packages/calendar/src/components/header/Component.tsx b/packages/calendar/src/components/header/Component.tsx index 6aac70518d..d2f8eba91b 100644 --- a/packages/calendar/src/components/header/Component.tsx +++ b/packages/calendar/src/components/header/Component.tsx @@ -6,7 +6,7 @@ import styles from './index.module.css'; export type HeaderProps = { /** - * Вид шапки — месяц и год, только месяц или пустой + * Вид шапки — месяц и год или только месяц или без шапки */ view?: SelectorView;