Skip to content

Commit b3ef43e

Browse files
docs(datepicker): remove MDX file
- adds missing date picker docs - migrates documentation in MDX to stories.js instead - creates OpenClosedTemplate to display both states in a single story on the docs page - adds Range variant to the sidebar since that control isn't in the table
1 parent 908d3a7 commit b3ef43e

File tree

3 files changed

+52
-95
lines changed

3 files changed

+52
-95
lines changed

components/datepicker/stories/datepicker.mdx

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

components/datepicker/stories/datepicker.stories.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isDisabled, isInvalid, isOpen, isQuiet, isReadOnly, isRequired, isValid
44
import metadata from "../metadata/metadata.json";
55
import packageJson from "../package.json";
66
import { DatePickerGroup } from "./datepicker.test.js";
7-
import { Template } from "./template.js";
7+
import { OpenClosedTemplate, Template } from "./template.js";
88

99
/**
1010
* A date picker displays a text field input with a button next to it, and can display two text fields next to each other for choosing a date range.
@@ -28,7 +28,7 @@ export default {
2828
if: { arg: "isInvalid", truthy: false },
2929
},
3030
isDateTimeRange: {
31-
name: "Date and Time styling",
31+
name: "Date and time styling",
3232
type: { name: "boolean" },
3333
table: {
3434
type: { summary: "boolean" },
@@ -81,16 +81,31 @@ export default {
8181

8282
export const Default = DatePickerGroup.bind({});
8383
Default.args = {};
84-
Default.parameters = {
84+
Default.tags = ["!autodocs"];
85+
86+
// ********* DOCS ONLY ********* //
87+
/**
88+
* Default styling for date pickers display a visible field button. This style works best in a dense array of controls where the field button helps separate the dropdown from its surroundings.
89+
*
90+
* The standard implementation for a date picker incorporates the display of a [calendar](/docs/components-calendar--docs) within a [popover component](/docs/components-popover--docs).
91+
*/
92+
export const DefaultGroup = OpenClosedTemplate.bind({});
93+
DefaultGroup.args = {};
94+
DefaultGroup.tags = [ "!dev"];
95+
DefaultGroup.storyName = "Default";
96+
DefaultGroup.parameters = {
8597
docs: {
8698
story: {
87-
height: "300px"
99+
height: "350px",
88100
}
89101
},
102+
chromatic: { disableSnapshot: true },
90103
};
91104

92-
// ********* DOCS ONLY ********* //
93-
export const Quiet = Template.bind({});
105+
/**
106+
* The quiet style works best when a clear layout (vertical stack, table, grid) makes it easy to parse.
107+
*/
108+
export const Quiet = OpenClosedTemplate.bind({});
94109
Quiet.tags = ["!dev"];
95110
Quiet.args = {
96111
isQuiet: true,
@@ -99,13 +114,15 @@ Quiet.parameters = {
99114
chromatic: { disableSnapshot: true },
100115
docs: {
101116
story: {
102-
height: "300px"
117+
height: "350px",
103118
}
104119
},
105120
};
106121

122+
/**
123+
* Date pickers can be used to select a date range (a start date and an end date).
124+
*/
107125
export const Range = Template.bind({});
108-
Range.tags = ["!dev"];
109126
Range.args = {
110127
lastDay: 3,
111128
isRange: true,
@@ -126,7 +143,11 @@ QuietRange.args = {
126143
QuietRange.parameters = {
127144
chromatic: { disableSnapshot: true },
128145
};
146+
QuietRange.storyName = "Range, quiet";
129147

148+
/**
149+
* A date picker can be marked as having an error to show that a value needs to be entered in order to move forward, or that an entered value is invalid.
150+
*/
130151
export const Invalid = Template.bind({});
131152
Invalid.tags = ["!dev"];
132153
Invalid.args = {
@@ -147,6 +168,7 @@ QuietInvalid.args = {
147168
QuietInvalid.parameters = {
148169
chromatic: { disableSnapshot: true },
149170
};
171+
QuietInvalid.storyName = "Invalid, quiet";
150172

151173
export const ReadOnly = Template.bind({});
152174
ReadOnly.tags = ["!dev"];
@@ -156,6 +178,7 @@ ReadOnly.args = {
156178
ReadOnly.parameters = {
157179
chromatic: { disableSnapshot: true },
158180
};
181+
ReadOnly.storyName = "Read-only";
159182

160183
export const Disabled = Template.bind({});
161184
Disabled.tags = ["!dev"];
@@ -175,6 +198,7 @@ QuietDisabled.args = {
175198
QuietDisabled.parameters = {
176199
chromatic: { disableSnapshot: true },
177200
};
201+
QuietDisabled.storyName = "Disabled, quiet";
178202

179203
// ********* VRT ONLY ********* //
180204
export const WithForcedColors = DatePickerGroup.bind({});

components/datepicker/stories/template.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Template as Calendar } from "@spectrum-css/calendar/stories/template.js";
22
import { Template as PickerButton } from "@spectrum-css/pickerbutton/stories/template.js";
33
import { Template as Popover } from "@spectrum-css/popover/stories/template.js";
4-
import { getRandomId } from "@spectrum-css/preview/decorators";
4+
import { Container, getRandomId } from "@spectrum-css/preview/decorators";
55
import { Template as TextField } from "@spectrum-css/textfield/stories/template.js";
66
import { html } from "lit";
77
import { when } from "lit-html/directives/when.js";
@@ -130,3 +130,22 @@ export const Template = ({
130130
}, context)}
131131
`;
132132
};
133+
134+
135+
/* Displays open and closed date pickers. */
136+
export const OpenClosedTemplate = (args, context) => Container({
137+
withBorder: false,
138+
wrapperStyles: { "column-gap": "56px", },
139+
content: html`
140+
${Container({
141+
withBorder: false,
142+
heading: "Open",
143+
content: Template(args, context),
144+
})}
145+
${Container({
146+
withBorder: false,
147+
heading: "Closed",
148+
content: Template({...args, isOpen: false}, context),
149+
})}
150+
`
151+
});

0 commit comments

Comments
 (0)