diff --git a/packages/components/src/components/form/SelectBar/SelectBar.stories.tsx b/packages/components/src/components/form/SelectBar/SelectBar.stories.tsx index 8b1418a1dd6..12f143f337e 100644 --- a/packages/components/src/components/form/SelectBar/SelectBar.stories.tsx +++ b/packages/components/src/components/form/SelectBar/SelectBar.stories.tsx @@ -1,13 +1,14 @@ import { useArgs } from '@storybook/client-api'; import { Meta, StoryObj } from '@storybook/react'; -import { SelectBar as SelectBarComponent, SelectBarProps } from './SelectBar'; +import { fillTypes, SelectBar as SelectBarComponent, SelectBarProps } from './SelectBar'; +import { IconName } from '../../Icon/Icon'; const options = [ { label: 'low', value: 'low' }, { label: 'medium', value: 'medium' }, { label: 'high', value: 'high' }, - { label: 'custom', value: 'custom' }, + { label: 'custom', value: 'custom', icon: 'clock' as IconName }, ]; const meta: Meta = { @@ -18,6 +19,7 @@ const meta: Meta = { selectedOption: 'low', isDisabled: false, isFullWidth: undefined, + fillType: 'default', }, argTypes: { label: { @@ -50,6 +52,12 @@ const meta: Meta = { type: 'boolean', }, }, + fillType: { + control: { + type: 'radio', + }, + options: fillTypes, + }, }, component: SelectBarComponent, } as unknown as Meta; diff --git a/packages/components/src/components/form/SelectBar/SelectBar.tsx b/packages/components/src/components/form/SelectBar/SelectBar.tsx index e173d3079ce..6fbdaa02cde 100644 --- a/packages/components/src/components/form/SelectBar/SelectBar.tsx +++ b/packages/components/src/components/form/SelectBar/SelectBar.tsx @@ -22,10 +22,15 @@ import { withFrameProps, } from '../../../utils/frameProps'; import { TransientProps } from '../../../utils/transientProps'; +import { Icon, IconName } from '../../Icon/Icon'; +import { Row } from '../../Flex/Flex'; export const allowedSelectBarFrameProps = ['margin', 'width'] as const satisfies FramePropsKeys[]; type AllowedFrameProps = Pick; +export const fillTypes = ['none', 'default'] as const; +export type FillType = (typeof fillTypes)[number]; + const Wrapper = styled.div & { $isFullWidth?: boolean }>` display: flex; align-items: center; @@ -63,6 +68,7 @@ const Options = styled.div<{ $optionsCount: number; $isFullWidth?: boolean; $elevation: Elevation; + $fillType: FillType; }>` position: relative; display: grid; @@ -70,7 +76,8 @@ const Options = styled.div<{ grid-auto-flow: column; gap: ${spacingsPx.xxs}; padding: ${spacingsPx.xxs}; - background: ${mapElevationToBackground}; + background: ${({ $fillType, theme, $elevation }) => + $fillType === 'default' ? mapElevationToBackground({ theme, $elevation }) : undefined}; border-radius: ${borders.radii.full}; width: ${({ $isFullWidth }) => ($isFullWidth ? '100%' : 'auto')}; @@ -156,6 +163,7 @@ type ValueTypes = number | string | boolean; type Option = { label: ReactNode; value: V; + icon?: IconName; }; export type SelectBarProps = { @@ -167,6 +175,7 @@ export type SelectBarProps = { isFullWidth?: boolean; className?: string; 'data-testid'?: string; + fillType?: FillType; } & AllowedFrameProps; // Generic type V is determined by selectedOption/options values @@ -178,6 +187,7 @@ export const SelectBar = ({ isDisabled = false, isFullWidth, className, + fillType = 'default', 'data-testid': dataTest, ...rest }: SelectBarProps) => { @@ -247,6 +257,7 @@ export const SelectBar = ({ $optionsCount={options.length} $isFullWidth={isFullWidth} $elevation={elevation} + $fillType={fillType} > ({ onKeyDown={handleKeyboardNav} /> - {options.map(option => ( - - ))} + ); + + return ( + + ); + })} ); diff --git a/packages/suite/src/views/wallet/coinmarket/common/CoinmarketLayout/CoinmarketLayoutNavigation/CoinmarketLayoutNavigation.tsx b/packages/suite/src/views/wallet/coinmarket/common/CoinmarketLayout/CoinmarketLayoutNavigation/CoinmarketLayoutNavigation.tsx index 19f052f47fd..c6779ac0245 100644 --- a/packages/suite/src/views/wallet/coinmarket/common/CoinmarketLayout/CoinmarketLayoutNavigation/CoinmarketLayoutNavigation.tsx +++ b/packages/suite/src/views/wallet/coinmarket/common/CoinmarketLayout/CoinmarketLayoutNavigation/CoinmarketLayoutNavigation.tsx @@ -1,23 +1,34 @@ -import { Row } from '@trezor/components'; +import { IconName, SelectBar } from '@trezor/components'; +import { Route } from '@suite-common/suite-types'; -import { CoinmarketLayoutNavigationItem } from 'src/views/wallet/coinmarket/common/CoinmarketLayout/CoinmarketLayoutNavigation/CoinmarketLayoutNavigationItem'; +import { Translation } from '../../../../../../components/suite'; +import { goto } from '../../../../../../actions/suite/routerActions'; +import { useDispatch, useSelector } from '../../../../../../hooks/suite'; -export const CoinmarketLayoutNavigation = () => ( - - - - - -); +const options = [ + { + label: , + value: 'wallet-coinmarket-buy' as Route['name'], + icon: 'plus' as IconName, + }, + { + label: , + value: 'wallet-coinmarket-sell' as Route['name'], + icon: 'minus' as IconName, + }, + { + label: , + value: 'wallet-coinmarket-dca' as Route['name'], + icon: 'clock' as IconName, + }, +]; + +export const CoinmarketLayoutNavigation = () => { + const dispatch = useDispatch(); + const routeName = useSelector(state => state.router.route?.name); + const onChange = (newRoute: Route['name']) => { + dispatch(goto(newRoute)); + }; + + return ; +};