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 |