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

Design System: Refactor IconButton and update documentation #66774

Merged
merged 27 commits into from May 15, 2023

Conversation

L-M-K-B
Copy link
Contributor

@L-M-K-B L-M-K-B commented Apr 18, 2023

Which issue(s) does this PR fix?:
Fixes #66600

Special notes for your reviewer:
Note: All sizes of plain button elements correspond with icon sizes.


size (Figma - code) status icon padding hover size
small - xs before 12px
after 12px 4px 20px
  • grafana-ui Storybook => IconButton Examples
  • in Code: packages/grafana-ui/src/components/IconButton/IconButton.tsx
Before: After:
Screenshot 2023-05-03 at 18 01 47 Screenshot 2023-05-03 at 18 04 27

size (Figma - code) status icon padding hover size
N/A - sm before 14px ~24px
after 14px 4px 22px
  • Explore => Elasticsearch query editor
  • in Code: public/app/plugins/datasource/elasticsearch/components/QueryEditor/QueryEditorRow.tsx
Before: After:
Screenshot 2023-05-03 at 18 14 17 Screenshot 2023-05-03 at 18 15 25

size (Figma - code) status icon padding hover size
medium - md before 16px ~25px
after 16px 4px 24px
  • Explore => any query Editor
  • in Code: public/app/core/components/QueryOperationRow/QueryOperationAction.tsx
Before: After:
Screenshot 2023-05-03 at 18 16 46 Screenshot 2023-05-11 at 10 26 52

size (Figma - code) status icon padding hover size
N/A - lg before 18px ~23px
after 18px 4px 26px
  • grafana-ui Storybook => IcoButton Examples
  • in Code: packages/grafana-ui/src/components/IconButton/IconButton.tsx
Before: After:
Screenshot 2023-05-11 at 11 13 59 Screenshot 2023-05-11 at 11 14 44

size (Figma - code) status icon padding hover size
large - xl before 24px ~28px
after 24px 4px 32px
  • Home => new navigation
  • in Code: public/app/core/components/AppChrome/MegaMenu/NavBarMenu.tsx
Before: After:
Screenshot 2023-05-03 at 18 24 34 Screenshot 2023-05-11 at 10 28 21

size (Figma - code) status icon padding hover size
N/A - xxl before 36px ~48px
after 24px 4px 32px
  • grafana-ui Storybook => PageToolbar Examples
  • in Code: packages/grafana-ui/src/components/PageLayout/PageToolbar.tsx
Before: After:
Screenshot 2023-05-03 at 18 49 19 Screenshot 2023-05-11 at 10 28 53

size (Figma - code) status icon padding hover size
N/A - xxxl before 48px
after 24px 4px 32px
Before: After:
Screenshot 2023-05-03 at 18 51 16 Screenshot 2023-05-11 at 10 29 42

@L-M-K-B L-M-K-B added area/frontend add to changelog no-backport Skip backport of PR saga design system Issues related to the work of the Saga Design System labels Apr 18, 2023
@L-M-K-B L-M-K-B added this to the 9.5.x milestone Apr 18, 2023
@L-M-K-B L-M-K-B marked this pull request as ready for review May 3, 2023 14:01
@L-M-K-B L-M-K-B requested review from a team as code owners May 3, 2023 14:01
@L-M-K-B L-M-K-B requested review from leventebalogh, joshhunt, eledobleefe, a team and JoaoSilvaGrafana and removed request for a team May 3, 2023 14:01
@L-M-K-B L-M-K-B changed the title Laura/unify icon button styling with button Design System: Refactor of IconButton and update documentation May 3, 2023
@L-M-K-B L-M-K-B changed the title Design System: Refactor of IconButton and update documentation Design System: Refactor IconButton and update documentation May 3, 2023
Copy link
Contributor

@JoaoSilvaGrafana JoaoSilvaGrafana left a comment

Choose a reason for hiding this comment

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

It seems like xl icons have grown a lot in hover state... Is our recommendation that those change to lg icons now? I feel like we have to address the hover size changes because they are quite drastic...

