Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: font.css not auto-generated from spectrum-css #319

Merged
merged 3 commits into from
Dec 2, 2019

Conversation

adixon-adobe
Copy link
Collaborator

Description

Added the @spectrum-css/commons package since we need to source our
fonts.css from 2 file to get what we need. Also updated the generation
script to allow building from multiple source files.

Related Issue

Fixes #308

Motivation and Context

Let's get rid of manual changes needed to update spectrum css.

How Has This Been Tested?

I ran the visual tests locally, and also did some testing on the local doc site (including a bit of manual inspection to make sure the styles I expected to see were there).

I haven't done a deep inspection though, since I'm still not sure how much this affects.

Screenshots (if appropriate):

Types of changes

  • [ x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ x ] I have signed the Adobe Open Source CLA.
  • [ x ] My code follows the code style of this project.
  • [ x ] My change requires a change to the documentation.
  • [ x ] I have updated the documentation accordingly.
  • [ x ] I have read the CONTRIBUTING document.
  • [ x ] I have added tests to cover my changes.
  • [ x ] All new and existing tests passed.

let result = '';

for (const srcPath of srcPaths) {
let data = fs.readFileSync(srcPath, 'utf8');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just did readFileSync here to keep things simple.

// fonts.css (2 sources so a little tricky)
{
const srcPath1 = path.join(typographyPath, 'font.css');
const srcPath2 = path.join(commonsPath, 'fonts.css');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now that I'm looking at the output again, I'll swap these so the variables are defined before they're used...

}

return result;
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

put the guts of processCSS here so I could re-use.

package.json Outdated
@@ -89,6 +89,7 @@
"@open-wc/polyfills-loader": "^0.3.2",
"@open-wc/testing": "^2.3.3",
"@open-wc/testing-karma": "^3.1.24",
"@spectrum-css/commons": "^2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add this to the styles package, rather than at the root.

It might make sense to move some of the scripting there over the course as well, but that's something we can get into later.

Copy link
Contributor

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

Looking good. Couple of nits, and then away we go!

--spectrum-font-fallbacks-mono: monospace;
--spectrum-font-family-ar: myriad-arabic,

/* Not used
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 upstream an issue to get this removed at the Spectrum CSS level?

governing permissions and limitations under the License.
*/

:root {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to look at how we're using this... :root won't work in a element, IIRC, which means it'll need to be updated to :root, :host to work at that level.

Copy link
Contributor

Choose a reason for hiding this comment

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

@adixon-adobe This may be the only note that must be solved before we move forward, but hopefully you have a minute to get into this soon as I'd love to have this updated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed -- I missed this in the conversion. I'm gonna write up a spectrum-css issue and just hard-code this final fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

We process this out in other contexts. .spectrum -> :root, :host...we should probably add that so we can keep up-to-date. It would be great if we could get Spectrum CSS to update, but I'd not bet very much money on it...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, and question, is this a bug in spectrum-css, or something we should be converting?

Copy link
Contributor

Choose a reason for hiding this comment

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

They don't really trade in :host as it's a Shadow DOM selector, so our conversion...until we convince them to only make a web component distribution of their code 🤔 😜

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks -- wasn't clear where things were at there.

}

result = `${license}\n/* stylelint-disable */\n${result}\n/* stylelint-enable */`;
fs.writeFile(dstPath, result, 'utf8');
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope we don't have to edit this again, but can we centralize these two lines (same as 65 and 67) just in case we need to alter the structure of the result in the future?

Westbrook
Westbrook previously approved these changes Dec 2, 2019
Copy link
Contributor

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

LGTM! Very happy to get more static files out of the Spectrum CSS usage workflow. 🥳

@Westbrook
Copy link
Contributor

Oh, the branch looks a little out of date, once you've rebased to maser I can approve again!

Added the @spectrum-css/commons package since we need to source our
fonts.css from 2 file to get what we need. Also updated the generation
script to allow building from multiple source files. Fixes #308
Fix :root selector, move @spectrum-css/commons dependency to styles, and DRY file
writing logic
@adixon-adobe
Copy link
Collaborator Author

Rebased and applied the err -> error change to the refactored code.

Copy link
Contributor

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

Let's do it!

@Westbrook Westbrook merged commit 441bbb7 into master Dec 2, 2019
@Westbrook Westbrook deleted the adixon/308-font-css branch December 2, 2019 19:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some files in the styles package need to be manually kept in sync with SpectrumCSS
2 participants