Skip to content

Commit

Permalink
Fix play
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Dec 12, 2024
1 parent 95d85bb commit 1d06c98
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/sdk-components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"@webstudio-is/react-sdk": "workspace:*",
"@webstudio-is/sdk": "workspace:*",
"colord": "^2.9.3",
"micromark": "^4.0.0"
"micromark": "^4.0.0",
"await-interaction-response": "^0.0.2"
},
"devDependencies": {
"@testing-library/react": "^14.2.2",
Expand Down
11 changes: 10 additions & 1 deletion packages/sdk-components-react/src/vimeo-play-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {
type ElementRef,
type ComponentProps,
useContext,
useCallback,
} from "react";
import { VimeoContext } from "./vimeo";
import { Button, defaultTag } from "./button";
import interactionResponse from "await-interaction-response";

export { defaultTag };

Expand All @@ -14,10 +16,17 @@ type Props = ComponentProps<typeof Button>;
export const VimeoPlayButton = forwardRef<ElementRef<typeof defaultTag>, Props>(
(props, ref) => {
const vimeoContext = useContext(VimeoContext);

const handleClick = useCallback(async () => {
await interactionResponse();
vimeoContext.onInitPlayer();
}, [vimeoContext]);

if (vimeoContext.status !== "initial") {
return;
}
return <Button {...props} onClick={vimeoContext.onInitPlayer} ref={ref} />;

return <Button {...props} onClick={handleClick} ref={ref} />;
}
);

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d06c98

Please sign in to comment.