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

fix(design system): font size inconsistencies with % and em units #30040

Merged

Conversation

valentinogiardino
Copy link
Contributor

@valentinogiardino valentinogiardino commented Sep 17, 2024

Proposed Changes

  • replace font-size in % per variables in .scss files
  • replace font-size in em per variables in .scss files

Additional Info

This PR addresses inconsistencies in font sizes caused by the use of % and em values. It focuses exclusively on .scss files, ensuring that all font sizes are now defined using standard variables.

Font sizes within HTML tags will be handled in a separate ticket if necessary. However, this PR includes fixes for two inline font sizes to resolve an IQA report.

Font size variables

Variable px rem
font-size-xxxl 32 2
font-size-xxl 28 1.75
font-size-xl 24 1.5
font-size-lg 20 1.25
font-size-lmd 16 1
font-size-md 14 0.875
font-size-sm 12 0.75
font-size-xs 10 0.625

Regex Used

  • Regex for %: font-size\s*:\s*\d*\.?\d+%
  • Regex for em: font-size\s*:\s*\d*\.?\d+em

Table for % replacement

font-size (%) Value base 14px Value base 16px Variable Variable Size (px) Variable Size (rem)
60 8.4 9.6 font-size-xs 10 0.625
77 10.78 12.32 font-size-xs 10 0.625
80 11.2 12.8 font-size-sm 12 0.75
85 11.9 13.6 font-size-sm 12 0.75
88 12.32 14.08 font-size-sm 12 0.75
90 12.6 14.4 font-size-sm 12 0.75
93 13.02 14.88 font-size-md 14 0.875
100 14 16 font-size-md 14 0.875
108 15.12 17.28 font-size-lmd 16 1
131 18.34 20.96 font-size-lg 20 1.25
138.5 19.39 22.16 font-size-lg 20 1.25
174 24.36 27.84 font-size-xl 24 1.5

Table for em replacement

em Value 14 Value 16
0.7 9.8 11.2
0.8 11.2 12.8
0.916 12.824 14.656
1 14 16
1.1667 16.3338 18.6672
1.2 16.8 19.2
1.25 17.5 20
1.33 18.62 21.28
1.5 21 24
2 28 32
3 42 48
4 56 64
5 70 80

Considerations taken:

dot-edit-page-nav.component.scss

.edit-page-nav__item {
    align-items: center;
    color: $color-palette-gray-800;
    display: flex;
    flex-direction: column;
    font-size: $font-size-xs;
    height: $nav-size;
    justify-content: center;
    text-decoration: none;
    text-transform: uppercase;
    transition: background-color $basic-speed ease-in;

    dot-icon {
        margin-bottom: $spacing-1;
    }

    &:hover {
        background-color: $color-palette-gray-200;
    }

    & > .fa {
        font-size: 1.25em;
        margin-bottom: 8px;
    }
}
  • .edit-page-nav__item font-size = 10px
  • & > .fa font-size = 1.25 * 10px = 12.5px
  • Replace with $font-size-sm = 12px

rule-engine.scss

.cw-filter-links {
    padding: $spacing-1;
    font-size: 0.8em;
    color: $foreground-disabled;

    span:first-child {
        padding: 0 4px 0 0;
    }

    span {
        padding: 0 4px;
    }
}

  • It was taking a base of 16px, so 0.8 * 16px = 12.8px
  • Replace with $font-size-sm = 12px

Screenshots

Original Updated
image image
image image
image image
image image

This PR fixes: #28724

This PR fixes: #28724

@zJaaal zJaaal changed the title chore(design system): fix font size inconsistencies with % and em units fix(design system): font size inconsistencies with % and em units Sep 17, 2024
Copy link

@valentinogiardino valentinogiardino added this pull request to the merge queue Sep 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 18, 2024
@valentinogiardino valentinogiardino added this pull request to the merge queue Sep 18, 2024
Merged via the queue into master with commit fd09776 Sep 18, 2024
34 checks passed
@valentinogiardino valentinogiardino deleted the issue-28724-fix-percentage-font-size-inconsistencies branch September 18, 2024 15:34
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.

UI: Update Base Font Size to 14px
5 participants