Skip to content

docs(dial,dialog,divider,dropindicator): Migrate docs to storybook pt7 #2833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8505ca3
docs(dial): add missing stories and chromatic coverage
marissahuysentruyt Aug 14, 2024
5aebcad
chore(tray): corrects variable spelling (isDismissible)
marissahuysentruyt Aug 14, 2024
001beb2
docs(dropindicator): add dropindicator template for docs page
marissahuysentruyt Aug 16, 2024
8c43f08
docs(divider): add missing stories and template fixes
marissahuysentruyt Aug 19, 2024
65bd7d4
docs(dialog): add missing stories, template fixes, chromatic coverage
marissahuysentruyt Aug 19, 2024
896fed9
docs(dialog): revert dialogHeading arg name change
marissahuysentruyt Aug 19, 2024
715896e
chore(dial): extends isFocused shared state
marissahuysentruyt Aug 20, 2024
6f5fd5d
chore(dialog): remove remaining comments from rebase
marissahuysentruyt Aug 20, 2024
a8bdfd9
docs(divider): use Sizes decorator instead of custom sizing template
marissahuysentruyt Aug 20, 2024
5e5ebf0
docs(divider): fix VRTs with refactored divider styles
marissahuysentruyt Aug 20, 2024
9e017da
chore(dialog): remove comments
marissahuysentruyt Aug 21, 2024
c404f9e
chore(dialog): expand test coverage variants
marissahuysentruyt Aug 21, 2024
ef8c077
chore(dialog): add default layout to args table
marissahuysentruyt Aug 22, 2024
fbecd97
chore(dialog): refactor custom template for testing
marissahuysentruyt Aug 22, 2024
4f6a4a6
chore(dialog): clean up template
marissahuysentruyt Aug 22, 2024
af43f9e
chore(dialog): removes hasHeroImage boolean from UI
marissahuysentruyt Aug 22, 2024
a68a7b1
chore(divider): rename VerticalGroup to VerticalSizing
marissahuysentruyt Aug 22, 2024
4146e5e
docs(divider): refactor divider
marissahuysentruyt Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions components/dial/stories/dial.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isFocused } from "@spectrum-css/preview/types";
import { version } from "../package.json";
import { DialGroup } from "./dial.test.js";
import { Template } from "./template.js";

/**
* A dial is an input control used for selecting a value within a range, similar to a slider. It's often used in audio and video mixing and editing applications, where horizontal space is limited.
Expand All @@ -28,7 +29,7 @@ export default {
},
control: "text",
},
isFocused,
isFocusVisible: isFocused,
isDragged: {
name: "Dragged",
type: { name: "boolean" },
Expand All @@ -51,7 +52,7 @@ export default {
args: {
rootClass: "spectrum-Dial",
size: "m",
isFocused: false,
isFocusVisible: false,
isDragged: false,
isDisabled: false,
},
Expand All @@ -63,6 +64,33 @@ export default {
export const Default = DialGroup.bind();
Default.args = {};

export const Small = Template.bind();
Small.args = {
size: "s",
};
Small.parameters = {
chromatic: { disableSnapshot: true },
};
Small.tags = ["!dev"];

export const WithLabel = Template.bind();
WithLabel.args = {
label: "Volume",
};
WithLabel.parameters = {
chromatic: { disableSnapshot: true },
};
WithLabel.tags = ["!dev"];

export const Disabled = Template.bind();
Disabled.args = {
isDisabled: true,
};
Disabled.parameters = {
chromatic: { disableSnapshot: true },
};
Disabled.tags = ["!dev"];

// ********* VRT ONLY ********* //
export const WithForcedColors = DialGroup.bind({});
WithForcedColors.args = Default.args;
Expand Down
8 changes: 4 additions & 4 deletions components/dial/stories/dial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export const DialGroup = Variants({
],
stateData: [
{
heading: "Disabled",
testHeading: "Disabled",
isDisabled: true,
},
{
heading: "Focused",
isFocused: true,
testHeading: "Focused",
isFocusVisible: true,
},
{
heading: "Dragged",
testHeading: "Dragged",
isDragged: true,
},
],
Expand Down
110 changes: 55 additions & 55 deletions components/dial/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Template = ({
rootClass = "spectrum-Dial",
size = "m",
label,
isFocused = false,
isFocusVisible = false,
isDragged = false,
isDisabled = false,
min = 0,
Expand Down Expand Up @@ -38,58 +38,58 @@ export const Template = ({
if (isDisabled) return;
if (!document.body.classList.contains("u-isGrabbing")) return;

const dial = e.target.closest(".spectrum-Dial");
const handle = dial.querySelector(".spectrum-Dial-handle");
const input = dial.querySelector("input");
const min = -45;
const max = 225;
const dialOffsetLeft = dial.offsetLeft + dial.offsetParent.offsetLeft;
var x = Math.max(Math.min(e.x - dialOffsetLeft, dial.offsetWidth), 0);
var percent = (x / dial.offsetWidth) * 100;
var deg = percent * 0.01 * (max - min) + min;
handle.style.transform = "rotate(" + deg + "deg" + ")";
input.value = Math.round(
percent * 0.01 * (input.max - input.min) + input.min
);
}}
>
${when(
label,
() => html`<div class="${rootClass}-labelContainer">
<label id="dialLabel" class="${rootClass}-label" for="labeledDial"
>${label}</label
>
<div
class="${rootClass}-value"
role="textbox"
aria-readonly="true"
aria-labelledby="dialLabel"
>
${min}
</div>
</div>`
)}
<div class="${rootClass}-controls">
<div
class="${rootClass}-handle ${isDragged ? "is-dragged" : ""} ${isFocused
? "is-focused"
: ""}"
tabindex="0"
>
<input
type="range"
class="${rootClass}-input"
min="${min}"
max="${max}"
value="${min}"
@change=${(e) => {
const value = e.target.value;
const label = document.getElementById("dialLabel");
label.nextSibling.textContent = value;
}}
/>
</div>
</div>
</div>
`;
const dial = e.target.closest(".spectrum-Dial");
const handle = dial.querySelector(".spectrum-Dial-handle");
const input = dial.querySelector("input");
const min = -45;
const max = 225;
const dialOffsetLeft = dial.offsetLeft + dial.offsetParent.offsetLeft;
var x = Math.max(Math.min(e.x - dialOffsetLeft, dial.offsetWidth), 0);
var percent = (x / dial.offsetWidth) * 100;
var deg = percent * 0.01 * (max - min) + min;
handle.style.transform = "rotate(" + deg + "deg" + ")";
input.value = Math.round(
percent * 0.01 * (input.max - input.min) + input.min
);
}}
>
${when(
label,
() => html`<div class="${rootClass}-labelContainer">
<label id="dialLabel" class="${rootClass}-label" for="labeledDial"
>${label}</label
>
<div
class="${rootClass}-value"
role="textbox"
aria-readonly="true"
aria-labelledby="dialLabel"
>
${min}
</div>
</div>`
)}
<div class="${rootClass}-controls">
<div
class="${rootClass}-handle
${isDragged ? "is-dragged": ""}
${isFocusVisible ? "is-focus-visible": ""}"
tabindex="0"
>
<input
type="range"
class="${rootClass}-input"
min="${min}"
max="${max}"
value="${min}"
@change=${(e) => {
const value = e.target.value;
const label = document.getElementById("dialLabel");
label.nextSibling.textContent = value;
}}
/>
</div>
</div>
</div>
`;
};
Loading
Loading