Skip to content

Commit

Permalink
feat: onboarding stepper (#8100)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Sep 5, 2024
1 parent 01fb748 commit 2daa0cd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
1 change: 0 additions & 1 deletion frontend/src/component/onboarding/ConnectSdkDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({
}));

const Navigation = styled('div')(({ theme }) => ({
marginTop: theme.spacing(16),
borderTop: `1px solid ${theme.palette.divider}}`,
display: 'flex',
justifyContent: 'flex-end',
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/component/onboarding/GenerateApiKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import EnvironmentsIcon from '@mui/icons-material/CloudCircle';
import { ArcherContainer, ArcherElement } from 'react-archer';
import { useEffect } from 'react';
import { SectionHeader } from './SharedComponents';
import { Stepper } from './Stepper';

const ChooseEnvironment = ({
environments,
Expand Down Expand Up @@ -226,7 +227,8 @@ export const GenerateApiKey = ({
return (
<SpacedContainer>
<Typography variant='h2'>Connect an SDK to Unleash</Typography>
<Box sx={{ mt: 4 }}>
<Stepper active={1} steps={3} />
<Box sx={{ mt: 2 }}>
<SectionHeader>Environment</SectionHeader>
<SectionDescription>
The environment SDK will connect to in order to retrieve
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/component/onboarding/SelectSdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { FC } from 'react';
import { formatAssetPath } from 'utils/formatPath';
import { SectionHeader } from './SharedComponents';
import { clientSdks, type Sdk, serverSdks } from './sharedTypes';
import { Stepper } from './Stepper';

const SpacedContainer = styled('div')(({ theme }) => ({
padding: theme.spacing(5, 8, 8, 8),
Expand Down Expand Up @@ -59,7 +60,8 @@ export const SelectSdk: FC<ISelectSdkProps> = ({ onSelect }) => {
return (
<SpacedContainer>
<Typography variant='h2'>Connect an SDK to Unleash</Typography>
<Box sx={{ mt: 4 }}>
<Stepper active={0} steps={3} />
<Box sx={{ mt: 2 }}>
<SectionHeader>Select SDK</SectionHeader>
<SecondarySectionHeader>
Server side SDKs
Expand Down
38 changes: 38 additions & 0 deletions frontend/src/component/onboarding/Stepper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { styled } from '@mui/material';
import type { FC } from 'react';

const StepContainer = styled('div')(({ theme }) => ({
display: 'flex',
gap: theme.spacing(1),
marginTop: theme.spacing(2),
}));

const Step = styled('div')(({ theme }) => ({
background: theme.palette.background.application,
borderRadius: theme.shape.borderRadius,
width: theme.spacing(7),
height: theme.spacing(1),
}));
const ActiveStep = styled('div')(({ theme }) => ({
background: theme.palette.background.sidebar,
borderRadius: theme.shape.borderRadius,
width: theme.spacing(7),
height: theme.spacing(1),
}));

export const Stepper: FC<{ active: number; steps: number }> = ({
active,
steps,
}) => {
return (
<StepContainer>
{Array.from({ length: steps }, (_, index) =>
index === active ? (
<ActiveStep key={index} />
) : (
<Step key={index} />
),
)}
</StepContainer>
);
};
7 changes: 5 additions & 2 deletions frontend/src/component/onboarding/TestSdkConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import copy from 'copy-to-clipboard';
import useToast from 'hooks/useToast';
import CopyIcon from '@mui/icons-material/FileCopy';
import { formatAssetPath } from '../../utils/formatPath';
import { Stepper } from './Stepper';

const SpacedContainer = styled('div')(({ theme }) => ({
padding: theme.spacing(5, 8, 8, 8),
padding: theme.spacing(5, 8, 2, 8),
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(3),
Expand All @@ -37,6 +38,7 @@ const StyledCodeBlock = styled('pre')(({ theme }) => ({
wordBreak: 'break-all',
whiteSpace: 'pre-wrap',
position: 'relative',
maxHeight: theme.spacing(34),
}));

const CopyToClipboard = styled(Tooltip)(({ theme }) => ({
Expand Down Expand Up @@ -114,7 +116,8 @@ export const TestSdkConnection: FC<ITestSdkConnectionProps> = ({
return (
<SpacedContainer>
<Typography variant='h2'>Connect an SDK to Unleash</Typography>
<Box sx={{ mt: 4 }}>
<Stepper active={2} steps={3} />
<Box sx={{ mt: 2 }}>
<ChangeSdk>
{sdkIcon ? (
<Avatar
Expand Down

0 comments on commit 2daa0cd

Please sign in to comment.