-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add defaultTheme prop to specify default theme if no previous value s…
…tored (#3619) * add defaultTheme prop to specify default theme if no previous value in storageContext * yoyo --------- Co-authored-by: Dimitri POSTOLOV <[email protected]>
- Loading branch information
1 parent
959ed21
commit 9aef83a
Showing
5 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
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,6 @@ | ||
--- | ||
'@graphiql/react': minor | ||
'graphiql': minor | ||
--- | ||
|
||
add new prop `defaultTheme` to set the default color preference theme |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
describe('Theme', () => { | ||
it('Switches to light theme when `forcedTheme` is light', () => { | ||
cy.visit('/?query={test}&forcedTheme=light'); | ||
cy.get('body').should('have.class', 'graphiql-light'); | ||
}); | ||
describe('`forcedTheme`', () => { | ||
it('Switches to light theme when `forcedTheme` is light', () => { | ||
cy.visit('/?forcedTheme=light'); | ||
cy.get('body').should('have.class', 'graphiql-light'); | ||
}); | ||
|
||
it('Switches to dark theme when `forcedTheme` is dark', () => { | ||
cy.visit('/?forcedTheme=dark'); | ||
cy.get('body').should('have.class', 'graphiql-dark'); | ||
}); | ||
|
||
it('Switches to dark theme when `forcedTheme` is dark', () => { | ||
cy.visit('/?query={test}&forcedTheme=dark'); | ||
cy.get('body').should('have.class', 'graphiql-dark'); | ||
it('Defaults to light theme when `forcedTheme` value is invalid', () => { | ||
cy.visit('/?forcedTheme=invalid'); | ||
cy.get('[data-value=settings]').click(); | ||
cy.get('.graphiql-dialog-section-title') | ||
.eq(1) | ||
.should('have.text', 'Theme'); // Check for the presence of the theme dialog | ||
}); | ||
}); | ||
|
||
it('Defaults to light theme when `forcedTheme` value is invalid', () => { | ||
cy.visit('/?query={test}&forcedTheme=invalid'); | ||
cy.get('[data-value=settings]').click(); | ||
cy.get('.graphiql-dialog-section-title').eq(1).should('have.text', 'Theme'); // Check for the presence of the theme dialog | ||
describe('`defaultTheme`', () => { | ||
it('should have light theme', () => { | ||
cy.visit('/?defaultTheme=light'); | ||
cy.get('body').should('have.class', 'graphiql-light'); | ||
}); | ||
it('should have dark theme', () => { | ||
cy.visit('/?defaultTheme=dark'); | ||
cy.get('body').should('have.class', 'graphiql-dark'); | ||
}); | ||
}); | ||
}); |
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