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.

Do not add CSS shorthands in runtime

See original GitHub issue

We don’t allow to use CSS shorthands: https://github.com/microsoft/griffel/blob/b4c7acc77e5e7b4883ca32249418a3d93dc43e77/packages/core/src/types.ts#L5-L49

We should implement something in runtime to prevent adding rules with shorthands. Currently shorthands usage produces TS errors, but rules are still inserted to DOM. That creates confusion and feeling that something is wrong with typings.

  • This should be based on typings that we have
  • The runtime check should be development (non-production) to avoid contributions to bundle size

Expected behavior

import { makeStyles } from "@griffel/react";

const useClasses = makeStyles({
  root: {
    // ⏭ "background" is not inserted to DOM & a warning is produced (currently inserted)
    // 💥 produces TS error (already done)
    background: "red"
  }
});

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
layershiftercommented, Apr 20, 2022

Maybe your document seems like didn’t mention that. and I don’t know why I can’t scroll down your docs page

This looks really strange. Can you please share details about your environment? OS, browser?

1reaction
layershiftercommented, Apr 19, 2022

@Aloento you find out more details in that comment, https://github.com/microsoft/griffel/issues/30#issuecomment-1045959297. If you have questions, let’s continue there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Beginner's Guide to CSS Shorthand - HubSpot Blog
Not all CSS properties can be written in shorthand, but some important ones can. In this post, we'll define what CSS shorthand is...
Read more >
Leaving certain values unchanged when using CSS ...
You'll have to stick with assigning margin-top and margin-bottom respectively. A shorthand property always changes the values of all its ...
Read more >
The Shorthand-Longhand Problem in Atomic CSS
The first and most obvious solution is to just not use shorthand properties at all. Doing that, we completely eliminate the problem. The...
Read more >
Decompose shorthand/compound styles to their constituent ...
I have some buttons in a nav with a default padding value: var style = { padding: '10px 20px' } When selected, I...
Read more >
Shorthand properties - CSS: Cascading Style Sheets | MDN
Shorthand properties are CSS properties that let you set the values of multiple other CSS properties simultaneously.
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