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

Line height reduction #856

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Line height reduction #856

wants to merge 21 commits into from

Conversation

Heydon
Copy link
Contributor

@Heydon Heydon commented Jan 3, 2023

Reduction of line-height values across brands.

See #789

@Heydon Heydon requested a review from sturobson January 3, 2023 13:34
@Heydon
Copy link
Contributor Author

Heydon commented Jan 3, 2023

I've tidied up and normalized stuff as much as I think I can get away with. The only thing I've left that seems very wrong is the following, which represents a massive line-height but there may be a reason for that. There's no demo available for the package to check.

.c-header__journal-title {
	@include media-query('md') {
		font-size: 1.375rem;
	}

	@include media-query('lg') {
		font-size: 1.6875rem;
	}

	font-family: $context--font-family-serif;
	line-height: 2.875rem;
	font-size: .9375rem;
	color: color('black');
}

@sturobson
Copy link
Contributor

sturobson commented Jan 5, 2023

although Sass compiles this to put the media queries after the initial declaration - I find it easier to understand if it's also written this way (see below).

So when authoring Sass it's: 'here's the general code and then if the browser is this big, do this' rather than 'if the browser is this big, do this, then do all this other stuff'

.c-header__journal-title {
	font-family: $context--font-family-serif;
	line-height: 2.875rem;
	font-size: .9375rem;
	color: color('black');

	@include media-query('md') {
		font-size: 1.375rem;
	}

	@include media-query('lg') {
		font-size: 1.6875rem;
	}
}

I've had a look in the front-end playbook and I couldn't spot guidance on this.

@sturobson
Copy link
Contributor

I won't mention my favouring CSS written in alphabetical order - I'll leave that to another day.

@alexkilgour
Copy link
Collaborator

There is a lot going on here. Seems to include the publishing of a new component global-product?
Can the update to context be a separate PR than adding/updating components to make it easier to follow?

The design token updates are very noisy as well, it's very hard to tell what is going on. I'm not sure what is related to the line-height change and what isn't

@@ -1,5 +1,10 @@
# History

## 31.1.0 (2023-01-09)
* BREAKING:
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is breaking, should it not be version 32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexkilgour True, I forgot to sync that when I made it breaking.

$t-icon-checkbox-checked-stroke: #ffffff;
Copy link
Collaborator

Choose a reason for hiding this comment

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

A lot of file seem to have this !default removed. Is this related at all to the line-height change or is this from something else and the tokens were not updated?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's related, when Sass meets two !defaults for the same variable - it takes the first one, rather than the second. This meant that the overriding variable for the nature theme wasn't coming through.

Me adding !default was a pre-cursor for the single release but I got it wrong here.

Sadly I had added !default to pretty much every literal or alias token so we decided to remove them all, and 'circle back' to their usage later.

@@ -1,6 +1,6 @@

// Do not edit directly
// Generated on Fri, 21 Oct 2022 11:11:43 GMT
// Generated on Mon, 09 Jan 2023 13:28:25 GMT
Copy link
Collaborator

@alexkilgour alexkilgour Jan 9, 2023

Choose a reason for hiding this comment

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

There aren't actually any changes to this file, I think we need a way to not generate this line when the file doesn't change as it's extremely noisy

Copy link
Collaborator

Choose a reason for hiding this comment

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

In fact is there any need for this "Generated on" message? Github shows the last changed date

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a way to not generate this

Agreed, I have a task to look at seeing how we can 'test' what has changed and get Style Dictionary to act accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact is there any need for this "Generated on" message?

I guess not - as the 'do not edit directly' message is there.

Github shows the last changed date

We're assuming folks would check this‽ Although tools like VSCode are quite adept at showing this information (even line-by-line).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think what we need is these files to be auto-generated as part of the package management, then there is no need fo anyone to check anything

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'd love some form of automation for this so it's not "yet another npm script" that someone needs to run. It not being on npmjs at the moment is probably scuppering possibilities.

🤞🏼 the single release 🤞🏼

@jon-stevens
Copy link
Contributor

jon-stevens commented Jan 10, 2023

although Sass compiles this to put the media queries after the initial declaration - I find it easier to understand if it's also written that way.

So when authoring Sass it's: 'here's the general code and then if the browser is this big, do this' rather than 'if the browser is this big, do this, then do all this other stuff'

.c-header__journal-title {
	font-family: $context--font-family-serif;
	line-height: 2.875rem;
	font-size: .9375rem;
	color: color('black');

	@include media-query('md') {
		font-size: 1.375rem;
	}

	@include media-query('lg') {
		font-size: 1.6875rem;
	}
}

