Skip to content

Commit 179202e

Browse files
feat(DatePicker): vertical spacing & no outer padding props (#6856)
* <DatePicker /> added noPadding prop * <DatePicker /> added weeks vertical spacing prop * <Date Picker /> - add missing applyUnit import * Update packages/wix-ui-tpa/src/components/DatePicker/DatePicker.st.css Co-authored-by: sivanharel <[email protected]> * <Date Picker /> - pr fixes Co-authored-by: sivanharel <[email protected]>
1 parent 3c2b556 commit 179202e

File tree

6 files changed

+79
-3
lines changed

6 files changed

+79
-3
lines changed

packages/wix-ui-tpa/src/components/DatePicker/DatePicker.st.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:import {
22
-st-from: "../../common/formatters.st";
3-
-st-named: color, applyOpacity, fallback, font, zeroAsTrue;
3+
-st-named: color, applyOpacity, fallback, font, zeroAsTrue, applyUnit;
44
}
55

66
:import {
@@ -40,6 +40,8 @@
4040
DefaultSelectedDayBGColor: color-8;
4141
DefaultSelectedDayBorderRadius: 100%;
4242
DefaultDisabledDayColor: color-3;
43+
44+
DefaultWeeksVerticalSpacing: 0;
4345
}
4446
4547
/*Overrides*/
@@ -107,6 +109,11 @@
107109
@default color-3
108110
*/
109111
DisabledDayColor: --overridable;
112+
/*
113+
The vertical space between weeks.
114+
@default 0
115+
*/
116+
WeeksVerticalSpacing: --overridable;
110117
}
111118
112119
/* Overrides - deceleration of overridable parameters by the consumer */
@@ -128,6 +135,8 @@
128135
CurrentSelectedDayBGColor: color(fallback(value(SelectedDayBGColor), value(DefaultSelectedDayBGColor)));
129136
CurrentSelectedDayBorderRadius: fallback(value(SelectedDayBorderRadius),value(DefaultSelectedDayBorderRadius));
130137
CurrentDisabledDayColor: color(fallback(value(DisabledDayColor), value(DefaultDisabledDayColor)));
138+
139+
CurrentWeeksVerticalSpacing: applyUnit(fallback(value(WeeksVerticalSpacing),value(DefaultWeeksVerticalSpacing)), px);
131140
}
132141
133142
/* The component's css without the overrideStyleParams */
@@ -141,6 +150,7 @@
141150
142151
.calendar {
143152
-st-extends: WSRCalendar;
153+
-st-states: removeOuterPadding;
144154
}
145155
146156
.calendar::month {
@@ -206,6 +216,27 @@
206216
background-color: value(CurrentBackgroundColor);
207217
}
208218
219+
.calendar:removeOuterPadding::header {
220+
padding: 0;
221+
}
222+
223+
.calendar:removeOuterPadding::body {
224+
padding: 0;
225+
}
226+
227+
.calendar:removeOuterPadding::weekdays {
228+
padding: 0;
229+
}
230+
231+
.calendar:removeOuterPadding::month {
232+
min-width: 240px;
233+
min-height: 284px;
234+
}
235+
236+
.calendar::week:not(:last-child) {
237+
margin-bottom: value(CurrentWeeksVerticalSpacing);
238+
}
239+
209240
.calendar::day {
210241
font: value(CurrentDayFont);
211242
color: value(CurrentDayColor);

packages/wix-ui-tpa/src/components/DatePicker/DatePicker.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export interface DatePickerProps extends TPAComponentProps {
6969
yearDropdownAriaLabel?: string;
7070
/** Identifies the element that labels the years dropdown in calendar header */
7171
yearDropdownAriaLabelledBy?: string;
72+
/** If true, renders date picker without outer padding */
73+
removeOuterPadding?: boolean;
7274
}
7375

7476
interface DefaultProps {
@@ -117,6 +119,7 @@ export class DatePicker extends React.Component<DatePickerProps> {
117119
monthDropdownAriaLabelledBy,
118120
yearDropdownAriaLabel,
119121
yearDropdownAriaLabelledBy,
122+
removeOuterPadding,
120123
} = this.props;
121124

122125
return (
@@ -130,7 +133,7 @@ export class DatePicker extends React.Component<DatePickerProps> {
130133
role="region"
131134
>
132135
<WSRCalendar
133-
className={classes.calendar}
136+
className={st(classes.calendar, { removeOuterPadding })}
134137
dataHook={DATA_HOOKS.WSR_CALENDAR}
135138
value={value}
136139
onChange={onChange}

packages/wix-ui-tpa/src/components/DatePicker/DatePicker.visual.st.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@
1414
SelectedDayBorderRadius 0,
1515
);
1616
}
17+
18+
.weeksVerticalSpacing{
19+
-st-mixin: DatePicker(
20+
WeeksVerticalSpacing 8,
21+
);
22+
}

packages/wix-ui-tpa/src/components/DatePicker/DatePicker.visual.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,23 @@ visualize('DatePicker', () => {
127127
onChange={() => {}}
128128
/>,
129129
);
130+
snap(
131+
'No outer padding',
132+
<VisualTestDatePicker
133+
width="280px"
134+
value={new Date('2019/12/15')}
135+
onChange={() => {}}
136+
removeOuterPadding
137+
/>,
138+
);
139+
snap(
140+
'Weeks Vertical Spacing',
141+
<VisualTestDatePicker
142+
className={classes.weeksVerticalSpacing}
143+
width="280px"
144+
value={new Date('2019/12/15')}
145+
onChange={() => {}}
146+
/>,
147+
);
130148
});
131149
});

packages/wix-ui-tpa/src/components/DatePicker/docs/DatePickerWiringExample.st.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
MonthAndYearCaptionFont '"--customMonthAndYearCaptionFont"',
1919
WeekdayFont '"--customWeekdayFont"',
2020
DayFont '"--customDayFont"',
21+
22+
WeeksVerticalSpacing '"--customWeeksVerticalSpacing"',
2123
);
2224
}
2325

@@ -39,4 +41,4 @@
3941
/* WeekdayFont '"--customWeekdayFont"',*/
4042
/* DayFont '"--customDayFont"',*/
4143
/* );*/
42-
/*}*/
44+
/*}*/

packages/wix-ui-tpa/src/components/DatePicker/docs/index.story.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ export default {
6161
{ label: 'Monday', value: 1 },
6262
{ label: 'Sunday', value: 0 },
6363
],
64+
removeOuterPadding: [
65+
{
66+
label: 'With Outer Padding',
67+
value: false,
68+
},
69+
{
70+
label: 'Without Outer Padding',
71+
value: true,
72+
},
73+
],
6474
},
6575
dataHook: 'storybook-DatePicker',
6676
sections: [
@@ -207,6 +217,12 @@ export default {
207217
defaultNumber: 100,
208218
unit: '%',
209219
},
220+
{
221+
label: 'Vertical Spacing Between Weeks',
222+
wixParam: 'customWeeksVerticalSpacing',
223+
defaultNumber: 0,
224+
unit: 'px',
225+
},
210226
],
211227
},
212228
}),

0 commit comments

Comments
 (0)