From 7e9c8e0c7b37af7f5804a85af4a9dad52cecfb4b Mon Sep 17 00:00:00 2001 From: Eileen Guo Date: Wed, 24 Jan 2024 11:19:44 +0100 Subject: [PATCH 1/4] add some margin between icon and text in select --- .../Form/Combobox/Combobox.stories.tsx | 22 +++++++++++++++++++ .../src/components/Form/Combobox/Combobox.tsx | 9 +++++++- .../src/components/Form/Select/Select.css.ts | 1 + .../components/Form/Select/Select.stories.tsx | 22 +++++++++++++++++++ .../components/Form/Select/SelectButton.tsx | 11 +++++++--- 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/packages/libs/react-ui/src/components/Form/Combobox/Combobox.stories.tsx b/packages/libs/react-ui/src/components/Form/Combobox/Combobox.stories.tsx index 9e1be88396..aa4f551197 100644 --- a/packages/libs/react-ui/src/components/Form/Combobox/Combobox.stories.tsx +++ b/packages/libs/react-ui/src/components/Form/Combobox/Combobox.stories.tsx @@ -141,6 +141,28 @@ export const Default: Story = { }, }; +export const WithIcon: Story = { + args: { + isDisabled: false, + isInvalid: false, + isRequired: false, + isPositive: false, + description: 'Some description', + label: 'Select something', + placeholder: 'Select an option', + }, + render: (args) => { + return ( + }> + Option 1 + Option 2 + Option 3 + Option 4 + + ); + }, +}; + export const ComplexItems = () => ( diff --git a/packages/libs/react-ui/src/components/Form/Combobox/Combobox.tsx b/packages/libs/react-ui/src/components/Form/Combobox/Combobox.tsx index dfc9a8e4cf..a6bf64a614 100644 --- a/packages/libs/react-ui/src/components/Form/Combobox/Combobox.tsx +++ b/packages/libs/react-ui/src/components/Form/Combobox/Combobox.tsx @@ -1,11 +1,12 @@ import { mergeProps, useObjectRef } from '@react-aria/utils'; import classNames from 'classnames'; -import type { ForwardedRef } from 'react'; +import type { ForwardedRef, ReactNode } from 'react'; import React, { forwardRef, useRef } from 'react'; import type { AriaComboBoxProps } from 'react-aria'; import { useComboBox, useFilter, useHover } from 'react-aria'; import { useComboBoxState } from 'react-stately'; +import { atoms } from '../../../styles'; import { ListBox } from '../../ListBox'; import { Popover } from '../../Popover'; import { formField } from '../Form.css'; @@ -17,6 +18,7 @@ import { ComboboxButton } from './ComboboxButton'; export interface IComboboxProps extends AriaComboBoxProps { isPositive?: boolean; + startIcon?: ReactNode; className?: string; tag?: string; info?: string; @@ -98,6 +100,11 @@ function ComboBoxBase( ref={triggerRef} className={comboBoxControlClass} > + {props.startIcon && ( + + {props.startIcon} + + )} { + return ( + + ); + }, +}; + export const ComplexItems = () => (