Skip to content

Commit 408e10f

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 1bf0399 commit 408e10f

File tree

3 files changed

+52
-94
lines changed

3 files changed

+52
-94
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 & 7 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,11 +114,14 @@ 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({});
108126
Range.args = {
109127
lastDay: 3,
@@ -125,7 +143,11 @@ QuietRange.args = {
125143
QuietRange.parameters = {
126144
chromatic: { disableSnapshot: true },
127145
};
146+
QuietRange.storyName = "Range, quiet";
128147

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+
*/
129151
export const Invalid = Template.bind({});
130152
Invalid.tags = ["!dev"];
131153
Invalid.args = {
@@ -146,6 +168,7 @@ QuietInvalid.args = {
146168
QuietInvalid.parameters = {
147169
chromatic: { disableSnapshot: true },
148170
};
171+
QuietInvalid.storyName = "Invalid, quiet";
149172

150173
export const ReadOnly = Template.bind({});
151174
ReadOnly.tags = ["!dev"];
@@ -155,6 +178,7 @@ ReadOnly.args = {
155178
ReadOnly.parameters = {
156179
chromatic: { disableSnapshot: true },
157180
};
181+
ReadOnly.storyName = "Read-only";
158182

159183
export const Disabled = Template.bind({});
160184
Disabled.tags = ["!dev"];
@@ -174,6 +198,7 @@ QuietDisabled.args = {
174198
QuietDisabled.parameters = {
175199
chromatic: { disableSnapshot: true },
176200
};
201+
QuietDisabled.storyName = "Disabled, quiet";
177202

178203
// ********* VRT ONLY ********* //
179204
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";
@@ -135,3 +135,22 @@ export const Template = ({
135135
}, context)}
136136
`;
137137
};
138+
139+
140+
/* Displays open and closed date pickers. */
141+
export const OpenClosedTemplate = (args, context) => Container({
142+
withBorder: false,
143+
wrapperStyles: { "column-gap": "56px", },
144+
content: html`
145+
${Container({
146+
withBorder: false,
147+
heading: "Open",
148+
content: Template(args, context),
149+
})}
150+
${Container({
151+
withBorder: false,
152+
heading: "Closed",
153+
content: Template({...args, isOpen: false}, context),
154+
})}
155+
`
156+
});

0 commit comments

Comments
 (0)