@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.
Files changed (275) hide show
  1. package/.gitattributes +37 -0
  2. package/.github/CODEOWNERS +1 -0
  3. package/.github/CONTRIBUTING.md +17 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +10 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +10 -0
  6. package/.github/ISSUE_TEMPLATE/question.md +10 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  8. package/.github/workflows/ci.yml +31 -0
  9. package/.husky/pre-commit +1 -0
  10. package/.prettierrc +14 -0
  11. package/.stylelintrc +4 -0
  12. package/CHANGELOG.md +13 -0
  13. package/CODE_OF_CONDUCT.md +76 -0
  14. package/LICENSE +21 -0
  15. package/README.md +24 -0
  16. package/blocks/init/assets/application-admin.js +10 -0
  17. package/blocks/init/assets/application.js +13 -0
  18. package/blocks/init/assets/images/index.js +5 -0
  19. package/blocks/init/assets/scripts/application-admin.js +7 -0
  20. package/blocks/init/assets/scripts/application.js +3 -0
  21. package/blocks/init/assets/scripts/theme-colors.js +39 -0
  22. package/blocks/init/assets/styles/application-admin.css +6 -0
  23. package/blocks/init/assets/styles/application.css +3 -0
  24. package/blocks/init/src/Blocks/assets/application-blocks-editor.js +14 -0
  25. package/blocks/init/src/Blocks/assets/application-blocks-frontend.js +13 -0
  26. package/blocks/init/src/Blocks/assets/application-blocks.js +9 -0
  27. package/blocks/init/src/Blocks/assets/scripts/application-blocks-editor.js +65 -0
  28. package/blocks/init/src/Blocks/assets/scripts/application-blocks-frontend.js +24 -0
  29. package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +258 -0
  30. package/blocks/init/src/Blocks/assets/scripts/shared.js +25 -0
  31. package/blocks/init/src/Blocks/assets/styles/application-blocks-editor.css +15 -0
  32. package/blocks/init/src/Blocks/assets/styles/application-blocks-frontend.css +12 -0
  33. package/blocks/init/src/Blocks/assets/styles/application-blocks.css +0 -0
  34. package/blocks/init/src/Blocks/assets/styles/editor/editor-overrides.css +15 -0
  35. package/blocks/init/src/Blocks/assets/styles/tailwind.css +34 -0
  36. package/blocks/init/src/Blocks/components/admin-theme-options/admin-theme-options.php +20 -0
  37. package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/index.js +36 -0
  38. package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/pages/parts.js +55 -0
  39. package/blocks/init/src/Blocks/components/admin-theme-options/manifest.json +5 -0
  40. package/blocks/init/src/Blocks/components/button/assets/index.js +22 -0
  41. package/blocks/init/src/Blocks/components/button/button.php +77 -0
  42. package/blocks/init/src/Blocks/components/button/components/button-editor.js +40 -0
  43. package/blocks/init/src/Blocks/components/button/components/button-options.js +135 -0
  44. package/blocks/init/src/Blocks/components/button/manifest.json +299 -0
  45. package/blocks/init/src/Blocks/components/card/card.php +42 -0
  46. package/blocks/init/src/Blocks/components/card/components/card-editor.js +39 -0
  47. package/blocks/init/src/Blocks/components/card/components/card-options.js +56 -0
  48. package/blocks/init/src/Blocks/components/card/manifest.json +111 -0
  49. package/blocks/init/src/Blocks/components/head/head.php +52 -0
  50. package/blocks/init/src/Blocks/components/head/manifest.json +17 -0
  51. package/blocks/init/src/Blocks/components/heading/components/heading-editor.js +30 -0
  52. package/blocks/init/src/Blocks/components/heading/components/heading-options.js +62 -0
  53. package/blocks/init/src/Blocks/components/heading/heading.php +45 -0
  54. package/blocks/init/src/Blocks/components/heading/manifest.json +76 -0
  55. package/blocks/init/src/Blocks/components/hero/components/hero-editor.js +42 -0
  56. package/blocks/init/src/Blocks/components/hero/components/hero-options.js +100 -0
  57. package/blocks/init/src/Blocks/components/hero/hero.php +45 -0
  58. package/blocks/init/src/Blocks/components/hero/manifest.json +96 -0
  59. package/blocks/init/src/Blocks/components/icon/components/icon-editor.js +23 -0
  60. package/blocks/init/src/Blocks/components/icon/components/icon-options.js +65 -0
  61. package/blocks/init/src/Blocks/components/icon/icon.php +34 -0
  62. package/blocks/init/src/Blocks/components/icon/manifest.json +1234 -0
  63. package/blocks/init/src/Blocks/components/image/components/image-editor.js +65 -0
  64. package/blocks/init/src/Blocks/components/image/components/image-options.js +111 -0
  65. package/blocks/init/src/Blocks/components/image/image.php +62 -0
  66. package/blocks/init/src/Blocks/components/image/manifest.json +125 -0
  67. package/blocks/init/src/Blocks/components/list/components/list-editor.js +30 -0
  68. package/blocks/init/src/Blocks/components/list/components/list-options.js +62 -0
  69. package/blocks/init/src/Blocks/components/list/list.php +32 -0
  70. package/blocks/init/src/Blocks/components/list/manifest.json +127 -0
  71. package/blocks/init/src/Blocks/components/load-more/assets/index.js +19 -0
  72. package/blocks/init/src/Blocks/components/load-more/assets/load-more.js +147 -0
  73. package/blocks/init/src/Blocks/components/load-more/components/load-more-editor.js +14 -0
  74. package/blocks/init/src/Blocks/components/load-more/components/load-more-options.js +18 -0
  75. package/blocks/init/src/Blocks/components/load-more/load-more.php +47 -0
  76. package/blocks/init/src/Blocks/components/load-more/manifest.json +39 -0
  77. package/blocks/init/src/Blocks/components/modal/assets/index.js +27 -0
  78. package/blocks/init/src/Blocks/components/modal/manifest.json +48 -0
  79. package/blocks/init/src/Blocks/components/modal/modal.php +46 -0
  80. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +40 -0
  81. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +48 -0
  82. package/blocks/init/src/Blocks/components/paragraph/manifest.json +83 -0
  83. package/blocks/init/src/Blocks/components/paragraph/paragraph.php +33 -0
  84. package/blocks/init/src/Blocks/components/post-header/manifest.json +5 -0
  85. package/blocks/init/src/Blocks/components/post-header/post-header.php +24 -0
  86. package/blocks/init/src/Blocks/components/quote/components/quote-editor.js +53 -0
  87. package/blocks/init/src/Blocks/components/quote/components/quote-options.js +29 -0
  88. package/blocks/init/src/Blocks/components/quote/manifest.json +47 -0
  89. package/blocks/init/src/Blocks/components/quote/quote.php +49 -0
  90. package/blocks/init/src/Blocks/components/share/assets/index.js +39 -0
  91. package/blocks/init/src/Blocks/components/share/components/share-editor.js +25 -0
  92. package/blocks/init/src/Blocks/components/share/components/share-options.js +112 -0
  93. package/blocks/init/src/Blocks/components/share/manifest.json +72 -0
  94. package/blocks/init/src/Blocks/components/share/share.php +66 -0
  95. package/blocks/init/src/Blocks/components/tracking-before-body-end/manifest.json +5 -0
  96. package/blocks/init/src/Blocks/components/tracking-before-body-end/tracking-before-body-end.php +9 -0
  97. package/blocks/init/src/Blocks/components/tracking-head/manifest.json +5 -0
  98. package/blocks/init/src/Blocks/components/tracking-head/tracking-head.php +9 -0
  99. package/blocks/init/src/Blocks/components/video/components/video-editor.js +74 -0
  100. package/blocks/init/src/Blocks/components/video/components/video-options.js +280 -0
  101. package/blocks/init/src/Blocks/components/video/manifest.json +116 -0
  102. package/blocks/init/src/Blocks/components/video/video.php +72 -0
  103. package/blocks/init/src/Blocks/custom/accordion/accordion-block.js +15 -0
  104. package/blocks/init/src/Blocks/custom/accordion/accordion.php +28 -0
  105. package/blocks/init/src/Blocks/custom/accordion/assets/index.js +37 -0
  106. package/blocks/init/src/Blocks/custom/accordion/components/accordion-editor.js +17 -0
  107. package/blocks/init/src/Blocks/custom/accordion/components/accordion-options.js +18 -0
  108. package/blocks/init/src/Blocks/custom/accordion/manifest.json +32 -0
  109. package/blocks/init/src/Blocks/custom/accordion-item/accordion-item-block.js +19 -0
  110. package/blocks/init/src/Blocks/custom/accordion-item/accordion-item.php +46 -0
  111. package/blocks/init/src/Blocks/custom/accordion-item/components/accordion-item-editor.js +60 -0
  112. package/blocks/init/src/Blocks/custom/accordion-item/manifest.json +69 -0
  113. package/blocks/init/src/Blocks/custom/button/button-block.js +13 -0
  114. package/blocks/init/src/Blocks/custom/button/button.php +11 -0
  115. package/blocks/init/src/Blocks/custom/button/components/button-editor.js +12 -0
  116. package/blocks/init/src/Blocks/custom/button/components/button-options.js +12 -0
  117. package/blocks/init/src/Blocks/custom/button/manifest.json +18 -0
  118. package/blocks/init/src/Blocks/custom/card/card-block.js +13 -0
  119. package/blocks/init/src/Blocks/custom/card/card.php +11 -0
  120. package/blocks/init/src/Blocks/custom/card/components/card-editor.js +12 -0
  121. package/blocks/init/src/Blocks/custom/card/components/card-options.js +15 -0
  122. package/blocks/init/src/Blocks/custom/card/manifest.json +18 -0
  123. package/blocks/init/src/Blocks/custom/carousel/assets/index.js +46 -0
  124. package/blocks/init/src/Blocks/custom/carousel/assets/navigation.js +31 -0
  125. package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +39 -0
  126. package/blocks/init/src/Blocks/custom/carousel/carousel-block.js +21 -0
  127. package/blocks/init/src/Blocks/custom/carousel/carousel.php +61 -0
  128. package/blocks/init/src/Blocks/custom/carousel/components/carousel-editor.js +25 -0
  129. package/blocks/init/src/Blocks/custom/carousel/components/carousel-options.js +47 -0
  130. package/blocks/init/src/Blocks/custom/carousel/manifest.json +130 -0
  131. package/blocks/init/src/Blocks/custom/column/column-block.js +21 -0
  132. package/blocks/init/src/Blocks/custom/column/column-hooks.js +32 -0
  133. package/blocks/init/src/Blocks/custom/column/column.php +21 -0
  134. package/blocks/init/src/Blocks/custom/column/components/column-editor.js +19 -0
  135. package/blocks/init/src/Blocks/custom/column/components/column-options.js +579 -0
  136. package/blocks/init/src/Blocks/custom/column/manifest.json +625 -0
  137. package/blocks/init/src/Blocks/custom/columns/columns-block.js +20 -0
  138. package/blocks/init/src/Blocks/custom/columns/columns.php +21 -0
  139. package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +81 -0
  140. package/blocks/init/src/Blocks/custom/columns/components/columns-options.js +104 -0
  141. package/blocks/init/src/Blocks/custom/columns/manifest.json +555 -0
  142. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-editor.js +28 -0
  143. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +239 -0
  144. package/blocks/init/src/Blocks/custom/featured-content/featured-content-block.js +13 -0
  145. package/blocks/init/src/Blocks/custom/featured-content/featured-content.php +139 -0
  146. package/blocks/init/src/Blocks/custom/featured-content/manifest.json +131 -0
  147. package/blocks/init/src/Blocks/custom/featured-content/partials/cards.php +39 -0
  148. package/blocks/init/src/Blocks/custom/group/components/group-editor.js +8 -0
  149. package/blocks/init/src/Blocks/custom/group/group-block.js +14 -0
  150. package/blocks/init/src/Blocks/custom/group/group.php +10 -0
  151. package/blocks/init/src/Blocks/custom/group/manifest.json +32 -0
  152. package/blocks/init/src/Blocks/custom/heading/components/heading-editor.js +15 -0
  153. package/blocks/init/src/Blocks/custom/heading/components/heading-options.js +38 -0
  154. package/blocks/init/src/Blocks/custom/heading/heading-block.js +13 -0
  155. package/blocks/init/src/Blocks/custom/heading/heading-transforms.js +25 -0
  156. package/blocks/init/src/Blocks/custom/heading/heading.php +15 -0
  157. package/blocks/init/src/Blocks/custom/heading/manifest.json +79 -0
  158. package/blocks/init/src/Blocks/custom/hero/components/hero-editor.js +12 -0
  159. package/blocks/init/src/Blocks/custom/hero/components/hero-options.js +14 -0
  160. package/blocks/init/src/Blocks/custom/hero/hero-block.js +13 -0
  161. package/blocks/init/src/Blocks/custom/hero/hero.php +11 -0
  162. package/blocks/init/src/Blocks/custom/hero/manifest.json +17 -0
  163. package/blocks/init/src/Blocks/custom/image/components/image-editor.js +12 -0
  164. package/blocks/init/src/Blocks/custom/image/components/image-options.js +14 -0
  165. package/blocks/init/src/Blocks/custom/image/image-block.js +13 -0
  166. package/blocks/init/src/Blocks/custom/image/image.php +11 -0
  167. package/blocks/init/src/Blocks/custom/image/manifest.json +105 -0
  168. package/blocks/init/src/Blocks/custom/list/components/list-editor.js +14 -0
  169. package/blocks/init/src/Blocks/custom/list/components/list-options.js +39 -0
  170. package/blocks/init/src/Blocks/custom/list/list-block.js +13 -0
  171. package/blocks/init/src/Blocks/custom/list/list.php +15 -0
  172. package/blocks/init/src/Blocks/custom/list/manifest.json +58 -0
  173. package/blocks/init/src/Blocks/custom/map/assets/index.js +20 -0
  174. package/blocks/init/src/Blocks/custom/map/assets/map-controller.js +42 -0
  175. package/blocks/init/src/Blocks/custom/map/assets/utils.js +161 -0
  176. package/blocks/init/src/Blocks/custom/map/components/map-components.js +403 -0
  177. package/blocks/init/src/Blocks/custom/map/components/map-editor.js +56 -0
  178. package/blocks/init/src/Blocks/custom/map/components/map-options.js +557 -0
  179. package/blocks/init/src/Blocks/custom/map/manifest.json +79 -0
  180. package/blocks/init/src/Blocks/custom/map/map-block.js +13 -0
  181. package/blocks/init/src/Blocks/custom/map/map.php +52 -0
  182. package/blocks/init/src/Blocks/custom/map/styles.css +2 -0
  183. package/blocks/init/src/Blocks/custom/modal/components/modal-editor.js +90 -0
  184. package/blocks/init/src/Blocks/custom/modal/manifest.json +51 -0
  185. package/blocks/init/src/Blocks/custom/modal/modal-block.js +14 -0
  186. package/blocks/init/src/Blocks/custom/modal/modal.php +20 -0
  187. package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-editor.js +41 -0
  188. package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-options.js +38 -0
  189. package/blocks/init/src/Blocks/custom/paragraph/manifest.json +79 -0
  190. package/blocks/init/src/Blocks/custom/paragraph/paragraph-block.js +13 -0
  191. package/blocks/init/src/Blocks/custom/paragraph/paragraph-transforms.js +45 -0
  192. package/blocks/init/src/Blocks/custom/paragraph/paragraph.php +15 -0
  193. package/blocks/init/src/Blocks/custom/quote/components/quote-editor.js +12 -0
  194. package/blocks/init/src/Blocks/custom/quote/components/quote-options.js +14 -0
  195. package/blocks/init/src/Blocks/custom/quote/manifest.json +17 -0
  196. package/blocks/init/src/Blocks/custom/quote/quote-block.js +13 -0
  197. package/blocks/init/src/Blocks/custom/quote/quote.php +13 -0
  198. package/blocks/init/src/Blocks/custom/share/components/share-editor.js +6 -0
  199. package/blocks/init/src/Blocks/custom/share/components/share-options.js +12 -0
  200. package/blocks/init/src/Blocks/custom/share/manifest.json +19 -0
  201. package/blocks/init/src/Blocks/custom/share/share-block.js +13 -0
  202. package/blocks/init/src/Blocks/custom/share/share.php +11 -0
  203. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-editor.js +57 -0
  204. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +106 -0
  205. package/blocks/init/src/Blocks/custom/site-footer/manifest.json +73 -0
  206. package/blocks/init/src/Blocks/custom/site-footer/site-footer-block.js +13 -0
  207. package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +72 -0
  208. package/blocks/init/src/Blocks/custom/site-navigation/assets/index.js +9 -0
  209. package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-editor.js +42 -0
  210. package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-options.js +73 -0
  211. package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +77 -0
  212. package/blocks/init/src/Blocks/custom/site-navigation/site-navigation-block.js +13 -0
  213. package/blocks/init/src/Blocks/custom/site-navigation/site-navigation.php +99 -0
  214. package/blocks/init/src/Blocks/custom/table-of-contents/assets/index.js +58 -0
  215. package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js +38 -0
  216. package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-options.js +32 -0
  217. package/blocks/init/src/Blocks/custom/table-of-contents/manifest.json +48 -0
  218. package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents-block.js +13 -0
  219. package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents.php +31 -0
  220. package/blocks/init/src/Blocks/custom/video/components/video-editor.js +6 -0
  221. package/blocks/init/src/Blocks/custom/video/components/video-options.js +12 -0
  222. package/blocks/init/src/Blocks/custom/video/manifest.json +105 -0
  223. package/blocks/init/src/Blocks/custom/video/video-block.js +13 -0
  224. package/blocks/init/src/Blocks/custom/video/video.php +22 -0
  225. package/blocks/init/src/Blocks/manifest.json +14 -0
  226. package/blocks/init/src/Blocks/variations/card-simple/manifest.json +17 -0
  227. package/blocks/init/src/Blocks/wrapper/components/wrapper-editor.js +12 -0
  228. package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +348 -0
  229. package/blocks/init/src/Blocks/wrapper/manifest.json +450 -0
  230. package/blocks/init/src/Blocks/wrapper/styles-editor.css +13 -0
  231. package/blocks/init/src/Blocks/wrapper/styles.css +19 -0
  232. package/blocks/init/src/Blocks/wrapper/wrapper.js +30 -0
  233. package/blocks/init/src/Blocks/wrapper/wrapper.php +34 -0
  234. package/eslint.config.mjs +3 -0
  235. package/linters/base.config.mjs +81 -0
  236. package/linters/eslint.config.mjs +4 -0
  237. package/linters/ignore-gitignored.mjs +9 -0
  238. package/linters/stylelint.config.js +146 -0
  239. package/package.json +93 -0
  240. package/readme/packages.md +74 -0
  241. package/schemas/block.json +302 -0
  242. package/schemas/component.json +240 -0
  243. package/schemas/globalManifest.json +73 -0
  244. package/schemas/variation.json +83 -0
  245. package/scripts/components/block-inserter.js +70 -0
  246. package/scripts/components/file-picker.js +243 -0
  247. package/scripts/components/index.js +6 -0
  248. package/scripts/components/link-section-editor.js +319 -0
  249. package/scripts/components/media-picker.js +86 -0
  250. package/scripts/components/server-side-render.js +37 -0
  251. package/scripts/components/settings/settings.js +48 -0
  252. package/scripts/components/settings/use-theme-options.js +52 -0
  253. package/scripts/editor/attributes.js +304 -0
  254. package/scripts/editor/colors.js +64 -0
  255. package/scripts/editor/editor.js +139 -0
  256. package/scripts/editor/fetch.js +102 -0
  257. package/scripts/editor/hooks.js +44 -0
  258. package/scripts/editor/index.js +11 -0
  259. package/scripts/editor/options.js +152 -0
  260. package/scripts/editor/registration.js +901 -0
  261. package/scripts/editor/store.js +213 -0
  262. package/scripts/editor/tailwindcss.js +224 -0
  263. package/scripts/editor/utility.js +47 -0
  264. package/scripts/helpers/breakpoints.js +48 -0
  265. package/scripts/helpers/cookies.js +65 -0
  266. package/scripts/helpers/dynamic-import.js +19 -0
  267. package/scripts/helpers/index.js +11 -0
  268. package/scripts/index.js +22 -0
  269. package/scripts/plugins/index.js +3 -0
  270. package/scripts/plugins/yoast-seo.js +70 -0
  271. package/webpack/base.mjs +138 -0
  272. package/webpack/helpers.mjs +67 -0
  273. package/webpack/index.mjs +52 -0
  274. package/webpack/production.mjs +60 -0
  275. package/webpack/project.mjs +55 -0
@@ -0,0 +1,258 @@
1
+ import { useCallback } from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { RichText } from '@wordpress/block-editor';
4
+ import { Button } from '@eightshift/ui-components';
5
+ import { icons } from '@eightshift/ui-components/icons';
6
+
7
+ export const LinkSectionEditor = (props) => {
8
+ const { links, onChange, classNames } = props;
9
+
10
+ const defaultLink = {
11
+ text: '',
12
+ url: '',
13
+ newTab: false,
14
+ };
15
+
16
+ const defaultSection = {
17
+ header: '',
18
+ items: [defaultLink],
19
+ };
20
+
21
+ const addSection = useCallback(
22
+ (index = -1) => {
23
+ if (index < 0) {
24
+ onChange([...links, defaultSection]);
25
+
26
+ return;
27
+ }
28
+
29
+ const before = links.slice(0, index + 1);
30
+ const after = links.slice(index + 1);
31
+
32
+ onChange([...before, defaultSection, ...after]);
33
+ },
34
+ [links, onChange],
35
+ );
36
+
37
+ const addLink = useCallback(
38
+ (items, itemIndex, index = -1) => {
39
+ if (index < 0) {
40
+ updateItem(itemIndex, {
41
+ items: [defaultLink, ...items],
42
+ });
43
+
44
+ return;
45
+ }
46
+ const before = items.slice(0, index + 1);
47
+ const after = items.slice(index + 1);
48
+
49
+ updateItem(itemIndex, {
50
+ items: [...before, defaultLink, ...after],
51
+ });
52
+ },
53
+ [links, onChange],
54
+ );
55
+
56
+ const updateItem = useCallback((index, value) => {
57
+ const newValue = [...links];
58
+
59
+ newValue[index] = {
60
+ ...newValue[index],
61
+ ...value,
62
+ };
63
+
64
+ onChange(newValue);
65
+ });
66
+
67
+ const updateInnerItem = useCallback(
68
+ (index, innerIndex, value) => {
69
+ const newValue = [...links];
70
+
71
+ newValue[index].items[innerIndex] = {
72
+ ...newValue[index].items[innerIndex],
73
+ ...value,
74
+ };
75
+
76
+ onChange(newValue);
77
+ },
78
+ [links, onChange],
79
+ );
80
+
81
+ const jumpToEnd = useCallback((element) => {
82
+ if (!element) {
83
+ return;
84
+ }
85
+
86
+ const textNode = element.childNodes[0];
87
+
88
+ if (!textNode) {
89
+ return;
90
+ }
91
+
92
+ const selection = document.getSelection();
93
+ selection.removeAllRanges();
94
+
95
+ const range = document.createRange();
96
+ range.setStart(textNode, textNode?.length);
97
+ range.setEnd(textNode, textNode?.length);
98
+
99
+ selection.addRange(range);
100
+ });
101
+
102
+ const handleKeyDown = useCallback(
103
+ (event, index, i, text) => {
104
+ const { code, target } = event;
105
+
106
+ const { baseNode, baseOffset } = document.getSelection();
107
+
108
+ if (!baseNode || !target.contains(baseNode)) {
109
+ return;
110
+ }
111
+
112
+ if (baseOffset === text.length && code === 'Enter' && !(event.metaKey || event.ctrlKey)) {
113
+ event.preventDefault();
114
+ addLink(links[index].items, index, i);
115
+
116
+ setTimeout(() => {
117
+ target.nextElementSibling?.focus();
118
+ }, 25);
119
+ } else if (baseOffset === text.length && code === 'Enter' && (event.metaKey || event.ctrlKey)) {
120
+ event.preventDefault();
121
+ addSection(index);
122
+
123
+ setTimeout(() => {
124
+ target.parentElement.nextElementSibling?.querySelector('[contenteditable="true"]')?.focus();
125
+ }, 25);
126
+ } else if (code === 'Backspace' && text === '') {
127
+ event.preventDefault();
128
+
129
+ jumpToEnd(target.previousElementSibling);
130
+
131
+ updateItem(index, {
132
+ items: links[index].items.filter((_, j) => j !== i),
133
+ });
134
+ } else if (code === 'Delete' && links?.[index].items[i + 1]?.text?.length < 1) {
135
+ event.preventDefault();
136
+
137
+ updateItem(index, {
138
+ items: links[index].items.filter((_, j) => j !== i + 1),
139
+ });
140
+ }
141
+ },
142
+ [links, onChange],
143
+ );
144
+
145
+ // keyDown handling for section headers.
146
+ const handleSectionKeyDown = useCallback(
147
+ (event, index, items, header) => {
148
+ const { code, target } = event;
149
+
150
+ const { baseNode, baseOffset } = document.getSelection();
151
+
152
+ if (!target.contains(baseNode)) {
153
+ return;
154
+ }
155
+
156
+ if (baseOffset === header.length && code === 'Enter' && !(event.metaKey || event.ctrlKey)) {
157
+ event.preventDefault();
158
+
159
+ // Add a link to the first spot.
160
+ if (items.length > 1 || items?.[0]?.text !== '') {
161
+ addLink(links[index].items, index);
162
+ }
163
+
164
+ // Focus on that link.
165
+ setTimeout(() => {
166
+ target.nextElementSibling?.focus();
167
+ }, 25);
168
+ } else if (baseOffset === header.length && code === 'Enter' && (event.metaKey || event.ctrlKey)) {
169
+ event.preventDefault();
170
+
171
+ // Add a section.
172
+ addSection(index);
173
+
174
+ // Focus on next text input.
175
+ setTimeout(() => {
176
+ target.parentElement.nextElementSibling?.querySelector('[contenteditable="true"]')?.focus();
177
+ }, 25);
178
+ } else if (code === 'Backspace' && header === '' && (items?.length < 1 || items?.every(({ text }) => text === ''))) {
179
+ event.preventDefault();
180
+
181
+ // Jump to end of previous input.
182
+ jumpToEnd(target.parentElement.previousElementSibling?.querySelector('[contenteditable="true"]:last-of-type'));
183
+
184
+ // Remove current element.
185
+ setTimeout(() => {
186
+ onChange(links.filter((_, i) => i !== index));
187
+ }, 25);
188
+ }
189
+ },
190
+ [links, onChange],
191
+ );
192
+
193
+ return (
194
+ <>
195
+ {links.map(({ items, header }, index) => {
196
+ return (
197
+ <div className={classNames?.sectionContainer}>
198
+ <RichText
199
+ placeholder={__('Section', '%g_textdomain%')}
200
+ value={header}
201
+ onChange={(value) => updateItem(index, { header: value })}
202
+ allowedFormats={[]}
203
+ className={classNames?.sectionTitle}
204
+ onKeyDown={(event) => handleSectionKeyDown(event, index, items, header)}
205
+ withoutInteractiveFormatting
206
+ disableLineBreaks
207
+ />
208
+
209
+ {items.map(({ text }, i) => {
210
+ return (
211
+ <RichText
212
+ placeholder={__('Item', '%g_textdomain%')}
213
+ value={text}
214
+ onChange={(value) => updateInnerItem(index, i, { text: value })}
215
+ allowedFormats={[]}
216
+ className={classNames?.link}
217
+ onKeyDown={(event) => handleKeyDown(event, index, i, text)}
218
+ withoutInteractiveFormatting
219
+ disableLineBreaks
220
+ />
221
+ );
222
+ })}
223
+
224
+ <Button
225
+ size='small'
226
+ icon={icons.add}
227
+ tooltip={__('Add link', '%g_textdomain%')}
228
+ onPress={({ target }) => {
229
+ updateItem(index, {
230
+ items: [...links[index].items, defaultLink],
231
+ });
232
+
233
+ setTimeout(() => {
234
+ target?.previousElementSibling?.focus();
235
+ }, 20);
236
+ }}
237
+ />
238
+ </div>
239
+ );
240
+ })}
241
+
242
+ <Button
243
+ onPress={({ target }) => {
244
+ addSection();
245
+
246
+ setTimeout(() => {
247
+ target?.previousElementSibling?.querySelector('[contenteditable="true"]')?.focus();
248
+ }, 20);
249
+ }}
250
+ icon={icons.add}
251
+ tooltip={__('Add a section', '%g_textdomain%')}
252
+ className='justify-self-start'
253
+ >
254
+ {__('Section', '%g_textdomain%')}
255
+ </Button>
256
+ </>
257
+ );
258
+ };
@@ -0,0 +1,25 @@
1
+ import { getColorData } from '@eightshift/frontend-libs-tailwind/scripts';
2
+ import { themeColors } from '../../../../assets/scripts/theme-colors';
3
+
4
+ const colorData = getColorData(themeColors);
5
+
6
+ export const getColorOption = (key, manifest) => {
7
+ if (!manifest?.options?.[key]) {
8
+ throw new Error(
9
+ `The key ${key} is not defined in the manifest options for ${manifest?.componentName ?? manifest?.title}.`,
10
+ );
11
+ }
12
+
13
+ return colorData?.filter(({ slug }) => manifest?.options?.[key]?.includes(slug)) ?? [];
14
+ };
15
+
16
+ export const rotationClassName = {
17
+ 'to-t': 'rotate-0',
18
+ 'to-tr': 'rotate-45',
19
+ 'to-r': 'rotate-90',
20
+ 'to-br': 'rotate-135',
21
+ 'to-b': 'rotate-180',
22
+ 'to-bl': '-rotate-135',
23
+ 'to-l': '-rotate-90',
24
+ 'to-tl': '-rotate-45',
25
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This is the main entry point for Block Editor blocks styles used for the `WordPress admin editor`.
3
+ * File names must follow naming convention to be able to run dynamically.
4
+ *
5
+ * `src/blocks/custom/block_name/block_name-editor.css`.
6
+ *
7
+ * Usage: `WordPress admin editor`.
8
+ *
9
+ */
10
+
11
+ /* Eightshift UI components */
12
+ @import '~@eightshift/ui-components/dist/assets/fonts.css';
13
+ @import '~@eightshift/ui-components/dist/assets/wp-font-enhancements.css';
14
+ @import '~@eightshift/ui-components/dist/assets/wp-ui-enhancements.css';
15
+ @import '~@eightshift/ui-components/dist/assets/style.css';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This is the main entry point for Block Editor blocks styles used for the `WordPress frontend screen`.
3
+ * File names must follow naming convention to be able to run dynamically.
4
+ *
5
+ * `src/blocks/custom/block_name/block_name-editor.css`.
6
+ *
7
+ * Usage: `WordPress frontend screen`.
8
+ *
9
+ */
10
+
11
+ /* OpenLayers */
12
+ @import '~ol/ol.css';
@@ -0,0 +1,15 @@
1
+ .editor-styles-wrapper .wp-block:not(.editor-post-title, .block-list-appender) {
2
+ @apply !max-w-full;
3
+ }
4
+
5
+ .editor-post-title {
6
+ @apply text-3xl max-w-screen-md;
7
+ }
8
+
9
+ .edit-post-visual-editor__post-title-wrapper {
10
+ @apply !m-0 !px-4 !py-6 bg-gray-50;
11
+ }
12
+
13
+ .editor-styles-wrapper.block-editor-writing-flow {
14
+ @apply p-0;
15
+ }
@@ -0,0 +1,34 @@
1
+ /* Fonts */
2
+ @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wdth,wght@0,62.5..100,100..900;1,62.5..100,100..900&display=swap');
3
+ @import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT,WONK@0,9..144,100..900,0..100,0..1;1,9..144,100..900,0..100,0..1&display=swap');
4
+
5
+ /* stylelint-disable scss/at-rule-no-unknown */
6
+ @tailwind base;
7
+ @tailwind components;
8
+ @tailwind utilities;
9
+
10
+ @layer utilities {
11
+ .font-soft-0 {
12
+ font-variation-settings: 'SOFT' 0, 'WONK' 0;
13
+ }
14
+
15
+ .font-soft-25 {
16
+ font-variation-settings: 'SOFT' 25, 'WONK' 0;
17
+ }
18
+
19
+ .font-soft-50 {
20
+ font-variation-settings: 'SOFT' 50, 'WONK' 0;
21
+ }
22
+
23
+ .font-soft-100 {
24
+ font-variation-settings: 'SOFT' 100, 'WONK' 0;
25
+ }
26
+
27
+ .wp-admin-bar-offset {
28
+ @apply wp-logged-in-mobile:top-[46px] wp-logged-in:top-[32px];
29
+ }
30
+
31
+ .wp-admin-bar-pt {
32
+ @apply wp-logged-in-mobile:pt-[46px] wp-logged-in:pt-[32px];
33
+ }
34
+ }
@@ -0,0 +1,20 @@
1
+ <?php
2
+
3
+ /**
4
+ * Theme options settings screen component template.
5
+ *
6
+ * @package %g_namespace%
7
+ */
8
+
9
+ use %g_namespace%\ThemeOptions\ThemeOptions;
10
+ use %g_namespace_vendor_prefix%\EightshiftLibs\Helpers\Helpers;
11
+
12
+ $manifest = Helpers::getManifestByDir(__DIR__);
13
+ $patterns = wp_json_encode(ThemeOptions::getPatterns());
14
+ ?>
15
+
16
+ <input type="hidden" id="es-pattern-data" value="<?php echo esc_attr($patterns); ?>">
17
+
18
+ <div class="wrap" id="es-theme-options">
19
+ <?php echo esc_html__('Loading...', '%g_textdomain%'); ?>
20
+ </div>
@@ -0,0 +1,36 @@
1
+ import domReady from '@wordpress/dom-ready';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { createRoot } from '@wordpress/element';
4
+ import { ThemeOptionsPage } from '@eightshift/frontend-libs-tailwind/scripts';
5
+ import { Parts } from './pages/parts';
6
+ import { Tabs, TabList, Tab, TabPanel } from '@eightshift/ui-components';
7
+ import { icons } from '@eightshift/ui-components/icons';
8
+
9
+ domReady(() => {
10
+ const rootElement = document.getElementById('es-theme-options');
11
+
12
+ if (!rootElement) {
13
+ return;
14
+ }
15
+
16
+ const root = createRoot(rootElement);
17
+ const patterns = JSON.parse(document.getElementById('es-pattern-data')?.value ?? '[]');
18
+
19
+ root.render(
20
+ <ThemeOptionsPage>
21
+ <Tabs>
22
+ <TabList>
23
+ <Tab
24
+ icon={icons.wrench}
25
+ label={__('Parts', '%g_textdomain%')}
26
+ />
27
+ </TabList>
28
+ <TabPanel>
29
+ <Parts patterns={patterns} />
30
+ </TabPanel>
31
+ </Tabs>
32
+ </ThemeOptionsPage>,
33
+ );
34
+ });
35
+
36
+ // https://developer.wordpress.org/news/2024/03/26/how-to-use-wordpress-react-components-for-plugin-pages/
@@ -0,0 +1,55 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { Select, OptionsPanel, OptionsPanelSection, Spacer } from '@eightshift/ui-components';
3
+ import { icons } from '@eightshift/ui-components/icons';
4
+ import { useContext } from '@wordpress/element';
5
+ import { EsThemeOptionsContext } from '@eightshift/frontend-libs-tailwind/scripts';
6
+
7
+ export const Parts = ({ patterns }) => {
8
+ const { settings, updateSettings, isLoading } = useContext(EsThemeOptionsContext);
9
+ return (
10
+ <OptionsPanel>
11
+ <OptionsPanelSection>
12
+ <Select
13
+ label={__('Header', '%g_textdomain%')}
14
+ icon={icons.header}
15
+ value={settings?.header}
16
+ onChange={(value) => updateSettings({ header: value })}
17
+ options={patterns}
18
+ className='es-uic-w-48'
19
+ disabled={isLoading}
20
+ simpleValue
21
+ clearable
22
+ inline
23
+ />
24
+
25
+ <Select
26
+ label={__('Footer', '%g_textdomain%')}
27
+ icon={icons.footer}
28
+ value={settings?.footer}
29
+ onChange={(value) => updateSettings({ footer: value })}
30
+ options={patterns}
31
+ className='es-uic-w-48'
32
+ disabled={isLoading}
33
+ simpleValue
34
+ clearable
35
+ inline
36
+ />
37
+
38
+ <Spacer size='s' />
39
+
40
+ <Select
41
+ label={__('404 page', '%g_textdomain%')}
42
+ icon={icons.emptyCircle}
43
+ value={settings?.fourOhFour}
44
+ onChange={(value) => updateSettings({ fourOhFour: value })}
45
+ options={patterns}
46
+ className='es-uic-w-48'
47
+ disabled={isLoading}
48
+ simpleValue
49
+ clearable
50
+ inline
51
+ />
52
+ </OptionsPanelSection>
53
+ </OptionsPanel>
54
+ );
55
+ };
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/component.json",
3
+ "componentName": "admin-theme-options",
4
+ "title": "Theme options"
5
+ }
@@ -0,0 +1,22 @@
1
+ import domReady from '@wordpress/dom-ready';
2
+
3
+ domReady(() => {
4
+ const elements = document.querySelectorAll('.button[href^="#"]');
5
+
6
+ if (!elements.length) {
7
+ return;
8
+ }
9
+
10
+ elements.forEach((element) => {
11
+ element.addEventListener('click', (event) => {
12
+ event.preventDefault();
13
+ const target = document.querySelector(event.currentTarget.getAttribute('href'));
14
+
15
+ window.scrollTo({
16
+ top: target.offsetTop,
17
+ left: 0,
18
+ behavior: 'smooth',
19
+ });
20
+ });
21
+ });
22
+ });
@@ -0,0 +1,77 @@
1
+ <?php
2
+
3
+ /**
4
+ * Button component 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
+ $buttonUse = Helpers::checkAttr('buttonUse', $attributes, $manifest);
14
+
15
+ if (!$buttonUse) {
16
+ return;
17
+ }
18
+
19
+ $additionalClass = $attributes['additionalClass'] ?? '';
20
+ $additionalAttributes = $attributes['additionalAttributes'] ?? [];
21
+ $buttonId = Helpers::checkAttr('buttonId', $attributes, $manifest);
22
+
23
+ $buttonUrl = Helpers::checkAttr('buttonUrl', $attributes, $manifest);
24
+ $buttonIsNewTab = Helpers::checkAttr('buttonIsNewTab', $attributes, $manifest);
25
+
26
+ $buttonContent = Helpers::checkAttr('buttonContent', $attributes, $manifest);
27
+
28
+ $buttonAriaLabel = Helpers::checkAttr('buttonAriaLabel', $attributes, $manifest);
29
+
30
+ $buttonAttrs = [];
31
+
32
+ if (!empty($additionalAttributes)) {
33
+ $buttonAttrs = $additionalAttributes;
34
+ }
35
+
36
+ if (!empty($buttonUrl)) {
37
+ $buttonAttrs['href'] = $buttonUrl;
38
+ }
39
+
40
+ if ($buttonIsNewTab) {
41
+ $buttonAttrs['target'] = '_blank';
42
+ $buttonAttrs['rel'] = 'noopener noreferrer';
43
+ }
44
+
45
+ if (!empty($buttonId)) {
46
+ $buttonAttrs['id'] = $buttonId;
47
+ }
48
+
49
+ if (!empty($buttonAriaLabel)) {
50
+ $buttonAttrs['aria-label'] = $buttonAriaLabel;
51
+ }
52
+
53
+ $buttonAttrs['class'] = Helpers::getTwClasses($attributes, $manifest, 'button', $additionalClass);
54
+
55
+ $buttonTag = !empty($buttonUrl) ? 'a' : 'button';
56
+ ?>
57
+
58
+ <<?php echo $buttonTag; // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped ?>
59
+ <?php
60
+ foreach ($buttonAttrs as $key => $value) {
61
+ if (empty($key) && empty($value)) {
62
+ continue;
63
+ }
64
+
65
+ // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
66
+ echo "{$key}=" . '"' . esc_attr($value) . '"';
67
+ }
68
+ ?>
69
+ >
70
+ <?php
71
+ echo Helpers::render('icon', Helpers::props('icon', $attributes));
72
+ ?>
73
+
74
+ <?php if (!empty($buttonContent)) { ?>
75
+ <span><?php echo esc_html($buttonContent); ?></span>
76
+ <?php } ?>
77
+ </<?php echo $buttonTag; // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped ?>>
@@ -0,0 +1,40 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { RichText } from '@wordpress/block-editor';
3
+ import { checkAttr, getAttrKey, getTwClasses, props } from '@eightshift/frontend-libs-tailwind/scripts';
4
+ import { IconEditor } from '../../icon/components/icon-editor';
5
+ import manifest from './../manifest.json';
6
+
7
+ export const ButtonEditor = (attributes) => {
8
+ const { componentClass } = manifest;
9
+
10
+ const {
11
+ setAttributes,
12
+ additionalClass,
13
+ placeholder = __('Add content', '%g_textdomain%'),
14
+ } = attributes;
15
+
16
+ const buttonContent = checkAttr('buttonContent', attributes, manifest);
17
+ const buttonUse = checkAttr('buttonUse', attributes, manifest);
18
+
19
+ if (!buttonUse) {
20
+ return null;
21
+ }
22
+
23
+ return (
24
+ <div className={getTwClasses(attributes, manifest, additionalClass)}>
25
+ <IconEditor
26
+ {...props('icon', attributes, {
27
+ blockClass: componentClass,
28
+ })}
29
+ />
30
+
31
+ <RichText
32
+ placeholder={placeholder}
33
+ value={buttonContent}
34
+ onChange={(value) => setAttributes({ [getAttrKey('buttonContent', attributes, manifest)]: value })}
35
+ keepPlaceholderOnFocus
36
+ allowedFormats={[]}
37
+ />
38
+ </div>
39
+ );
40
+ };