From ce69bc91f0c98d02bb2b14eb315bcca60d6798f3 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jun 2024 12:32:13 -0400 Subject: [PATCH 1/3] spike on allowing text --- .../ActionList.features.stories.tsx | 24 +++++-- packages/react/src/ActionList/Item.tsx | 2 +- .../react/src/ActionList/TrailingAction.tsx | 65 ++++++++++++------- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/packages/react/src/ActionList/ActionList.features.stories.tsx b/packages/react/src/ActionList/ActionList.features.stories.tsx index 55f1e598cd7..2d949e4b18a 100644 --- a/packages/react/src/ActionList/ActionList.features.stories.tsx +++ b/packages/react/src/ActionList/ActionList.features.stories.tsx @@ -744,23 +744,35 @@ export const WithTrailingAction = () => { Item 1 (with default TrailingAction) - + Item 2 (with link TrailingAction) - + Item 3This is an inline description. - + Item 4This is a block description. - + + + + Item 5This is a block description. + + + + Item 6 + + + + Item 7 + LinkItem 1with TrailingAction shown on hover - + LinkItem 2with TrailingVisual @@ -770,7 +782,7 @@ export const WithTrailingAction = () => { Inactive ItemWith TrailingAction - + diff --git a/packages/react/src/ActionList/Item.tsx b/packages/react/src/ActionList/Item.tsx index ab1b5fd273e..07ebb11d96c 100644 --- a/packages/react/src/ActionList/Item.tsx +++ b/packages/react/src/ActionList/Item.tsx @@ -172,7 +172,7 @@ export const Item = React.forwardRef( }, ':hover, :focus, :focus-within': { // Used when `showOnHover` is passed to `TrailingAction` - '[data-component="IconButton"]': { + '[data-component="ActionList.TrailingAction"]': { display: 'flex', }, }, diff --git a/packages/react/src/ActionList/TrailingAction.tsx b/packages/react/src/ActionList/TrailingAction.tsx index cf65118fc7e..eab7357defe 100644 --- a/packages/react/src/ActionList/TrailingAction.tsx +++ b/packages/react/src/ActionList/TrailingAction.tsx @@ -1,42 +1,57 @@ import React, {forwardRef} from 'react' import Box from '../Box' -import {IconButton} from '../Button' +import {Button, IconButton} from '../Button' import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic' export type ActionListTrailingActionProps = { as?: 'button' | 'a' href?: string - icon: React.ElementType - 'aria-label': string + icon?: React.ElementType + label: string showOnHover?: boolean } export const TrailingAction = forwardRef( - ({as, icon, 'aria-label': ariaLabel, showOnHover = false, href = null, ...props}, forwardedRef) => { - return ( - - { + if (!icon) { + return ( + - - ) + > + {/* @ts-expect-error TODO: Fix this */} + + + ) + } else { + return ( + + + + ) + } }, ) as PolymorphicForwardRefComponent<'button' | 'a', ActionListTrailingActionProps> From 9405e71cb9154ad15cedfefdbd87af7255eb5023 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:37:49 -0400 Subject: [PATCH 2/3] showOnHover support --- .../react/src/ActionList/ActionList.features.stories.tsx | 8 ++++---- packages/react/src/ActionList/TrailingAction.tsx | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react/src/ActionList/ActionList.features.stories.tsx b/packages/react/src/ActionList/ActionList.features.stories.tsx index 2d949e4b18a..c9412e0aab1 100644 --- a/packages/react/src/ActionList/ActionList.features.stories.tsx +++ b/packages/react/src/ActionList/ActionList.features.stories.tsx @@ -767,12 +767,12 @@ export const WithTrailingAction = () => { - Item 7 - + Item 7with TrailingAction shown on hover + LinkItem 1with TrailingAction shown on hover - + LinkItem 2with TrailingVisual @@ -782,7 +782,7 @@ export const WithTrailingAction = () => { Inactive ItemWith TrailingAction - + diff --git a/packages/react/src/ActionList/TrailingAction.tsx b/packages/react/src/ActionList/TrailingAction.tsx index eab7357defe..fbca6696005 100644 --- a/packages/react/src/ActionList/TrailingAction.tsx +++ b/packages/react/src/ActionList/TrailingAction.tsx @@ -36,6 +36,7 @@ export const TrailingAction = forwardRef( data-component="ActionList.TrailingAction" sx={{ flexShrink: 0, + display: showOnHover ? 'none' : 'flex', }} > Date: Mon, 10 Jun 2024 16:36:41 -0400 Subject: [PATCH 3/3] Add overflow example --- .../src/ActionList/ActionList.features.stories.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/react/src/ActionList/ActionList.features.stories.tsx b/packages/react/src/ActionList/ActionList.features.stories.tsx index c9412e0aab1..204f46e4d21 100644 --- a/packages/react/src/ActionList/ActionList.features.stories.tsx +++ b/packages/react/src/ActionList/ActionList.features.stories.tsx @@ -775,7 +775,19 @@ export const WithTrailingAction = () => { - LinkItem 2with TrailingVisual + LinkItem 1 + + with TrailingAction this is a long description and should not cause horizontal scroll on smaller screen + sizes + + + + + LinkItem 2 + + with TrailingVisual this is a long description and should not cause horizontal scroll on smaller screen + sizes +