diff --git a/site/source/design-system/icons/index.stories.tsx b/site/source/design-system/icons/index.stories.tsx index ac6687e3a..0ef8d8a59 100644 --- a/site/source/design-system/icons/index.stories.tsx +++ b/site/source/design-system/icons/index.stories.tsx @@ -1,6 +1,7 @@ -import { Meta } from '@storybook/react' +import { Meta, StoryObj } from '@storybook/react' +import { ComponentProps, useState } from 'react' -import { SvgIcon } from '.' +import { RotatingChevronIcon, SvgIcon } from '.' const meta: Meta = { component: SvgIcon, @@ -32,3 +33,25 @@ export { TriangleIcon, WarningIcon, } from '@/design-system/icons' + +const RotatingChevronExample = ( + args: ComponentProps +) => { + const [isOpen, setIsOpen] = useState(false) + + return ( + <> + + {isOpen &&
Visible si ouvert
} + + ) +} + +type Story = StoryObj + +export const Chevron: Story = { + render: (args) => , +} diff --git a/site/source/design-system/icons/index.tsx b/site/source/design-system/icons/index.tsx index f7665d86b..32a09159c 100644 --- a/site/source/design-system/icons/index.tsx +++ b/site/source/design-system/icons/index.tsx @@ -1,5 +1,5 @@ import { HTMLAttributes } from 'react' -import { styled } from 'styled-components' +import { css, styled } from 'styled-components' export const SvgIcon = styled.svg` /* width: ${({ theme }) => theme.spacings.lg}; @@ -27,6 +27,17 @@ export const ChevronIcon = (props: HTMLAttributes) => ( ) +export const RotatingChevronIcon = styled(ChevronIcon)<{ $isOpen: boolean }>` + vertical-align: middle; + transform: rotate(-90deg); + transition: transform 0.3s; + ${({ $isOpen }) => + !$isOpen && + css` + transform: rotate(90deg); + `} +` + export const InfoIcon = (props: HTMLAttributes) => ( ` - vertical-align: middle; - transform: rotate(-90deg); - transition: transform 0.3s; - ${({ $isOpen }) => - !$isOpen && - css` - transform: rotate(90deg); - `} +const StyledChevron = styled(RotatingChevronIcon)` ${({ theme }) => theme.darkMode && css` diff --git a/site/source/pages/simulateurs/reduction-generale/components/RéductionGénéraleMoisParMoisRow.tsx b/site/source/pages/simulateurs/reduction-generale/components/RéductionGénéraleMoisParMoisRow.tsx index c26d84802..58ee80db5 100644 --- a/site/source/pages/simulateurs/reduction-generale/components/RéductionGénéraleMoisParMoisRow.tsx +++ b/site/source/pages/simulateurs/reduction-generale/components/RéductionGénéraleMoisParMoisRow.tsx @@ -1,7 +1,7 @@ import { formatValue, PublicodesExpression } from 'publicodes' import { useState } from 'react' import { Trans, useTranslation } from 'react-i18next' -import { css, styled } from 'styled-components' +import { styled } from 'styled-components' import NumberInput from '@/components/conversation/NumberInput' import { Condition } from '@/components/EngineValue/Condition' @@ -10,7 +10,11 @@ import { useEngine } from '@/components/utils/EngineContext' import { Message, NumberField } from '@/design-system' import { Button, HelpButtonWithPopover } from '@/design-system/buttons' import { FlexCenter } from '@/design-system/global-style' -import { ChevronIcon, SearchIcon, WarningIcon } from '@/design-system/icons' +import { + RotatingChevronIcon, + SearchIcon, + WarningIcon, +} from '@/design-system/icons' import { Tooltip } from '@/design-system/tooltip' import { Body, SmallBody } from '@/design-system/typography/paragraphs' @@ -128,7 +132,7 @@ export default function RéductionGénéraleMoisParMoisRow({ aria-label={!isOptionVisible ? t('Déplier') : t('Replier')} > {t('Options')}  - + ` - vertical-align: middle; - transform: rotate(-90deg); - transition: transform 0.3s; - ${({ $isOpen }) => - !$isOpen && - css` - transform: rotate(90deg); - `} -`