PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.2.0
GenerateBlocks v2.2.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / hooks / useBlockStyles.js
generateblocks / src / hooks Last commit date
index.js 1 year ago useAuthors.js 3 years ago useBlockStyles.js 1 year ago useDebounceState.js 4 years ago useDeviceAttributes.js 2 years ago useDeviceType.js 1 year ago useInnerBlocksCount.js 4 years ago useQueryReducer.js 1 year ago useRecordsReducer.js 3 years ago useSelectedBlockElements.js 2 years ago useStyleIndicator.js 2 years ago useTaxonomies.js 1 year ago useTaxonomyRecords.js 3 years ago
useBlockStyles.js
37 lines
1 import { useSelect, useDispatch } from '@wordpress/data';
2 import { applyFilters } from '@wordpress/hooks';
3
4 import { useDeviceType, getPreviewDevice, useCurrentAtRule } from '@edge22/block-styles';
5 import { defaultAtRules } from '@edge22/styles-builder';
6
7 import { currentStyleStore, atRuleStore, nestedRuleStore } from '../store/block-styles';
8
9 export function useBlockStyles() {
10 const atRule = useSelect( ( select ) => select( atRuleStore ).getAtRule() );
11 const { setAtRule } = useDispatch( atRuleStore );
12 const nestedRule = useSelect( ( select ) => select( nestedRuleStore ).getNestedRule() );
13 const { setNestedRule } = useDispatch( nestedRuleStore );
14 const currentAtRule = useCurrentAtRule( defaultAtRules );
15 const { setCurrentStyle } = useDispatch( currentStyleStore );
16 const currentStyle = useSelect( ( select ) => select( currentStyleStore ).currentStyle() );
17 const { deviceType, setDeviceType } = useDeviceType();
18
19 const setGlobalStyle = applyFilters( 'generateblocks.useBlockStyles.setGlobalStyle', () => {} );
20 const cancelEditGlobalStyle = applyFilters( 'generateblocks.useBlockStyles.cancelEditGlobalStyle', () => {} );
21
22 return {
23 atRule,
24 nestedRule,
25 setAtRule,
26 currentAtRule,
27 setNestedRule,
28 setDeviceType,
29 deviceType,
30 setCurrentStyle,
31 currentStyle,
32 getPreviewDevice,
33 setGlobalStyle,
34 cancelEditGlobalStyle,
35 };
36 }
37