Skip to content

Migrate from Sass to vanilla CSS with native nesting and custom properties#43

Merged
davish merged 6 commits intomainfrom
devin/1772412659-sass-to-vanilla-css
Apr 12, 2026
Merged

Migrate from Sass to vanilla CSS with native nesting and custom properties#43
davish merged 6 commits intomainfrom
devin/1772412659-sass-to-vanilla-css

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 2, 2026

Migrate from Sass to vanilla CSS

Summary

Replaces all Sass/SCSS usage with vanilla CSS, leveraging native CSS nesting and CSS custom properties. The sass dev dependency is removed entirely.

New files:

  • src/variables.css — all Sass $variables converted to CSS custom properties on :root, including --font-serif / --font-sans-serif with a @media print override
  • src/tufte.css — vanilla CSS rewrite of tufte.scss using native nesting
  • src/custom-media.css@custom-media breakpoint aliases (--phone, --tablet, --desktop, --small-desktop)
  • postcss.config.mjs — configures postcss-custom-media and @csstools/postcss-global-data to resolve @custom-media at build time

Across ~40+ .astro files:

  • <style lang="scss"><style>
  • Removed all @import "/src/variables.scss"
  • $varvar(--var)
  • @include serif/sans-seriffont-family: var(--font-serif/--font-sans-serif)
  • @include dimmedopacity: var(--dimmed-opacity) (defined as --dimmed-opacity: 0.6 in variables.css)
  • @media #{$media-size-phone}@media (--phone) (and --tablet, --desktop, --small-desktop for other breakpoints) — resolved to concrete values at build time by postcss-custom-media
  • rgba($accent-color, 0.2)color-mix(in srgb, var(--accent-color) 20%, transparent)
  • Flattened BEM-style &-item patterns to top-level selectors (e.g., .pagination &-item.pagination-item)

Build verified: npm run build passes with no errors. Netlify deploy preview is live.

Updates since last revision

  • Replaced hardcoded opacity: 0.6 with var(--dimmed-opacity) CSS variable — Added --dimmed-opacity: 0.6 to variables.css and replaced all 13 hardcoded opacity: 0.6 usages across 11 .astro files with var(--dimmed-opacity). This mirrors the old Sass @include dimmed mixin pattern with a single source of truth.
  • Factored out media query breakpoints with @custom-media — Added postcss-custom-media and @csstools/postcss-global-data as devDependencies. All hardcoded media query strings (e.g., @media (max-width: 684px)) are now @custom-media references (e.g., @media (--phone)), defined once in src/custom-media.css. PostCSS resolves these at build time so the output CSS is identical to before.

Previous updates

  • Fixed :global() inside native CSS nesting — Astro's scoped CSS processor does not handle :global() directives when they appear inside native CSS nesting blocks (with Sass, nesting was flattened first, then Astro processed :global()). This caused the h2 subtitle on the reading page ("Goodreads at home") to render unstyled (bold/large) instead of the intended font-weight: 400; font-size: 1rem. Fixed by flattening :global() selectors to top-level in Intro.astro and Hero.astro.
  • Updated pnpm-lock.yaml — Netlify uses pnpm with frozen-lockfile, so the lockfile needed updating to reflect the sass removal.

Review & Testing Checklist for Human

⚠️ Risk level: GREEN — Straightforward variable extraction with no behavioral change

  • Visual spot-check on deploy preview — Confirm dimmed elements (dates, metadata, image captions) still appear at the same opacity across homepage, blog posts, reading list, resume, and TIL pages.

Notes

  • The opacity: 0.65 in src/components/og/og_image.tsx was intentionally left as-is since it uses a different value and is for OG image generation, not the dimmed pattern.
  • The opacity: 0.6 in src/styles.js is inside a comment block (old Sass reference) and was left unchanged.

Link to Devin session: https://app.devin.ai/sessions/e973f791f04f40fda3ee828b4e1ad9f8
Requested by: @davish


Open with Devin

- Replace variables.scss with variables.css using CSS custom properties
- Replace tufte.scss with tufte.css using native CSS nesting
- Convert all 40+ Astro component style blocks from SCSS to vanilla CSS
- Replace Sass variables () with CSS custom properties (var(--var))
- Replace @include serif/sans-serif mixins with font-family: var(--font-serif/--font-sans-serif)
- Replace @include dimmed with opacity: 0.6
- Replace Sass media query interpolation with inline media query values
- Replace rgba($color, val) with color-mix() for CSS variable compatibility
- Remove sass dependency from package.json

Co-Authored-By: Davis Haupt <davis@davishaupt.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 2, 2026

Deploy Preview for davish-site ready!

Name Link
🔨 Latest commit 3bc0c4d
🔍 Latest deploy log https://app.netlify.com/projects/davish-site/deploys/69dc0ae3d02fc40008bf8c9b
😎 Deploy Preview https://deploy-preview-43--davish-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Co-Authored-By: Davis Haupt <davis@davishaupt.com>
Copy link
Copy Markdown
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 6 additional findings.

Open in Devin Review

devin-ai-integration bot and others added 4 commits March 2, 2026 01:17
… Astro processing

Co-Authored-By: Davis Haupt <davis@davishaupt.com>
…tom-media

- Add postcss-custom-media and @csstools/postcss-global-data as devDependencies
- Define @Custom-Media aliases in src/custom-media.css (--phone, --tablet, --desktop, --small-desktop)
- Replace all hardcoded media query strings with @Custom-Media references across 17 files
- PostCSS resolves the aliases at build time, so output CSS is identical

Co-Authored-By: Davis Haupt <davis@davishaupt.com>
Co-Authored-By: Davis Haupt <davis@davishaupt.com>
Co-Authored-By: Davis Haupt <davis@davishaupt.com>
@davish davish merged commit d033685 into main Apr 12, 2026
4 checks passed
@davish davish deleted the devin/1772412659-sass-to-vanilla-css branch April 12, 2026 21:20
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.

1 participant