Skip to content

Commit

Permalink
chore(@kadena/react-ui): Update select spacing and added "startIcon" …
Browse files Browse the repository at this point in the history
…to combobox
  • Loading branch information
eileenmguo authored Jan 24, 2024
2 parents 1ed3173 + d974e5c commit 03d8282
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-rocks-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kadena/react-ui': patch
---

Update Select and Combobox styles
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Combobox {...args} startIcon={<Account />}>
<ComboboxItem key="option1">Option 1</ComboboxItem>
<ComboboxItem key="option2">Option 2</ComboboxItem>
<ComboboxItem key="option3">Option 3</ComboboxItem>
<ComboboxItem key="option4">Option 4</ComboboxItem>
</Combobox>
);
},
};

export const ComplexItems = () => (
<Combobox label="Select an option">
<ComboboxItem key="option1" textValue="Option 1">
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,6 +18,7 @@ import { ComboboxButton } from './ComboboxButton';
export interface IComboboxProps<T extends object = any>
extends AriaComboBoxProps<T> {
isPositive?: boolean;
startIcon?: ReactNode;
className?: string;
tag?: string;
info?: string;
Expand Down Expand Up @@ -98,6 +100,11 @@ function ComboBoxBase<T extends object>(
ref={triggerRef}
className={comboBoxControlClass}
>
{props.startIcon && (
<span className={atoms({ marginInlineEnd: 'sm' })}>
{props.startIcon}
</span>
)}
<input {...inputProps} ref={inputRef} className={comboBoxInputClass} />
<ComboboxButton
{...buttonProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Select {...args} startIcon={<Account />}>
<SelectItem key="option1">Option 1</SelectItem>
<SelectItem key="option2">Option 2</SelectItem>
<SelectItem key="option3">Option 3</SelectItem>
<SelectItem key="option4">Option 4</SelectItem>
</Select>
);
},
};

export const ComplexItems = () => (
<Select label="Select an option">
<SelectItem key="option1" textValue="Option 1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { forwardRef } from 'react';
import type { AriaButtonProps } from 'react-aria';
import { useButton, useHover } from 'react-aria';
import type { SelectState } from 'react-stately';
import { rotate180Transition } from '../../../styles';
import { atoms, rotate180Transition } from '../../../styles';
import { ChevronDown } from '../../Icon/System/SystemIcon';
import { selectButtonClass } from './Select.css';

Expand Down Expand Up @@ -41,9 +41,13 @@ function SelectButtonBase<T extends object>(
className={classNames(selectButtonClass, props.className)}
ref={ref}
>
{props.startIcon && <span>{props.startIcon}</span>}
{props.startIcon && (
<span className={atoms({ marginInlineEnd: 'sm' })}>
{props.startIcon}
</span>
)}
{props.children}
<span>
<span className={atoms({ marginInlineStart: 'sm' })}>
<ChevronDown
data-open={props.state.isOpen}
className={rotate180Transition}
Expand Down

1 comment on commit 03d8282

@vercel
Copy link

@vercel vercel bot commented on 03d8282 Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

alpha-docs – ./packages/apps/docs

docs-silk-two.vercel.app
docs.kadena.io
alpha-docs.kadena.io
alpha-docs-kadena-js.vercel.app
alpha-docs-git-main-kadena-js.vercel.app

Please sign in to comment.