((props, ref) => {
const {
id,
- size,
children,
view = 'idle',
disabled = false,
- selected = false,
className,
- onUpdate,
icon: customIcon,
+ ...restButtonProps
} = props;
+ const {onUpdate, value, size} = useStepperContext();
+
const onClick = (e: React.MouseEvent) => {
props.onClick?.(e);
@@ -66,10 +62,12 @@ export const StepperItem = (props: ComponentProps) => {
}
}, [view, customIcon]);
- const selectedItem = id === selected;
+ const selectedItem = id === undefined ? false : id === value;
return (
);
-};
+});
+
+StepperItem.displayName = 'StepperItem';
diff --git a/src/components/Stepper/StepperSeparator.tsx b/src/components/Stepper/StepperSeparator.tsx
index ac54ff1ed..01c966615 100644
--- a/src/components/Stepper/StepperSeparator.tsx
+++ b/src/components/Stepper/StepperSeparator.tsx
@@ -1,19 +1,19 @@
-import {ChevronRight} from '@gravity-ui/icons';
+import {ChevronLeft, ChevronRight} from '@gravity-ui/icons';
import {Icon} from '../Icon';
+import {useDirection} from '../theme';
import {b} from './utils';
-import './Stepper.scss';
-
type StepperSeparatorProps = {
separator?: React.ReactNode;
};
export const StepperSeparator = ({separator}: StepperSeparatorProps) => {
+ const direction = useDirection();
return (
- {separator ?? }
+ {separator ?? }
);
};
diff --git a/src/components/Stepper/__stories__/Docs.mdx b/src/components/Stepper/__stories__/Docs.mdx
index 6c6e1a242..ed08c8aef 100644
--- a/src/components/Stepper/__stories__/Docs.mdx
+++ b/src/components/Stepper/__stories__/Docs.mdx
@@ -17,6 +17,9 @@ export const StepperCustomSeparator = () => (
);
export const StepperDisabled = () => ;
+export const StepperWithFloatingElements = () => (
+
+);
export const StepperInteractiveShowcase = () => (
);
@@ -36,6 +39,7 @@ export const StepperInteractiveShowcase = () => (
StepperCustomSeparator,
StepperDisabled,
StepperInteractiveShowcase,
+ StepperWithFloatingElements,
},
}}
>
diff --git a/src/components/Stepper/__stories__/Stepper.stories.tsx b/src/components/Stepper/__stories__/Stepper.stories.tsx
index 83e641883..1d5773e14 100644
--- a/src/components/Stepper/__stories__/Stepper.stories.tsx
+++ b/src/components/Stepper/__stories__/Stepper.stories.tsx
@@ -2,10 +2,10 @@ import {Cloud, CreditCard, Rocket} from '@gravity-ui/icons';
import type {Meta, StoryObj} from '@storybook/react';
import {Text} from '../../Text';
-import {Flex} from '../../layout';
+import {Tooltip} from '../../Tooltip';
import {Stepper} from '../Stepper';
-import {StepperShowcase} from './StepperShowcase';
+import {StepperInteractiveShowcase, StepperSizeShowcase} from './StepperShowcase';
export default {
title: 'Components/Navigation/Stepper',
@@ -59,28 +59,8 @@ export const View = {
} satisfies Story;
export const Size = {
- render: (args) => {
- return (
-
-
- Step 1
- Step 2
- Step 3
-
-
-
- Step 1
- Step 2
- Step 3
-
-
-
- Step 1
- Step 2
- Step 3
-
-
- );
+ render: () => {
+ return ;
},
} satisfies Story;
@@ -133,6 +113,21 @@ export const CustomSeparator = {
export const InteractiveShowcase = {
render: (args) => {
- return ;
+ return ;
+ },
+} satisfies Story;
+
+export const WithFloatingElements = {
+ render: (args) => {
+ return (
+ }>
+
+ Step 1
+
+ Step 2
+ Step 3
+ Step 4 with very long title
+
+ );
},
} satisfies Story;
diff --git a/src/components/Stepper/__stories__/StepperShowcase.tsx b/src/components/Stepper/__stories__/StepperShowcase.tsx
index 8353ae126..bd8d8bdbb 100644
--- a/src/components/Stepper/__stories__/StepperShowcase.tsx
+++ b/src/components/Stepper/__stories__/StepperShowcase.tsx
@@ -1,9 +1,10 @@
import * as React from 'react';
-import Stepper from '../Stepper';
+import {Flex} from '../../layout/Flex/Flex';
+import {Stepper} from '../Stepper';
import type {StepperProps} from '../Stepper';
-export const StepperShowcase = (props: StepperProps) => {
+export const StepperInteractiveShowcase = (props: StepperProps) => {
const [value, setValue] = React.useState(0);
return (
@@ -15,3 +16,27 @@ export const StepperShowcase = (props: StepperProps) => {
);
};
+
+export const StepperSizeShowcase = () => {
+ return (
+
+
+ Step 1
+ Step 2
+ Step 3
+
+
+
+ Step 1
+ Step 2
+ Step 3
+
+
+
+ Step 1
+ Step 2
+ Step 3
+
+
+ );
+};
diff --git a/src/components/Stepper/context.ts b/src/components/Stepper/context.ts
new file mode 100644
index 000000000..7d1f54807
--- /dev/null
+++ b/src/components/Stepper/context.ts
@@ -0,0 +1,17 @@
+import * as React from 'react';
+
+import type {StepperProps} from './Stepper';
+
+export type StepperContextProps = Pick;
+
+export const StepperContext = React.createContext({
+ size: 'm',
+ onUpdate: undefined,
+ value: undefined,
+});
+
+export const useStepperContext = () => {
+ const data = React.useContext(StepperContext);
+
+ return data;
+};