-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from player-ui/storybook
storybook
- Loading branch information
Showing
89 changed files
with
9,239 additions
and
1,993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@aspect_rules_js//npm:defs.bzl", "npm_package") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
load("@npm//:tsup/package_json.bzl", tsup_bin = "bin") | ||
|
||
npm_link_all_packages( | ||
name = "node_modules", | ||
) | ||
|
||
dependencies = [ | ||
"//:node_modules/@storybook/manager-api", | ||
"//:node_modules/@storybook/preview-api", | ||
"//:node_modules/@storybook/core-events", | ||
"//:node_modules/@storybook/components", | ||
"//:node_modules/@storybook/icons", | ||
"//:node_modules/react-redux", | ||
"//:node_modules/redux", | ||
"//:node_modules/react", | ||
"//:node_modules/@types/react", | ||
"//:node_modules/dequal", | ||
"//:node_modules/@monaco-editor/react", | ||
"//:node_modules/@chakra-ui/react", | ||
"//:node_modules/@storybook/types", | ||
"//:node_modules/esbuild-wasm", | ||
"//:node_modules/@player-tools/dsl", | ||
"//:node_modules/@player-ui/react", | ||
"//:node_modules/lz-string", | ||
"//:node_modules/@player-ui/beacon-plugin-react", | ||
"//:node_modules/@player-ui/make-flow", | ||
"//:node_modules/@player-ui/metrics-plugin-react", | ||
"//:node_modules/@storybook/channels", | ||
"//:node_modules/@reduxjs/toolkit", | ||
"//:node_modules/@types/redux-state-sync", | ||
"//:node_modules/redux-state-sync", | ||
"//:node_modules/@types/uuid", | ||
"//:node_modules/uuid", | ||
"//:node_modules/@storybook/manager", | ||
"//:node_modules/tsup", | ||
"//:node_modules/@storybook/preview", | ||
] | ||
|
||
tsup_bin.tsup_node( | ||
name = "addon-storybook-tsup", | ||
srcs = glob(["src/**"]) + [ | ||
"package.json", | ||
"tsconfig.json", | ||
"tsup.config.ts", | ||
] + dependencies, | ||
outs = [ | ||
"dist/index.js", | ||
"dist/index.mjs", | ||
], | ||
args = [ | ||
], | ||
chdir = package_name(), | ||
) | ||
|
||
js_library( | ||
name = "addon-storybook-library", | ||
srcs = glob(["src/**"]) + [ | ||
"manager.mjs", | ||
"package.json", | ||
":addon-storybook-tsup", | ||
], | ||
deps = dependencies, | ||
) | ||
|
||
npm_package( | ||
name = "addon-storybook", | ||
srcs = [ | ||
":addon-storybook-library", | ||
":addon-storybook-tsup", | ||
], | ||
package = "@player-ui/storybook-addon-player", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { register } from "./dist"; | ||
register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@player-ui/storybook-addon-player", | ||
"version": "0.0.0-PLACEHOLDER", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"node": "./dist/index.js", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs" | ||
}, | ||
"./manager": "./manager.mjs", | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "./src/index.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from "react"; | ||
import type { API } from "@storybook/manager-api"; | ||
import { useParameter } from "@storybook/preview-api"; | ||
import { STORY_CHANGED } from "@storybook/core-events"; | ||
import { | ||
IconButton, | ||
WithTooltip, | ||
TooltipLinkList, | ||
} from "@storybook/components"; | ||
import { BrowserIcon, MobileIcon } from "@storybook/icons"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import type { StateType } from "../../redux"; | ||
import { setPlatform } from "../../redux"; | ||
import type { RenderTarget } from "../../types"; | ||
|
||
interface RenderSelectionProps { | ||
/** storybook api */ | ||
api: API; | ||
} | ||
|
||
/** Component to show the appetize dropdown */ | ||
export const RenderSelection = ({ api }: RenderSelectionProps) => { | ||
const params = useParameter("appetizeTokens", {}); | ||
const dispatch = useDispatch(); | ||
|
||
const selectedPlatform = useSelector<StateType, RenderTarget["platform"]>( | ||
(state) => state.platform.platform ?? "web" | ||
); | ||
|
||
React.useEffect(() => { | ||
/** callback for the subscribe listener */ | ||
const listener = () => { | ||
dispatch(setPlatform({ platform: "web" })); | ||
}; | ||
|
||
api.getChannel()?.addListener(STORY_CHANGED, listener); | ||
|
||
return () => { | ||
api.getChannel()?.removeListener(STORY_CHANGED, listener); | ||
}; | ||
}, [api, dispatch]); | ||
|
||
const mobilePlatforms = Object.keys(params ?? {}) as Array<"ios" | "android">; | ||
|
||
if (mobilePlatforms.length === 0) { | ||
// No keys set so don't show | ||
return null; | ||
} | ||
|
||
return ( | ||
<WithTooltip | ||
placement="top" | ||
trigger="click" | ||
tooltip={({ onHide }) => ( | ||
<TooltipLinkList | ||
links={(["web", ...mobilePlatforms] as const).map((platform) => ({ | ||
id: platform, | ||
title: platform, | ||
onClick: () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
setPlatform(platform as any); | ||
dispatch(setPlatform({ platform })); | ||
onHide(); | ||
}, | ||
value: platform, | ||
active: platform === selectedPlatform, | ||
}))} | ||
/> | ||
)} | ||
> | ||
<IconButton title="Change the render target"> | ||
{selectedPlatform === "web" ? <BrowserIcon /> : <MobileIcon />} | ||
</IconButton> | ||
</WithTooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const PARAM_KEY = "web-player"; | ||
export const ADDON_ID = "web-player/addon"; | ||
|
||
export const FLOW_PANEL_ID = `${ADDON_ID}/flow-editor-panel`; | ||
export const EVENT_PANEL_ID = `${ADDON_ID}/events-panel`; | ||
export const DOCS_PANEL_ID = `${ADDON_ID}/asset-docs-panel`; | ||
export const MOBILE_TOOL_ID = `${ADDON_ID}/mobile-tool`; | ||
export const FLOW_REFRESH_TOOL_ID = `${ADDON_ID}/flow-refresh-tool`; | ||
export const PLAYER_RENDERER_TOOL_ID = `${ADDON_ID}/player-renderer-tool`; | ||
export const RENDER_SELECT_TOOL_ID = `${ADDON_ID}/render-select-tool`; |
Oops, something went wrong.