@wordpress/edit-site 6.8.3 → 6.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-template/add-custom-template-modal-content.js +2 -4
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/index.js +2 -4
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/editor/index.js +3 -5
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +2 -4
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +2 -4
- package/build/components/error-boundary/warning.js.map +1 -1
- package/build/components/global-styles/font-families.js +2 -16
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -3
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/ui.js +0 -4
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +1 -3
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +0 -42
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +1 -4
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +2 -4
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/index.js +2 -4
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/editor/index.js +4 -6
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +2 -4
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +2 -4
- package/build-module/components/error-boundary/warning.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +4 -18
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -3
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/ui.js +0 -4
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +1 -3
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +1 -42
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +2 -5
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-style/posts-rtl.css +12 -6
- package/build-style/posts.css +12 -6
- package/build-style/style-rtl.css +15 -9
- package/build-style/style.css +15 -9
- package/package.json +30 -30
- package/src/components/add-new-template/add-custom-template-modal-content.js +1 -2
- package/src/components/add-new-template/index.js +1 -2
- package/src/components/editor/index.js +3 -4
- package/src/components/editor/style.scss +4 -0
- package/src/components/editor-canvas-container/index.js +1 -2
- package/src/components/error-boundary/warning.js +1 -6
- package/src/components/global-styles/font-families.js +5 -28
- package/src/components/global-styles/screen-typography.js +3 -3
- package/src/components/global-styles/ui.js +0 -5
- package/src/components/sidebar-dataviews/dataview-item.js +0 -2
- package/src/components/sidebar-dataviews/default-views.js +1 -45
- package/src/components/sidebar-dataviews/index.js +2 -7
- package/src/components/sidebar-dataviews/style.scss +0 -4
- package/build/components/global-styles/screen-typeset.js +0 -40
- package/build/components/global-styles/screen-typeset.js.map +0 -1
- package/build/components/global-styles/typeset-button.js +0 -98
- package/build/components/global-styles/typeset-button.js.map +0 -1
- package/build-module/components/global-styles/screen-typeset.js +0 -34
- package/build-module/components/global-styles/screen-typeset.js.map +0 -1
- package/build-module/components/global-styles/typeset-button.js +0 -90
- package/build-module/components/global-styles/typeset-button.js.map +0 -1
- package/src/components/global-styles/screen-typeset.js +0 -42
- package/src/components/global-styles/typeset-button.js +0 -100
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isRTL, __ } from '@wordpress/i18n';
|
|
5
|
-
import { __experimentalItemGroup as ItemGroup, __experimentalVStack as VStack, __experimentalHStack as HStack, FlexItem } from '@wordpress/components';
|
|
6
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
-
import { useSelect } from '@wordpress/data';
|
|
8
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
9
|
-
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
10
|
-
import { useMemo, useContext } from '@wordpress/element';
|
|
11
|
-
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import FontLibraryProvider from './font-library-modal/context';
|
|
17
|
-
import { getFontFamilies } from './utils';
|
|
18
|
-
import { NavigationButtonAsItem } from './navigation-button';
|
|
19
|
-
import Subtitle from './subtitle';
|
|
20
|
-
import { unlock } from '../../lock-unlock';
|
|
21
|
-
import { filterObjectByProperties, useCurrentMergeThemeStyleVariationsWithUserConfig } from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
const {
|
|
25
|
-
GlobalStylesContext
|
|
26
|
-
} = unlock(blockEditorPrivateApis);
|
|
27
|
-
const {
|
|
28
|
-
mergeBaseAndUserConfigs
|
|
29
|
-
} = unlock(editorPrivateApis);
|
|
30
|
-
function TypesetButton() {
|
|
31
|
-
const propertiesToFilter = ['typography'];
|
|
32
|
-
const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter);
|
|
33
|
-
const hasTypographyVariations = typographyVariations?.length > 1;
|
|
34
|
-
const {
|
|
35
|
-
base,
|
|
36
|
-
user: userConfig
|
|
37
|
-
} = useContext(GlobalStylesContext);
|
|
38
|
-
const config = mergeBaseAndUserConfigs(base, userConfig);
|
|
39
|
-
const allFontFamilies = getFontFamilies(config);
|
|
40
|
-
const hasFonts = allFontFamilies.filter(font => font !== null).length > 0;
|
|
41
|
-
const variations = useSelect(select => {
|
|
42
|
-
return select(coreStore).__experimentalGetCurrentThemeGlobalStylesVariations();
|
|
43
|
-
}, []);
|
|
44
|
-
const userTypographyConfig = filterObjectByProperties(userConfig, 'typography');
|
|
45
|
-
const title = useMemo(() => {
|
|
46
|
-
if (Object.keys(userTypographyConfig).length === 0) {
|
|
47
|
-
return __('Default');
|
|
48
|
-
}
|
|
49
|
-
const activeVariation = variations?.find(variation => {
|
|
50
|
-
return JSON.stringify(filterObjectByProperties(variation, 'typography')) === JSON.stringify(userTypographyConfig);
|
|
51
|
-
});
|
|
52
|
-
if (activeVariation) {
|
|
53
|
-
return activeVariation.title;
|
|
54
|
-
}
|
|
55
|
-
return allFontFamilies.map(font => font?.name).join(', ');
|
|
56
|
-
}, [allFontFamilies, userTypographyConfig, variations]);
|
|
57
|
-
return hasTypographyVariations && hasFonts && /*#__PURE__*/_jsxs(VStack, {
|
|
58
|
-
spacing: 2,
|
|
59
|
-
children: [/*#__PURE__*/_jsx(HStack, {
|
|
60
|
-
justify: "space-between",
|
|
61
|
-
children: /*#__PURE__*/_jsx(Subtitle, {
|
|
62
|
-
level: 3,
|
|
63
|
-
children: __('Typeset')
|
|
64
|
-
})
|
|
65
|
-
}), /*#__PURE__*/_jsx(ItemGroup, {
|
|
66
|
-
isBordered: true,
|
|
67
|
-
isSeparated: true,
|
|
68
|
-
children: /*#__PURE__*/_jsx(NavigationButtonAsItem, {
|
|
69
|
-
path: "/typography/typeset",
|
|
70
|
-
"aria-label": __('Typeset'),
|
|
71
|
-
children: /*#__PURE__*/_jsxs(HStack, {
|
|
72
|
-
direction: "row",
|
|
73
|
-
children: [/*#__PURE__*/_jsx(FlexItem, {
|
|
74
|
-
children: title
|
|
75
|
-
}), /*#__PURE__*/_jsx(Icon, {
|
|
76
|
-
icon: isRTL() ? chevronLeft : chevronRight
|
|
77
|
-
})]
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})]
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
export default (({
|
|
84
|
-
...props
|
|
85
|
-
}) => /*#__PURE__*/_jsx(FontLibraryProvider, {
|
|
86
|
-
children: /*#__PURE__*/_jsx(TypesetButton, {
|
|
87
|
-
...props
|
|
88
|
-
})
|
|
89
|
-
}));
|
|
90
|
-
//# sourceMappingURL=typeset-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isRTL","__","__experimentalItemGroup","ItemGroup","__experimentalVStack","VStack","__experimentalHStack","HStack","FlexItem","store","coreStore","useSelect","privateApis","blockEditorPrivateApis","editorPrivateApis","useMemo","useContext","Icon","chevronLeft","chevronRight","FontLibraryProvider","getFontFamilies","NavigationButtonAsItem","Subtitle","unlock","filterObjectByProperties","useCurrentMergeThemeStyleVariationsWithUserConfig","jsx","_jsx","jsxs","_jsxs","GlobalStylesContext","mergeBaseAndUserConfigs","TypesetButton","propertiesToFilter","typographyVariations","hasTypographyVariations","length","base","user","userConfig","config","allFontFamilies","hasFonts","filter","font","variations","select","__experimentalGetCurrentThemeGlobalStylesVariations","userTypographyConfig","title","Object","keys","activeVariation","find","variation","JSON","stringify","map","name","join","spacing","children","justify","level","isBordered","isSeparated","path","direction","icon","props"],"sources":["@wordpress/edit-site/src/components/global-styles/typeset-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\tFlexItem,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { useMemo, useContext } from '@wordpress/element';\nimport { Icon, chevronLeft, chevronRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport FontLibraryProvider from './font-library-modal/context';\nimport { getFontFamilies } from './utils';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport Subtitle from './subtitle';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tfilterObjectByProperties,\n\tuseCurrentMergeThemeStyleVariationsWithUserConfig,\n} from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\nfunction TypesetButton() {\n\tconst propertiesToFilter = [ 'typography' ];\n\tconst typographyVariations =\n\t\tuseCurrentMergeThemeStyleVariationsWithUserConfig( propertiesToFilter );\n\tconst hasTypographyVariations = typographyVariations?.length > 1;\n\tconst { base, user: userConfig } = useContext( GlobalStylesContext );\n\tconst config = mergeBaseAndUserConfigs( base, userConfig );\n\tconst allFontFamilies = getFontFamilies( config );\n\tconst hasFonts =\n\t\tallFontFamilies.filter( ( font ) => font !== null ).length > 0;\n\tconst variations = useSelect( ( select ) => {\n\t\treturn select(\n\t\t\tcoreStore\n\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\t}, [] );\n\tconst userTypographyConfig = filterObjectByProperties(\n\t\tuserConfig,\n\t\t'typography'\n\t);\n\n\tconst title = useMemo( () => {\n\t\tif ( Object.keys( userTypographyConfig ).length === 0 ) {\n\t\t\treturn __( 'Default' );\n\t\t}\n\t\tconst activeVariation = variations?.find( ( variation ) => {\n\t\t\treturn (\n\t\t\t\tJSON.stringify(\n\t\t\t\t\tfilterObjectByProperties( variation, 'typography' )\n\t\t\t\t) === JSON.stringify( userTypographyConfig )\n\t\t\t);\n\t\t} );\n\t\tif ( activeVariation ) {\n\t\t\treturn activeVariation.title;\n\t\t}\n\t\treturn allFontFamilies.map( ( font ) => font?.name ).join( ', ' );\n\t}, [ allFontFamilies, userTypographyConfig, variations ] );\n\n\treturn (\n\t\thasTypographyVariations &&\n\t\thasFonts && (\n\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t<Subtitle level={ 3 }>{ __( 'Typeset' ) }</Subtitle>\n\t\t\t\t</HStack>\n\t\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\tpath=\"/typography/typeset\"\n\t\t\t\t\t\taria-label={ __( 'Typeset' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack direction=\"row\">\n\t\t\t\t\t\t\t<FlexItem>{ title }</FlexItem>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ isRTL() ? chevronLeft : chevronRight }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t</ItemGroup>\n\t\t\t</VStack>\n\t\t)\n\t);\n}\n\nexport default ( { ...props } ) => (\n\t<FontLibraryProvider>\n\t\t<TypesetButton { ...props } />\n\t</FontLibraryProvider>\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;AAC3C,SACCC,uBAAuB,IAAIC,SAAS,EACpCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,QACF,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASD,WAAW,IAAIE,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,OAAO,EAAEC,UAAU,QAAQ,oBAAoB;AACxD,SAASC,IAAI,EAAEC,WAAW,EAAEC,YAAY,QAAQ,kBAAkB;;AAElE;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,8BAA8B;AAC9D,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,sBAA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AAC,CACf,CAAC;EAAA,CACL,CACR;AAEH;AAEA,gBAAe,CAAE;EAAE,GAAGmD;AAAM,CAAC,kBAC5B1C,IAAA,CAACR,mBAAmB;EAAA0C,QAAA,eACnBlC,IAAA,CAACK,aAAa;IAAA,GAAMqC;EAAK,CAAI;AAAC,CACV,CACrB","ignoreList":[]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useSelect } from '@wordpress/data';
|
|
6
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
7
|
-
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import TypographyVariations from './variations/variations-typography';
|
|
13
|
-
import ScreenHeader from './header';
|
|
14
|
-
import FontFamilies from './font-families';
|
|
15
|
-
|
|
16
|
-
function ScreenTypeset() {
|
|
17
|
-
const fontLibraryEnabled = useSelect(
|
|
18
|
-
( select ) =>
|
|
19
|
-
select( editorStore ).getEditorSettings().fontLibraryEnabled,
|
|
20
|
-
[]
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<>
|
|
25
|
-
<ScreenHeader
|
|
26
|
-
title={ __( 'Typesets' ) }
|
|
27
|
-
description={ __(
|
|
28
|
-
'Fonts and typographic styling applied across the site.'
|
|
29
|
-
) }
|
|
30
|
-
/>
|
|
31
|
-
<div className="edit-site-global-styles-screen">
|
|
32
|
-
<VStack spacing={ 7 }>
|
|
33
|
-
<TypographyVariations />
|
|
34
|
-
|
|
35
|
-
{ fontLibraryEnabled && <FontFamilies /> }
|
|
36
|
-
</VStack>
|
|
37
|
-
</div>
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default ScreenTypeset;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isRTL, __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
__experimentalItemGroup as ItemGroup,
|
|
7
|
-
__experimentalVStack as VStack,
|
|
8
|
-
__experimentalHStack as HStack,
|
|
9
|
-
FlexItem,
|
|
10
|
-
} from '@wordpress/components';
|
|
11
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
-
import { useSelect } from '@wordpress/data';
|
|
13
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
|
-
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
15
|
-
import { useMemo, useContext } from '@wordpress/element';
|
|
16
|
-
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
import FontLibraryProvider from './font-library-modal/context';
|
|
22
|
-
import { getFontFamilies } from './utils';
|
|
23
|
-
import { NavigationButtonAsItem } from './navigation-button';
|
|
24
|
-
import Subtitle from './subtitle';
|
|
25
|
-
import { unlock } from '../../lock-unlock';
|
|
26
|
-
import {
|
|
27
|
-
filterObjectByProperties,
|
|
28
|
-
useCurrentMergeThemeStyleVariationsWithUserConfig,
|
|
29
|
-
} from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';
|
|
30
|
-
|
|
31
|
-
const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
|
|
32
|
-
const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
|
|
33
|
-
|
|
34
|
-
function TypesetButton() {
|
|
35
|
-
const propertiesToFilter = [ 'typography' ];
|
|
36
|
-
const typographyVariations =
|
|
37
|
-
useCurrentMergeThemeStyleVariationsWithUserConfig( propertiesToFilter );
|
|
38
|
-
const hasTypographyVariations = typographyVariations?.length > 1;
|
|
39
|
-
const { base, user: userConfig } = useContext( GlobalStylesContext );
|
|
40
|
-
const config = mergeBaseAndUserConfigs( base, userConfig );
|
|
41
|
-
const allFontFamilies = getFontFamilies( config );
|
|
42
|
-
const hasFonts =
|
|
43
|
-
allFontFamilies.filter( ( font ) => font !== null ).length > 0;
|
|
44
|
-
const variations = useSelect( ( select ) => {
|
|
45
|
-
return select(
|
|
46
|
-
coreStore
|
|
47
|
-
).__experimentalGetCurrentThemeGlobalStylesVariations();
|
|
48
|
-
}, [] );
|
|
49
|
-
const userTypographyConfig = filterObjectByProperties(
|
|
50
|
-
userConfig,
|
|
51
|
-
'typography'
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const title = useMemo( () => {
|
|
55
|
-
if ( Object.keys( userTypographyConfig ).length === 0 ) {
|
|
56
|
-
return __( 'Default' );
|
|
57
|
-
}
|
|
58
|
-
const activeVariation = variations?.find( ( variation ) => {
|
|
59
|
-
return (
|
|
60
|
-
JSON.stringify(
|
|
61
|
-
filterObjectByProperties( variation, 'typography' )
|
|
62
|
-
) === JSON.stringify( userTypographyConfig )
|
|
63
|
-
);
|
|
64
|
-
} );
|
|
65
|
-
if ( activeVariation ) {
|
|
66
|
-
return activeVariation.title;
|
|
67
|
-
}
|
|
68
|
-
return allFontFamilies.map( ( font ) => font?.name ).join( ', ' );
|
|
69
|
-
}, [ allFontFamilies, userTypographyConfig, variations ] );
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
hasTypographyVariations &&
|
|
73
|
-
hasFonts && (
|
|
74
|
-
<VStack spacing={ 2 }>
|
|
75
|
-
<HStack justify="space-between">
|
|
76
|
-
<Subtitle level={ 3 }>{ __( 'Typeset' ) }</Subtitle>
|
|
77
|
-
</HStack>
|
|
78
|
-
<ItemGroup isBordered isSeparated>
|
|
79
|
-
<NavigationButtonAsItem
|
|
80
|
-
path="/typography/typeset"
|
|
81
|
-
aria-label={ __( 'Typeset' ) }
|
|
82
|
-
>
|
|
83
|
-
<HStack direction="row">
|
|
84
|
-
<FlexItem>{ title }</FlexItem>
|
|
85
|
-
<Icon
|
|
86
|
-
icon={ isRTL() ? chevronLeft : chevronRight }
|
|
87
|
-
/>
|
|
88
|
-
</HStack>
|
|
89
|
-
</NavigationButtonAsItem>
|
|
90
|
-
</ItemGroup>
|
|
91
|
-
</VStack>
|
|
92
|
-
)
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export default ( { ...props } ) => (
|
|
97
|
-
<FontLibraryProvider>
|
|
98
|
-
<TypesetButton { ...props } />
|
|
99
|
-
</FontLibraryProvider>
|
|
100
|
-
);
|