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(@clayui/form): add regular size to input storybook and make it … #5801

Merged
merged 3 commits into from
May 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/clay-button/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface IProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
/**
* Determines the size of a button.
*/
size?: 'xs' | 'sm';
size?: 'xs' | 'regular' | 'sm';

/**
* Indicates button should be a small variant.
Expand All @@ -96,7 +96,7 @@ const ClayButton = React.forwardRef<HTMLButtonElement, IProps>(
monospaced,
outline,
rounded,
size,
size = 'regular',
small,
translucent,
type = 'button',
Expand Down Expand Up @@ -133,15 +133,15 @@ const ClayButton = React.forwardRef<HTMLButtonElement, IProps>(
'btn-block': block,
'btn-monospaced': monospaced,
'btn-outline-borderless': borderless,
'btn-sm': small && !size,
'btn-sm': small && (!size || size === 'regular'),
'btn-translucent': translucent,
'clay-dark': dark,
[`btn-${displayType}`]:
displayType && !outline && !borderless,
[`btn-outline-${displayType}`]:
displayType && (outline || borderless),
'rounded-pill': rounded,
[`btn-${size}`]: size,
[`btn-${size}`]: size && size !== 'regular',
})}
ref={ref}
type={type}
Expand Down
6 changes: 3 additions & 3 deletions packages/clay-form/src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ interface IProps extends React.InputHTMLAttributes<HTMLInputElement> {
/**
* Selects the height of the input.
*/
sizing?: 'lg' | 'sm';
sizing?: 'lg' | 'regular' | 'sm';
}

const ClayInput = React.forwardRef<HTMLInputElement, IProps>(
Expand All @@ -184,7 +184,7 @@ const ClayInput = React.forwardRef<HTMLInputElement, IProps>(
component: Component = 'input',
insetAfter,
insetBefore,
sizing,
sizing = 'regular',
type = 'text',
...otherProps
}: IProps,
Expand All @@ -193,7 +193,7 @@ const ClayInput = React.forwardRef<HTMLInputElement, IProps>(
<Component
{...otherProps}
className={classNames('form-control', className, {
[`form-control-${sizing}`]: sizing,
[`form-control-${sizing}`]: sizing && sizing !== 'regular',
['input-group-inset']: insetAfter || insetBefore,
['input-group-inset-after']: insetAfter,
['input-group-inset-before']: insetBefore,
Expand Down
6 changes: 3 additions & 3 deletions packages/clay-form/stories/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
argTypes: {
sizing: {
control: {type: 'select'},
options: ['lg', 'sm'],
options: ['lg', 'regular', 'sm'],
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this could be an option in the API directly instead of just in the storybook? we can add regular and if it is passed, we leave it as the default value. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have a strong opinion on this. Do you think it will make it clearer for everyone to understand sizing if we add a regular value? I always thought the default was implied if the sizing attribute wasn't specified.

Copy link
Member

Choose a reason for hiding this comment

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

Well, I thought that too when sizing is not defined it would imply that it is using the regular value but I think that when you are defining the size it is strange for you to look at it and see that there is only lg and sm this is something else implicit than explicit so maybe we can just make it more explicit I think this is more aesthetic too.

Copy link
Member

Choose a reason for hiding this comment

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

I think adding regular may make sense, but if we want to add that we should probably be applying that consistently. For instance button currently has the options: null | xs | sm. @drakonux were you thinking the regular option should be applied everywhere?

Copy link
Member

Choose a reason for hiding this comment

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

Oh yes I agree with that, it makes a lot of sense to do this for all components.

Copy link
Member

@drakonux drakonux Apr 17, 2024

Choose a reason for hiding this comment

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

Yes @ethib137 . Let's make a decision and apply it consistently. We are using regular size for buttons and also for inputs in the Figma library as examples.

Our top priority is maintaining a consistent approach with Clay and ensuring one-to-one correspondence at all components.

Copy link
Member

Choose a reason for hiding this comment

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

Okay buttons and inputs sound good. Are there any other usages of regular that we should apply this too?

Copy link
Member

Choose a reason for hiding this comment

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

I went ahead and added it to the Input and Button. We have some other components with size as well:

  • Table
  • Sheet
  • LoadingIndicator
  • Modal
  • MultiSelect
  • Pagination
  • PaginationBar
  • Panel
  • Sticker

Does it make sense to add to these too? I would say yes since we are talk for consistency here but I will wait for other opinions to see if I'm missing something.

Copy link
Member

Choose a reason for hiding this comment

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

@drakonux what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I think we can move forward with this and if it looks good we can do this for the other components just to not block this ticket any longer.

},
},
title: 'Design System/Components/Input',
Expand All @@ -27,7 +27,7 @@ export const Default = (args: any) => (
id="basicInputText"
placeholder="Insert your name here"
readOnly={args.readOnly}
sizing={args.sizing}
sizing={args.sizing === 'regular' ? null : args.sizing}
type="text"
/>
</ClayForm.Group>
Expand All @@ -37,7 +37,7 @@ export const Default = (args: any) => (
Default.args = {
disabled: false,
readOnly: false,
sizing: undefined,
sizing: 'regular',
};

export const InputFeedback = () => (
Expand Down