@eightshift/frontend-libs-tailwind 1.0.0
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/.gitattributes +37 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/CONTRIBUTING.md +17 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +10 -0
- package/.github/ISSUE_TEMPLATE/question.md +10 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- package/.github/workflows/ci.yml +31 -0
- package/.husky/pre-commit +1 -0
- package/.prettierrc +14 -0
- package/.stylelintrc +4 -0
- package/CHANGELOG.md +13 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/blocks/init/assets/application-admin.js +10 -0
- package/blocks/init/assets/application.js +13 -0
- package/blocks/init/assets/images/index.js +5 -0
- package/blocks/init/assets/scripts/application-admin.js +7 -0
- package/blocks/init/assets/scripts/application.js +3 -0
- package/blocks/init/assets/scripts/theme-colors.js +39 -0
- package/blocks/init/assets/styles/application-admin.css +6 -0
- package/blocks/init/assets/styles/application.css +3 -0
- package/blocks/init/src/Blocks/assets/application-blocks-editor.js +14 -0
- package/blocks/init/src/Blocks/assets/application-blocks-frontend.js +13 -0
- package/blocks/init/src/Blocks/assets/application-blocks.js +9 -0
- package/blocks/init/src/Blocks/assets/scripts/application-blocks-editor.js +65 -0
- package/blocks/init/src/Blocks/assets/scripts/application-blocks-frontend.js +24 -0
- package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +258 -0
- package/blocks/init/src/Blocks/assets/scripts/shared.js +25 -0
- package/blocks/init/src/Blocks/assets/styles/application-blocks-editor.css +15 -0
- package/blocks/init/src/Blocks/assets/styles/application-blocks-frontend.css +12 -0
- package/blocks/init/src/Blocks/assets/styles/application-blocks.css +0 -0
- package/blocks/init/src/Blocks/assets/styles/editor/editor-overrides.css +15 -0
- package/blocks/init/src/Blocks/assets/styles/tailwind.css +34 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/admin-theme-options.php +20 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/index.js +36 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/pages/parts.js +55 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/button/assets/index.js +22 -0
- package/blocks/init/src/Blocks/components/button/button.php +77 -0
- package/blocks/init/src/Blocks/components/button/components/button-editor.js +40 -0
- package/blocks/init/src/Blocks/components/button/components/button-options.js +135 -0
- package/blocks/init/src/Blocks/components/button/manifest.json +299 -0
- package/blocks/init/src/Blocks/components/card/card.php +42 -0
- package/blocks/init/src/Blocks/components/card/components/card-editor.js +39 -0
- package/blocks/init/src/Blocks/components/card/components/card-options.js +56 -0
- package/blocks/init/src/Blocks/components/card/manifest.json +111 -0
- package/blocks/init/src/Blocks/components/head/head.php +52 -0
- package/blocks/init/src/Blocks/components/head/manifest.json +17 -0
- package/blocks/init/src/Blocks/components/heading/components/heading-editor.js +30 -0
- package/blocks/init/src/Blocks/components/heading/components/heading-options.js +62 -0
- package/blocks/init/src/Blocks/components/heading/heading.php +45 -0
- package/blocks/init/src/Blocks/components/heading/manifest.json +76 -0
- package/blocks/init/src/Blocks/components/hero/components/hero-editor.js +42 -0
- package/blocks/init/src/Blocks/components/hero/components/hero-options.js +100 -0
- package/blocks/init/src/Blocks/components/hero/hero.php +45 -0
- package/blocks/init/src/Blocks/components/hero/manifest.json +96 -0
- package/blocks/init/src/Blocks/components/icon/components/icon-editor.js +23 -0
- package/blocks/init/src/Blocks/components/icon/components/icon-options.js +65 -0
- package/blocks/init/src/Blocks/components/icon/icon.php +34 -0
- package/blocks/init/src/Blocks/components/icon/manifest.json +1234 -0
- package/blocks/init/src/Blocks/components/image/components/image-editor.js +65 -0
- package/blocks/init/src/Blocks/components/image/components/image-options.js +111 -0
- package/blocks/init/src/Blocks/components/image/image.php +62 -0
- package/blocks/init/src/Blocks/components/image/manifest.json +125 -0
- package/blocks/init/src/Blocks/components/list/components/list-editor.js +30 -0
- package/blocks/init/src/Blocks/components/list/components/list-options.js +62 -0
- package/blocks/init/src/Blocks/components/list/list.php +32 -0
- package/blocks/init/src/Blocks/components/list/manifest.json +127 -0
- package/blocks/init/src/Blocks/components/load-more/assets/index.js +19 -0
- package/blocks/init/src/Blocks/components/load-more/assets/load-more.js +147 -0
- package/blocks/init/src/Blocks/components/load-more/components/load-more-editor.js +14 -0
- package/blocks/init/src/Blocks/components/load-more/components/load-more-options.js +18 -0
- package/blocks/init/src/Blocks/components/load-more/load-more.php +47 -0
- package/blocks/init/src/Blocks/components/load-more/manifest.json +39 -0
- package/blocks/init/src/Blocks/components/modal/assets/index.js +27 -0
- package/blocks/init/src/Blocks/components/modal/manifest.json +48 -0
- package/blocks/init/src/Blocks/components/modal/modal.php +46 -0
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +40 -0
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +48 -0
- package/blocks/init/src/Blocks/components/paragraph/manifest.json +83 -0
- package/blocks/init/src/Blocks/components/paragraph/paragraph.php +33 -0
- package/blocks/init/src/Blocks/components/post-header/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/post-header/post-header.php +24 -0
- package/blocks/init/src/Blocks/components/quote/components/quote-editor.js +53 -0
- package/blocks/init/src/Blocks/components/quote/components/quote-options.js +29 -0
- package/blocks/init/src/Blocks/components/quote/manifest.json +47 -0
- package/blocks/init/src/Blocks/components/quote/quote.php +49 -0
- package/blocks/init/src/Blocks/components/share/assets/index.js +39 -0
- package/blocks/init/src/Blocks/components/share/components/share-editor.js +25 -0
- package/blocks/init/src/Blocks/components/share/components/share-options.js +112 -0
- package/blocks/init/src/Blocks/components/share/manifest.json +72 -0
- package/blocks/init/src/Blocks/components/share/share.php +66 -0
- package/blocks/init/src/Blocks/components/tracking-before-body-end/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/tracking-before-body-end/tracking-before-body-end.php +9 -0
- package/blocks/init/src/Blocks/components/tracking-head/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/tracking-head/tracking-head.php +9 -0
- package/blocks/init/src/Blocks/components/video/components/video-editor.js +74 -0
- package/blocks/init/src/Blocks/components/video/components/video-options.js +280 -0
- package/blocks/init/src/Blocks/components/video/manifest.json +116 -0
- package/blocks/init/src/Blocks/components/video/video.php +72 -0
- package/blocks/init/src/Blocks/custom/accordion/accordion-block.js +15 -0
- package/blocks/init/src/Blocks/custom/accordion/accordion.php +28 -0
- package/blocks/init/src/Blocks/custom/accordion/assets/index.js +37 -0
- package/blocks/init/src/Blocks/custom/accordion/components/accordion-editor.js +17 -0
- package/blocks/init/src/Blocks/custom/accordion/components/accordion-options.js +18 -0
- package/blocks/init/src/Blocks/custom/accordion/manifest.json +32 -0
- package/blocks/init/src/Blocks/custom/accordion-item/accordion-item-block.js +19 -0
- package/blocks/init/src/Blocks/custom/accordion-item/accordion-item.php +46 -0
- package/blocks/init/src/Blocks/custom/accordion-item/components/accordion-item-editor.js +60 -0
- package/blocks/init/src/Blocks/custom/accordion-item/manifest.json +69 -0
- package/blocks/init/src/Blocks/custom/button/button-block.js +13 -0
- package/blocks/init/src/Blocks/custom/button/button.php +11 -0
- package/blocks/init/src/Blocks/custom/button/components/button-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/button/components/button-options.js +12 -0
- package/blocks/init/src/Blocks/custom/button/manifest.json +18 -0
- package/blocks/init/src/Blocks/custom/card/card-block.js +13 -0
- package/blocks/init/src/Blocks/custom/card/card.php +11 -0
- package/blocks/init/src/Blocks/custom/card/components/card-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/card/components/card-options.js +15 -0
- package/blocks/init/src/Blocks/custom/card/manifest.json +18 -0
- package/blocks/init/src/Blocks/custom/carousel/assets/index.js +46 -0
- package/blocks/init/src/Blocks/custom/carousel/assets/navigation.js +31 -0
- package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +39 -0
- package/blocks/init/src/Blocks/custom/carousel/carousel-block.js +21 -0
- package/blocks/init/src/Blocks/custom/carousel/carousel.php +61 -0
- package/blocks/init/src/Blocks/custom/carousel/components/carousel-editor.js +25 -0
- package/blocks/init/src/Blocks/custom/carousel/components/carousel-options.js +47 -0
- package/blocks/init/src/Blocks/custom/carousel/manifest.json +130 -0
- package/blocks/init/src/Blocks/custom/column/column-block.js +21 -0
- package/blocks/init/src/Blocks/custom/column/column-hooks.js +32 -0
- package/blocks/init/src/Blocks/custom/column/column.php +21 -0
- package/blocks/init/src/Blocks/custom/column/components/column-editor.js +19 -0
- package/blocks/init/src/Blocks/custom/column/components/column-options.js +579 -0
- package/blocks/init/src/Blocks/custom/column/manifest.json +625 -0
- package/blocks/init/src/Blocks/custom/columns/columns-block.js +20 -0
- package/blocks/init/src/Blocks/custom/columns/columns.php +21 -0
- package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +81 -0
- package/blocks/init/src/Blocks/custom/columns/components/columns-options.js +104 -0
- package/blocks/init/src/Blocks/custom/columns/manifest.json +555 -0
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-editor.js +28 -0
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +239 -0
- package/blocks/init/src/Blocks/custom/featured-content/featured-content-block.js +13 -0
- package/blocks/init/src/Blocks/custom/featured-content/featured-content.php +139 -0
- package/blocks/init/src/Blocks/custom/featured-content/manifest.json +131 -0
- package/blocks/init/src/Blocks/custom/featured-content/partials/cards.php +39 -0
- package/blocks/init/src/Blocks/custom/group/components/group-editor.js +8 -0
- package/blocks/init/src/Blocks/custom/group/group-block.js +14 -0
- package/blocks/init/src/Blocks/custom/group/group.php +10 -0
- package/blocks/init/src/Blocks/custom/group/manifest.json +32 -0
- package/blocks/init/src/Blocks/custom/heading/components/heading-editor.js +15 -0
- package/blocks/init/src/Blocks/custom/heading/components/heading-options.js +38 -0
- package/blocks/init/src/Blocks/custom/heading/heading-block.js +13 -0
- package/blocks/init/src/Blocks/custom/heading/heading-transforms.js +25 -0
- package/blocks/init/src/Blocks/custom/heading/heading.php +15 -0
- package/blocks/init/src/Blocks/custom/heading/manifest.json +79 -0
- package/blocks/init/src/Blocks/custom/hero/components/hero-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/hero/components/hero-options.js +14 -0
- package/blocks/init/src/Blocks/custom/hero/hero-block.js +13 -0
- package/blocks/init/src/Blocks/custom/hero/hero.php +11 -0
- package/blocks/init/src/Blocks/custom/hero/manifest.json +17 -0
- package/blocks/init/src/Blocks/custom/image/components/image-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/image/components/image-options.js +14 -0
- package/blocks/init/src/Blocks/custom/image/image-block.js +13 -0
- package/blocks/init/src/Blocks/custom/image/image.php +11 -0
- package/blocks/init/src/Blocks/custom/image/manifest.json +105 -0
- package/blocks/init/src/Blocks/custom/list/components/list-editor.js +14 -0
- package/blocks/init/src/Blocks/custom/list/components/list-options.js +39 -0
- package/blocks/init/src/Blocks/custom/list/list-block.js +13 -0
- package/blocks/init/src/Blocks/custom/list/list.php +15 -0
- package/blocks/init/src/Blocks/custom/list/manifest.json +58 -0
- package/blocks/init/src/Blocks/custom/map/assets/index.js +20 -0
- package/blocks/init/src/Blocks/custom/map/assets/map-controller.js +42 -0
- package/blocks/init/src/Blocks/custom/map/assets/utils.js +161 -0
- package/blocks/init/src/Blocks/custom/map/components/map-components.js +403 -0
- package/blocks/init/src/Blocks/custom/map/components/map-editor.js +56 -0
- package/blocks/init/src/Blocks/custom/map/components/map-options.js +557 -0
- package/blocks/init/src/Blocks/custom/map/manifest.json +79 -0
- package/blocks/init/src/Blocks/custom/map/map-block.js +13 -0
- package/blocks/init/src/Blocks/custom/map/map.php +52 -0
- package/blocks/init/src/Blocks/custom/map/styles.css +2 -0
- package/blocks/init/src/Blocks/custom/modal/components/modal-editor.js +90 -0
- package/blocks/init/src/Blocks/custom/modal/manifest.json +51 -0
- package/blocks/init/src/Blocks/custom/modal/modal-block.js +14 -0
- package/blocks/init/src/Blocks/custom/modal/modal.php +20 -0
- package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-editor.js +41 -0
- package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-options.js +38 -0
- package/blocks/init/src/Blocks/custom/paragraph/manifest.json +79 -0
- package/blocks/init/src/Blocks/custom/paragraph/paragraph-block.js +13 -0
- package/blocks/init/src/Blocks/custom/paragraph/paragraph-transforms.js +45 -0
- package/blocks/init/src/Blocks/custom/paragraph/paragraph.php +15 -0
- package/blocks/init/src/Blocks/custom/quote/components/quote-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/quote/components/quote-options.js +14 -0
- package/blocks/init/src/Blocks/custom/quote/manifest.json +17 -0
- package/blocks/init/src/Blocks/custom/quote/quote-block.js +13 -0
- package/blocks/init/src/Blocks/custom/quote/quote.php +13 -0
- package/blocks/init/src/Blocks/custom/share/components/share-editor.js +6 -0
- package/blocks/init/src/Blocks/custom/share/components/share-options.js +12 -0
- package/blocks/init/src/Blocks/custom/share/manifest.json +19 -0
- package/blocks/init/src/Blocks/custom/share/share-block.js +13 -0
- package/blocks/init/src/Blocks/custom/share/share.php +11 -0
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-editor.js +57 -0
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +106 -0
- package/blocks/init/src/Blocks/custom/site-footer/manifest.json +73 -0
- package/blocks/init/src/Blocks/custom/site-footer/site-footer-block.js +13 -0
- package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +72 -0
- package/blocks/init/src/Blocks/custom/site-navigation/assets/index.js +9 -0
- package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-editor.js +42 -0
- package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-options.js +73 -0
- package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +77 -0
- package/blocks/init/src/Blocks/custom/site-navigation/site-navigation-block.js +13 -0
- package/blocks/init/src/Blocks/custom/site-navigation/site-navigation.php +99 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/assets/index.js +58 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js +38 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-options.js +32 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/manifest.json +48 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents-block.js +13 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents.php +31 -0
- package/blocks/init/src/Blocks/custom/video/components/video-editor.js +6 -0
- package/blocks/init/src/Blocks/custom/video/components/video-options.js +12 -0
- package/blocks/init/src/Blocks/custom/video/manifest.json +105 -0
- package/blocks/init/src/Blocks/custom/video/video-block.js +13 -0
- package/blocks/init/src/Blocks/custom/video/video.php +22 -0
- package/blocks/init/src/Blocks/manifest.json +14 -0
- package/blocks/init/src/Blocks/variations/card-simple/manifest.json +17 -0
- package/blocks/init/src/Blocks/wrapper/components/wrapper-editor.js +12 -0
- package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +348 -0
- package/blocks/init/src/Blocks/wrapper/manifest.json +450 -0
- package/blocks/init/src/Blocks/wrapper/styles-editor.css +13 -0
- package/blocks/init/src/Blocks/wrapper/styles.css +19 -0
- package/blocks/init/src/Blocks/wrapper/wrapper.js +30 -0
- package/blocks/init/src/Blocks/wrapper/wrapper.php +34 -0
- package/eslint.config.mjs +3 -0
- package/linters/base.config.mjs +81 -0
- package/linters/eslint.config.mjs +4 -0
- package/linters/ignore-gitignored.mjs +9 -0
- package/linters/stylelint.config.js +146 -0
- package/package.json +93 -0
- package/readme/packages.md +74 -0
- package/schemas/block.json +302 -0
- package/schemas/component.json +240 -0
- package/schemas/globalManifest.json +73 -0
- package/schemas/variation.json +83 -0
- package/scripts/components/block-inserter.js +70 -0
- package/scripts/components/file-picker.js +243 -0
- package/scripts/components/index.js +6 -0
- package/scripts/components/link-section-editor.js +319 -0
- package/scripts/components/media-picker.js +86 -0
- package/scripts/components/server-side-render.js +37 -0
- package/scripts/components/settings/settings.js +48 -0
- package/scripts/components/settings/use-theme-options.js +52 -0
- package/scripts/editor/attributes.js +304 -0
- package/scripts/editor/colors.js +64 -0
- package/scripts/editor/editor.js +139 -0
- package/scripts/editor/fetch.js +102 -0
- package/scripts/editor/hooks.js +44 -0
- package/scripts/editor/index.js +11 -0
- package/scripts/editor/options.js +152 -0
- package/scripts/editor/registration.js +901 -0
- package/scripts/editor/store.js +213 -0
- package/scripts/editor/tailwindcss.js +224 -0
- package/scripts/editor/utility.js +47 -0
- package/scripts/helpers/breakpoints.js +48 -0
- package/scripts/helpers/cookies.js +65 -0
- package/scripts/helpers/dynamic-import.js +19 -0
- package/scripts/helpers/index.js +11 -0
- package/scripts/index.js +22 -0
- package/scripts/plugins/index.js +3 -0
- package/scripts/plugins/yoast-seo.js +70 -0
- package/webpack/base.mjs +138 -0
- package/webpack/helpers.mjs +67 -0
- package/webpack/index.mjs +52 -0
- package/webpack/production.mjs +60 -0
- package/webpack/project.mjs +55 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
2
|
+
import { props, checkAttr, getAttrKey, MediaPicker, wpSearchRoute } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
3
|
+
import { ShareOptions } from '../../../components/share/components/share-options';
|
|
4
|
+
import { BaseControl, Repeater, RepeaterItem, LinkInput, Toggle } from '@eightshift/ui-components';
|
|
5
|
+
import { icons } from '@eightshift/ui-components/icons';
|
|
6
|
+
import { truncate } from '@eightshift/ui-components/utilities';
|
|
7
|
+
import manifest from '../manifest.json';
|
|
8
|
+
|
|
9
|
+
export const SiteFooterOptions = ({ attributes, setAttributes, randId, setRandId }) => {
|
|
10
|
+
const siteFooterLogoUrl = checkAttr('siteFooterLogoUrl', attributes, manifest);
|
|
11
|
+
const siteFooterLogoId = checkAttr('siteFooterLogoId', attributes, manifest);
|
|
12
|
+
const siteFooterPrimary = checkAttr('siteFooterPrimary', attributes, manifest);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<BaseControl
|
|
17
|
+
icon={icons.iconGeneric}
|
|
18
|
+
label={__('Logo', '%g_textdomain%')}
|
|
19
|
+
>
|
|
20
|
+
<MediaPicker
|
|
21
|
+
onChange={({ id, url }) => {
|
|
22
|
+
setAttributes({
|
|
23
|
+
[getAttrKey('siteFooterLogoId', attributes, manifest)]: id,
|
|
24
|
+
[getAttrKey('siteFooterLogoUrl', attributes, manifest)]: url,
|
|
25
|
+
});
|
|
26
|
+
}}
|
|
27
|
+
imageId={siteFooterLogoId}
|
|
28
|
+
imageUrl={siteFooterLogoUrl}
|
|
29
|
+
imageMode='contain'
|
|
30
|
+
/>
|
|
31
|
+
</BaseControl>
|
|
32
|
+
|
|
33
|
+
<ShareOptions
|
|
34
|
+
{...props('share', attributes, { setAttributes })}
|
|
35
|
+
noUseToggle
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<Repeater
|
|
39
|
+
icon={icons.linkNav}
|
|
40
|
+
label={__('Links', '%g_textdomain%')}
|
|
41
|
+
items={siteFooterPrimary}
|
|
42
|
+
onChange={(value) => setAttributes({ [getAttrKey('siteFooterPrimary', attributes, manifest)]: value })}
|
|
43
|
+
addDefaultItem={{
|
|
44
|
+
header: '',
|
|
45
|
+
items: [
|
|
46
|
+
{
|
|
47
|
+
text: '',
|
|
48
|
+
url: '',
|
|
49
|
+
newTab: false,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{(item) => {
|
|
55
|
+
const { header, items, updateData, itemIndex } = item;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<RepeaterItem
|
|
59
|
+
label={header?.length > 0 ? header : __('New section', '%g_textdomain%')}
|
|
60
|
+
subtitle={
|
|
61
|
+
items.length > 0 && sprintf(_n('%d link', '%d links', items.length, '%g_textdomain%'), items.length)
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<Repeater
|
|
65
|
+
icon={icons.link}
|
|
66
|
+
label={__('Links', '%g_textdomain%')}
|
|
67
|
+
items={items}
|
|
68
|
+
onChange={(value) => updateData({ items: value })}
|
|
69
|
+
addDefaultItem={{
|
|
70
|
+
text: '',
|
|
71
|
+
url: '',
|
|
72
|
+
newTab: false,
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{(item) => {
|
|
76
|
+
const { text, url, newTab, updateData } = item;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<RepeaterItem
|
|
80
|
+
label={text?.length > 0 ? text : __('New link', '%g_textdomain%')}
|
|
81
|
+
subtitle={truncate(url?.replace(window.location.origin, ''), 30)}
|
|
82
|
+
>
|
|
83
|
+
<LinkInput
|
|
84
|
+
icon={url?.includes('#')}
|
|
85
|
+
url={url}
|
|
86
|
+
onChange={({ url }) => updateData({ url: url })}
|
|
87
|
+
fetchSuggestions={wpSearchRoute}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<Toggle
|
|
91
|
+
icon={icons.newTab}
|
|
92
|
+
label={__('Open in new tab', '%g_textdomain%')}
|
|
93
|
+
checked={newTab}
|
|
94
|
+
onChange={(value) => updateData({ newTab: value })}
|
|
95
|
+
/>
|
|
96
|
+
</RepeaterItem>
|
|
97
|
+
);
|
|
98
|
+
}}
|
|
99
|
+
</Repeater>
|
|
100
|
+
</RepeaterItem>
|
|
101
|
+
);
|
|
102
|
+
}}
|
|
103
|
+
</Repeater>
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/block.json",
|
|
3
|
+
"blockName": "site-footer",
|
|
4
|
+
"title": "Site footer",
|
|
5
|
+
"description": "Add extra navigation links, a logo, and social media buttons to complete your posts.",
|
|
6
|
+
"category": "eightshift",
|
|
7
|
+
"icon": {
|
|
8
|
+
"src": "es-card-teaser-alt-2"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"site",
|
|
12
|
+
"footer"
|
|
13
|
+
],
|
|
14
|
+
"example": {
|
|
15
|
+
"attributes": {
|
|
16
|
+
"siteFooterLogoUrl": "https://loremflickr.com/200/150"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"attributes": {
|
|
20
|
+
"siteFooterPrimary": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"default": []
|
|
23
|
+
},
|
|
24
|
+
"siteFooterLogoUrl": {
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"siteFooterLogoId": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"siteFooterCopyright": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"components": {
|
|
35
|
+
"share": "share"
|
|
36
|
+
},
|
|
37
|
+
"tailwind": {
|
|
38
|
+
"base": {
|
|
39
|
+
"twClasses": "pt-8 pb-4"
|
|
40
|
+
},
|
|
41
|
+
"parts": {
|
|
42
|
+
"topContainer": {
|
|
43
|
+
"twClasses": "sm:grid sm:grid-cols-[auto,_1fr] sm:gap-x-20 px-2"
|
|
44
|
+
},
|
|
45
|
+
"bottomContainer": {
|
|
46
|
+
"twClasses": "mt-8 flex items-center justify-between gap-8 border-t border-t-gray-200 pt-4 px-2"
|
|
47
|
+
},
|
|
48
|
+
"copyright": {
|
|
49
|
+
"twClasses": "inline-flex gap-1 text-sm text-gray-400"
|
|
50
|
+
},
|
|
51
|
+
"linksContainer": {
|
|
52
|
+
"twClasses": "grid grid-cols-1 sm:grid-cols-[repeat(auto-fill,_minmax(10rem,_1fr))] gap-x-8 gap-y-4 mt-8 sm:mt-0"
|
|
53
|
+
},
|
|
54
|
+
"sectionContainer": {
|
|
55
|
+
"twClasses": "space-y-0.5"
|
|
56
|
+
},
|
|
57
|
+
"sectionTitle": {
|
|
58
|
+
"twClasses": "text-sm font-medium text-gray-500"
|
|
59
|
+
},
|
|
60
|
+
"link": {
|
|
61
|
+
"twClasses": "block w-fit text-base text-gray-700 hover:underline underline-offset-2 decoration-navy-500 decoration-2",
|
|
62
|
+
"twClassesEditor": "text-base text-gray-700"
|
|
63
|
+
},
|
|
64
|
+
"logo": {
|
|
65
|
+
"twClasses": "min-h-16 w-28",
|
|
66
|
+
"twClassesEditor": "min-h-16 max-w-28 p-1 [&_img]:!object-contain"
|
|
67
|
+
},
|
|
68
|
+
"share": {
|
|
69
|
+
"twClasses": "mt-5"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SiteFooterEditor } from './components/site-footer-editor';
|
|
2
|
+
import { SiteFooterOptions } from './components/site-footer-options';
|
|
3
|
+
import { GutenbergBlock } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
4
|
+
|
|
5
|
+
export const SiteFooter = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<GutenbergBlock
|
|
8
|
+
{...props}
|
|
9
|
+
options={SiteFooterOptions}
|
|
10
|
+
editor={SiteFooterEditor}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Site footer block template.
|
|
5
|
+
*
|
|
6
|
+
* @package %g_namespace%
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
use %g_namespace_vendor_prefix%\EightshiftLibs\Helpers\Helpers;
|
|
10
|
+
|
|
11
|
+
$manifest = Helpers::getManifestByDir(__DIR__);
|
|
12
|
+
|
|
13
|
+
$siteFooterPrimary = Helpers::checkAttr('siteFooterPrimary', $attributes, $manifest);
|
|
14
|
+
$siteFooterCopyright = Helpers::checkAttr('siteFooterCopyright', $attributes, $manifest);
|
|
15
|
+
|
|
16
|
+
$siteFooterLogoUrl = Helpers::checkAttr('siteFooterLogoUrl', $attributes, $manifest);
|
|
17
|
+
$siteFooterLogoId = Helpers::checkAttr('siteFooterLogoId', $attributes, $manifest);
|
|
18
|
+
|
|
19
|
+
$logoAlt = get_post_meta($siteFooterLogoId, '_wp_attachment_image_alt', true) ?? '';
|
|
20
|
+
?>
|
|
21
|
+
|
|
22
|
+
<div class="<?php echo esc_attr(Helpers::getTwClasses($attributes, $manifest)); ?>">
|
|
23
|
+
<div class="<?php echo esc_attr(Helpers::getTwPart('topContainer', $manifest)); ?>">
|
|
24
|
+
<a href="<?php echo esc_url(get_home_url()); ?>">
|
|
25
|
+
<img
|
|
26
|
+
src="<?php echo esc_attr($siteFooterLogoUrl); ?>"
|
|
27
|
+
alt="<?php echo esc_attr($logoAlt); ?>"
|
|
28
|
+
class="<?php echo esc_attr(Helpers::getTwPart('logo', $manifest)); ?>"
|
|
29
|
+
>
|
|
30
|
+
</a>
|
|
31
|
+
<div class="<?php echo esc_attr(Helpers::getTwPart('linksContainer', $manifest)); ?>">
|
|
32
|
+
|
|
33
|
+
<?php
|
|
34
|
+
foreach ($siteFooterPrimary as $index => $value) {
|
|
35
|
+
$items = $value['items'] ?? [];
|
|
36
|
+
$header = $value['header'] ?? '';
|
|
37
|
+
?>
|
|
38
|
+
<div class="<?php echo esc_attr(Helpers::getTwPart('sectionContainer', $manifest)); ?>">
|
|
39
|
+
<p class="<?php echo esc_attr(Helpers::getTwPart('sectionTitle', $manifest)); ?>">
|
|
40
|
+
<?php echo wp_kses_post($header); ?>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<?php
|
|
44
|
+
foreach ($items as $item) {
|
|
45
|
+
$url = $item['url'] ?? '';
|
|
46
|
+
?>
|
|
47
|
+
<a
|
|
48
|
+
href="<?php echo esc_url($item['url']); ?>"
|
|
49
|
+
class="<?php echo esc_attr(Helpers::getTwPart('link', $manifest)); ?>"
|
|
50
|
+
<?php if ($item['newTab'] ?? false) { ?>
|
|
51
|
+
target="_blank"
|
|
52
|
+
rel="noopener noreferrer"
|
|
53
|
+
<?php } ?>
|
|
54
|
+
>
|
|
55
|
+
<?php echo wp_kses_post($item['text'] ?? ''); ?>
|
|
56
|
+
</a>
|
|
57
|
+
<?php } ?>
|
|
58
|
+
</div>
|
|
59
|
+
<?php } ?>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div class="<?php echo esc_attr(Helpers::getTwPart('bottomContainer', $manifest)); ?>">
|
|
64
|
+
<span class="<?php echo esc_attr(Helpers::getTwPart('copyright', $manifest)); ?>">
|
|
65
|
+
© <?php echo esc_attr($siteFooterCopyright); ?>
|
|
66
|
+
</span>
|
|
67
|
+
|
|
68
|
+
<?php
|
|
69
|
+
echo Helpers::render('share', Helpers::props('share', $attributes));
|
|
70
|
+
?>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { RichText } from '@wordpress/block-editor';
|
|
3
|
+
import { checkAttr, getAttrKey, getTwClasses, getTwPart } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
4
|
+
import { ImagePlaceholder } from '@eightshift/ui-components';
|
|
5
|
+
import manifest from '../manifest.json';
|
|
6
|
+
|
|
7
|
+
export const SiteNavigationEditor = ({ attributes, setAttributes }) => {
|
|
8
|
+
const siteNavigationLinks = checkAttr('siteNavigationLinks', attributes, manifest);
|
|
9
|
+
const siteNavigationLogoUrl = checkAttr('siteNavigationLogoUrl', attributes, manifest);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className={getTwClasses(attributes, manifest)}>
|
|
13
|
+
<ImagePlaceholder
|
|
14
|
+
style='simple'
|
|
15
|
+
imageMode='contain'
|
|
16
|
+
url={siteNavigationLogoUrl}
|
|
17
|
+
size='fullWidth'
|
|
18
|
+
className={getTwPart('logo', manifest)}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<div className={getTwPart('linkContainer', manifest)}>
|
|
22
|
+
{siteNavigationLinks.map(({ text }, index) => {
|
|
23
|
+
return (
|
|
24
|
+
<RichText
|
|
25
|
+
placeholder={__('Item', '%g_textdomain%')}
|
|
26
|
+
value={text}
|
|
27
|
+
onChange={(value) => {
|
|
28
|
+
const newLinks = [...siteNavigationLinks];
|
|
29
|
+
newLinks[index].text = value;
|
|
30
|
+
setAttributes({ [getAttrKey('siteNavigationLinks', attributes, manifest)]: newLinks });
|
|
31
|
+
}}
|
|
32
|
+
allowedFormats={[]}
|
|
33
|
+
className={getTwPart('link', manifest)}
|
|
34
|
+
withoutInteractiveFormatting
|
|
35
|
+
disableLineBreaks
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
})}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { checkAttr, getAttrKey, MediaPicker, wpSearchRoute } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
3
|
+
import { BaseControl, Repeater, RepeaterItem, LinkInput, Toggle, Spacer } from '@eightshift/ui-components';
|
|
4
|
+
import { icons } from '@eightshift/ui-components/icons';
|
|
5
|
+
import { truncate } from '@eightshift/ui-components/utilities';
|
|
6
|
+
import manifest from '../manifest.json';
|
|
7
|
+
|
|
8
|
+
export const SiteNavigationOptions = ({ attributes, setAttributes }) => {
|
|
9
|
+
const siteNavigationLinks = checkAttr('siteNavigationLinks', attributes, manifest);
|
|
10
|
+
const siteNavigationLogoUrl = checkAttr('siteNavigationLogoUrl', attributes, manifest);
|
|
11
|
+
const siteNavigationLogoId = checkAttr('siteNavigationLogoId', attributes, manifest);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<BaseControl
|
|
16
|
+
icon={icons.iconGeneric}
|
|
17
|
+
label={__('Logo', '%g_textdomain%')}
|
|
18
|
+
>
|
|
19
|
+
<MediaPicker
|
|
20
|
+
onChange={({ id, url }) => {
|
|
21
|
+
setAttributes({
|
|
22
|
+
[getAttrKey('siteNavigationLogoId', attributes, manifest)]: id,
|
|
23
|
+
[getAttrKey('siteNavigationLogoUrl', attributes, manifest)]: url,
|
|
24
|
+
});
|
|
25
|
+
}}
|
|
26
|
+
imageId={siteNavigationLogoId}
|
|
27
|
+
imageUrl={siteNavigationLogoUrl}
|
|
28
|
+
imageMode='contain'
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
<Spacer />
|
|
32
|
+
|
|
33
|
+
<Repeater
|
|
34
|
+
icon={icons.link}
|
|
35
|
+
label={__('Links', '%g_textdomain%')}
|
|
36
|
+
items={siteNavigationLinks}
|
|
37
|
+
onChange={(value) => setAttributes({ [getAttrKey('siteNavigationLinks', attributes, manifest)]: value })}
|
|
38
|
+
addDefaultItem={{
|
|
39
|
+
text: '',
|
|
40
|
+
url: '',
|
|
41
|
+
newTab: false,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{(item) => {
|
|
45
|
+
const { text, url, newTab, updateData } = item;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<RepeaterItem
|
|
49
|
+
icon={text?.length < 1 && icons.solidCircleGradient}
|
|
50
|
+
label={text?.length > 0 ? text : __('New link', '%g_textdomain%')}
|
|
51
|
+
subtitle={truncate(url?.replace(window.location.origin, ''), 30)}
|
|
52
|
+
>
|
|
53
|
+
<LinkInput
|
|
54
|
+
icon={url?.includes('#')}
|
|
55
|
+
url={url}
|
|
56
|
+
onChange={({ url }) => updateData({ url: url })}
|
|
57
|
+
fetchSuggestions={wpSearchRoute}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<Toggle
|
|
61
|
+
icon={icons.newTab}
|
|
62
|
+
label={__('Open in new tab', '%g_textdomain%')}
|
|
63
|
+
checked={newTab}
|
|
64
|
+
onChange={(value) => updateData({ newTab: value })}
|
|
65
|
+
/>
|
|
66
|
+
</RepeaterItem>
|
|
67
|
+
);
|
|
68
|
+
}}
|
|
69
|
+
</Repeater>
|
|
70
|
+
</BaseControl>
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/block.json",
|
|
3
|
+
"blockName": "site-navigation",
|
|
4
|
+
"title": "Site navigation",
|
|
5
|
+
"description": "Add top-level navigation links to your website.",
|
|
6
|
+
"category": "eightshift",
|
|
7
|
+
"icon": {
|
|
8
|
+
"src": "es-navbar"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"site",
|
|
12
|
+
"navigation",
|
|
13
|
+
"navbar"
|
|
14
|
+
],
|
|
15
|
+
"example": {
|
|
16
|
+
"attributes": {
|
|
17
|
+
"siteNavigationLogoUrl": "https://loremflickr.com/200/150"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"attributes": {
|
|
21
|
+
"siteNavigationLinks": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"default": []
|
|
24
|
+
},
|
|
25
|
+
"siteNavigationLogoUrl": {
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"siteNavigationLogoId": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"wrapperUse": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"default": false
|
|
34
|
+
},
|
|
35
|
+
"wrapperNoControls": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"default": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"tailwind": {
|
|
41
|
+
"base": {
|
|
42
|
+
"twClasses": "flex items-center justify-between gap-4 max-w-screen-md mx-auto h-full ~sm/md:~px-8/20",
|
|
43
|
+
"twClassesEditor": "flex items-center justify-between gap-4 p-1"
|
|
44
|
+
},
|
|
45
|
+
"parts": {
|
|
46
|
+
"wrapper": {
|
|
47
|
+
"twClasses": "bg-white border-b border-b-gray-100 ~sm/md:~h-16/20"
|
|
48
|
+
},
|
|
49
|
+
"logo": {
|
|
50
|
+
"twClasses": "~sm/md:~w-20/28",
|
|
51
|
+
"twClassesEditor": "max-w-32"
|
|
52
|
+
},
|
|
53
|
+
"link": {
|
|
54
|
+
"twClasses": "text-base text-gray-700 hover:underline underline-offset-2 decoration-red-500 decoration-2",
|
|
55
|
+
"twClassesEditor": "text-base"
|
|
56
|
+
},
|
|
57
|
+
"drawerLink": {
|
|
58
|
+
"twClasses": "text-lg sm:text-base text-gray-700 hover:underline underline-offset-2 decoration-red-500 decoration-2 block py-4 sm:py-2"
|
|
59
|
+
},
|
|
60
|
+
"linkContainer": {
|
|
61
|
+
"twClasses": "hidden sm:flex items-center gap-6 pr-2"
|
|
62
|
+
},
|
|
63
|
+
"button": {
|
|
64
|
+
"twClasses": "size-9 flex items-center justify-center rounded-md border border-gray-500 hover:bg-gray-500 focus:outline-none focus-visible:ring focus-visible:ring-navy-500/30 text-gray-600 hover:text-white transition"
|
|
65
|
+
},
|
|
66
|
+
"modalWrapper": {
|
|
67
|
+
"twClasses": "hidden open:block group"
|
|
68
|
+
},
|
|
69
|
+
"modalBackdrop": {
|
|
70
|
+
"twClasses": "fixed inset-0 wp-admin-bar-offset bg-black/50 z-30 duration-300 group-aria-hidden:animate-out group-aria-hidden:fade-out animate-in fade-in-0"
|
|
71
|
+
},
|
|
72
|
+
"modalContent": {
|
|
73
|
+
"twClasses": "bg-white rounded-lg ~sm/md:~m-2/6 sm:w-80 p-6 sm:p-4 sm:pl-6 space-y-3 sm:ml-auto shadow-md animate-in slide-in-from-top-4 group-aria-hidden:animate-out group-aria-hidden:slide-out-to-top-4"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SiteNavigationEditor } from './components/site-navigation-editor';
|
|
2
|
+
import { SiteNavigationOptions } from './components/site-navigation-options';
|
|
3
|
+
import { GutenbergBlock } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
4
|
+
|
|
5
|
+
export const SiteNavigation = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<GutenbergBlock
|
|
8
|
+
{...props}
|
|
9
|
+
options={SiteNavigationOptions}
|
|
10
|
+
editor={SiteNavigationEditor}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Site navigation block template.
|
|
5
|
+
*
|
|
6
|
+
* @package %g_namespace%
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
use %g_namespace_vendor_prefix%\EightshiftLibs\Helpers\Helpers;
|
|
10
|
+
|
|
11
|
+
$manifest = Helpers::getManifestByDir(__DIR__);
|
|
12
|
+
|
|
13
|
+
$blockJsClass = $attributes['blockJsClass'] ?? '';
|
|
14
|
+
|
|
15
|
+
$siteNavigationLinks = Helpers::checkAttr('siteNavigationLinks', $attributes, $manifest) ?? [];
|
|
16
|
+
$siteNavigationLogoUrl = Helpers::checkAttr('siteNavigationLogoUrl', $attributes, $manifest);
|
|
17
|
+
$siteNavigationLogoId = Helpers::checkAttr('siteNavigationLogoId', $attributes, $manifest);
|
|
18
|
+
|
|
19
|
+
$logoAlt = get_post_meta($siteNavigationLogoId, '_wp_attachment_image_alt', true) ?? '';
|
|
20
|
+
|
|
21
|
+
$drawerId = 'navbar-mobile-flyout';
|
|
22
|
+
?>
|
|
23
|
+
|
|
24
|
+
<nav class="<?php echo esc_attr(Helpers::getTwPart('wrapper', $manifest)); ?>">
|
|
25
|
+
<div class="<?php echo esc_attr(Helpers::getTwClasses($attributes, $manifest)); ?>">
|
|
26
|
+
<a href="<?php echo esc_url(get_home_url()); ?>">
|
|
27
|
+
<img
|
|
28
|
+
src="<?php echo esc_attr($siteNavigationLogoUrl); ?>"
|
|
29
|
+
alt="<?php echo esc_attr($logoAlt); ?>"
|
|
30
|
+
class="<?php echo esc_attr(Helpers::getTwPart('logo', $manifest)); ?>"
|
|
31
|
+
>
|
|
32
|
+
</a>
|
|
33
|
+
|
|
34
|
+
<div class="<?php echo esc_attr(Helpers::getTwPart('linkContainer', $manifest)); ?>">
|
|
35
|
+
<?php
|
|
36
|
+
foreach ($siteNavigationLinks as $navLink) {
|
|
37
|
+
$url = $navLink['url'] ?? '';
|
|
38
|
+
$text = $navLink['text'] ?? '';
|
|
39
|
+
|
|
40
|
+
if (empty($url) || empty($text)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
?>
|
|
44
|
+
<a
|
|
45
|
+
href="<?php echo esc_attr($url); ?>"
|
|
46
|
+
class="<?php echo esc_attr(Helpers::getTwPart('link', $manifest)); ?>"
|
|
47
|
+
<?php if ($navLink['newTab'] ?? false) { ?>
|
|
48
|
+
target="_blank"
|
|
49
|
+
rel="noopener noreferrer"
|
|
50
|
+
<?php } ?>
|
|
51
|
+
>
|
|
52
|
+
<?php echo wp_kses_post($text); ?>
|
|
53
|
+
</a>
|
|
54
|
+
<?php } ?>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<button class="<?php echo esc_attr(Helpers::getTwPart('button', $manifest, 'sm:hidden')); ?>" data-micromodal-trigger="<?php echo esc_attr($drawerId); ?>">
|
|
58
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
|
59
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
|
|
60
|
+
</svg>
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
</nav>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<div id="<?php echo esc_attr($drawerId); ?>" aria-hidden="true" class="<?php echo esc_attr(Helpers::getTwPart('modalWrapper', $manifest)); ?>">
|
|
67
|
+
<div tabindex="-1" class="<?php echo esc_attr(Helpers::getTwPart('modalBackdrop', $manifest)); ?>" data-micromodal-close>
|
|
68
|
+
<div class="<?php echo esc_attr(Helpers::getTwPart('modalContent', $manifest)); ?>" role="dialog" aria-modal="true" aria-label="<?php echo esc_html__('Main menu', '%g_textdomain%'); ?>-title">
|
|
69
|
+
<button class="<?php echo esc_attr(Helpers::getTwPart('button', $manifest, 'ml-auto')); ?>" aria-label="Close menu" data-micromodal-close>
|
|
70
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
|
71
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
|
72
|
+
</svg>
|
|
73
|
+
</button>
|
|
74
|
+
|
|
75
|
+
<div id="<?php echo esc_attr($drawerId); ?>-content">
|
|
76
|
+
<?php
|
|
77
|
+
foreach ($siteNavigationLinks as $navLink) {
|
|
78
|
+
$url = $navLink['url'] ?? '';
|
|
79
|
+
$text = $navLink['text'] ?? '';
|
|
80
|
+
|
|
81
|
+
if (empty($url) || empty($text)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
?>
|
|
85
|
+
<a
|
|
86
|
+
href="<?php echo esc_attr($url); ?>"
|
|
87
|
+
class="<?php echo esc_attr(Helpers::getTwPart('drawerLink', $manifest)); ?>"
|
|
88
|
+
<?php if ($navLink['newTab'] ?? false) { ?>
|
|
89
|
+
target="_blank"
|
|
90
|
+
rel="noopener noreferrer"
|
|
91
|
+
<?php } ?>
|
|
92
|
+
>
|
|
93
|
+
<?php echo wp_kses_post($text); ?>
|
|
94
|
+
</a>
|
|
95
|
+
<?php } ?>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import domReady from '@wordpress/dom-ready';
|
|
2
|
+
|
|
3
|
+
domReady(async () => {
|
|
4
|
+
const tocBlocks = document.querySelectorAll('.js-block-table-of-contents');
|
|
5
|
+
|
|
6
|
+
if (tocBlocks?.length < 1) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
tocBlocks.forEach((tocBlock) => {
|
|
11
|
+
const levelsToUse = tocBlock?.dataset?.levels ?? 'h1,h2,h3,h4,h5,h6';
|
|
12
|
+
|
|
13
|
+
const headings = document.querySelectorAll(`.main-content :where(${levelsToUse})`);
|
|
14
|
+
|
|
15
|
+
headings.forEach((heading) => {
|
|
16
|
+
const entry = document.createElement('button');
|
|
17
|
+
entry.className = 'block py-0.5 focus:outline-none group';
|
|
18
|
+
|
|
19
|
+
const itemClassName =
|
|
20
|
+
'transition text-sm rounded group-hover:bg-navy-100 group-hover:ring-4 group-hover:ring-navy-100 group-hover:text-navy-950 group-focus-visible:bg-navy-950 group-focus-visible:ring-4 group-focus-visible:ring-navy-950 group-focus-visible:text-navy-50';
|
|
21
|
+
|
|
22
|
+
let preText = '';
|
|
23
|
+
const dash = '–';
|
|
24
|
+
|
|
25
|
+
const dashClassName = 'text-gray-300 mr-1.5 tracking-tighter';
|
|
26
|
+
|
|
27
|
+
switch (heading.tagName.toLowerCase()) {
|
|
28
|
+
case 'h2':
|
|
29
|
+
preText = `<span class="${dashClassName}">${dash}</span>`;
|
|
30
|
+
break;
|
|
31
|
+
case 'h3':
|
|
32
|
+
preText = `<span class="${dashClassName}">${dash.repeat(2)}</span>`;
|
|
33
|
+
break;
|
|
34
|
+
case 'h4':
|
|
35
|
+
preText = `<span class="${dashClassName}">${dash.repeat(3)}</span>`;
|
|
36
|
+
break;
|
|
37
|
+
case 'h5':
|
|
38
|
+
preText = `<span class="${dashClassName}">${dash.repeat(4)}</span>`;
|
|
39
|
+
break;
|
|
40
|
+
case 'h6':
|
|
41
|
+
preText = `<span class="${dashClassName}">${dash.repeat(5)}</span>`;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
entry.innerHTML = `${preText}<span class="${itemClassName}${heading.tagName.toLowerCase() !== 'h1' ? 'px-0.5' : ''}">${heading.innerText}</span>`;
|
|
46
|
+
|
|
47
|
+
entry.addEventListener('click', () => {
|
|
48
|
+
heading.scrollIntoView({
|
|
49
|
+
behavior: 'smooth',
|
|
50
|
+
block: 'start',
|
|
51
|
+
inline: 'start',
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
tocBlock.appendChild(entry);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
2
|
+
import { RichText } from '@wordpress/block-editor';
|
|
3
|
+
import { checkAttr, getTwPart } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
4
|
+
import { clsx } from '@eightshift/ui-components/utilities';
|
|
5
|
+
import manifest from '../manifest.json';
|
|
6
|
+
|
|
7
|
+
export const TableOfContentsEditor = ({ attributes, setAttributes }) => {
|
|
8
|
+
const tableOfContentsDescription = checkAttr('tableOfContentsDescription', attributes, manifest);
|
|
9
|
+
const tableOfContentsHeadingLevels = checkAttr('tableOfContentsHeadingLevels', attributes, manifest);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className={getTwPart('container', manifest)}>
|
|
13
|
+
<RichText
|
|
14
|
+
placeholder={manifest.attributes.tableOfContentsDescription.default}
|
|
15
|
+
value={tableOfContentsDescription}
|
|
16
|
+
onChange={(value) => setAttributes({ [getAttrKey('tableOfContentsDescription', attributes, manifest)]: value })}
|
|
17
|
+
allowedFormats={[]}
|
|
18
|
+
className={getTwPart('description', manifest)}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
{Object.entries(tableOfContentsHeadingLevels).map(([tag, enabled = false]) => (
|
|
22
|
+
<DemoTocItem
|
|
23
|
+
level={parseInt(tag.replace('h', ''))}
|
|
24
|
+
disabled={!enabled}
|
|
25
|
+
/>
|
|
26
|
+
))}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const DemoTocItem = ({ level, disabled }) => (
|
|
32
|
+
<div class={clsx('group block select-none py-0.5 focus:outline-none', disabled && 'pointer-events-none opacity-25')}>
|
|
33
|
+
{level > 1 && <span class='mr-1.5 tracking-tighter text-gray-300'>{'–'.repeat(level - 1)}</span>}
|
|
34
|
+
<span class='group-focus-visible:text-navy-50px-0.5 rounded text-sm transition group-hover:bg-navy-100 group-hover:text-navy-950 group-hover:ring-4 group-hover:ring-navy-100 group-focus-visible:bg-navy-950 group-focus-visible:ring-4 group-focus-visible:ring-navy-950'>
|
|
35
|
+
{sprintf(__('Heading %d', '%g_textdomain%'), level)}
|
|
36
|
+
</span>
|
|
37
|
+
</div>
|
|
38
|
+
);
|