Giter VIP home page Giter VIP logo

Comments (5)

silvenon avatar silvenon commented on June 15, 2024 1

The best place for it is probably your layout file, the one you use for wrapping every page. That way those styles will be included in all pages. You might not even need to assign it to a variable, because I don't know what you would do with it, try to just run:

css`
  :global() {
    /* ... */
  }
`

but I'm not 100% sure about that. The point is that it has to reside in the file which actually runs. Where did you put it?

from gatsby-plugin-linaria.

silvenon avatar silvenon commented on June 15, 2024 1

For me adding it to a page works as well, this is my src/pages/index.js:

import React from 'react'
import { css } from 'linaria'

css`
  :global() {
    html {
      background: black;
      color: #fff;
    }
  }
`

const Home = () => <h1>Hello World!</h1>

export default Home

I hope you'll figure it out.

from gatsby-plugin-linaria.

silvenon avatar silvenon commented on June 15, 2024

It works for me, please provide steps to reproduce (or better yet, a repo).

Btw, I'm not sure why their example contains export, since it doesn't have any context.

from gatsby-plugin-linaria.

koss-lebedev avatar koss-lebedev commented on June 15, 2024

@silvenon thank you for a quick reply! In your working example, where do you use this globals variable? From the docs, I understood that you just need to export in one of the files accessible by Gatbsy (similar to how fragments work) and it should be enough, but maybe I'm wrong

from gatsby-plugin-linaria.

koss-lebedev avatar koss-lebedev commented on June 15, 2024

Thank you so much for you help, it actually does work! Originally, I was trying to include it in a file inside pages folder, which didn't work for some reason, but when I imported it inside one of the components, it worked.

from gatsby-plugin-linaria.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.