From 796393fd8f59bb9f848cf9791fe3536fb89fbe07 Mon Sep 17 00:00:00 2001 From: Manuel Bahamondez-Honores Date: Tue, 20 Jan 2026 10:16:22 -0300 Subject: [PATCH 1/2] feat(dropdown): add iconColor prop to DropdownButton --- src/elements/dropdown/dropdownButton.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/elements/dropdown/dropdownButton.tsx b/src/elements/dropdown/dropdownButton.tsx index 989bb214..9ed2a9cd 100644 --- a/src/elements/dropdown/dropdownButton.tsx +++ b/src/elements/dropdown/dropdownButton.tsx @@ -29,6 +29,8 @@ interface DropdownButtonProps { isActive?: boolean; /** Icon to render on the left. If nothing is set, no icon will be rendered. */ iconName?: IconName; + /** Color for the icon. Defaults to greys.shade50. */ + iconColor?: string; /** The max width of the button. Default is 100%. */ maxWidth?: number; /** Reference the button itself. */ @@ -153,7 +155,7 @@ const StyledChevronWrapperDiv = styled.div` */ export const DropdownButton: FC = (props) => { - const {maxWidth, value, iconName, isDisabled, isActive, isErred, buttonRef} = props; + const {maxWidth, value, iconName, iconColor, isDisabled, isActive, isErred, buttonRef} = props; const [childrenContainerRef, {buttonWidth: width}] = useMeasureElement(); return ( @@ -165,7 +167,7 @@ export const DropdownButton: FC = (props) => { $isDisabled={isDisabled} $isErred={isErred}> - {maybeRenderIcon(iconName)} + {maybeRenderIcon(iconName, iconColor)} {maybeRenderPlaceholder(props)} {renderDropdownContent(value, width)} @@ -203,11 +205,11 @@ function renderDropdownContent(value: string | ReadonlyArray, childrenCo return value; } -function maybeRenderIcon(iconName?: IconName) { +function maybeRenderIcon(iconName?: IconName, iconColor?: string) { if (!iconName) return null; return ( - + ); } From 1f869b0e01844f2f4f150b5b4ee06b894ba86dfe Mon Sep 17 00:00:00 2001 From: Manuel Bahamondez-Honores Date: Tue, 20 Jan 2026 10:57:05 -0300 Subject: [PATCH 2/2] feat(dropdown): add Storybook story for iconColor prop Add a new story demonstrating the iconColor prop on DropdownButton, showing how to display colored icons in the dropdown button to match the selected item's color (e.g., inbox color). --- .../dropdown/__docs__/index.stories.tsx | 1 + .../__docs__/stories/iconColor.stories.tsx | 85 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 src/elements/dropdown/__docs__/stories/iconColor.stories.tsx diff --git a/src/elements/dropdown/__docs__/index.stories.tsx b/src/elements/dropdown/__docs__/index.stories.tsx index 7ef72408..b8b5c4c5 100644 --- a/src/elements/dropdown/__docs__/index.stories.tsx +++ b/src/elements/dropdown/__docs__/index.stories.tsx @@ -31,6 +31,7 @@ export {MultiLine} from './stories/multi-line.stories'; export {Avatar} from './stories/avatar.stories'; export {Header} from './stories/header.stories'; export {Form} from './stories/form.stories'; +export {IconColor} from './stories/iconColor.stories'; // Nested Dropdown Examples (Hover-based) export {BasicNestedDropdown} from './stories/nestedDropdown.stories'; diff --git a/src/elements/dropdown/__docs__/stories/iconColor.stories.tsx b/src/elements/dropdown/__docs__/stories/iconColor.stories.tsx new file mode 100644 index 00000000..1fe33a54 --- /dev/null +++ b/src/elements/dropdown/__docs__/stories/iconColor.stories.tsx @@ -0,0 +1,85 @@ +import type {StoryFn} from '@storybook/react'; +import React, {useState} from 'react'; +import styled from 'styled-components'; + +import {palette} from '../../../../helpers/colorHelpers'; +import {Icon} from '../../../icon/icon'; +import {Dropdown} from '../../dropdown'; +import {DropdownButton} from '../../dropdownButton'; +import {DropdownCoordinator} from '../../dropdownCoordinator'; +import {DropdownItem} from '../../dropdownItem'; + +const StyledWrapperDiv = styled.div` + display: flex; + flex-flow: row; + justify-content: center; + height: 300px; +`; + +const StyledDropdownWrapperDiv = styled.div` + width: 300px; +`; + +const StyledDropdownItemContentDiv = styled.div` + display: flex; + align-items: center; + gap: 8px; +`; + +interface InboxOption { + id: string; + name: string; + color: string; +} + +const inboxOptions: ReadonlyArray = [ + {id: '1', name: 'Support', color: palette.red.shade40}, + {id: '2', name: 'Sales', color: palette.blue.shade40}, + {id: '3', name: 'Engineering', color: palette.green.shade40}, + {id: '4', name: 'Marketing', color: palette.purple.shade40}, + {id: '5', name: 'Operations', color: palette.orange.shade40} +]; + +const Template: StoryFn = () => { + const [selectedInboxId, setSelectedInboxId] = useState(); + const selectedInbox = inboxOptions.find((inbox) => inbox.id === selectedInboxId); + + return ( + + + ( + + )} + renderDropdown={(_onRequestClose, buttonWidth) => ( + + {inboxOptions.map((inbox) => ( + setSelectedInboxId(inbox.id)} + isSelected={inbox.id === selectedInboxId}> + + + {inbox.name} + + + ))} + + )} + /> + + + ); +}; + +export const IconColor = Template.bind({});