From dbc0bd9b4cc74449c55ae92bb1eb6ae362902f2a Mon Sep 17 00:00:00 2001 From: Klink <85062+dogmar@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:34:46 -0700 Subject: [PATCH] fix: Broken styles on Stepper when importing (#529) --- src/components/Stepper.tsx | 239 +++-------------------- src/components/StepperStep.tsx | 174 +++++++++++++++++ src/components/StepperStepConnection.tsx | 54 +++++ 3 files changed, 254 insertions(+), 213 deletions(-) create mode 100644 src/components/StepperStep.tsx create mode 100644 src/components/StepperStepConnection.tsx diff --git a/src/components/Stepper.tsx b/src/components/Stepper.tsx index 08d352eb..06e1e889 100644 --- a/src/components/Stepper.tsx +++ b/src/components/Stepper.tsx @@ -9,19 +9,18 @@ import { useState, } from 'react' import { mergeRefs } from '@react-aria/utils' -import { useTheme } from 'styled-components' +import styled from 'styled-components' import useResizeObserver from '../hooks/useResizeObserver' -import StatusOkIcon from './icons/StatusOkIcon' import type createIcon from './icons/createIcon' -import Tooltip from './Tooltip' -import WrapWithIf from './WrapWithIf' +import { StepperStepConnection } from './StepperStepConnection' +import { StepperStep } from './StepperStep' -const DEFAULT_CIRCLE_SIZE = 48 -const DEFAULT_ICON_SIZE = 24 -const COMPACT_CIRCLE_SIZE = 32 -const COMPACT_ICON_SIZE = 16 +export const DEFAULT_CIRCLE_SIZE = 48 +export const DEFAULT_ICON_SIZE = 24 +export const COMPACT_CIRCLE_SIZE = 32 +export const COMPACT_ICON_SIZE = 16 type StepBaseProps = { stepTitle?: ReactNode @@ -35,7 +34,7 @@ type StepBaseProps = { canComplete?: boolean } -type StepProps = StepBaseProps & { +export type StepProps = StepBaseProps & { isActive?: boolean isComplete?: boolean circleSize?: number @@ -43,10 +42,11 @@ type StepProps = StepBaseProps & { collapseTitles?: boolean } -type StepConnectionProps = { +export type StepConnectionProps = { isActive: boolean vertical?: boolean compact?: boolean + circleSize?: number } export type StepperSteps = (StepBaseProps & { key: string })[] @@ -60,188 +60,15 @@ type StepperProps = { compact?: boolean } -function Step({ - isActive = false, - isComplete = false, - stepTitle, - IconComponent, - imageUrl = '', - iconSize, - circleSize, - vertical = false, - collapseTitles = false, - compact = false, - canComplete = true, - ...props -}: StepProps) { - const theme = useTheme() - const bounceEase = 'cubic-bezier(.37,1.4,.62,1)' - const shownClassName = 'shown' - const completeIconStyles = { - opacity: '1', - transform: 'scale(0)', - transition: 'all 0.2s ease', - [`&.${shownClassName}`]: { - transform: 'scale(1)', - opacity: '1', - transition: `transform 0.3s ${bounceEase}, opacity 0.1s ease`, - transitionDelay: '0.1s', - }, - } - - circleSize = - circleSize ?? (compact ? COMPACT_CIRCLE_SIZE : DEFAULT_CIRCLE_SIZE) - iconSize = iconSize ?? (compact ? COMPACT_ICON_SIZE : DEFAULT_ICON_SIZE) - - return ( -
- } - > -
-
- {IconComponent && ( - - )} - {imageUrl && ( - - )} -
-
- -
-
-
- {!collapseTitles && ( -
- {stepTitle} -
- )} -
- ) -} - -function StepConnection({ - isActive = false, - vertical = false, - compact = false, - ...props -}: StepConnectionProps) { - const theme = useTheme() - - return ( -