From 700d9a8fbab958974a809ebb55f29d7aea631400 Mon Sep 17 00:00:00 2001 From: Katie Langerman <18661030+langermank@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:19:03 -0800 Subject: [PATCH] starting item --- .../ActionList.features.stories.tsx | 2 +- packages/react/src/ActionList/Item.tsx | 100 +++++++++++++++++- 2 files changed, 97 insertions(+), 5 deletions(-) diff --git a/packages/react/src/ActionList/ActionList.features.stories.tsx b/packages/react/src/ActionList/ActionList.features.stories.tsx index a06525b3b4e..0bf9f6e9209 100644 --- a/packages/react/src/ActionList/ActionList.features.stories.tsx +++ b/packages/react/src/ActionList/ActionList.features.stories.tsx @@ -241,7 +241,7 @@ export const BlockDescription = () => ( {user.login} - {user.name} + {user.name} ))} diff --git a/packages/react/src/ActionList/Item.tsx b/packages/react/src/ActionList/Item.tsx index 168333b770a..13d1b67c847 100644 --- a/packages/react/src/ActionList/Item.tsx +++ b/packages/react/src/ActionList/Item.tsx @@ -21,6 +21,8 @@ import {ConditionalWrapper} from '../internal/components/ConditionalWrapper' import {invariant} from '../utils/invariant' import {useFeatureFlag} from '../FeatureFlags' import VisuallyHidden from '../_VisuallyHidden' +import classes from './ActionList.module.css' +import {clsx} from 'clsx' const LiBox = styled.li(sx) @@ -54,8 +56,9 @@ export const Item = React.forwardRef( leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, trailingAction: TrailingAction, - blockDescription: [Description, props => props.variant === 'block'], - inlineDescription: [Description, props => props.variant !== 'block'], + // blockDescription: [Description, props => props.variant === 'block' || props.variant === undefined], + inlineDescription: [Description, props => props.variant === 'inline'], + description: Description, }) const {container, afterSelect, selectionAttribute, defaultTrailingVisual} = @@ -292,6 +295,8 @@ export const Item = React.forwardRef( const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option'] const includeSelectionAttribute = itemSelectionAttribute && itemRole && selectableRoles.includes(itemRole) + const blockDescriptionSlot = [Description, (props: any) => props.variant === 'block' || props.variant === undefined] + const menuItemProps = { onClick: clickHandler, onKeyPress: !buttonSemantics ? keyPressHandler : undefined, @@ -334,6 +339,90 @@ export const Item = React.forwardRef( wrapperProps = _PrivateItemWrapper ? menuItemProps : {} } + const enabled = useFeatureFlag('primer_react_css_modules_team') + + if (enabled) { + // if (sxProp !== defaultSxProp) { + // return () + + // } + return ( + +
  • + + + + {slots.leadingVisual} + +
    + + + + {childrenWithoutSlots} + {/* Loading message needs to be in here so it is read with the label */} + {loading === true && Loading} + + {/* {console.log(slots.inlineDescription)} */} + {/* {console.log(slots.blockDescription)} */} + {console.log(slots.description)} + {/* {slots.inlineDescription} */} + {/* {slots.blockDescription} */} + {slots.description} + + + {trailingVisual} + + + { + // If the item is inactive, but it's not in an overlay (e.g. ActionMenu, SelectPanel), + // render the inactive warning message directly in the item. + inactive && container ? {inactiveText} : null + } + {/* {slots.blockDescription} */} +
    +
    + {!inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction} +
  • +
    + ) + } + return ( ( {/* Loading message needs to be in here so it is read with the label */} {loading === true && Loading} - {slots.inlineDescription} + {/* {slots.inlineDescription} */} + + {slots.description && React.cloneElement(slots.description, {variant: 'inline'})} ( ) : null } - {slots.blockDescription} + {/* {slots.blockDescription} */} + {slots.description && React.cloneElement(slots.description, {variant: 'block'})} {!inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction}