codyhouse / codyhouse-framework

A lightweight front-end framework for building accessible, bespoke interfaces.
https://codyhouse.co/
MIT License
1.16k stars 172 forks source link

Variable X is undefined and used without a fallback #88

Closed madsfors closed 3 years ago

madsfors commented 3 years ago

When using the gulp script "npm run gulp watch-ie" I get following postcss-css-variables error:

CleanShot 2021-05-12 at 11 03 32@2x

The variables are from the TOC component and haven't been altered in any way.

ghost commented 3 years ago

Same here. Happens even on a completely fresh download of the codyhouse-framework-master.zip when running the sass-ie task. screenshot

sebastiano-guerriero commented 3 years ago

Hi 👋 It's an issue with the postcss-css-variables plugin: if the variables are not defined in the :root, it throws a warning. The variables are defined and work fine (e.g., the --gap-x variable is defined in the .grid class).

madsfors commented 3 years ago

Hi Sebastiano. Thanks for the reply! The variables work as expected (and thus works 👌 in any modern browser), but whenever using the generated style-fallback.css, the styling seems to break. I'm in the (unfortunate) situation that I have to support IE11 so I'm experiencing code that turns out with "undefined" declarations. This is i.e. happening with the lists component. See below:

CleanShot 2021-05-13 at 13 21 31@2x CleanShot 2021-05-13 at 13 22 15@2x

How would you suggest fixing this issue?

sebastiano-guerriero commented 3 years ago

Hi! Moving the custom properties to the :root element should fix the issue:

:root {
  --list-space-y: var(--space-xxs); // vertical gaps
  --list-offset: var(--space-xs);  // sublist horizontal offset
  --list-line-height: var(--body-line-height);  // items line-height
}

I'll give it a test 👍

madsfors commented 3 years ago

It's not really fixing it, unfortunately. The error is gone but the output is not satisfactory:

CleanShot 2021-05-17 at 10 08 33@2x
sebastiano-guerriero commented 3 years ago

We just published a new version of the List component that fixes the IE issues: https://codyhouse.co/ds/components/app/list

madsfors commented 3 years ago

Perfect. Thanks a lot!