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

15087: Add Button Base #15998

Merged
merged 13 commits into from
Oct 4, 2022
Merged

15087: Add Button Base #15998

merged 13 commits into from
Oct 4, 2022

Conversation

garrettbear
Copy link
Contributor

Explanation

Adding new Design System Button:

  • ButtonBase (foundational button component)

The ButtonBase can be used when needing to build a customized button, which can then be proposed to the design system.

[Figma].(https://www.figma.com/file/HKpPKij9V3TpsyMV1TpV7C/DS-Components?node-id=11%3A15)

More Information

Fixes #15087

Screenshots/Screencaps

Screen Shot 2022-09-27 at 10 31 01 AM

Screen Shot 2022-09-27 at 10 31 14 AM

Screen Shot 2022-09-27 at 10 31 22 AM

Manual Testing Steps

yarn test:unit:jest .ui/components/component-library/button-base/button-base.test.js

Pre-Merge Checklist

  • PR template is filled out
  • IF this PR fixes a bug, a test that would have caught the bug has been added
  • PR is linked to the appropriate GitHub issue
  • PR has been added to the appropriate release Milestone

+ If there are functional changes:

  • Manual testing complete & passed
  • "Extension QA Board" label has been applied

@garrettbear garrettbear requested a review from a team as a code owner September 27, 2022 17:37
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

it('should render with different button states', () => {
const { getByTestId } = render(
<>
{/* <ButtonBase loading data-testid="loading" /> */}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commented this one out because the loading icon is using Icon component, but in testing doesn't have access to the ICON_NAMES

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@garrettbear garrettbear Sep 28, 2022

Choose a reason for hiding this comment

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

not sure that the MOCK_ICON_NAMES will actually solve this either since it is referring to the loading icon which is nested inside the component.

Copy link
Contributor

@georgewrmarshall georgewrmarshall Sep 29, 2022

Choose a reason for hiding this comment

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

One work around is to add loadingIconProps to the button component and pass in the name for this test just to make sure it's working for tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this still need addressing?

Copy link
Contributor Author

@garrettbear garrettbear Sep 30, 2022

Choose a reason for hiding this comment

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

@darkwing @georgewrmarshall

Do we think loadingIconProps is worth adding to the button just for the test?

Is there something we can do to the Icon component so we can avoid doing workarounds on all of our future components that use the icon?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup something that will need to be fixed for Icons. I've created an issue #16046 I think we can move forward with this PR and resolve this test once this issue has been resolved

@metamaskbot
Copy link
Collaborator

Builds ready [f034118]
Page Load Metrics (2593 ± 159 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint93179122199
domContentLoaded217233802579320154
load219434972593330159
domInteractive217233802579320154

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Looking really good 💯 Left some tiny suggestions

ui/components/component-library/button-base/README.mdx Outdated Show resolved Hide resolved
ui/components/component-library/button-base/README.mdx Outdated Show resolved Hide resolved
ui/components/component-library/button-base/button-base.js Outdated Show resolved Hide resolved
ui/components/component-library/button-base/button-base.js Outdated Show resolved Hide resolved
ui/components/component-library/button-base/button-base.js Outdated Show resolved Hide resolved
it('should render with different button states', () => {
const { getByTestId } = render(
<>
{/* <ButtonBase loading data-testid="loading" /> */}
Copy link
Contributor

Choose a reason for hiding this comment

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

ui/components/component-library/icon/icon.scss Outdated Show resolved Hide resolved
Comment on lines +85 to +92
&--inherit {
font-family: inherit;
font-weight: inherit;
font-size: inherit;
line-height: inherit;
letter-spacing: inherit;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Should any documentation in the Text component reflect this update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea probably should. I will add a quick something

@metamaskbot
Copy link
Collaborator

Builds ready [4d13701]
Page Load Metrics (2223 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint872301221478230
domContentLoaded19132496220612761
load19922496222311455
domInteractive19132496220612761

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [87cd0ed]
Page Load Metrics (2443 ± 91 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint983671345928
domContentLoaded20902829242418890
load20902854244319091
domInteractive20902829242418890

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Looking really good! I was playing around with making the default display: inline-flex; so when the root element is changed to an a tag it doesn't break but no biggy. Cause I know it will generally be used with ButtonLink type and then we also would need have some irrelevant flex options so up to you 🤷

Screen Shot 2022-09-28 at 12 40 16 PM

This fixes it but you get those irrelevant flex options for all buttons and I'm not sure if it's worth conditionally adding them

Screen Shot 2022-09-28 at 12 56 08 PM

add button constants

button base updates

base button docs update

add iconprops base button

update block doc on button
@garrettbear garrettbear force-pushed the feat/15087/button-base-component branch from 526f91c to c903ed4 Compare September 29, 2022 17:14
@garrettbear garrettbear added team-design-system All issues relating to design system in Extension IA/NAV labels Sep 29, 2022
@garrettbear garrettbear self-assigned this Sep 29, 2022
@metamaskbot
Copy link
Collaborator

Builds ready [54f05f6]
Page Load Metrics (2257 ± 123 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint88127105115
domContentLoaded178528142236258124
load178528142257257123
domInteractive178528142236258124

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work 🔥🔥🔥

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

Just a nit and a question. Nice work!

'mm-button',
`mm-button--size-${size}`,
{
[`mm-button--loading`]: Boolean(loading),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe we need the wrapping [] around the classname keys here and the next few lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, no need for the [] 👍

it('should render with different button states', () => {
const { getByTestId } = render(
<>
{/* <ButtonBase loading data-testid="loading" /> */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this still need addressing?

border-radius: 999px;
cursor: pointer;
color: var(--color-text-default);
background-color: #dcdcdc;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be using a variable here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably, all ask the designer if we want to use a different color. #dcdcdc color is used in the design, but we currently don't have that as a defined token(variable) color

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Designer said it's fine to leave as is, but can also use Brand/Grey100 (#D6D9DC). I will update using that variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch @segun! We shouldn't have any static hex values in our code base if we can avoid it :)

@metamaskbot
Copy link
Collaborator

Builds ready [ce4d401]
Page Load Metrics (2468 ± 107 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint932691353818
domContentLoaded204329292437219105
load204329572468223107
domInteractive204329292437219105

highlights:

storybook

Co-authored-by: George Marshall <[email protected]>
@metamaskbot
Copy link
Collaborator

Builds ready [25bf9c4]
Page Load Metrics (2174 ± 91 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint87149103167
domContentLoaded18182531215218790
load18242531217418991
domInteractive18182531215218790

highlights:

storybook

Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

LGTM :)

@garrettbear garrettbear merged commit 46d970e into develop Oct 4, 2022
@garrettbear garrettbear deleted the feat/15087/button-base-component branch October 4, 2022 16:55
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2022
@metamaskbot
Copy link
Collaborator

Builds ready [1021345]
Page Load Metrics (2377 ± 64 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint872841184019
domContentLoaded21802688235912861
load22322714237713364
domInteractive21802688235912861

highlights:

storybook

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team-design-system All issues relating to design system in Extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Ext Nav] Create component: ButtonBase
6 participants