-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Background image: add support for absolute theme path URLs #60578
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5c83713
Supporting background.backgroundImage.source === "theme" relative paths
ramonjd 5b27773
This is an experimental commit to test out how to:
ramonjd 6bf575a
Roll back API changes and insert into editor settings under `currentT…
ramonjd 967bbac
If we pass a 'baseUrl' to the style engine, it will it append it to a…
ramonjd e65bf84
Rolls back f7bf075d4a0b143008f1809c8254ebab61492e00
ramonjd 9e517d3
Removed useBlockProps and now editing style object directly
ramonjd bbddc18
Remove unused "parentDirectoryURI" prop in block editor settings
ramonjd 1827703
Yes, spacing.
ramonjd 39b8783
Unit test no styles
ramonjd 8b27b57
Getting URI from themes API response
ramonjd f8cda05
Switching to experimental
ramonjd df2ffb1
Testing get_theme_file_uri on the backend and duping the background i…
ramonjd eca8d3c
Just a commit to explore adding a private selector to mimic get_theme…
ramonjd 7e9e4c5
whoops
ramonjd 1aa8f6a
Resolving urls in theme.json
ramonjd 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 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
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
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ import { LAYOUT_DEFINITIONS } from '../../layouts/definitions'; | |
import { getValueFromObjectPath, setImmutably } from '../../utils/object'; | ||
import BlockContext from '../block-context'; | ||
import { unlock } from '../../lock-unlock'; | ||
import { setBackgroundStyleDefaults } from '../../hooks/background'; | ||
|
||
// List of block support features that can have their related styles | ||
// generated under their own feature level selector rather than the block's. | ||
|
@@ -314,6 +315,7 @@ const getFeatureDeclarations = ( selectors, styles ) => { | |
* @param {Object} tree A theme.json tree containing layout definitions. | ||
* | ||
* @param {boolean} isTemplate Whether the entity being edited is a full template or a pattern. | ||
* @param {Object} editorSettings Current editor settings. | ||
* @return {Array} An array of style declarations. | ||
*/ | ||
export function getStylesDeclarations( | ||
|
@@ -391,6 +393,17 @@ export function getStylesDeclarations( | |
[] | ||
); | ||
|
||
/* | ||
* Set styles defaults. | ||
* Applies default values to the style object based on the block settings. | ||
* Only applies to background styles for now. | ||
*/ | ||
if ( !! blockStyles?.background ) { | ||
blockStyles = setBackgroundStyleDefaults( blockStyles, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
selector, | ||
} ); | ||
} | ||
|
||
// The goal is to move everything to server side generated engine styles | ||
// This is temporary as we absorb more and more styles into the engine. | ||
const extraRules = getCSSRules( blockStyles ); | ||
|
@@ -947,19 +960,19 @@ export const toStyles = ( | |
} ); | ||
} | ||
|
||
// Process the remaining block styles (they use either normal block class or __experimentalSelector). | ||
const declarations = getStylesDeclarations( | ||
styles, | ||
selector, | ||
useRootPaddingAlign, | ||
tree, | ||
isTemplate | ||
); | ||
if ( declarations?.length ) { | ||
ruleset += `:where(${ selector }){${ declarations.join( | ||
';' | ||
) };}`; | ||
} | ||
// Process the remaining block styles (they use either normal block class or __experimentalSelector). | ||
const declarations = getStylesDeclarations( | ||
styles, | ||
selector, | ||
useRootPaddingAlign, | ||
tree, | ||
isTemplate | ||
); | ||
if ( declarations?.length ) { | ||
ruleset += `:where(${ selector }){${ declarations.join( | ||
';' | ||
) };}`; | ||
} | ||
|
||
// Check for pseudo selector in `styles` and handle separately. | ||
const pseudoSelectorStyles = Object.entries( styles ).filter( | ||
|
@@ -1219,9 +1232,12 @@ export function useGlobalStylesOutputWithConfig( mergedConfig = {} ) { | |
const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' ); | ||
const hasBlockGapSupport = blockGap !== null; | ||
const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support. | ||
const disableLayoutStyles = useSelect( ( select ) => { | ||
const { getSettings } = select( blockEditorStore ); | ||
return !! getSettings().disableLayoutStyles; | ||
|
||
const { disableLayoutStyles } = useSelect( ( select ) => { | ||
const _settings = select( blockEditorStore ).getSettings(); | ||
return { | ||
disableLayoutStyles: !! _settings.disableLayoutStyles, | ||
}; | ||
} ); | ||
|
||
const blockContext = useContext( BlockContext ); | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this needs to match WordPress/wordpress-develop#6399