Skip to content

Commit

Permalink
move theme detection into SHowcaseStandalone
Browse files Browse the repository at this point in the history
  • Loading branch information
heswell committed Feb 6, 2024
1 parent ad9d671 commit 8931ba4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 30 deletions.
2 changes: 1 addition & 1 deletion vuu-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"view-bundle": "node ./scripts/visualize-bundle.mjs",
"type-defs": "node ./scripts/build-all-type-defs.mjs",
"showcase": "cd showcase && npm run showcase",
"showcase:preview": "serve ./showcase/dist",
"showcase:preview": "serve ./showcase/dist -p 4173",
"showcase:build": " cd showcase && node scripts/build.mjs",
"test:cypress": "cypress run --component --browser chrome --headless",
"test:cypress:local": "cypress open --component --browser chrome",
Expand Down
3 changes: 1 addition & 2 deletions vuu-ui/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"main": "index.js",
"private": true,
"scripts": {
"build": "vite build",
"build": "node ./scripts/build.mjs",
"dev": "vite",
"docs": "node ./scripts/build-docs.mjs",
"preview": "node ./scripts/preview.mjs",
"showcase": "node ./scripts/showcase.mjs",
"stories": "node ./scripts/parse-stories.mjs"
},
Expand Down
15 changes: 0 additions & 15 deletions vuu-ui/showcase/scripts/preview.mjs

This file was deleted.

12 changes: 1 addition & 11 deletions vuu-ui/showcase/src/index-standalone.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { ShowcaseStandalone } from "@finos/vuu-showcase";
import ReactDOM from "react-dom";
import { getUrlParameter } from "@finos/vuu-utils";

const theme = getUrlParameter("theme", "vuu");

const root = document.getElementById("root") as HTMLDivElement;

ReactDOM.render(
<ShowcaseStandalone
density="high"
theme={theme}
themeMode="light"
></ShowcaseStandalone>,
root
);
ReactDOM.render(<ShowcaseStandalone />, root);
8 changes: 7 additions & 1 deletion vuu-ui/tools/vuu-showcase/src/ShowcaseStandalone.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
assertModuleExportsAtLeastOneComponent,
Density,
getUrlParameter,
ThemeMode,
ThemeProvider,
} from "@finos/vuu-utils";
Expand All @@ -11,7 +12,7 @@ import "./Showcase.css";

export const ShowcaseStandalone = ({
density = "high",
theme = "vuu",
theme: themeProp,
themeMode = "light",
}: {
density?: Density;
Expand All @@ -21,6 +22,11 @@ export const ShowcaseStandalone = ({
const [component, setComponent] = useState<ReactNode>(null);
const [themeReady, setThemeReady] = useState(false);

const theme = useMemo(
() => themeProp ?? getUrlParameter("theme", "vuu"),
[themeProp]
);

useMemo(() => {
switch (theme) {
case "vuu":
Expand Down

0 comments on commit 8931ba4

Please sign in to comment.