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

createTheme, createGlobalTheme: Add support for assigning themes to a layer #1512

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

askoufis
Copy link
Contributor

@askoufis askoufis commented Dec 19, 2024

Original discussion.

This is currently possible in VE using existing APIs (example), however it's not exactly ergonomic, nor is it obvious that this is possible, so first-class support would be nice.

Sprinkles supports layers via an @layer property, so I implemented the same thing for createTheme and createGlobalTheme.

EXAMPLE USAGE:

// themes.css.ts
import { createTheme, createGlobalTheme, layer } from '@vanilla-extract/css';

export const themeLayer = layer();

export const [themeA, vars] = createTheme({
  '@layer': themeLayer,
  color: {
    brand: 'blue'
  },
  font: {
    body: 'arial'
  }
});

export const vars2 = createGlobalTheme(':root', {
  '@layer': themeLayer,
  space: {
    small: '10px',
    large: '20px',
  }
});

Copy link

changeset-bot bot commented Dec 19, 2024

🦋 Changeset detected

Latest commit: 0326d21

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@vanilla-extract/css Minor
@vanilla-extract/integration Patch
@vanilla-extract/rollup-plugin Patch
@vanilla-extract/esbuild-plugin Patch
@vanilla-extract/jest-transform Patch
@vanilla-extract/parcel-transformer Patch
@vanilla-extract/vite-plugin Patch
@vanilla-extract/webpack-plugin Patch
@vanilla-extract/next-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@mattcompiles mattcompiles left a comment

Choose a reason for hiding this comment

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

Nice one bud 🍻 🧁 🎄

@askoufis askoufis merged commit 4abfc0b into master Dec 20, 2024
11 checks passed
@askoufis askoufis deleted the create-theme-in-layer branch December 20, 2024 00:50
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.

2 participants