Skip to content

Commit

Permalink
feat(Wizard): add isCompleted to WizardStep
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframev committed Aug 13, 2023
1 parent fb2c88a commit aff00ae
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 36 deletions.
20 changes: 0 additions & 20 deletions packages/orbit-components/src/Wizard/CheckCircle.tsx

This file was deleted.

9 changes: 5 additions & 4 deletions packages/orbit-components/src/Wizard/README.md
Expand Up @@ -36,7 +36,8 @@ Then use `Wizard` as the container for multiple `WizardStep`s:

## WizardStep props

| Name | Type | Default | Description |
| :-------- | :------------------------------ | :------ | :---------------------------------- |
| `title` | `string` | | Name of the step. |
| `onClick` | `event => void \| Promise<any>` | | Function which handles click event. |
| Name | Type | Default | Description |
| :------------ | :------------------------------ | :------ | :---------------------------------- |
| `title` | `string` | | Name of the step. |
| `onClick` | `event => void \| Promise<any>` | | Function which handles click event. |
| `isCompleted` | `boolean` | | Marks current step as completed. |
9 changes: 5 additions & 4 deletions packages/orbit-components/src/Wizard/Wizard.stories.tsx
Expand Up @@ -20,16 +20,17 @@ export const Default = () => {
<Wizard
id="wizard"
direction={direction}
completedSteps={3}
activeStep={3}
completedSteps={2}
activeStep={1}
labelClose={labelClose}
labelProgress={`3 ${labelProgress} 3`}
labelProgress={`2 ${labelProgress} 6`}
onChangeStep={action("onChangeStep")}
>
<WizardStep title="Search" />
<WizardStep title="Passenger details" />
<WizardStep title="Ticket fare" />
<WizardStep title="Customize your trip" />
<WizardStep title="Kiwi.com guarantee" isCompleted />
<WizardStep title="Seating" />
<WizardStep title="Overview & Payment" />
</Wizard>
);
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Wizard/WizardStep.js.flow
Expand Up @@ -8,6 +8,7 @@ export type Props = {|
...Globals,
+title: Translation,
+onClick?: (SyntheticEvent<HTMLElement>) => void | Promise<any>,
+isCompleted?: boolean,
|};

declare export var StyledStepIconContainer: StyledComponent<any, any, HTMLElement>;
Expand Down
4 changes: 2 additions & 2 deletions packages/orbit-components/src/Wizard/WizardStep.tsx
Expand Up @@ -139,7 +139,7 @@ StyledButtonWrapper.defaultProps = {
theme: defaultTheme,
};

const WizardStep = ({ dataTest, title, onClick }: WizardStepProps) => {
const WizardStep = ({ dataTest, title, onClick, isCompleted }: WizardStepProps) => {
const theme = useTheme();
const {
index,
Expand Down Expand Up @@ -192,7 +192,7 @@ const WizardStep = ({ dataTest, title, onClick }: WizardStepProps) => {
spacing="XSmall"
spaceAfter={isColumnOnDesktop ? "large" : "none"}
>
<WizardStepIcon />
<WizardStepIcon isCompleted={isCompleted} />
<div
css={css`
padding: ${theme.orbit.paddingBadge};
Expand Down
15 changes: 9 additions & 6 deletions packages/orbit-components/src/Wizard/WizardStepIcon.tsx
Expand Up @@ -3,7 +3,7 @@ import styled, { css } from "styled-components";
import { convertHexToRgba } from "@kiwicom/orbit-design-tokens";

import Text from "../Text";
import CheckCircle from "./CheckCircle";
import Check from "../icons/Check";
import useTheme from "../hooks/useTheme";
import defaultTheme from "../defaultTheme";
import { WizardStepContext } from "./WizardContext";
Expand Down Expand Up @@ -33,17 +33,20 @@ StyledStepIconContainer.defaultProps = {
theme: defaultTheme,
};

const WizardStepIcon = () => {
const WizardStepIcon = ({ isCompleted }: { isCompleted?: boolean }) => {
const { index, status, isCompact, isActive } = React.useContext(WizardStepContext);
const theme = useTheme();

return (
<StyledStepIconContainer $disabled={status === "disabled"} $glow={isActive && !isCompact}>
{status === "completed" ? (
<CheckCircle
ariaLabel="completed"
{isCompleted || status === "completed" ? (
<Check
size="small"
customColor={theme.orbit.paletteProductNormal}
customColor={
isCompleted && status !== "completed" && status !== "available"
? theme.orbit.paletteInkDark
: theme.orbit.paletteWhiteNormal
}
/>
) : (
<Text
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Wizard/types.d.ts
Expand Up @@ -16,5 +16,6 @@ export interface Props extends Common.Globals {

export interface WizardStepProps extends Common.Globals {
readonly title: string;
readonly isCompleted?: boolean;
readonly onClick?: Common.Event<React.SyntheticEvent<HTMLElement>>;
}

0 comments on commit aff00ae

Please sign in to comment.