diff --git a/src/components/ButtonAction.stories.tsx b/src/components/ButtonAction.stories.tsx index d4813a39..bf0bd7bc 100644 --- a/src/components/ButtonAction.stories.tsx +++ b/src/components/ButtonAction.stories.tsx @@ -11,58 +11,51 @@ const meta: Meta = { export default meta; type Story = StoryObj; -export const Default: Story = { +export const IconOnly: Story = { args: { children: '', icon: 'starhollow', isActive: false, - isLoading: false, }, }; -export const WithLabel: Story = { +export const IconOnlyActive: Story = { args: { - children: 'Hello World', + children: '', icon: 'starhollow', - isActive: false, - isLoading: false, + isActive: true, }, }; -export const WithTooltip: Story = { +export const WithLabel: Story = { args: { children: 'Hello World', icon: 'starhollow', isActive: false, - isLoading: false, - tooltip: "I'm a tooltip", }, }; -export const Active: Story = { +export const WithLabelActive: Story = { args: { children: 'Hello World', icon: 'starhollow', isActive: true, - isLoading: false, }, }; -export const Loading: Story = { +export const IconOnlyWithTooltip: Story = { args: { - children: 'Hello World', icon: 'starhollow', isActive: false, - isLoading: true, + tooltip: "I'm a tooltip", }, }; -export const LoadingWithText: Story = { +export const WithLabelWithTooltip: Story = { args: { children: 'Hello World', icon: 'starhollow', isActive: false, - isLoading: true, - loadingText: 'Loading', + tooltip: "I'm a tooltip", }, }; diff --git a/src/components/ButtonAction.tsx b/src/components/ButtonAction.tsx index 972d2f87..248d698a 100644 --- a/src/components/ButtonAction.tsx +++ b/src/components/ButtonAction.tsx @@ -1,24 +1,20 @@ -import React, { ComponentProps, ReactNode } from 'react'; +import React from 'react'; import { styled } from '@storybook/theming'; import { transparentize } from 'polished'; import { typography, color } from './shared/styles'; import { Icon, IconType } from './Icon'; -import { Spinner } from './Spinner'; import { TooltipNote } from './tooltip/TooltipNote'; import WithTooltip from './tooltip/WithTooltip'; interface ButtonActionProps { icon: IconType; - children?: ReactNode; + children?: string; isActive?: boolean; - isLoading?: boolean; - loadingText?: string | null; tooltip?: string; } interface ButtonStylingProps { isActive?: boolean; - isLoading?: boolean; } const StyledButton = styled.button` @@ -46,15 +42,15 @@ const StyledButton = styled.button` color: ${color.mediumdark}; ${(props) => - (props.isActive || props.isLoading) && + props.isActive && ` - background-color: ${transparentize(0.7, color.secondary)}; + background-color: ${transparentize(0.93, color.secondary)}; color: ${color.secondary}; `} &:hover { color: ${color.secondary}; - background-color: ${transparentize(0.54, color.secondary)}; + background-color: ${transparentize(0.86, color.secondary)}; } `; @@ -62,55 +58,27 @@ export const ButtonAction = ({ children, icon, isActive = false, - isLoading = false, - loadingText = null, tooltip, ...rest -}: ButtonActionProps & ComponentProps) => { +}: ButtonActionProps) => { if (tooltip) return ( - } hasChrome={false} tagName="span"> - + } + hasChrome={false} + delayShow={600} + {...rest} + > + + {icon && } {children} - + ); return ( - + + {icon && } {children} - + ); }; - -const InsideButtonAction = ({ - children, - icon, - isActive = false, - isLoading = false, - loadingText = null, - tooltip, - ...rest -}: ButtonActionProps & ComponentProps) => ( - - {icon && !isLoading && } - {isLoading && ( -
- -
- )} - {children && !isLoading && children} - {isLoading && loadingText} -
-); diff --git a/src/components/tooltip/WithTooltip.tsx b/src/components/tooltip/WithTooltip.tsx index 80649164..8c3964ca 100644 --- a/src/components/tooltip/WithTooltip.tsx +++ b/src/components/tooltip/WithTooltip.tsx @@ -89,6 +89,7 @@ interface WithTooltipProps { children: ReactNode; startOpen?: boolean; delayHide?: number; + delayShow?: number; // eslint-disable-next-line @typescript-eslint/ban-types onVisibilityChange?: Function; portalContainer?: ComponentProps['portalContainer']; @@ -99,6 +100,7 @@ const WithTooltip = ({ children, closeOnClick = false, delayHide = 100, + delayShow = 0, hasChrome = true, modifiers = {}, onVisibilityChange = () => {}, @@ -139,6 +141,7 @@ const WithTooltip = ({ return (