diff --git a/src/components/Dialog/ActionDialog/ActionDialogContentInner.tsx b/src/components/Dialog/ActionDialog/ActionDialogContentInner.tsx index 61e2f6e64f..85c1e2d8cd 100644 --- a/src/components/Dialog/ActionDialog/ActionDialogContentInner.tsx +++ b/src/components/Dialog/ActionDialog/ActionDialogContentInner.tsx @@ -2,7 +2,7 @@ import React, { FC, ReactNode, useCallback } from 'react' import styled, { css } from 'styled-components' import { Theme, useTheme } from '../../../hooks/useTheme' -import { DecoratorsType } from '../../../types/props' +import { DecoratorsType, ResponseMessageType } from '../../../types/props' import { Button } from '../../Button' import { HeadingTagTypes } from '../../Heading' import { FaCheckCircleIcon, FaExclamationCircleIcon } from '../../Icon' @@ -57,18 +57,9 @@ export type BaseProps = { decorators?: DecoratorsType<'closeButtonLabel'> } -type responseMessageType = - | { - status: 'success' | 'error' - text: ReactNode - } - | { - status: 'processing' - } - export type ActionDialogContentInnerProps = BaseProps & { onClickClose: () => void - responseMessage?: responseMessageType + responseMessage?: ResponseMessageType titleId: string } diff --git a/src/components/Dropdown/FilterDropdown/FilterDropdown.stories.tsx b/src/components/Dropdown/FilterDropdown/FilterDropdown.stories.tsx index d69bea0c58..1955638abd 100644 --- a/src/components/Dropdown/FilterDropdown/FilterDropdown.stories.tsx +++ b/src/components/Dropdown/FilterDropdown/FilterDropdown.stories.tsx @@ -1,11 +1,12 @@ import { action } from '@storybook/addon-actions' import { Meta, StoryObj } from '@storybook/react' -import React, { ReactNode, useCallback, useState } from 'react' +import React, { ComponentProps, ReactNode, useCallback, useState } from 'react' import styled from 'styled-components' +import { Button } from '../../Button' import { MultiComboBox, SingleComboBox } from '../../ComboBox' import { Input } from '../../Input' -import { Stack } from '../../Layout' +import { Cluster, Stack } from '../../Layout' import { RadioButton } from '../../RadioButton' import { FilterDropdown } from './FilterDropdown' @@ -30,6 +31,8 @@ const Render: React.FC = () => { const [isFiltered2, setIsFiltered2] = React.useState(true) const [isFiltered3, setIsFiltered3] = React.useState(true) const [isFiltered4, setIsFiltered4] = React.useState(true) + const [responseMessage, setResponseMessage] = + useState['responseMessage']>() return ( @@ -138,6 +141,45 @@ const Render: React.FC = () => {

+
Has response message
+
+ setIsFiltered4(true)} + onReset={() => setIsFiltered4(false)} + responseMessage={responseMessage} + > + +

+ You can change border text and color of the trigger button by setting `isFiltered`. +

+

切り替えボタン:

+ + + + + +
+
+
) diff --git a/src/components/Dropdown/FilterDropdown/FilterDropdown.tsx b/src/components/Dropdown/FilterDropdown/FilterDropdown.tsx index b83720a071..5346027544 100644 --- a/src/components/Dropdown/FilterDropdown/FilterDropdown.tsx +++ b/src/components/Dropdown/FilterDropdown/FilterDropdown.tsx @@ -3,10 +3,10 @@ import innerText from 'react-innertext' import styled, { css } from 'styled-components' import { Theme, useTheme } from '../../../hooks/useTheme' -import { DecoratorType, DecoratorsType } from '../../../types/props' +import { DecoratorType, DecoratorsType, ResponseMessageType } from '../../../types/props' import { Button } from '../../Button' -import { FaCheckCircleIcon, FaFilterIcon, FaUndoAltIcon } from '../../Icon' -import { Cluster } from '../../Layout' +import { FaCheckCircleIcon, FaExclamationCircleIcon, FaFilterIcon, FaUndoAltIcon } from '../../Icon' +import { Cluster, Stack } from '../../Layout' import { Dropdown } from '../Dropdown' import { DropdownCloser } from '../DropdownCloser' import { DropdownContent } from '../DropdownContent' @@ -23,6 +23,7 @@ type Props = { decorators?: DecoratorsType< 'status' | 'triggerButton' | 'applyButton' | 'cancelButton' | 'resetButton' > + responseMessage?: ResponseMessageType } type ElementProps = Omit, keyof Props> @@ -43,6 +44,7 @@ export const FilterDropdown: FC = ({ children, hasStatusText, decorators, + responseMessage, ...props }: Props) => { const themes = useTheme() @@ -70,6 +72,8 @@ export const FilterDropdown: FC = ({ () => (hasStatusText ? undefined : innerText(status)), [status, hasStatusText], ) + const isRequestProcessing = + responseMessage !== undefined && responseMessage.status === 'processing' return ( @@ -93,25 +97,54 @@ export const FilterDropdown: FC = ({ {children} - - {onReset && ( - - - + + + {onReset && ( + + + + )} + + + + + + + + + + + {responseMessage?.status === 'success' && ( + + + + )} + {responseMessage?.status === 'error' && ( + + + )} - - - - - - - - - + ) @@ -139,10 +172,8 @@ const ContentLayout = styled.div<{ themes: Theme }>` padding: ${space(1.5)}; `} ` -const BottomLayout = styled(Cluster).attrs({ gap: 1, align: 'center', justify: 'space-between' })<{ - themes: Theme -}>` - ${({ themes: { border, space } }) => css` +const ActionArea = styled(Stack).attrs({ gap: 0.5 })<{ themes: Theme }>` + ${({ themes: { space, border } }) => css` border-block-start: ${border.shorthand}; padding: ${space(1)} ${space(1.5)}; `} @@ -158,3 +189,6 @@ const RightButtonLayout = styled(Cluster).attrs({ })` margin-inline-start: auto; ` +const Message = styled.div` + text-align: right; +` diff --git a/src/types/props.ts b/src/types/props.ts index 1988e3b4eb..cbafb2a54e 100644 --- a/src/types/props.ts +++ b/src/types/props.ts @@ -23,3 +23,12 @@ export type DecoratorsType = { } export type DecoratorType = (text: string) => ReactNode + +export type ResponseMessageType = + | { + status: 'success' | 'error' + text: ReactNode + } + | { + status: 'processing' + }