Skip to content

Commit 7f1d858

Browse files
docs(calendar): remove MDX file
- migrates documentation from MDX file to the stories file instead
1 parent 9eca12d commit 7f1d858

File tree

3 files changed

+40
-75
lines changed

3 files changed

+40
-75
lines changed

components/calendar/stories/calendar.mdx

Lines changed: 0 additions & 60 deletions
This file was deleted.

components/calendar/stories/calendar.stories.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const months = [...Array(12).keys()].map((key) =>
1111
);
1212

1313
/**
14-
* Calendars display a grid of days in one or more months and allow users to select a single date.
14+
* Calendars display a grid of days in one or more months and allow users to select a single date or a range of dates.
1515
*/
1616
export default {
1717
title: "Calendar",
@@ -27,6 +27,9 @@ export default {
2727
options: months,
2828
control: "select",
2929
},
30+
// The date selection controls don't update the story, so they are removed from the table.
31+
// TODO: We may have to refactor some of the template to create a working controls for the
32+
// selectable dates.
3033
selectedDay: {
3134
name: "Selected date or range start (date)",
3235
description:
@@ -35,19 +38,33 @@ export default {
3538
table: {
3639
type: { summary: "datetime" },
3740
category: "Content",
41+
disable: true,
3842
},
3943
control: "date",
4044
if: { arg: "isDisabled", truthy: false },
4145
},
46+
isRangeSelection : {
47+
name: "Range selection",
48+
description: "Allow users to select a range of dates.",
49+
type: { name: "boolean" },
50+
table: {
51+
type: { summary: "boolean" },
52+
category: "Content",
53+
disable: true,
54+
},
55+
control: "boolean",
56+
},
4257
lastDay: {
4358
name: "Range end (date)",
4459
description: "Defines the end of a date range.",
4560
type: { name: "number" },
4661
table: {
4762
type: { summary: "datetime" },
4863
category: "Content",
64+
disable: true,
4965
},
5066
control: "date",
67+
if: { arg: "isRangeSelection", truthy: true}
5168
},
5269
year: {
5370
name: "Year",
@@ -69,7 +86,8 @@ export default {
6986
control: "boolean",
7087
},
7188
useDOWAbbrev: {
72-
name: "Use 3 letter abbreviation for day of week",
89+
name: "Days of the week",
90+
description: "Use 3 letter abbreviation for day of week.",
7391
type: { name: "boolean" },
7492
table: {
7593
type: { summary: "boolean" },
@@ -89,6 +107,7 @@ export default {
89107
isFocused: false,
90108
useDOWAbbrev: false,
91109
buttonSize: ActionButtonStories.args.size,
110+
isRangeSelection: false,
92111
},
93112
parameters: {
94113
actions: {
@@ -99,45 +118,52 @@ export default {
99118
packageJson,
100119
metadata,
101120
},
102-
tags: ["!autodocs"],
103121
};
104122

105123
export const Default = CalendarGroup.bind({});
106124
Default.args = {
107125
month: months[6],
108-
selectedDay: new Date(2023, 6, 3),
109-
year: 2023,
126+
selectedDay: new Date(2025, 6, 3),
127+
year: 2025,
110128
};
111129

112130
// ********* DOCS ONLY ********* //
113131
export const AbbreviatedWeekdays = Template.bind({});
114132
AbbreviatedWeekdays.args = {
133+
...Default.args,
115134
useDOWAbbrev: true,
116135
};
117136
AbbreviatedWeekdays.tags = ["!dev"];
118137
AbbreviatedWeekdays.parameters = {
119138
chromatic: { disableSnapshot: true },
120139
};
140+
AbbreviatedWeekdays.storyName = "Abbreviated weekdays";
141+
142+
/**
143+
* For calendars with a selectable range:
121144
145+
- The `.is-range-start` and `.is-range-selection` classes go on the first day in the selection.
146+
- The `.is-range-end` and `.is-range-selection` classes go on the last day of the selection.
147+
- The `.is-range-selection` class goes on all days in the middle of the selection.
148+
*/
122149
export const RangeSelection = Template.bind({});
123150
RangeSelection.args = {
151+
isRangeSelection: true,
124152
month: months[6],
125-
selectedDay: new Date(2023, 6, 3),
126-
year: 2023,
127-
lastDay: new Date(2023, 6, 7),
128-
useDOWAbbrev: true,
153+
selectedDay: new Date(2025, 6, 3),
154+
year: 2025,
155+
lastDay: new Date(2025, 6, 7),
129156
isPadded: true,
130157
};
131-
RangeSelection.tags = ["!dev"];
132158
RangeSelection.parameters = {
133159
chromatic: { disableSnapshot: true },
134160
};
161+
RangeSelection.storyName = "Range selection";
135162

136163
export const Focused = Template.bind({});
137164
Focused.args = {
138-
month: undefined,
165+
...Default.args,
139166
selectedDay: undefined,
140-
year: undefined,
141167
isFocused: true,
142168
};
143169
Focused.tags = ["!dev"];
@@ -148,6 +174,7 @@ Focused.parameters = {
148174
export const Disabled = Template.bind({});
149175
Disabled.tags = ["!dev"];
150176
Disabled.args = {
177+
...Default.args,
151178
isDisabled: true
152179
};
153180
Disabled.parameters = {

components/calendar/stories/template.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const Template = ({
139139
if (firstDOWInMonth > DOW.length - orphanedDays) {
140140
weeksInMonth++;
141141
}
142-
if (displayedMonth === 1 && firstDOWInMonth > 0) { // accounts for Feburary
142+
if (displayedMonth === 1 && firstDOWInMonth > 0) { // accounts for February
143143
weeksInMonth++;
144144
}
145145

@@ -368,8 +368,6 @@ export const Template = ({
368368
"is-range-start": thisDay.isRangeStart,
369369
"is-range-end": thisDay.isRangeEnd,
370370
"is-selected": thisDay.isSelected,
371-
// "is-selection-start": thisDay.isRangeStart,
372-
// "is-selection-end": thisDay.isRangeEnd,
373371
"is-disabled": isDisabled,
374372
"is-focused": (isFocused && thisDay.isFocused) || thisDay.isSelected,
375373
})}

0 commit comments

Comments
 (0)