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.

[jss] Support @page rules

See original GitHub issue

Currently using a @page rule with JSS causes a warning. It still works fine, maybe it just needs to be added as a simple rule to https://github.com/cssinjs/jss/blob/master/src/plugins/rules.js#L9-L19 ?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
jarekscommented, Oct 1, 2018

@kof are you sure that @page needs to be handled by plugin? After all, it’s part of basic CSS.

If we could just add it to global rules here: https://github.com/cssinjs/jss/blob/9b7daa79aeea23422664a283a2557bb70b19b1b5/packages/jss/src/plugins/rules.js then it would be simple even for me to implement 😃

0reactions
prajun7commented, Sep 14, 2022

I was able to remove the warning by using the GlobalStyles component of MUI. I was using @page to define page size and page margin while printing. I did something like this,

import { GlobalStyles } from '@mui/material';
  const printStyle = {
   ['@media print']: {
     ['@page']: {
       size: 'landscape',
       margin: '2px',
      },
    },
  };

You might not need to use @page inside the @media print because @page is only for printing. Documentation We can use the GlobalStyles in our App container. Like this

    const App: React.FC = () => (
      <>
         <GlobalStyles styles={printStyle} />
         <AppView />
      </>
     );
Read more comments on GitHub >

github_iconTop Results From Across the Web

Enables caching JSS rules
This plugin will cache JSS rules by comparing a reference from the object. It should be used as a first plugin, to bail...
Read more >
Enables functions for dynamic styles - JSS
If you want dynamic behavior for your Style Sheet, you can use functions as a value which return the actual value or a...
Read more >
Objects based styles syntax for declaring Style Sheets - JSS
Objects based styles syntax for declaring Style Sheets · Basic syntax · Media Queries · Keyframes Animation · Fallbacks · Font Face ·...
Read more >
Setting up Content Security Policy with JSS
When loading the initial index page, the Content-Security-Policy header should now ... webpack config const config = { module: { rules: [ {...
Read more >
JSS
JSS is an authoring tool for CSS which allows you to use JavaScript to describe styles in a declarative, conflict-free and reusable way....
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