-
Notifications
You must be signed in to change notification settings - Fork 551
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
Select input component #1736
Select input component #1736
Conversation
🦋 Changeset detectedLatest commit: fa45ce6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
@@ -0,0 +1,100 @@ | |||
--- | |||
title: Select |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking maybe "SelectInput" is a better name. I'd love to hear what other reviewers think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! I think so too. It kinda cements it as a Form component and not any fancy menu/overlay interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only recently decided to avoid using *Input
suffix on form components, so I'm in favour of keeping it as Select
here. Reason: a) To match the underlying HTML and b) be consistent with other form components like Radio, Checkbox.
There seems to be a clash here 😅 I'll close mine, as I'm yet to implement optgroups and review yours. |
src/Select.tsx
Outdated
|
||
export default Object.assign(Select, { | ||
Option, | ||
Group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this OptGroup
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➕ . Can we call it OptionGroup
to avoid the abbreviation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we're going to call the parent component Select
, OptGroup
might make more sense because it's closer to the HTML tag name: <optgroup>
src/Select.tsx
Outdated
{...rest} | ||
> | ||
{placeholder ? ( | ||
<option value="" disabled={required} selected hidden={required}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a storybook to show what this looks like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see it by using the Controls. Do you think we need something more prominent?
type: 'boolean' | ||
} | ||
}, | ||
contrast: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be relevant for this component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I can remove it and we can always add it later if we decide we want parity with TextInput
src/stories/Select.stories.tsx
Outdated
} | ||
}, | ||
variant: { | ||
name: 'Variant', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we call this size
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely. I was waiting for #1661 to merge which deprecates variant
and adds size
.
docs/content/Select.mdx
Outdated
storybook: '/react/storybook?path=/story/forms-select--default' | ||
--- | ||
|
||
import {ComponentChecklist} from '../src/component-checklist' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need to import this anymore as it's global
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought too, but if I don't import it, it doesn't render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could your /docs
node_modules need updating?
src/Select.tsx
Outdated
|
||
const StyledSelect = styled(TextInputWrapper)<SelectProps>` | ||
appearance: none; | ||
background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0iIzU4NjA2OSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNC40MjcgOS40MjdsMy4zOTYgMy4zOTZhLjI1MS4yNTEgMCAwMC4zNTQgMGwzLjM5Ni0zLjM5NkEuMjUuMjUgMCAwMDExLjM5NiA5SDQuNjA0YS4yNS4yNSAwIDAwLS4xNzcuNDI3ek00LjQyMyA2LjQ3TDcuODIgMy4wNzJhLjI1LjI1IDAgMDEuMzU0IDBMMTEuNTcgNi40N2EuMjUuMjUgMCAwMS0uMTc3LjQyN0g0LjZhLjI1LjI1IDAgMDEtLjE3Ny0uNDI3eiIgLz48L3N2Zz4=); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we can show the icon without using a base64 uri? It's quite expensive on the runtime and AFAIK a new pattern to PRC that could set a slippery precedent. Also, this image in its current form seems incompatible with other colour modes. Worth looking at pulling this in as a composable icon instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are both great points. I'll investigate alternatives.
background-size: 16px; | ||
padding-right: 20px; | ||
cursor: pointer; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth setting the background-color here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be handled in the TextInputWrapper
component.
That will be handled by the InputFieldComponent added in #1611
That's no good. I'll take a look. |
Co-authored-by: Rez <rezrah@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to go, nice one @mperrotti. Just a heads up, this won't appear on the primer.style/status page until you add comonentId
to the front-matter. Might be worth sticking that into this PR or in a follow-up.
Adds a styled native
<select>
input componentCloses https://github.com/github/primer/issues/540
Screenshots
Kapture.2021-12-14.at.15.24.42.mp4
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.