@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,65 @@
1
+ import {
2
+ checkAttr,
3
+ getBreakpointData,
4
+ getBreakpointNames,
5
+ getTwClasses,
6
+ getTwPart,
7
+ } from '@eightshift/frontend-libs-tailwind/scripts';
8
+ import { ImagePlaceholder } from '@eightshift/ui-components';
9
+ import manifest from './../manifest.json';
10
+
11
+ export const ImageEditor = (attributes) => {
12
+ const { additionalClass } = attributes;
13
+
14
+ const imageUse = checkAttr('imageUse', attributes, manifest);
15
+ const imageData = checkAttr('imageData', attributes, manifest);
16
+
17
+ if (!imageUse || typeof imageData?.['_default'] === 'undefined') {
18
+ return null;
19
+ }
20
+
21
+ const isDesktopFirst = imageData['_desktopFirst'] ?? false;
22
+
23
+ const breakpointNames = getBreakpointNames();
24
+ const breakpointData = getBreakpointData();
25
+
26
+ return (
27
+ <>
28
+ {imageData?.['_default']?.url && (
29
+ <picture className={additionalClass?.picture ?? ''}>
30
+ {breakpointNames.map((breakpointName) => {
31
+ if (!imageData?.[breakpointName]?.url) {
32
+ return null;
33
+ }
34
+
35
+ const breakpointWidth = breakpointData?.[breakpointName];
36
+
37
+ if (!breakpointWidth) {
38
+ return null;
39
+ }
40
+
41
+ return (
42
+ <source
43
+ key={breakpointName}
44
+ srcSet={imageData?.[breakpointName]?.url}
45
+ media={`(${isDesktopFirst ? 'max-width' : 'min-width'}: ${breakpointWidth}em)`}
46
+ />
47
+ );
48
+ })}
49
+ <img
50
+ className={getTwClasses(attributes, manifest, additionalClass?.image ?? additionalClass)}
51
+ src={imageData?.['_default'].url}
52
+ />
53
+ </picture>
54
+ )}
55
+
56
+ {!imageData?.['_default']?.url && (
57
+ <ImagePlaceholder
58
+ style='simple'
59
+ size='large'
60
+ className={additionalClass?.imagePlaceholder}
61
+ />
62
+ )}
63
+ </>
64
+ );
65
+ };
@@ -0,0 +1,111 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import {
3
+ checkAttr,
4
+ getAttrKey,
5
+ MediaPicker,
6
+ generateOptionsFromValue,
7
+ getOption,
8
+ getHiddenOptions,
9
+ getResponsiveData,
10
+ } from '@eightshift/frontend-libs-tailwind/scripts';
11
+ import manifest from './../manifest.json';
12
+ import { ComponentToggle, OptionSelect, Responsive, Spacer, Toggle } from '@eightshift/ui-components';
13
+ import { icons } from '@eightshift/ui-components/icons';
14
+ import { truncateMiddle } from '@eightshift/ui-components/utilities';
15
+
16
+ export const ImageOptions = (attributes) => {
17
+ const { setAttributes, hideOptions, additionalControls, ...rest } = attributes;
18
+
19
+ const hiddenOptions = getHiddenOptions(hideOptions);
20
+
21
+ const imageUse = checkAttr('imageUse', attributes, manifest);
22
+ const imageRoundedCorners = checkAttr('imageRoundedCorners', attributes, manifest);
23
+ const imageAspectRatio = checkAttr('imageAspectRatio', attributes, manifest);
24
+ const imageSize = checkAttr('imageSize', attributes, manifest);
25
+
26
+ const imageData = checkAttr('imageData', attributes, manifest);
27
+
28
+ const responsiveData = getResponsiveData(true);
29
+
30
+ return (
31
+ <ComponentToggle
32
+ label={manifest.title}
33
+ icon={icons.image}
34
+ onChange={(value) => setAttributes({ [getAttrKey('imageUse', attributes, manifest)]: value })}
35
+ useComponent={imageUse}
36
+ {...rest}
37
+ >
38
+ <Responsive
39
+ value={imageData}
40
+ onChange={(value) => setAttributes({ [getAttrKey('imageData', attributes, manifest)]: value })}
41
+ icon={icons.imageFile}
42
+ label={__('Image', 'eightshift-ui-components')}
43
+ options={generateOptionsFromValue(imageData, (v) =>
44
+ truncateMiddle(
45
+ v?.url?.replace(window.location.origin, '')?.replace(/\/wp-content\/uploads\/\d{4}\/\d{2}\//g, '') ??
46
+ __('Not set', '%g_textdomain%'),
47
+ 15,
48
+ ),
49
+ )}
50
+ hidden={hiddenOptions?.imagePicker}
51
+ {...responsiveData}
52
+ >
53
+ {({ breakpoint, currentValue, handleChange }) => (
54
+ <MediaPicker
55
+ onChange={({ id, url }) => handleChange({ id: id, url: url })}
56
+ imageId={currentValue?.id}
57
+ imageUrl={currentValue?.url}
58
+ noDelete={breakpoint !== '_default'}
59
+ />
60
+ )}
61
+ </Responsive>
62
+
63
+ <Spacer hidden={hiddenOptions?.borderRadius} />
64
+
65
+ <OptionSelect
66
+ icon={icons.roundedCorners}
67
+ label={__('Rounded corners', '%g_textdomain%')}
68
+ options={getOption('imageRoundedCorners', attributes, manifest)}
69
+ value={imageRoundedCorners}
70
+ onChange={(value) =>
71
+ setAttributes({
72
+ [getAttrKey('imageRoundedCorners', attributes, manifest)]: value,
73
+ })
74
+ }
75
+ type='menu'
76
+ hidden={hiddenOptions?.borderRadius}
77
+ inline
78
+ />
79
+
80
+ <Spacer hidden={hiddenOptions?.aspectRatio || hiddenOptions?.stretch} />
81
+
82
+ <OptionSelect
83
+ icon={icons.aspectRatio}
84
+ label={__('Aspect ratio', '%g_textdomain%')}
85
+ options={getOption('imageAspectRatio', attributes, manifest)}
86
+ value={imageAspectRatio}
87
+ onChange={(value) =>
88
+ setAttributes({
89
+ [getAttrKey('imageAspectRatio', attributes, manifest)]: value,
90
+ })
91
+ }
92
+ type='menu'
93
+ hidden={hiddenOptions?.aspectRatio}
94
+ inline
95
+ />
96
+
97
+ <Toggle
98
+ icon={icons.expandXl}
99
+ label={__('Stretch', '%g_textdomain%')}
100
+ checked={imageSize === 'stretch'}
101
+ onChange={(value) =>
102
+ setAttributes({ [getAttrKey('imageSize', attributes, manifest)]: value ? 'stretch' : 'default' })
103
+ }
104
+ hidden={hiddenOptions?.stretch}
105
+ />
106
+
107
+ <Spacer hidden={!additionalControls} />
108
+ {additionalControls}
109
+ </ComponentToggle>
110
+ );
111
+ };
@@ -0,0 +1,62 @@
1
+ <?php
2
+
3
+ /**
4
+ * Image component template.
5
+ *
6
+ * @package %g_namespace%
7
+ */
8
+
9
+ use %g_namespace_vendor_prefix%\EightshiftLibs\Helpers\Helpers;
10
+
11
+ $globalManifest = Helpers::getSettings();
12
+ $manifest = Helpers::getManifestByDir(__DIR__);
13
+
14
+ $additionalClass = $attributes['additionalClass'] ?? '';
15
+
16
+ $imageUse = Helpers::checkAttr('imageUse', $attributes, $manifest) ?? false;
17
+ $imageData = Helpers::checkAttr('imageData', $attributes, $manifest);
18
+
19
+ if (!$imageUse || empty($imageData['_default']['url'])) {
20
+ return;
21
+ }
22
+
23
+ $imageAlt = get_post_meta($imageData['_default']['id'], '_wp_attachment_image_alt', true) ?? '';
24
+
25
+ $isMobileFirst = $imageData['_desktopFirst'] ?? false;
26
+
27
+ $breakpointData = Helpers::getSettingsGlobalVariablesBreakpoints();
28
+ $breakpoints = Helpers::getTwBreakpoints($isMobileFirst);
29
+ ?>
30
+
31
+ <picture
32
+ <?php if (!empty($additionalClass['picture'])) { ?>
33
+ class="<?php echo esc_attr($additionalClass['picture']); ?>"
34
+ <?php } ?>
35
+ >
36
+ <?php foreach ($breakpoints as $breakpoint) { ?>
37
+ <?php
38
+ if (!isset($imageData[$breakpoint])) {
39
+ continue;
40
+ }
41
+
42
+ $value = $imageData[$breakpoint]['url'] ?? '';
43
+
44
+ if (empty($value)) {
45
+ continue;
46
+ }
47
+
48
+ $breakpointWidth = $breakpointData[str_replace('max-', '', $breakpoint)];
49
+
50
+ $widthMode = $isMobileFirst ? 'min-width' : 'max-width';
51
+
52
+ // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
53
+ echo '<source srcset="' . esc_url($value) . '" media="(' . $widthMode . ': ' . $breakpointWidth . 'rem)" />';
54
+ ?>
55
+ <?php } ?>
56
+
57
+ <img
58
+ src="<?php echo esc_url($imageData['_default']['url'] ?? ''); ?>"
59
+ alt="<?php echo esc_attr($imageAlt); ?>"
60
+ class="<?php echo esc_attr(Helpers::getTwClasses($attributes, $manifest, $additionalClass['image'] ?? $additionalClass)); ?>"
61
+ />
62
+ </picture>
@@ -0,0 +1,125 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/component.json",
3
+ "componentName": "image",
4
+ "title": "Image",
5
+ "componentClass": "image",
6
+ "example": {
7
+ "attributes": {
8
+ "imageData": {
9
+ "_desktopFirst": false,
10
+ "_default": {
11
+ "id": "1",
12
+ "url": "https://loremflickr.com/1000/800"
13
+ }
14
+ },
15
+ "imageUse": true
16
+ }
17
+ },
18
+ "attributes": {
19
+ "imageData": {
20
+ "type": "object",
21
+ "default": {
22
+ "_desktopFirst": false,
23
+ "_default": {
24
+ "id": "",
25
+ "url": ""
26
+ }
27
+ }
28
+ },
29
+ "imageUse": {
30
+ "type": "boolean",
31
+ "default": true
32
+ },
33
+ "imageRoundedCorners": {
34
+ "type": "string",
35
+ "default": "none"
36
+ },
37
+ "imageAspectRatio": {
38
+ "type": "string",
39
+ "default": "auto"
40
+ },
41
+ "imageSize": {
42
+ "type": "string",
43
+ "default": "default"
44
+ }
45
+ },
46
+ "options": {
47
+ "imageRoundedCorners": [
48
+ {
49
+ "label": "0",
50
+ "value": "none"
51
+ },
52
+ {
53
+ "label": "4",
54
+ "value": "small"
55
+ },
56
+ {
57
+ "label": "8",
58
+ "value": "medium"
59
+ },
60
+ {
61
+ "label": "16",
62
+ "value": "large"
63
+ },
64
+ {
65
+ "label": "Full",
66
+ "value": "full"
67
+ }
68
+ ],
69
+ "imageAspectRatio": [
70
+ {
71
+ "label": "Auto",
72
+ "value": "auto"
73
+ },
74
+ {
75
+ "label": "Square",
76
+ "value": "square"
77
+ },
78
+ {
79
+ "label": "3/2",
80
+ "value": "three-two"
81
+ },
82
+ {
83
+ "label": "5/4",
84
+ "value": "five-four"
85
+ },
86
+ {
87
+ "label": "16/9",
88
+ "value": "sixteen-nine"
89
+ },
90
+ {
91
+ "label": "21/9",
92
+ "value": "twentyone-nine"
93
+ }
94
+ ]
95
+ },
96
+ "tailwind": {
97
+ "base": {
98
+ "twClasses": "object-cover"
99
+ },
100
+ "options": {
101
+ "imageRoundedCorners": {
102
+ "twClasses": {
103
+ "small": "rounded",
104
+ "medium": "rounded-lg",
105
+ "large": "rounded-2xl",
106
+ "full": "rounded-full"
107
+ }
108
+ },
109
+ "imageAspectRatio": {
110
+ "twClasses": {
111
+ "square": "aspect-square",
112
+ "three-two": "aspect-3/2",
113
+ "five-four": "aspect-5/4",
114
+ "sixteen-nine": "aspect-video",
115
+ "twentyone-nine": "aspect-21/9"
116
+ }
117
+ },
118
+ "imageSize": {
119
+ "twClasses": {
120
+ "stretch": "size-full"
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,30 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { RichText } from '@wordpress/block-editor';
3
+ import { checkAttr, getAttrKey, getTwClasses } from '@eightshift/frontend-libs-tailwind/scripts';
4
+ import manifest from '../manifest.json';
5
+
6
+ export const ListEditor = (attributes) => {
7
+ const { setAttributes, additionalClass, placeholder = __('Add content', '%g_textdomain%') } = attributes;
8
+
9
+ const listUse = checkAttr('listUse', attributes, manifest);
10
+
11
+ if (!listUse) {
12
+ return null;
13
+ }
14
+
15
+ const listContent = checkAttr('listContent', attributes, manifest);
16
+ const listType = checkAttr('listType', attributes, manifest);
17
+
18
+ return (
19
+ <div className={getTwClasses(attributes, manifest, additionalClass)}>
20
+ <RichText
21
+ tagName={listType}
22
+ multiline='li'
23
+ placeholder={placeholder}
24
+ value={listContent}
25
+ onChange={(value) => setAttributes({ [getAttrKey('listContent', attributes, manifest)]: value })}
26
+ allowedFormats={['core/bold', 'core/link']}
27
+ />
28
+ </div>
29
+ );
30
+ };
@@ -0,0 +1,62 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { getOption, getAttrKey, checkAttr, getHiddenOptions } from '@eightshift/frontend-libs-tailwind/scripts';
3
+ import { ComponentToggle, OptionSelect, HStack, ToggleButton } from '@eightshift/ui-components';
4
+ import { icons } from '@eightshift/ui-components/icons';
5
+ import manifest from '../manifest.json';
6
+
7
+ export const ListOptions = (attributes) => {
8
+ const { setAttributes, additionalControls, hideOptions, ...rest } = attributes;
9
+
10
+ const hiddenOptions = getHiddenOptions(hideOptions);
11
+
12
+ const listUse = checkAttr('listUse', attributes, manifest);
13
+ const listSize = checkAttr('listSize', attributes, manifest);
14
+ const listFontWeight = checkAttr('listFontWeight', attributes, manifest);
15
+ const listStyle = checkAttr('listStyle', attributes, manifest);
16
+
17
+ return (
18
+ <ComponentToggle
19
+ label={manifest.title}
20
+ icon={icons.listUnordered}
21
+ onChange={(value) => setAttributes({ [getAttrKey('listUse', attributes, manifest)]: value })}
22
+ useComponent={listUse}
23
+ {...rest}
24
+ >
25
+ <HStack>
26
+ <OptionSelect
27
+ options={getOption('listSize', attributes, manifest)}
28
+ onChange={(value) => setAttributes({ [getAttrKey('listSize', attributes, manifest)]: value })}
29
+ value={listSize}
30
+ aria-label={__('Font size', '%g_textdomain%')}
31
+ hidden={hiddenOptions.size}
32
+ type='menu'
33
+ />
34
+
35
+ <ToggleButton
36
+ selected={listFontWeight === '700'}
37
+ icon={icons.bold}
38
+ onChange={(value) =>
39
+ setAttributes({ [getAttrKey('listFontWeight', attributes, manifest)]: value ? '700' : '400' })
40
+ }
41
+ tooltip={__('Bold', '%g_textdomain%')}
42
+ hidden={hiddenOptions.weight}
43
+ />
44
+
45
+ <OptionSelect
46
+ value={listStyle}
47
+ onChange={(value) =>
48
+ setAttributes({
49
+ [getAttrKey('listStyle', attributes, manifest)]: value,
50
+ [getAttrKey('listType', attributes, manifest)]: value === 'decimal' ? 'ol' : 'ul',
51
+ })
52
+ }
53
+ aria-label={__('List style', '%g_textdomain%')}
54
+ options={getOption('listStyle', attributes, manifest)}
55
+ noItemLabel
56
+ />
57
+ </HStack>
58
+
59
+ {additionalControls}
60
+ </ComponentToggle>
61
+ );
62
+ };
@@ -0,0 +1,32 @@
1
+ <?php
2
+
3
+ /**
4
+ * List 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
+ $listUse = Helpers::checkAttr('listUse', $attributes, $manifest);
14
+
15
+ if (!$listUse) {
16
+ return;
17
+ }
18
+
19
+ $additionalClass = $attributes['additionalClass'] ?? '';
20
+
21
+ $listContent = Helpers::checkAttr('listContent', $attributes, $manifest);
22
+ $listType = Helpers::checkAttr('listType', $attributes, $manifest);
23
+ ?>
24
+
25
+ <<?php echo esc_attr($listType); ?>
26
+ class="<?php echo esc_attr(Helpers::getTwClasses($attributes, $manifest, $additionalClass)); ?>"
27
+ >
28
+ <?php
29
+ // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
30
+ echo $listContent;
31
+ ?>
32
+ </<?php echo esc_attr($listType); ?>>
@@ -0,0 +1,127 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/component.json",
3
+ "componentName": "list",
4
+ "title": "List",
5
+ "componentClass": "list",
6
+ "example": {
7
+ "attributes": {
8
+ "listContent": "<li>List item 1</li><li>List item 2</li><li>List item 3</li>",
9
+ "listType": "ul",
10
+ "listSize": "default",
11
+ "listColor": "primary500",
12
+ "listUse": true
13
+ }
14
+ },
15
+ "attributes": {
16
+ "listContent": {
17
+ "type": "string"
18
+ },
19
+ "listType": {
20
+ "type": "string",
21
+ "default": "ul"
22
+ },
23
+ "listStyle": {
24
+ "type": "string",
25
+ "default": "disc"
26
+ },
27
+ "listSize": {
28
+ "type": "string",
29
+ "default": "base"
30
+ },
31
+ "listFontWeight": {
32
+ "type": "string",
33
+ "default": "400"
34
+ },
35
+ "listUse": {
36
+ "type": "boolean",
37
+ "default": true
38
+ }
39
+ },
40
+ "options": {
41
+ "listSize": [
42
+ {
43
+ "label": "24",
44
+ "value": "lg"
45
+ },
46
+ {
47
+ "label": "20",
48
+ "value": "md"
49
+ },
50
+ {
51
+ "label": "16",
52
+ "value": "base"
53
+ },
54
+ {
55
+ "label": "14",
56
+ "value": "sm"
57
+ }
58
+ ],
59
+ "listFontWeight": [
60
+ {
61
+ "label": "Normal",
62
+ "value": "400"
63
+ },
64
+ {
65
+ "label": "Bold",
66
+ "value": "700"
67
+ }
68
+ ],
69
+ "listStyle": [
70
+ {
71
+ "label": "No list markers",
72
+ "value": "none",
73
+ "icon": "emptyCircle"
74
+ },
75
+ {
76
+ "label": "Numeric list",
77
+ "value": "decimal",
78
+ "icon": "listOrdered"
79
+ },
80
+ {
81
+ "label": "Bulleted list",
82
+ "value": "disc",
83
+ "icon": "listUnordered"
84
+ },
85
+ {
86
+ "label": "Checkmark list",
87
+ "value": "checks",
88
+ "icon": "optionList"
89
+ }
90
+ ]
91
+ },
92
+ "tailwind": {
93
+ "base": {
94
+ "twClasses": "font-sans [&>a]:underline font-synthesis-none",
95
+ "twClassesEditor": "font-sans [&>a]:underline font-synthesis-none"
96
+ },
97
+ "options": {
98
+ "listSize": {
99
+ "twClasses": {
100
+ "sm": "text-sm",
101
+ "base": "~sm/md:~text-sm/base",
102
+ "md": "~sm/md:~text-lg/2xl",
103
+ "lg": "~sm/md:~text-xl/3xl"
104
+ }
105
+ },
106
+ "listFontWeight": {
107
+ "twClasses": {
108
+ "700": "font-bold"
109
+ }
110
+ },
111
+ "listStyle": {
112
+ "twClasses": {
113
+ "none": "list-none",
114
+ "disc": "list-disc ml-[1.125em]",
115
+ "decimal": "list-decimal ml-[1.125em]",
116
+ "checks": "list-['✓_'] ml-[1em]"
117
+ },
118
+ "twClassesEditor": {
119
+ "none": "*:list-none",
120
+ "disc": "*:list-disc *:ml-[1.125em]",
121
+ "decimal": "*:list-decimal *:ml-[1.125em]",
122
+ "checks": "*:list-['✓_'] *:ml-[1em]"
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,19 @@
1
+ import domReady from '@wordpress/dom-ready';
2
+ import manifest from './../manifest.json';
3
+
4
+ domReady(async () => {
5
+ const selectors = `.${manifest.componentJsClass}`;
6
+ const elements = document.querySelectorAll(selectors);
7
+
8
+ if (!elements.length) {
9
+ return;
10
+ }
11
+
12
+ const { LoadMore } = await import('./load-more');
13
+
14
+ elements.forEach((element) => {
15
+ new LoadMore({
16
+ element,
17
+ }).init();
18
+ });
19
+ });