Skip to content

Commit cc2008b

Browse files
committed
docs: improve embedding and add link to codesandbox
1 parent ec01d4c commit cc2008b

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
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-
{ new URL(window.location.href).searchParams.has("hideControls") ? null :<Controls/> }
8+
{ new URL(window.location.href).searchParams.get("hideControls") === "true" ? null :<Controls/> }
99

1010
<Stories includePrimary={false}/>

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ The Google Picker API is a JavaScript API that allows users to select or upload
1212

1313
Explore the [storybook demo](https://googleworkspace.github.io/drive-picker-element/?path=/docs/stories-drive-picker--docs) to see the component in action.
1414

15+
See the framework specific demos:
16+
17+
- [React](https://codesandbox.io/p/sandbox/xenodochial-leaf-j2xtdq)
18+
1519
## Index
1620

1721
- [Install](#install)

src/stories/drive-picker.stories.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const argsAllowedFromParams = [
3333
...Object.keys(elementArgTypes["drive-picker"]),
3434
...Object.keys(elementArgTypes["drive-picker-docs-view"]),
3535
];
36+
const searchParamsArgs = JSON.parse(searchParams.get("args") || "{}");
3637
const argValuesFromParams = Object.fromEntries(
37-
argsAllowedFromParams.map((arg) => [arg, searchParams.get(arg) || undefined]),
38+
argsAllowedFromParams.map((arg) => [arg, searchParamsArgs[arg] || undefined]),
3839
);
3940

4041
const postHeightToParent = () => {
@@ -126,20 +127,7 @@ const render = ({ ...args }) => {
126127

127128
// Use a template to show the drive-picker element only when the user clicks the preview button
128129
const template = document.createElement("template");
129-
const withBundlers = document.createElement("script");
130-
withBundlers.textContent = `
131-
import "@googleworkspace/drive-picker-element";
132-
`;
133-
const withoutBundlers = document.createElement("script");
134-
withoutBundlers.src =
135-
"https://unpkg.com/@googleworkspace/drive-picker-element@0/dist/index.iife.min.js";
136-
template.innerHTML = [
137-
"<!-- Using JavaScript bundler or CDN -->",
138-
withBundlers.outerHTML,
139-
`<!-- ${withoutBundlers.outerHTML} -->`,
140-
"", // Add a newline for better readability
141-
drivePicker.outerHTML,
142-
].join("\n");
130+
template.innerHTML = drivePicker.outerHTML;
143131
lazyPreviewElement.appendChild(template);
144132

145133
return lazyPreviewElement;

0 commit comments

Comments
 (0)