-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Dropdown] Apply box-shadow changes #338
Conversation
…make typings consistent
@benkolde Tagging you for a design review before an engineer for a code review because this behavior in particular seems suboptimal. Since our focus outline is smaller than the new |
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 great, thanks @michaeljaltamirano
.create( | ||
<MobileDropdown | ||
onSelectChange={() => undefined} | ||
borderRadius="4px" |
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.
It's a little annoying to have to provide borderRadius
for the Jest tests--however, I thought it was cleaner to add the optional argument w/ default at the parent component Dropdown
, instead of keep the value optional there (without a default) and setting the default on both MobileDropdown
and DesktopDropdown
.
max-height: ${SPACER.x4large}; | ||
|
||
border: 1px solid ${COLORS.border}; | ||
${dropdownBorderRadius}; |
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 line is the only change--the diff is larger due to indentatio.
optionsContainerMaxHeight: string; | ||
textAlign: 'left' | 'center'; | ||
value?: string; | ||
}; | ||
|
||
const DesktopDropdown = ({ |
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.
Larger diff is from alphabetizing--only change in this file is adding borderRadius
(and shouldBeFullyRounded
) logic.
}; | ||
|
||
const Dropdown = (props: DropdownProps) => { |
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.
CHANGELOG:
- Move
defaultProps
to ES6 defaults.- Improved type-inference from relying on language built-ins without working out
defaultProps
limitations.- e.g., the compiler can infer that even though
borderRadius
is optional, since we're providing it with defaults when we pass it intoDesktopDropdown
andMobileDropdown
we can type it there as required.
- e.g., the compiler can infer that even though
- There's still some inconsistencies: we're passing an ES6 default in
MobileDropdown
even though we typed it as a required prop. I'm not sure if that's just due to making things easier to test (related comment: https://github.com/curology/radiance-ui/pull/338/files#r488011625) but this PR already has enough ancillary changes so I didn't want to change too much.
- Improved type-inference from relying on language built-ins without working out
- Modify type of
value
inOptionType
- We rely on a falsy default for our dropdown: changing the type from
string
tostring | undefined
reflects this. - There's some inconsistency in our falsy default--
null
vs.undefined
. The type definition for<option>
prefersundefined
instead ofnull
(OptionHTMLAttributes<HTMLOptionElement>.value?: string | number | readonly string[] | undefined
) so this PR prefers that when making changes.
- We rely on a falsy default for our dropdown: changing the type from
onSelectChange: (event: React.ChangeEvent<HTMLSelectElement>) => void; | ||
options: OptionType[]; | ||
textAlign?: 'left' | 'center'; | ||
value?: string | number | undefined; | ||
}; | ||
|
||
const MobileDropdown = ({ |
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.
CHANGELOG:
- Change default
value
andoptions[number].value
type fromnull
toundefined
to conform to HTML attribute types. - Remove defaultProps for
onSelectChange
- I'm assuming this was included to make the tests easier--it's a required TypeScript type so this makes things more consistent.
- Sets
textAlign
TypeScript type as optional to reflect that we have an ES6 default.- This isn't consistent with parent
Dropdown
behavior but I didn't want to remove this functionality. All sub-component usage goes throughDropdown
.
- This isn't consistent with parent
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.
💯
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.
👏
What and Why
clickable
andclickableHover
styles to match what design has in Figma.border-radius
styling for the Dropdown component, which previously had noborder-radius
.border-radius: 4px
since we rely on native select dropdown for functionality.border-radius: 4px
unless it is open, at which point the following occurs:border-radius: 4px 4px 0 0
, shorthand for setting the top-left and top-right border radius.border-radius: 0 0 4px 4px
, shorthand for setting the bottom-left and bottom-right border radius.borderRadius
prop, so that the aboveborder-radius
values are programmable, with4px
as the default.Clickable changes
Before:
After:
**Action button changes (as a result of
clickable
changes)``Before:
After:
Dropdown changes
Before:
After:
Next Steps
clickable
andclickableHover
style changes will also be used in future PRs updating ourAccordion
andOptionButton
component.