Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 7 changed files with 773 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/package.json
Expand Up @@ -66,8 +66,10 @@
"chartjs-adapter-date-fns": "3.0.0",
"classnames": "2.3.2",
"copy-to-clipboard": "3.3.3",
"countries-and-timezones": "^3.4.0",
"cypress": "9.7.0",
"date-fns": "2.29.3",
"date-fns-tz": "^2.0.0",
"debounce": "1.2.1",
"deep-diff": "1.0.2",
"dequal": "2.0.3",
Expand All @@ -92,7 +94,9 @@
"react-dropzone": "14.2.3",
"react-error-boundary": "3.1.4",
"react-hooks-global-state": "2.1.0",
"react-joyride": "^2.5.3",
"react-markdown": "^8.0.4",
"react-linkify": "^1.0.0-alpha",
"react-router-dom": "6.8.1",
"react-table": "7.8.0",
"react-test-renderer": "17.0.2",
Expand All @@ -107,10 +111,7 @@
"vite-plugin-svgr": "2.4.0",
"vite-tsconfig-paths": "4.0.5",
"vitest": "0.28.5",
"whatwg-fetch": "3.6.2",
"countries-and-timezones": "^3.4.0",
"date-fns-tz": "^2.0.0",
"react-linkify": "^1.0.0-alpha"
"whatwg-fetch": "3.6.2"
},
"optionalDependencies": {
"orval": "^6.10.3"
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/component/App.tsx
Expand Up @@ -20,6 +20,7 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import MaintenanceBanner from './maintenance/MaintenanceBanner';
import { styled } from '@mui/material';
import { InitialRedirect } from './InitialRedirect';
import { Demo } from './demo/Demo';

const StyledContainer = styled('div')(() => ({
'& ul': {
Expand Down Expand Up @@ -100,6 +101,13 @@ export const App = () => {

<FeedbackNPS openUrl="http://feedback.unleash.run" />

<ConditionallyRender
condition={Boolean(
uiConfig.flags.demo
)}
show={<Demo />}
/>

<SplashPageRedirect />
</StyledContainer>
</>
Expand Down
236 changes: 236 additions & 0 deletions frontend/src/component/demo/Demo.tsx
@@ -0,0 +1,236 @@
import { Typography } from '@mui/material';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import { Badge } from 'component/common/Badge/Badge';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { useEffect, useState } from 'react';
import { Step } from 'react-joyride';
import { DemoTopics } from './DemoTopics/DemoTopics';
import { DemoSteps } from './DemoSteps/DemoSteps';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { createLocalStorage } from 'utils/createLocalStorage';

export interface ITutorialTopic {
title: string;
steps: Step[];
}

const defaultProgress = {
expanded: true,
run: false,
topic: 0,
steps: [0],
};

const { value: storedProgress, setValue: setStoredProgress } =
createLocalStorage('Tutorial:v1', defaultProgress);

const TOPICS: ITutorialTopic[] = [
{
title: 'Import',
steps: [
{
target: 'button[data-testid="IMPORT_BUTTON"]',
title: (
<Typography fontWeight="bold">
Import toggle configuration
</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
This is a cool feature that enables you to import
your toggle configuration. This is just an example
and not part of the final guide.
</Typography>
</>
),
disableBeacon: true,
},
],
},
{
title: 'New feature toggle',
steps: [
{
target: 'button[data-testid="NAVIGATE_TO_CREATE_FEATURE"]',
title: (
<Typography fontWeight="bold">
Add a new feature toggle
</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
You can use this button to add a new feature toggle.
This is just an example and not part of the final
guide.
</Typography>
</>
),
disableBeacon: true,
},
],
},
{
title: 'Enable/disable a feature toggle',
steps: [
{
target: '.MuiSwitch-sizeMedium',
title: (
<Typography fontWeight="bold">
Enable/disable a feature toggle
</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
The simplest way to use a feature toggle is to
enable or disable it for everyone (on/off).
</Typography>
<Badge
sx={{ marginTop: 2 }}
icon={<InfoOutlinedIcon />}
>
Look at the demo page when toggling!
</Badge>
</>
),
disableBeacon: true,
},
],
},
{
title: 'Community',
steps: [
{
target: 'a[href="https://twitter.com/getunleash"]',
title: (
<Typography fontWeight="bold">
Follow us on Twitter!
</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
Following us on Twitter is one of the easiest ways
of keeping up with us. This is just an example and
not part of the final guide.
</Typography>
</>
),
disableBeacon: true,
},
{
target: 'a[href="https://www.linkedin.com/company/getunleash"]',
title: (
<Typography fontWeight="bold">
Follow us on LinkedIn!
</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
You can also follow us LinkedIn. This is just an
example and not part of the final guide.
</Typography>
</>
),
disableBeacon: true,
},
{
target: 'a[href="https://github.com/Unleash/unleash"]',
title: (
<Typography fontWeight="bold">
Check out Unleash on GitHub!
</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
Unleash is open-source, check out the project on
GitHub. This is just an example and not part of the
final guide.
</Typography>
</>
),
disableBeacon: true,
},
{
target: 'a[href="https://slack.unleash.run"]',
title: (
<Typography fontWeight="bold">Join us on Slack!</Typography>
),
content: (
<>
<Typography variant="body2" color="text.secondary">
Join our community in Slack. This is just an example
and not part of the final guide.
</Typography>
</>
),
disableBeacon: true,
},
],
},
];

export const Demo = () => {
const { uiConfig } = useUiConfig();
const [loaded, setLoaded] = useState(false);
const [expanded, setExpanded] = useState(storedProgress.expanded ?? true);
const [run, setRun] = useState(storedProgress.run ?? false);
const [topic, setTopic] = useState(storedProgress.topic ?? 0);
const [steps, setSteps] = useState(storedProgress.steps ?? [0]);

useEffect(() => {
setTimeout(() => {
setLoaded(true);
}, 1000);
}, []);

useEffect(() => {
setStoredProgress({
expanded,
run,
topic,
steps,
});
}, [expanded, run, topic, steps]);

if (!uiConfig.flags.demo) return null;

return (
<>
<DemoTopics
expanded={expanded}
setExpanded={setExpanded}
steps={steps}
currentTopic={topic}
setCurrentTopic={(topic: number) => {
setTopic(topic);
setSteps(steps => {
const newSteps = [...steps];
newSteps[topic] = 0;
return newSteps;
});
}}
topics={TOPICS}
/>
<ConditionallyRender
condition={loaded}
show={
<DemoSteps
run={run}
setRun={setRun}
setExpanded={setExpanded}
steps={steps}
setSteps={setSteps}
topic={topic}
setTopic={setTopic}
topics={TOPICS}
/>
}
/>
</>
);
};

0 comments on commit 6c79c79

Please sign in to comment.