question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

core: `background` doesn't want to show up (without any errors)

See original GitHub issue

In the playground, I tried adding this:

import { makeStyles, shorthands } from '@griffel/core';

export default makeStyles({
  root: {
    backgroundColor: 'red',
  },
  foo: {
    background: 'green'
  }
});

Expected: green shows up in the output.

Resulted:

.f3xbvq9 {
  background-color: red;
}

Changing background to backgroundColor fixes it. But this was the first thing I tried, and it failed to update or even show an error message. Would be good to expand shorthand.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dzearingcommented, Apr 28, 2022

I think it’s fine to do that for performance and the css variable nondeterministic reasons, but I think there needs to be feedback to train developers to do the right thing; ideally in the IDE like lint rules which can add red squiggle lines under incorrect syntax with fixers to adjust. In the sandbox, there was no error. It just didn’t work, leaving curious people frustrated and moving on to other solutions.

The ideal would be to “just work” and manage this at runtime, but address performance costs by optimizing at babel transform time. I think that’s possible for expansion; just not for the padding: --var(--padding) scenario where the caller is providing shorthand values intended for shorthand properties. Maybe that could be avoided by providing helpers around defining variables. (Again some kind of linting, or even runtime name checks that get stripped in production.)

0reactions
dzearingcommented, May 3, 2022

I’ve been thinking about it. I think the most ideal would be to do something possibly expensive at runtime, but removable at build time, like:

if (name === 'padding') {
  expandedProps = padding(value)
}

…basically, call the helper to auto expand for the user so they don’t need to apply extra mental cycles on something they’ve used forever.

If you detect the value is a css variable, maybe you could do something special there:


// given this: { padding: '--var(--somePaddingShorthand)' } // 4px 4px 3px

if (name === 'padding') {
  if (isVariable(value)) {
    console.warn(`Using css variables for shorthand values has edge case issues and is discouraged. Use variables for atomic css properties only.`);
  }

Then at transform time, expand things and remove the runtime overhead.

Also consider removing the helpers themselves in retail/transformed output.

I think even if there are ts/lint/console errors about the usage, it’s going to create mental headaches for the dev experience. It’s a fine stopgap but the ideal is “it just works”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forums - CSS - [Solved] Background Image Not Showing
I have the background image saved in the images folder, obviously, as a jpeg. When I go to preview the HTML in Firefox,...
Read more >
How to fix CSS background-image not working | HTML/CSS
If the image isn't showing up, but you aren't getting any 404 errors, go into the code inspector and check the element itself....
Read more >
swift - Background thread Core Data object property changes ...
The thing is we want to do heavy CoreData task on background thread and reflect the changes in UI on foreground(main thread).
Read more >
Troubleshooting Zoom Virtual Background not working
If your virtual background is not showing up when you start a meeting, do the following: Go to Zoom.Us and sign in to...
Read more >
Troubleshooting Zoom Virtual Background Issues - Technipages
Sometimes Zoom may fail to add a virtual background or the green screen may not work properly. Use this troubleshooting guide to fix...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found