Skip to content

Commit

Permalink
docs: improve storybook for embedding (#30)
Browse files Browse the repository at this point in the history
- allow setting attributes from url params
- change button text from "Preview" to "Open Drive Picker"
  • Loading branch information
jpoehnelt authored Jan 13, 2025
1 parent 3c8e640 commit 8b9c87f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .storybook/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import "./page.css";

<Canvas/>

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

<Stories includePrimary={false}/>
10 changes: 10 additions & 0 deletions src/stories/drive-picker.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@ const elementEventNames = getElementEvents("drive-picker").map(
(event) => event.name,
);

const searchParams = new URL(location.href).searchParams;
const argsAllowedFromParams = [
...Object.keys(elementArgTypes["drive-picker"]),
...Object.keys(elementArgTypes["drive-picker-docs-view"]),
];
const argValuesFromParams = Object.fromEntries(
argsAllowedFromParams.map((arg) => [arg, searchParams.get(arg) || undefined]),
);

const meta: Meta = {
component: "drive-picker",
argTypes: {
...elementArgTypes["drive-picker"],
...elementArgTypes["drive-picker-docs-view"],
},
args: {
...argValuesFromParams,
"app-id": APP_ID,
"client-id": CLIENT_ID,
},
Expand Down
2 changes: 1 addition & 1 deletion src/stories/utils/lazy-preview-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ lazy-preview button:hover {
this.appendChild(style);

const button = document.createElement("button");
button.textContent = "Preview";
button.textContent = "Open Drive Picker";
this.appendChild(button);

button.addEventListener("click", () => {
Expand Down

0 comments on commit 8b9c87f

Please sign in to comment.