Skip to content

Commit

Permalink
fixed tsconfig, defined types, added storybook modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mercillo committed Aug 2, 2024
1 parent 1f080eb commit a8a147d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
3 changes: 3 additions & 0 deletions docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ genrule(
name = "full_site",
srcs = [
"//docs/site",
"//docs/storybook"
],
outs = [
"merged_site.tar.gz"
Expand All @@ -14,6 +15,8 @@ genrule(
tmp_dir=$$(mktemp -d) &&
touch $$tmp_dir/.nojekyll &&
cp -LR $(location //docs/site)/** $$tmp_dir &&
mkdir $$tmp_dir/storybook-demo &&
cp -LR $(location //docs/storybook)/** $$tmp_dir/storybook-demo &&
chmod -R u+rwX,a+rX $$tmp_dir &&
tar -czhf $@ -C $$tmp_dir .
"""
Expand Down
7 changes: 4 additions & 3 deletions docs/site/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const useSearch = () => {
.slice(0, 10)
.map((r) => {
return searchIndex.searchIndex[r.ref];
});
})
.filter((e) => e !== undefined);

setResults(searchResults);
}
Expand Down Expand Up @@ -103,7 +104,7 @@ const SearchResult = (props: SearchIndex) => {
);
};

export const FallbackSearchInput = () => {
export const FallbackSearchInput = (): React.JSX.Element => {
const { search, results, clear } = useSearch();
const [searchActive, setSearchActive] = React.useState(false);
const [query, setQuery] = React.useState("");
Expand Down Expand Up @@ -162,7 +163,7 @@ export const FallbackSearchInput = () => {
);
};

export const SearchInput = () => {
export const SearchInput = (): React.JSX.Element => {
// Only use algolia search if we're on the /latest/ version
// it's the only one that's indexed
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { FlowManager, CompletedState, Flow } from '@player-ui/react';
import flow1 from './flow-1.json';
import flow2 from './flow-2.json';
import flow3 from './flow-3.json';
import {
FlowManager,
CompletedState,
Flow,
FinalState,
} from "@player-ui/react";
import flow1 from "./flow-1.json";
import flow2 from "./flow-2.json";
import flow3 from "./flow-3.json";

const basicFlows = [flow1, flow2, flow3];

Expand All @@ -16,24 +21,26 @@ export function createStaticFlowManager(flows: Array<Flow>): FlowManager {
return {
next: async (previousResult?: CompletedState) => {
if (!previousResult) {
return { value: flows[0] };
const firstFlow = flows[0] as Flow;
return { done: false, value: firstFlow };
}

const prevIndex = flows.findIndex((v) => v.id === previousResult.flow.id);
const nextIndex =
prevIndex + (previousResult.endState.outcome === 'back' ? -1 : 1);
prevIndex + (previousResult.endState.outcome === "back" ? -1 : 1);

if (nextIndex < 0 || nextIndex >= flows.length) {
return { done: true };
return { done: true } as FinalState;
}

await delay(Math.random() * 500);

return { value: flows[nextIndex] };
const nextFlow = flows[nextIndex] as Flow;
return { done: false, value: nextFlow };
},
};
}

export const basicFlowManager = createStaticFlowManager(
basicFlows as Array<Flow>
export const basicFlowManager: FlowManager = createStaticFlowManager(
basicFlows as Array<Flow>,
);
2 changes: 2 additions & 0 deletions docs/storybook/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ deps = [
"//:node_modules/@babel/preset-env",
"//:node_modules/@storybook/react-webpack5",
"//:node_modules/@storybook/addon-docs",
"//:node_modules/@storybook/components",
"//:node_modules/@storybook/manager-api",
"//:node_modules/@types/react-redux",
"//:node_modules/react-redux",
"//:node_modules/redux-state-sync",
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
"resolveJsonModule": true,
"composite": true,
"lib": ["DOM", "ES2020"],
"isolatedDeclarations": true,
"noUncheckedIndexedAccess": true,
}
}

0 comments on commit a8a147d

Please sign in to comment.