diff --git a/packages/clay-drop-down/docs/drop-down.mdx b/packages/clay-drop-down/docs/drop-down.mdx index d0c2938f59..93d0ca0233 100644 --- a/packages/clay-drop-down/docs/drop-down.mdx +++ b/packages/clay-drop-down/docs/drop-down.mdx @@ -253,9 +253,9 @@ Clay provides other ways to use the Clay component, which we call high-level com ### Icon -By default, a caret icon (▼) is displayed alongside the button text to indicate the dropdown functionality. This visually indicates a dropdown menu and improve user understanding. +To indicate a dropdown menu and improve user understanding, set the `triggerIcon` property and it will display the icon chosen alongside the button text to indicate the dropdown functionality. -The caret icon can be removed by passing `null` to the `triggerIcon` prop. +The default value is `null`. ### With Items diff --git a/packages/clay-drop-down/docs/index.js b/packages/clay-drop-down/docs/index.js index 60d1079592..0099d8feac 100644 --- a/packages/clay-drop-down/docs/index.js +++ b/packages/clay-drop-down/docs/index.js @@ -16,7 +16,7 @@ const dropDownImportsCode = `import ClayDropDown from '@clayui/drop-down';`; const dropDownCode = `const Component = () => { return ( Click here!} + closeOnClick menuElementAttrs={{ className: 'my-custom-dropdown-menu', containerProps: { @@ -24,7 +24,8 @@ const dropDownCode = `const Component = () => { id: 'dropdownMenuReactPortalDiv', }, }} - closeOnClick + trigger={} + triggerIcon='caret-bottom' > {'Can I help you?'} @@ -153,6 +154,7 @@ const dropDownWithItemsCode = `const Component = () => { searchable={true} spritemap={spritemap} trigger={{'Click Me'}} + triggerIcon='caret-bottom' /> ); } @@ -194,6 +196,7 @@ const dropDownWithDrilldownCode = `const Component = () => { }} spritemap={spritemap} trigger={{'Click Me'}} + triggerIcon='caret-bottom' /> ); } @@ -241,6 +244,7 @@ const dropDownExampleCode = `const Component = () => { Select} + triggerIcon='caret-bottom' > diff --git a/packages/clay-drop-down/src/DropDown.tsx b/packages/clay-drop-down/src/DropDown.tsx index 9df81cfcb8..029aa2ac34 100644 --- a/packages/clay-drop-down/src/DropDown.tsx +++ b/packages/clay-drop-down/src/DropDown.tsx @@ -184,7 +184,7 @@ function ClayDropDown({ renderMenuOnClick = false, role = 'menu', trigger, - triggerIcon = 'caret-bottom', + triggerIcon = null, ...otherProps }: IProps) { const triggerElementRef = useRef(null); diff --git a/packages/clay-drop-down/src/DropDownWithDrilldown.tsx b/packages/clay-drop-down/src/DropDownWithDrilldown.tsx index 4c56837731..b84464e3f2 100644 --- a/packages/clay-drop-down/src/DropDownWithDrilldown.tsx +++ b/packages/clay-drop-down/src/DropDownWithDrilldown.tsx @@ -109,6 +109,11 @@ export interface IProps extends React.HTMLAttributes { * Element that is used as the trigger which will activate the dropdown on click. */ trigger: React.ReactElement; + + /** + * Flag indicating if the caret icon should be displayed on the right side. + */ + triggerIcon?: string | null; } type History = { @@ -138,6 +143,7 @@ export const ClayDropDownWithDrilldown = ({ renderMenuOnClick, spritemap, trigger, + triggerIcon = null, }: IProps) => { const [activeMenu, setActiveMenu] = useState( defaultActiveMenu ?? initialActiveMenu @@ -218,6 +224,7 @@ export const ClayDropDownWithDrilldown = ({ }} renderMenuOnClick={renderMenuOnClick} trigger={trigger} + triggerIcon={triggerIcon} > {menuIds.map((menuKey) => { diff --git a/packages/clay-drop-down/stories/DropDown.stories.tsx b/packages/clay-drop-down/stories/DropDown.stories.tsx index c58270b03b..304f9b3386 100644 --- a/packages/clay-drop-down/stories/DropDown.stories.tsx +++ b/packages/clay-drop-down/stories/DropDown.stories.tsx @@ -91,6 +91,7 @@ export const Default = (args: any) => ( menuWidth={args.width} renderMenuOnClick={args.renderMenuOnClick} trigger={Click Me} + triggerIcon="caret-bottom" > {[ @@ -123,6 +124,7 @@ export const Dynamic = () => ( Click Me} + triggerIcon="caret-bottom" > {(item) => ( {}}> @@ -134,7 +136,10 @@ export const Dynamic = () => ( export const DynamicWithSearch = () => { return ( - Click Me}> + Click Me} + triggerIcon="caret-bottom" + > {(item: string) => ( @@ -173,6 +178,7 @@ export const DynamicGroup = () => { Select} + triggerIcon="caret-bottom" > @@ -201,6 +207,7 @@ export const Groups = () => ( Click Me} + triggerIcon="caret-bottom" > @@ -234,6 +241,7 @@ export const Checkbox = () => ( Click Me} + triggerIcon="caret-bottom" > @@ -254,6 +262,7 @@ export const Search = () => { Click Me} + triggerIcon="caret-bottom" > setQuery(event.target.value)} @@ -282,6 +291,7 @@ export const Radio = () => ( Click Me} + triggerIcon="caret-bottom" > @@ -300,6 +310,7 @@ export const CaptionAndHelp = () => ( Click Me} + triggerIcon="caret-bottom" > Can I help you? @@ -325,6 +336,7 @@ export const ItemsWithIcons = () => ( hasLeftSymbols hasRightSymbols trigger={Click Me} + triggerIcon="caret-bottom" > {[ @@ -350,6 +362,7 @@ export const CustomOffset = () => ( alignmentPosition={Align.BottomLeft} offsetFn={() => [20, 20]} trigger={Click Me} + triggerIcon="caret-bottom" > {[ @@ -382,6 +395,7 @@ export const AlignmentPositions = () => ( ]} key={alignPosition} trigger={{alignPosition}} + triggerIcon="caret-bottom" />
@@ -413,6 +427,7 @@ export const Drilldown = (args: any) => ( }} renderMenuOnClick={args.renderMenuOnClick} trigger={Click Me} + triggerIcon="caret-bottom" /> ); @@ -455,6 +470,7 @@ export const DrillDownWithActive = () => { }} onActiveChange={onActiveChange} trigger={Click Me} + triggerIcon="caret-bottom" /> ); }; @@ -486,6 +502,7 @@ export const DropDownWithItems = (args: any) => { searchValue={value} searchable={args.searchable} trigger={Click Me} + triggerIcon="caret-bottom" /> ); }; @@ -526,6 +543,7 @@ export const DropDownWithItemsWithCustomActive = () => { searchValue={value} searchable trigger={Click Me} + triggerIcon="caret-bottom" />