Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(@kadena/react-ui): Update select spacing and added "startIcon" to combobox #1519

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading