-
Notifications
You must be signed in to change notification settings - Fork 36
Updated styles for responsive visibility #3024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+92
−1
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
79 changes: 79 additions & 0 deletions
79
src/blocks/test/e2e/blocks/atomic-wind-hide-conditions.spec.js
This file contains hidden or 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,79 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { test, expect } from '../fixtures'; | ||
| import { setAtomicWind } from '../helpers/design-library'; | ||
| import { publishAndViewPost } from '../helpers/editor'; | ||
|
|
||
| /** | ||
| * Atomic Wind compiles Tailwind in important mode, so a `flex` utility lands as | ||
| * `display:flex!important`. The "Hide on" screen-size condition is also | ||
| * `!important`, so unless its rules outrank the utilities the block stays | ||
| * visible on the device it was hidden for, depending on which stylesheet the | ||
| * page happened to print last. | ||
| */ | ||
| const MOBILE = { width: 375, height: 700 }; | ||
| const TABLET = { width: 900, height: 700 }; | ||
| const DESKTOP = { width: 1280, height: 700 }; | ||
|
|
||
| const insertHiddenBox = ( editor, screenSizes ) => | ||
| editor.insertBlock({ | ||
| name: 'atomic-wind/box', | ||
| attributes: { | ||
| className: 'flex gap-4 p-8', | ||
| otterConditions: [ | ||
| [ | ||
| { | ||
| type: 'screenSize', | ||
| screen_sizes: screenSizes | ||
| } | ||
| ] | ||
| ] | ||
| }, | ||
| innerBlocks: [ | ||
| { name: 'core/paragraph', attributes: { content: 'Boxed content' }} | ||
| ] | ||
| }); | ||
|
|
||
| test.describe( 'Atomic Wind hide on screen size', () => { | ||
| test.beforeEach( async({ otterUtils, admin }) => { | ||
| await setAtomicWind( otterUtils, true ); | ||
| await admin.createNewPost(); | ||
| }); | ||
|
|
||
| test.afterAll( async({ otterUtils }) => { | ||
| await setAtomicWind( otterUtils, false ); | ||
| }); | ||
|
|
||
| test( 'hiding on mobile beats the flex utility', async({ editor, page }) => { | ||
| await insertHiddenBox( editor, [ 'mobile' ] ); | ||
| await publishAndViewPost({ editor, page }); | ||
|
|
||
| const box = page.locator( '.wp-block-atomic-wind-box' ); | ||
|
|
||
| await expect( box ).toHaveClass( /o-hide-on-mobile/ ); | ||
|
|
||
| // Outside the hidden range the utility must still apply, so a passing | ||
| // hidden assertion cannot come from a stylesheet that never loaded. | ||
| await page.setViewportSize( TABLET ); | ||
| await expect( box ).toHaveCSS( 'display', 'flex' ); | ||
|
|
||
| await page.setViewportSize( MOBILE ); | ||
| await expect( box ).toHaveCSS( 'display', 'none' ); | ||
| }); | ||
|
|
||
| test( 'hiding on desktop beats the flex utility', async({ editor, page }) => { | ||
|
girishpanchal30 marked this conversation as resolved.
|
||
| await insertHiddenBox( editor, [ 'desktop' ] ); | ||
| await publishAndViewPost({ editor, page }); | ||
|
|
||
| const box = page.locator( '.wp-block-atomic-wind-box' ); | ||
|
|
||
| await expect( box ).toHaveClass( /o-hide-on-desktop/ ); | ||
|
|
||
| await page.setViewportSize( MOBILE ); | ||
| await expect( box ).toHaveCSS( 'display', 'flex' ); | ||
|
|
||
| await page.setViewportSize( DESKTOP ); | ||
| await expect( box ).toHaveCSS( 'display', 'none' ); | ||
| }); | ||
| }); | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.