-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Global Styles: Don't display browse styles unless the theme has full …
…styles available
- Loading branch information
Showing
3 changed files
with
35 additions
and
32 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
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,4 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './push-changes-to-global-styles'; | ||
import { isVariationWithProperties } from './use-theme-style-variations/use-theme-style-variations-by-property'; | ||
|
||
export function useThemeStyles() { | ||
const variations = useSelect( ( select ) => { | ||
return select( | ||
coreStore | ||
).__experimentalGetCurrentThemeGlobalStylesVariations(); | ||
}, [] ); | ||
|
||
// Filter out variations that are of single property type, i.e. color or typography variations. | ||
return variations?.filter( ( variation ) => { | ||
return ( | ||
! isVariationWithProperties( variation, [ 'color' ] ) && | ||
! isVariationWithProperties( variation, [ 'typography' ] ) | ||
); | ||
} ); | ||
} |