Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Onboarding UI updates #2931

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/components/common/Onboarding/Wizard/DesktopWizardSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react';

import Heading3 from '~shared/Heading/Heading3.tsx';
import Sidebar from '~v5/shared/Navigation/Sidebar/Sidebar.tsx';

import { type WizardProps } from './types.ts';
import WizardSidebarItem from './WizardSidebarItem.tsx';

const displayName = 'common.Onboarding.Wizard.DesktopWizardSidebar';

const DesktopWizardSidebar = ({
currentStep,
wizardSteps,
sidebarTitle,
sidebarTitleValues,
enableMobileAndDesktopLayoutBreakpoints,
}: WizardProps) => (
<Sidebar
className="!w-[280px] sm:!flex"
colonySwitcherProps={{
isLogoButton: true,
offset: [-20, 226],
enableMobileAndDesktopLayoutBreakpoints,
}}
>
<div className="px-3 pt-10">
<Heading3
appearance={{ theme: 'dark' }}
className="mb-6 text-xl font-semibold text-base-white"
text={sidebarTitle}
textValues={sidebarTitleValues}
/>
<div className="flex flex-1 flex-col content-between">
<div className="relative flex flex-1 gap-4">
<div className="-mt-1 flex flex-col gap-4">
{wizardSteps.map((step, index) => {
// To work out the current step we add all the previous
// subitems to the index (the current step count) minus one
// in order to account the for the containing index of the subitems
const previousStepSubItemsLength =
wizardSteps[index - 1]?.subItems?.length || 0;

const previousStepsCount = previousStepSubItemsLength
? previousStepSubItemsLength - 1
: 0;

const id = index + previousStepsCount;

return (
<WizardSidebarItem
text={step.text}
subItems={step.subItems}
currentStep={currentStep}
key={`step-${step.text?.id}`}
id={id}
isLastItem={index + 1 === wizardSteps.length}
/>
);
})}
</div>
</div>
</div>
</div>
</Sidebar>
);

DesktopWizardSidebar.displayName = displayName;

export default DesktopWizardSidebar;
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ import { FormattedMessage } from 'react-intl';
import Stepper from '~v5/shared/Stepper/Stepper.tsx';
import { type StepperItem } from '~v5/shared/Stepper/types.ts';

import { type WizardSidebarStep } from './WizardSidebar.tsx';
import { type WizardProps } from './types.ts';

const displayName = 'routes.WizardRoute.WizardSidebar.MobileWizardSidebar';
const displayName = 'common.Onboarding.WizardSidebar.MobileWizardHeader';

interface Props {
currentStep: number;
wizardSteps: WizardSidebarStep[];
}

const MobileWizardSidebar = ({ currentStep, wizardSteps }: Props) => {
const MobileWizardHeader = ({ currentStep, wizardSteps }: WizardProps) => {
const steps: StepperItem<number>[] = [];
let stepsCount = 0;

Expand Down Expand Up @@ -62,6 +57,6 @@ const MobileWizardSidebar = ({ currentStep, wizardSteps }: Props) => {
);
};

MobileWizardSidebar.displayName = displayName;
MobileWizardHeader.displayName = displayName;

export default MobileWizardSidebar;
export default MobileWizardHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import clsx from 'clsx';
import React from 'react';
import { FormattedMessage } from 'react-intl';

import { type WizardSidebarStep } from './WizardSidebar.tsx';
import { type WizardStep } from './types.ts';
import WizardSidebarItemFlowLine from './WizardSidebarItemFlowLine.tsx';
import WizardSidebarSubItem from './WizardSidebarSubItem.tsx';

const displayName = 'routes.WizardRoute.WizardSidebar.WizardSidebarItem';

interface Props extends WizardSidebarStep {
interface Props extends WizardStep {
currentStep: number;
isLastItem: boolean;
}
Expand Down Expand Up @@ -40,19 +40,13 @@ const WizardSidebarItem = ({
<div className="relative flex items-center">
<div
className={clsx('h-2.5 w-2.5 rounded-full', {
'bg-gray-900': currentStep >= stepId && hasSubItems,
'border border-gray-900': currentStep < stepId,
'bg-blue-400': !hasSubItems && currentStep === stepId,
'bg-base-white':
(currentStep >= stepId && hasSubItems) ||
(!hasSubItems && currentStep === stepId),
'border border-base-white': currentStep < stepId,
})}
/>
<span
className={clsx(
'ml-4 text-sm font-semibold',
currentStep === stepId && !hasSubItems
? 'text-blue-400'
: 'text-gray-900',
)}
>
<span className="ml-4 text-sm font-semibold text-base-white">
<FormattedMessage {...stepText} />
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const WizardSidebarItemFlowLine = ({
return (
<div className="absolute top-[13px] flex h-[calc(100%+8px)] w-2.5 flex-col items-center gap-2.5">
<div
className={clsx('h-full w-px bg-gray-900', {
className={clsx('h-full w-px bg-base-white', {
'h-6': currentStep < stepId || currentStep > lastSubid,
})}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ import React from 'react';
import { FormattedMessage } from 'react-intl';
import { type Optional } from 'utility-types';

import { type WizardSidebarStep } from './WizardSidebar.tsx';
import { type WizardStep } from './types.ts';

const displayName =
'routes.WizardRoute.WizardSidebar.WizardSidebarItem.WizardSidebarSubItem';

export type WizardSidebarSubStep = Optional<
WizardSidebarStep,
'subItems' | 'text'
>;
export type WizardSidebarSubStep = Optional<WizardStep, 'subItems' | 'text'>;

interface Props extends Pick<WizardSidebarSubStep, 'text'> {
isActive: boolean;
}

const WizardSidebarSubItem = ({ text: stepText, isActive }: Props) => (
<span
className={clsx('ml-[26px] text-xs', {
'font-semibold text-blue-400': isActive,
className={clsx('ml-[26px] text-xs text-base-white', {
'font-semibold underline': isActive,
})}
>
<FormattedMessage {...stepText} />
Expand Down
19 changes: 19 additions & 0 deletions src/components/common/Onboarding/Wizard/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { type MessageDescriptor } from 'react-intl';

import { type UniversalMessageValues } from '~types';

import { type WizardSidebarSubStep } from './WizardSidebarSubItem.tsx';

export interface WizardStep {
id: number;
text: MessageDescriptor;
subItems?: WizardSidebarSubStep[];
}

export interface WizardProps {
currentStep: number;
wizardSteps: WizardStep[];
sidebarTitle: MessageDescriptor;
sidebarTitleValues?: UniversalMessageValues;
enableMobileAndDesktopLayoutBreakpoints?: boolean;
}

This file was deleted.

76 changes: 0 additions & 76 deletions src/components/common/Onboarding/WizardSidebar/WizardSidebar.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/common/Onboarding/WizardSidebar/index.ts

This file was deleted.

Loading
Loading