Skip to content

refactor: Remove Deprecated Bourbon/Neat from CSS stack#17160

Merged
miketheman merged 15 commits intopypi:mainfrom
miketheman:miketheman/clean-up-css-stack
Nov 25, 2024
Merged

refactor: Remove Deprecated Bourbon/Neat from CSS stack#17160
miketheman merged 15 commits intopypi:mainfrom
miketheman:miketheman/clean-up-css-stack

Conversation

@miketheman
Copy link
Copy Markdown
Member

@miketheman miketheman commented Nov 25, 2024

Bourbon 4.2.5 was released on Sep 17, 2015.
Neat 1.7.2 was released on Mar 13, 2015.

Warehouse vendored them on Nov 18, 2015 from a design repo, using gulp to handle the build process, replaced since by webpack.

Bourbon and Neat are now both deprecated libraries, with the final Neat release of 4.0.0 on Jul 10, 2019, and the final Bourbon release of 7.3.0 on Jan 23, 2023.

The authors have also helpfully provided a Bourbon replacement guide to native CSS features.

Steps

Here's a list of tasks to get us there:

  • replace neat with native CSS features
  • replace vendored bourbon 4.2.5 with package, reintroducing warnings from chore: handle sass warnings #12742
  • update to most recent bourbon 4.2.x version
  • update to most recent bourbon 4.3.x version, fix issues found
  • update to most recent bourbon 5.x version
  • update to most recent bourbon 6.x version
  • update to most recent and final bourbon 7.x version
  • Replace bourbon functions with native CSS features
    • all-text-inputs
    • margin
    • clearfix - vendored, and deferred for now
    • border-width
    • ellipsis
  • Remove bourbon from the stack
  • Celebrate! 🎉

Bundle Size

Before: 252k uncompressed, 30k gzip, 24k brotli
After: 195k uncompressed, 29k gzip, 23k brotli

The CSS bundle size drops a little, largely due to removing the vendored files with custom license headers - since the rest of bourbon/neat were only used during compile-time, the resulting compiled bundles have the same functionality as before.

Related links

Bourbon's Neat has been deprecated and unmaintained since October 2019.

The usage of Bourbon's `@span-columns` which uses the underlying
functionality from Neat is only used in a couple of places -
specifically the project description page, and the recovery codes pages.

With CSS Grid being widely available, convert usages to create a
`grid-container` mixin to set the column count and desired spacing.

Removing `neat` from the build artifact reduces ~12KB from the bundle.

Refs: thoughtbot/neat@6c76100
Refs: thoughtbot/neat.bourbon.io@fee0b05
Refs: https://developer.mozilla.org/en-US/docs/Web/CSS/grid

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
The differences are minimal, and this sets an upgrade path to get us on
track for potential upgrades and removal.

After installing, using a creative `diff` command:

    diff --ignore-blank-lines --strip-trailing-cr \
        <(find warehouse/static/sass/tools/bourbon/ -type f -exec sed '/\/\*!/,/\*\//d' {} +) \
        <(find node_modules/bourbon/app/assets/stylesheets/ -type f -exec cat {} +)

The only differences found are:

- a header when vendored back in 5db8496
- license headers added in 9370bc5
- spelling fixes in 13c5a7c
- sass warning fixes in a0f3817

Commits following this one will remove the vendored code, and start upgrades to
get us updated, and see about other removals.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Expect Dart Sass warnings to be emitted, as our custom updates have been
reverted.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Last before 5.x release, emits deprecation warnings.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Many of these are being replaced by native CSS functions available at
this time.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Changes the import path slightly, no other changes.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
This is the final release of bourbon, after which we likely want to
replace any usage with native CSS.

Refs: https://thoughtbot.com/blog/you-might-not-need-bourbon

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
The `all-text-inputs*` selector macro from Bourbon does some nice stuff,
replace it with native CSS behavior.

- A better selector that can be overridden more specifically with `:where`
- A mixin for the active/hover styles
- Collapse duplicated selectors

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
It's small enough to vendor safely, until all usages have been reviewed
and updated with better layouts.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
The `card` mixin is already setting the border width properties for tables.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Good-night, sweet prince.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman miketheman added CSS/SCSS requires change to CSS/SCSS files dependencies Pull requests that update a dependency file labels Nov 25, 2024
@miketheman miketheman requested a review from a team as a code owner November 25, 2024 13:41
@miketheman
Copy link
Copy Markdown
Member Author

Any open TODOs inline are considered beyond the scope of this change, since they were too extensive to try and get done with this already-large PR.

Copy link
Copy Markdown
Member

@ewdurbin ewdurbin left a comment

Choose a reason for hiding this comment

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

Reviewed by running locally and viewing. So, quite literally LGTM.

@miketheman miketheman merged commit eb6e6ad into pypi:main Nov 25, 2024
@miketheman miketheman deleted the miketheman/clean-up-css-stack branch November 25, 2024 14:19
miketheman added a commit to miketheman/warehouse that referenced this pull request Dec 6, 2024
`display: grid` needs to be at a parent level, and `col-half` didn't
have a container per se, as the previous implementation was a computed
column width, not part of a CSS Grid.

Fixes pypi#17233
Refs: pypi#17160

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
ewdurbin pushed a commit that referenced this pull request Dec 6, 2024
* fix: create a parent for column grids

`display: grid` needs to be at a parent level, and `col-half` didn't
have a container per se, as the previous implementation was a computed
column width, not part of a CSS Grid.

Fixes #17233
Refs: #17160

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

* make translations

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

---------

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS/SCSS requires change to CSS/SCSS files dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants