-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add new Select
component
#828
Conversation
// URI-encoded source of `CaretDownIcon` | ||
// Currently, the color (stroke) is hard-coded | ||
const arrowImage = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' aria-hidden='true' focusable='false'%3E%3Cg fill-rule='evenodd'%3E%3Crect fill='none' stroke='none' x='0' y='0' width='16' height='16'%3E%3C/rect%3E%3Cpath fill='none' stroke='%239c9c9c' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6l-4 4-4-4'%3E%3C/path%3E%3C/g%3E%3C/svg%3E")`; |
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.
Alternately, we can extend the Tailwind theme in the package's preset:
theme: {
extend: {
backgroundImage: {
'caret-down': 'url("/* ... *./")',
}
}
}
which could then be applied with the bg-caret-down
utility class.
Putting the source of the image here in the component module means we could ostensibly set stroke
color or other attribute values dynamically. The up side of putting it in the tailwind preset is that, ostensibly, a consumer could override it with something completely different.
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 guess there are pros and cons to both approaches, but since it's hard to see how the needs for this component will evolve, I would suggest keeping it like this and change it later if wee see the need.
style={{ | ||
backgroundImage: arrowImage, | ||
}} |
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.
The LMS implementation of this <select>
uses a separate Icon component/element and absolutely-positions it at the right edge of a wrapping container element.
The advantage of using a background image is that no wrapping container is needed. This allows <Select>
to take advantage of InputGroup
styling, e.g.
// URI-encoded source of `CaretDownIcon` | ||
// Currently, the color (stroke) is hard-coded | ||
const arrowImage = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' aria-hidden='true' focusable='false'%3E%3Cg fill-rule='evenodd'%3E%3Crect fill='none' stroke='none' x='0' y='0' width='16' height='16'%3E%3C/rect%3E%3Cpath fill='none' stroke='%239c9c9c' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6l-4 4-4-4'%3E%3C/path%3E%3C/g%3E%3C/svg%3E")`; |
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 guess there are pros and cons to both approaches, but since it's hard to see how the needs for this component will evolve, I would suggest keeping it like this and change it later if wee see the need.
ce79162
to
399a7fc
Compare
Codecov Report
@@ Coverage Diff @@
## main #828 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 57 58 +1
Lines 686 691 +5
Branches 241 242 +1
=========================================
+ Hits 686 691 +5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Depends on #827
This PR adds a basic
Select
component, building onInputRoot
. Its purpose right now is to capture, standardize and simplify the design pattern used in the grading toolbar in LMS:This is to support some UI improvements in that area.
The component is simple and young. You can see its documentation on this branch at http://localhost:4001/input-select