Skip to content

Commit

Permalink
docs: improve embedding and add link to codesandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoehnelt committed Jan 15, 2025
1 parent ec01d4c commit cc2008b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 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/>

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

<Stories includePrimary={false}/>
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The Google Picker API is a JavaScript API that allows users to select or upload

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

See the framework specific demos:

- [React](https://codesandbox.io/p/sandbox/xenodochial-leaf-j2xtdq)

## Index

- [Install](#install)
Expand Down
18 changes: 3 additions & 15 deletions src/stories/drive-picker.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const argsAllowedFromParams = [
...Object.keys(elementArgTypes["drive-picker"]),
...Object.keys(elementArgTypes["drive-picker-docs-view"]),
];
const searchParamsArgs = JSON.parse(searchParams.get("args") || "{}");
const argValuesFromParams = Object.fromEntries(
argsAllowedFromParams.map((arg) => [arg, searchParams.get(arg) || undefined]),
argsAllowedFromParams.map((arg) => [arg, searchParamsArgs[arg] || undefined]),
);

const postHeightToParent = () => {
Expand Down Expand Up @@ -126,20 +127,7 @@ const render = ({ ...args }) => {

// Use a template to show the drive-picker element only when the user clicks the preview button
const template = document.createElement("template");
const withBundlers = document.createElement("script");
withBundlers.textContent = `
import "@googleworkspace/drive-picker-element";
`;
const withoutBundlers = document.createElement("script");
withoutBundlers.src =
"https://unpkg.com/@googleworkspace/drive-picker-element@0/dist/index.iife.min.js";
template.innerHTML = [
"<!-- Using JavaScript bundler or CDN -->",
withBundlers.outerHTML,
`<!-- ${withoutBundlers.outerHTML} -->`,
"", // Add a newline for better readability
drivePicker.outerHTML,
].join("\n");
template.innerHTML = drivePicker.outerHTML;
lazyPreviewElement.appendChild(template);

return lazyPreviewElement;
Expand Down

0 comments on commit cc2008b

Please sign in to comment.