-
Notifications
You must be signed in to change notification settings - Fork 45
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
Replace TailwindCSS with Protocol and SCSS for styling #312
Conversation
1b715e3
to
5e8a4c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
My main feedback at this point is that I think some files shouldn't be copied over into the repo. In particular, I believe we should have everything we need (after running npm install
) in node_modules/@mozilla-protocol
. For the fonts, I believe we should be able to get rollup to copy them over from there into public/
.
Let me know if I'm missing something.
.storybook/main.js
Outdated
style: "scss", | ||
}, | ||
scss: { | ||
prependData: `@import 'src/scss/protocol/includes/_lib.scss';`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prependData: `@import 'src/scss/protocol/includes/_lib.scss';`, | |
prependData: `@import 'node_modules/@mozilla-protocol/core/protocol/css/includes/_lib.scss/scss/protocol/includes/_lib.scss';`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type scale, which needed to be changed from the default "standard" to "condensed", is defined in /includes/lib, which then gets the value for sizing from /includes/themes. I could just directly update this in node_modules/@mozilla-protocol
, but since node_modules
is gitignored, should I remove all the copied scss files, make the edit directly in the package, and un-gitignore node_modules/@mozilla-protocol
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, no definitely don't un-gitignore anything in node_modules/*
! That's meant to be installed dynamically at build time.
I think it would be better if we copied as little as possible from protocol into this repository, and reuse as much as possible as-is from what's installed in node_modules/
. That way we can just upgrade the protocol dependency as we go to gain new features and fixes as they come in, with hopefully a minimal number of changes inside this repository.
However, I admit that I've never done anything like this before (integrating a sass library into a repository) so there might be something I'm missing. I wonder if @craigcook might be able to give us some guidance on how best to handle this (whether that be copying parts of protocol into glean dictionary, or something else...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah right now only what's needed is copied over, which is the /base folder and a couple files from /components. The reason why the number of migrated files is big is because I can't just pick and choose the component files, I have to also copy the dependencies which are the scss variables and mixins in /includes
. Not sure if it's necessary, but I did add a README that explains the process to minimize confusion for other contributors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I see a reason you couldn't copy the whole Protocol framework into your project rather than referencing node_modules
directly, though I'm not sure how you'd actually do the copying in your particular setup (I've only done it with Gulp). Since you seem to be copying over some of it already you might as well get whole thing.
And because you're now compiling Sass yourself you can definitely pick-and-choose specific components at the compile step. The protocol-components.css
file is only provided for use if you're not compiling your own Sass, but it ends up being a huge file with EVERY component so it will always be more than you need. You don't need it at all if you're compiling yourself, just @import
the components you're actually using.
What we've done on other sites is copy Protocol from node_modules
into some local build folder and all our own SCSS is in a local scss
folder (or whatever you want to name it). The local SCSS can reference the local copy of Protocol files, and any customization or extensions we need to make to it are only done in our own SCSS (relying on specificity or the cascade to override the original Protocol styling). Definitely don't change any of the Protocol source files since any changes would just be overwritten next time you copy it.
You can also configure the brand theme and type scale in your local SCSS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we've done on other sites is copy Protocol from
node_modules
into some local build folder and all our own SCSS is in a localscss
folder (or whatever you want to name it). The local SCSS can reference the local copy of Protocol files, and any customization or extensions we need to make to it are only done in our own SCSS (relying on specificity or the cascade to override the original Protocol styling). Definitely don't change any of the Protocol source files since any changes would just be overwritten next time you copy it.
Is there any reason you'd recommend copying protocol into the project and checking it in, vs. just referencing it via node_modules
? The latter feels a little more elegant to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason you'd recommend copying protocol into the project and checking it in, vs. just referencing it via
node_modules
? The latter feels a little more elegant to me.
I suppose not, other than shortening the paths on your imports. I just meant to say you can copy it without hurting anything as long as you're not modifying anything.
That's just what we've done on other sites like bedrock or kitsune, which admittedly have a lot more stuff happening during the build process so there might be performance advantages to a local copy in those cases that might not apply to you. And we only copy it into a local build folder; the copy isn't committed to git.
Some things you will want to copy and commit, such as the fonts, icons, and any scripts you're using from Protocol. Anything that needs to be served to the client, but you could do that manually. All the Protocol SCSS could stay in node_modules
if that's better for you.
Was playing around with the site a bit this afternoon. I think the styling mostly looks really good. There's just two things that stick out:
|
The reduction in font size was due to the change in type scale to "condensed". If your preference is go back to the standard scale, and the only place that we want condensed typography is the h1 tags, would it be better that we go with your original idea of creating a separate component for it? This will also eliminate the need for theme customization (for now) and let us directly import from |
* Use Protocol styling for footer * Remove extra class name * Update footer license info
ddc0ecf
to
08ed0fc
Compare
08ed0fc
to
50f69fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking quite excellent, thank you @Iinh! Two items:
- I think we can get around needing to import the fonts into
public/
by adding the following symbolic links:
node_modules/@mozilla-protocol/core/protocol/img -> public/img
node_modules/@mozilla-protocol/core/protocol/fonts -> public/fonts
Can you give that a try? You should be able to make the links like so from the root directory:
ln -s node_modules/@mozilla-protocol/core/protocol/img public/img
(then just add them to the PR)
- It seems like storybook building is timing out on netlify, do you have any idea why? I turned it off for now, since the last build took 20 minutes (!) Here's a snapshot of the log, which was 250k+ lines long: https://gist.github.com/wlach/bb799b808500e8ddd9c390907a143ddb
I am personally ok with fixing the second item later (since I only recently added the storybook deploy to the netlify deploy preview, and wasn't really depending on it) but if it's easy to figure out...
d016404
to
a853b8c
Compare
Because we imported the whole Protocol package but are only using some of it, there's a lot of unused CSS selectors, and My initial approach to solve this (this commit) was to find a way to remove the unused CSS selectors using Since what's causing the gridlock is the 250k+ lines of warning in Storybook, my next approach was to turn off these warnings completely in the Other than that, I think I've addressed all of your requested changes. Let me know what you think @wlach. |
a853b8c
to
1e8b140
Compare
Great stuff @Iinh, thanks for such a thorough investigation. I just tried re-enabling the storybook build in netlify, and it now completes in a very reasonable 2 minutes and 18 seconds. 🚀 This seems like a very reasonable approach, I have some minor extra comments but this is looking 99% of the way done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small things before we land (in addition to the review comments). Thanks, as always, for your patience and persistence:
npm run dev
doesn't seem to work for me anymore, I'm getting a similar error to the one you were getting a few days ago: https://gist.github.com/wlach/8c7fc5abd046537f1d7348bfd8d55203- On reflection, I think we probably ought to use the colored Glean logo, if it looks at all reasonable-- I think it's probably more familiar to people, and more consistent with what's in the Glean documentation, etc. I was going to test this out myself, but got stuck on (1).
1e8b140
to
e89a6bb
Compare
I only get this error if I compile SCSS with
Done! I actually like this header better. Thank you for suggesting this improvement. vs One last thing, I was trying to remove the symbolic links created, but I'm not very familiar with this so could you help check if the links have been removed? Thank you! @wlach |
Just to be sure, I tried this with a fresh checkout on your branch and am still getting the same error. Are you sure you checked everything in? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing, I was trying to remove the symbolic links created, but I'm not very familiar with this so could you help check if the links have been removed? Thank you! @wlach
It looks like the links have been removed, but the files are still in your commit. You probably want to git rm -r public/fonts public/img
and then make another commit.
Aside from that, just one more question. 😄
e171311
to
1a69e06
Compare
1a69e06
to
15b5df4
Compare
This PR was 💯 -- congrats @Iinh! 🎉 |
@wlach Thank you 😭 Filing a couple follow up issues from our discussion in this PR. |
Continuation from the work started in PR#294 to transition to Protocol from Tailwindcss.
Since the goal was to remove Tailwind, my focus was less on making sure the transformation looks pixel perfect. There are sections where styling still looks awkward, I'd appreciate the feedback on this front.
Work to be done in follow up PRs:
Pull Request checklist
fixes, if applicable)