@L-M-K-B
Copy link
Contributor Author

L-M-K-B commented May 5, 2023

We definitely need to discuss the sizes for xl and lg that's why I added it as a topic to our Saga weekly on Monday.

@L-M-K-B L-M-K-B requested a review from a team as a code owner May 11, 2023 09:19
@@ -125,9 +125,8 @@ export const DynamicTable = <T extends object>({
<div className={cx(styles.cell, styles.expandCell)}>
<IconButton
aria-label={`${isItemExpanded ? 'Collapse' : 'Expand'} row`}
size="lg"
Copy link
Contributor Author

@L-M-K-B L-M-K-B May 11, 2023

Choose a reason for hiding this comment

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

Before: After:
Screenshot 2023-05-03 at 18 43 42 Screenshot 2023-05-11 at 10 52 02

Changed to md due to consistency reasons (the chevron used above is also size md).

@L-M-K-B
Copy link
Contributor Author

L-M-K-B commented May 11, 2023

We definitely need to discuss the sizes for xl and lg that's why I added it as a topic to our Saga weekly on Monday.

Since the padding according to Figma especially for larger sizes would break the UI @staton-hyse11, @JoaoSilvaGrafana and I decided to set the padding to 4px for each size and let the IconSize define how large the hover state is becoming.

Copy link
Contributor

@JoaoSilvaGrafana JoaoSilvaGrafana left a comment

Choose a reason for hiding this comment

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

I think it looks better now with the 4px!

const getStyles = stylesFactory((theme: GrafanaTheme2, size, variant: IconButtonVariant) => {
// overall size of the IconButton on hover
// the value 8 originates from 2*4px and letting the IconSize generally decide on the hoverSize
const hoverSize = getSvgSize(size) + 8;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should make it use the theme here, so 2 * theme.spacing(0.5)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately theme.spacing() is returning a string including 'px'.
I could do something like parseInt(theme.spacing(0.5).substring(0)) but this is cumbersome. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh thats true... We could also use theme.spacing.gridSize which returns 8? And keep this in mind when we do spacing tokens

Copy link
Contributor Author

@L-M-K-B L-M-K-B May 12, 2023

Choose a reason for hiding this comment

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

I changed it to theme.spacing.gridSize, modified the related comment in the code and added a reminder to the related epic for spacing tokens.

Copy link
Contributor

@JoaoSilvaGrafana JoaoSilvaGrafana left a comment

Choose a reason for hiding this comment

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

Lgtm! 🙌

@L-M-K-B L-M-K-B merged commit e7dc357 into main May 15, 2023
15 checks passed
@L-M-K-B L-M-K-B deleted the laura/unify-IconButton-styling-with-Button branch May 15, 2023 11:57
ryantxu pushed a commit that referenced this pull request May 16, 2023
* refactor: remove unnecessary styling and adjust to button styling

* refactor: improve story

* refactor: use new default styling for border radius

* refactor: add missing pseudo classes and clean up

* refactor: repair disabled styling and add to story

* refactor: clean up and apply styles defined in figma

* refactor: set hover background in a pseudo-element

* refactor: unify large sizes

* refactor: add information for further use

* refactor: add comment

* refactor: comments and clean up import

* refactor: add changes after code review

* refactor: replace some bad example code in documentation

* refactor: update comment

Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>

* refactor: add changes requested in review

* refactor: move deprecation warning

* refactor: replace padding

* refactor: remove local styling

* refactor: create separate stories for different examples

* refactor: change style of story

* refactor: replace absolute value by variable

* Update toggles_gen.go

---------

Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
@zerok zerok modified the milestones: 9.5.x, 10.1.x Jun 29, 2023
@ricky-undeadcoders ricky-undeadcoders modified the milestones: 10.1.x, 10.1.0 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/backend area/frontend no-backport Skip backport of PR saga design system Issues related to the work of the Saga Design System
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Adjust styling in IconButton to Button
6 participants