-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow plugins to use gatsby-browser.js to load global styles, et…
…c. (#10845)
- Loading branch information
1 parent
fe1f827
commit 33a3e61
Showing
11 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
e2e-tests/production-runtime/cypress/integration/global-styles.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const zIndex = `9001` | ||
|
||
describe(`Global style from gatsby-browser.js`, () => { | ||
beforeEach(() => { | ||
cy.visit(`/global-style`).waitForAPI(`onRouteUpdate`) | ||
}) | ||
|
||
it(`should apply any styles in root gatsby-browser.js`, () => { | ||
cy.getTestElement(`global-style`).should(`have.css`, `zIndex`, zIndex) | ||
}) | ||
|
||
it(`should apply any styles in plugin(s) gatsby-browser.js`, () => { | ||
cy.getTestElement(`global-plugin-style`).should( | ||
`have.css`, | ||
`zIndex`, | ||
zIndex | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require(`./src/index.css`) | ||
|
||
if (typeof window !== `undefined`) { | ||
window.___PageComponentLifecycleCallsLog = [] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
e2e-tests/production-runtime/plugins/gatsby-plugin-global-style/gatsby-browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './index.css' |
4 changes: 4 additions & 0 deletions
4
e2e-tests/production-runtime/plugins/gatsby-plugin-global-style/index.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[data-testid='global-plugin-style'] { | ||
position: relative; | ||
z-index: 9001; /* it's over 9000 */ | ||
} |
1 change: 1 addition & 0 deletions
1
e2e-tests/production-runtime/plugins/gatsby-plugin-global-style/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// noop |
3 changes: 3 additions & 0 deletions
3
e2e-tests/production-runtime/plugins/gatsby-plugin-global-style/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "gatsby-plugin-global-style" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[data-testid='global-style'] { | ||
position: relative; | ||
z-index: 9001; /* it's over 9000 */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
|
||
import Layout from '../components/layout' | ||
|
||
const GlobalStyle = () => ( | ||
<Layout> | ||
<h1 data-testid="global-plugin-style"> | ||
This text should have a large z-index (via `gatsby-plugin-global-style`) | ||
</h1> | ||
<h2 data-testid="global-style"> | ||
This text should have a large z-index (via root-level `gatsby-browser.js`) | ||
</h2> | ||
</Layout> | ||
) | ||
|
||
export default GlobalStyle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters