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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align accordion's icon with heading #4424

Merged
merged 3 commits into from
Apr 22, 2022

Conversation

andesol
Copy link
Contributor

@andesol andesol commented Apr 20, 2022

Done

- Add a media query to change the alignment of the icon when next to a heading, so we use a different line-height to calculate the icon's position depending on the screen size.

Update the styling of the accordion.

Fixes #4418

QA

Check if PR is ready for release

If this PR contains Vanilla SCSS code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 馃巵, Breaking Change 馃挘, Bug 馃悰, Documentation 馃摑, Maintenance 馃敤.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention:
    • if CSS class names are not changed it can be bugfix relesase (x.x.X)
    • if CSS class names are changed/added/removed it should be minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) should be listed on the what's new page.
  • Documentation side navigation should be updated with the relevant labels.

Screenshots

[if relevant, include a screenshot or screen capture]

@webteam-app
Copy link

Demo starting at https://vanilla-framework-4424.demos.haus

@andesol
Copy link
Contributor Author

andesol commented Apr 21, 2022

I updated the styling trying to follow what @lyubomir-popov shared yesterday. Now the icon's alignment is done from the baseline and we don't need media-queries.

image

Side effect 1: since the icon is part of the "flow" now (previously it was position: absolute), the text in a h2 is slightly missaligned (due to the icon being a bit bigger and pushing to the right). I don't know if having different headings in the same accordion is a real use-case.

Side effect 2: since icon size scales with font-size, the icon next to an h2 is slightly bigger on large screen but slightly smaller than the rest in small screens. I don't know if that's to be expected, but it happens here as well: https://vanillaframework.io/docs/examples/utilities/font-metrics

$icon-top-position: calc(#{$table-cell-vertical-padding + (map-get($line-heights, h4) - $icon-size) * 0.5});
top: $icon-top-position;
h4.p-accordion__heading > .p-accordion__tab::before {
vertical-align: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
vertical-align: 0;

Why is this here? It undoes the font metrics calculations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed it was an exception to align the icon to the heading. It is used in the font metrics example and defined here: https://github.com/canonical-web-and-design/vanilla-framework/blob/main/scss/_patterns_icons.scss#L62

Copy link
Contributor

Choose a reason for hiding this comment

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

@lyubomir-popov

current (with vertical-align: 0):

Screenshot 2022-04-21 at 16 43 57

without vertical-align 0:

Screenshot 2022-04-21 at 16 44 53

@lyubomir-popov
Copy link
Contributor

lyubomir-popov commented Apr 22, 2022

@bartaz it tries to align with the top of lowercase letters - known as x-height. It might need a bit of finessing, but it shouldn't just be reset to 0 IMO.

@bartaz
Copy link
Contributor

bartaz commented Apr 22, 2022

Created #4437 for further adjustments. We can merge this as it is.

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

Successfully merging this pull request may close these issues.

Misaligned accordion icons
4 participants