I've had a look in the front-end playbook and I couldn't spot guidance on this.

I think it makes more sense as you suggested. I seem to remember sass lint 'recommending' putting the media queries first. But I've just tested it in one of my local projects and no complaint. I may have dreamt it or changed linting config since..

@Heydon
Copy link
Contributor Author

Heydon commented Jan 10, 2023

There is a lot going on here. Seems to include the publishing of a new component global-product?
Can the update to context be a separate PR than adding/updating components to make it easier to follow?

@alexkilgour That, naturally, shouldn't be there at all. My editor seems to like dropping one's branch's changes into another's. I'll unstage all that.

@Heydon
Copy link
Contributor Author

Heydon commented Jan 10, 2023

although Sass compiles this to put the media queries after the initial declaration - I find it easier to understand if it's also written that way.

@jon-stevens Would you say this is relevant to this PR? I haven't created/touched those media queries.

@dsmr
Copy link
Contributor

dsmr commented Jan 10, 2023

Hi Heydon

Me and Ben C have had a go at looking at the changes on your branch with npm link in our Oscar codebase. I think it is unrelated to the changes in this PR but we wanted to let you know that there is an issue in Brand Context that is not letting our builds complete:

Message:
    ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss
Error: Undefined variable.
   ╷
13 │     margin-block-start: $tokens--typography-block-spacing-medium;
   │                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss 13:22  @import
  ../../node_modules/@springernature/brand-context/nature/scss/enhanced.scss 17:9                 @import
  css/homepage/homepage-150.scss 1:9                                                              root stylesheet
Details:
    formatted: Error: Undefined variable.
   ╷
13 │     margin-block-start: $tokens--typography-block-spacing-medium;
   │                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss 13:22  @import
  ../../node_modules/@springernature/brand-context/nature/scss/enhanced.scss 17:9                 @import
  css/homepage/homepage-150.scss 1:9                                                              root stylesheet
    line: 13
    column: 22
    file: /Users/drt9804/IdeaProjects/oscar/lib/frontend/node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss
    status: 1
    messageFormatted: ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss
Error: Undefined variable.
   ╷
13 │     margin-block-start: $tokens--typography-block-spacing-medium;
   │                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss 13:22  @import
  ../../node_modules/@springernature/brand-context/nature/scss/enhanced.scss 17:9                 @import
  css/homepage/homepage-150.scss 1:9                                                              root stylesheet
    messageOriginal: Undefined variable.
   ╷
13 │     margin-block-start: $tokens--typography-block-spacing-medium;
   │                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss 13:22  @import
  ../../node_modules/@springernature/brand-context/nature/scss/enhanced.scss 17:9                 @import
  css/homepage/homepage-150.scss 1:9                                                              root stylesheet
    relativePath: ../../node_modules/@springernature/brand-context/default/scss/40-base/block-spacing.scss
    domainEmitter: [object Object]
    domainThrown: false

It appears as though the block-spacing.scss code in default brand context references a variable that doesn't exist: $tokens--typography-block-spacing-medium. We have run all of the scripts in the design-tokens package that generate Sass variables but this variable still does not exist.

For now we can manually override the code in block-spacing.scss to allow our frontend build to complete, which will allow us to test your changes on our sites locally. But we thought we would let you know as I guess that issue will need to be addressed separately to this PR.

Thanks!

@sturobson
Copy link
Contributor

sturobson commented Jan 10, 2023

@dsmr

It appears as though the block-spacing.scss code in default brand context references a variable that doesn't exist: $tokens--typography-block-spacing-medium

$tokens--typography-block-spacing-medium was changed to $t-typography-block-spacing-medium (all generated tokens were changed to a shorthand t over tokens.

Taking a look at the block-spacing.scss file for the default brand it seems we missed renaming a couple of instances.

A hotfix/patch is incoming which should sort this out.

Sorry for the bother

EDIT

I have created the relevant PR that moves towards fixing any issues where we have $tokens-- which should be $t-.

EDIT EDIT

@dsmr this was resolved in #861 and is now released in v31.0.1 of the brand-context 🙏🏼

@sturobson
Copy link
Contributor

Would you say this is relevant to this PR? I haven't created/touched those media queries.

@Heydon as I made the suggestion and it doesn't effect the PR we can ignore it for the interim I reckon.

@sturobson sturobson requested review from foxintherain and removed request for foxintherain January 11, 2023 09:48
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.

5 participants