Skip to content

Commit 2bced72

Browse files
author
Justin Poehnelt
committed
docs: improve storybook for embedding
- allow setting attributes from url params - change button text from "Preview" to "Open Drive Picker"
1 parent 3c8e640 commit 2bced72

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.storybook/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import "./page.css";
55

66
<Canvas/>
77

8-
<Controls/>
8+
{ new URL(window.location.href).searchParams.has("hideControls") ? null :<Controls/> }
99

1010
<Stories includePrimary={false}/>

src/stories/drive-picker.stories.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,23 @@ const elementEventNames = getElementEvents("drive-picker").map(
2828
(event) => event.name,
2929
);
3030

31+
const searchParams = new URL(location.href).searchParams;
32+
const argsAllowedFromParams = [
33+
...Object.keys(elementArgTypes["drive-picker"]),
34+
...Object.keys(elementArgTypes["drive-picker-docs-view"]),
35+
];
36+
const argValuesFromParams = Object.fromEntries(
37+
argsAllowedFromParams.map((arg) => [arg, searchParams.get(arg) || undefined]),
38+
);
39+
3140
const meta: Meta = {
3241
component: "drive-picker",
3342
argTypes: {
3443
...elementArgTypes["drive-picker"],
3544
...elementArgTypes["drive-picker-docs-view"],
3645
},
3746
args: {
47+
...argValuesFromParams,
3848
"app-id": APP_ID,
3949
"client-id": CLIENT_ID,
4050
},

src/stories/utils/lazy-preview-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ lazy-preview button:hover {
4444
this.appendChild(style);
4545

4646
const button = document.createElement("button");
47-
button.textContent = "Preview";
47+
button.textContent = "Open Drive Picker";
4848
this.appendChild(button);
4949

5050
button.addEventListener("click", () => {

0 commit comments

Comments
 (0)