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

[Dropdown] Apply box-shadow changes #338

Merged
merged 9 commits into from
Sep 14, 2020

Conversation

michaeljaltamirano
Copy link
Contributor

@michaeljaltamirano michaeljaltamirano commented Sep 9, 2020

What and Why

  1. Updates our clickable and clickableHover styles to match what design has in Figma.
  2. Updates our border-radius styling for the Dropdown component, which previously had no border-radius.
    • Our Mobile dropdown will always have border-radius: 4px since we rely on native select dropdown for functionality.
    • Our Desktop dropdown will have border-radius: 4px unless it is open, at which point the following occurs:
      • The Dropdown select will have border-radius: 4px 4px 0 0, shorthand for setting the top-left and top-right border radius.
      • The last child of the Dropdown options will have border-radius: 0 0 4px 4px, shorthand for setting the bottom-left and bottom-right border radius.
  3. Updates our Dropdown component to accept an optional borderRadius prop, so that the above border-radius values are programmable, with 4px as the default.

Clickable changes

Before:

Screen Shot 2020-09-09 at 2 30 40 PM

After:

Screen Shot 2020-09-09 at 2 30 33 PM

**Action button changes (as a result of clickable changes)``

Before:

button-before

After:

button-after

Dropdown changes

Before:

Screen Shot 2020-09-09 at 2 40 05 PM

After:

Screen Shot 2020-09-09 at 2 40 38 PM

Next Steps

  1. These clickable and clickableHover style changes will also be used in future PRs updating our Accordion and OptionButton component.
    • I plan on releasing all these changes together.

@snags88 snags88 temporarily deployed to curology-radiance-pr-338 September 9, 2020 19:26 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-338 September 9, 2020 20:49 Inactive
@michaeljaltamirano
Copy link
Contributor Author

**Action button changes (as a result of clickable changes)``

Before:

button-before

After:

button-after

@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 box-shadow size the keyboard effect is somewhat jarring.

Copy link
Contributor

@benkolde benkolde left a 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"
Copy link
Contributor Author

@michaeljaltamirano michaeljaltamirano Sep 14, 2020

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};
Copy link
Contributor Author

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 = ({
Copy link
Contributor Author

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) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CHANGELOG:

  1. 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 into DesktopDropdown and MobileDropdown we can type it there as required.
    • 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.
  2. Modify type of value in OptionType
    • We rely on a falsy default for our dropdown: changing the type from string to string | undefined reflects this.
    • There's some inconsistency in our falsy default--null vs. undefined. The type definition for <option> prefers undefined instead of null (OptionHTMLAttributes<HTMLOptionElement>.value?: string | number | readonly string[] | undefined) so this PR prefers that when making changes.

onSelectChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
options: OptionType[];
textAlign?: 'left' | 'center';
value?: string | number | undefined;
};

const MobileDropdown = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CHANGELOG:

  1. Change default value and options[number].value type from null to undefined to conform to HTML attribute types.
  2. 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.
  3. 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 through Dropdown.

Copy link
Contributor

@ZeMunchkin ZeMunchkin left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Member

@cmgmyr cmgmyr left a comment

Choose a reason for hiding this comment

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

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants