stitches icon indicating copy to clipboard operation
stitches copied to clipboard

stitches does not pull through filter variables defined in theme

Open lockhaty opened this issue 4 years ago • 1 comments

Bug report

Describe the bug

When attempting to define a custom variable for a filter using themes, the css variable is created correctly but you cannot use the stitches variable in your code. It does not work

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

import { createStitches } from "@stitches/react";

export const { theme, styled, createTheme } = createStitches({
  colors: {
    primaryText: "#000",
    background: "#fff"
  },
  theme: {
    filters: {
      datePickerCalendarIconFilter: "invert(0)"
    }
  }
});

export const darkTheme = createTheme({
  colors: {
    primaryText: "#fff",
    hiContrast: "hsl(206,2%,93%)",
    gray100: "hsl(206,8%,12%)",
    background: "$gray100"
  },
  filters: {
    datePickerCalendarIconFilter: "invert(1)"
  }
});

const Input = styled("input", {
  border: "1px solid lightgray",
  color: "$hiContrast",
  "&&::-webkit-calendar-picker-indicator": {
    filter: "$datePickerCalendarIconFilter"
  }
});

Link to sandbox: https://codesandbox.io/s/spring-meadow-5rxzd?file=/src/App.js

Expected behavior

The calendar icon in the input box should be white when using the dark theme and black when using the light theme. The snippet below provides the expected behaviour using css variables:

const Input = styled("input", {
  border: "1px solid lightgray",
  color: "$hiContrast",
  "&&::-webkit-calendar-picker-indicator": {
    filter: "var(--filters-datePickerCalendarIconFilter)"
  }
});

Screenshots

If applicable, add screenshots to help explain your problem. dark light

System information

  • OS: [e.g. macOS, Windows]: Ubuntu 20.04
  • Browser (if applies) [e.g. chrome, safari] : chrome
  • Version of Stitches: [e.g. 0.0.2]: 1.0.0
  • Version of Node.js: [e.g. 10.10.0]: v14.17.0

Additional context

Add any other context about the problem here.

lockhaty avatar Sep 20 '21 07:09 lockhaty

You need to tell Stitches about the mapping of CSS Properties to Theme Scale: https://stitches.dev/docs/api#defaultthememap

Updated sandbox: https://codesandbox.io/s/morning-http-vb3wz?file=/src/stitches.js:131-195

peduarte avatar Sep 20 '21 09:09 peduarte