@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,280 @@
1
+ import { __, sprintf } from '@wordpress/i18n';
2
+ import {
3
+ getOption,
4
+ checkAttr,
5
+ getAttrKey,
6
+ FileSelector,
7
+ getHiddenOptions,
8
+ MediaPicker,
9
+ } from '@eightshift/frontend-libs-tailwind/scripts';
10
+ import {
11
+ AnimatedVisibility,
12
+ BaseControl,
13
+ Expandable,
14
+ InputField,
15
+ Notice,
16
+ OptionSelect,
17
+ Repeater,
18
+ RepeaterItem,
19
+ Spacer,
20
+ Toggle,
21
+ } from '@eightshift/ui-components';
22
+ import { icons } from '@eightshift/ui-components/icons';
23
+ import manifest from '../manifest.json';
24
+
25
+ export const VideoOptions = (attributes) => {
26
+ const { setAttributes, hideOptions } = attributes;
27
+
28
+ const hiddenOptions = getHiddenOptions(hideOptions);
29
+
30
+ const videoUrl = checkAttr('videoUrl', attributes, manifest, true);
31
+ const videoId = checkAttr('videoId', attributes, manifest, true);
32
+ const videoPosterId = checkAttr('videoPosterId', attributes, manifest);
33
+ const videoPosterUrl = checkAttr('videoPosterUrl', attributes, manifest);
34
+ const videoLoop = checkAttr('videoLoop', attributes, manifest);
35
+ const videoAutoplay = checkAttr('videoAutoplay', attributes, manifest);
36
+ const videoControls = checkAttr('videoControls', attributes, manifest);
37
+ const videoMuted = checkAttr('videoMuted', attributes, manifest);
38
+ const videoPreload = checkAttr('videoPreload', attributes, manifest);
39
+ const videoSubtitleTracks = checkAttr('videoSubtitleTracks', attributes, manifest);
40
+
41
+ const getTrackIcon = (kind) => {
42
+ switch (kind) {
43
+ case 'subtitles':
44
+ return icons.videoSubtitle;
45
+ case 'captions':
46
+ return icons.closedCaptions;
47
+ case 'descriptions':
48
+ return icons.hide;
49
+ case 'chapters':
50
+ return icons.videoChapters;
51
+ }
52
+ return icons.emptyRect;
53
+ };
54
+
55
+ return (
56
+ <>
57
+ <AnimatedVisibility
58
+ visible={videoPosterId && !videoControls}
59
+ noInitial
60
+ >
61
+ <Notice
62
+ type='warning'
63
+ label={__('Playback controls disabled', '%g_textdomain%')}
64
+ subtitle={__('Poster image might prevent users from playing the video', '%g_textdomain%')}
65
+ />
66
+ </AnimatedVisibility>
67
+
68
+ <FileSelector
69
+ onChange={({ id, url, mime, mime_type }) =>
70
+ setAttributes({
71
+ [getAttrKey('videoId', attributes, manifest)]: id,
72
+ [getAttrKey('videoUrl', attributes, manifest)]: url,
73
+ [getAttrKey('videoMimeType', attributes, manifest)]: typeof mime === 'undefined' ? mime_type : mime,
74
+ })
75
+ }
76
+ fileId={videoId}
77
+ fileName={videoUrl?.slice(videoUrl?.lastIndexOf('/') + 1)}
78
+ allowedTypes={['video/mp4', 'video/webm']}
79
+ kind='video'
80
+ />
81
+
82
+ <Spacer />
83
+
84
+ <Spacer
85
+ icon={icons.playbackOptions}
86
+ text={__('Playback', '%g_textdomain%')}
87
+ border
88
+ />
89
+
90
+ <Toggle
91
+ icon={icons.videoControls}
92
+ label={__('Video controls', '%g_textdomain%')}
93
+ checked={videoControls}
94
+ onChange={(value) => setAttributes({ [getAttrKey('videoControls', attributes, manifest)]: value })}
95
+ hidden={hiddenOptions?.playbackControls}
96
+ />
97
+
98
+ <Toggle
99
+ icon={icons.loopMode}
100
+ label={__('Loop', '%g_textdomain%')}
101
+ checked={videoLoop}
102
+ onChange={(value) => setAttributes({ [getAttrKey('videoLoop', attributes, manifest)]: value })}
103
+ hidden={hiddenOptions?.loop}
104
+ />
105
+
106
+ <Toggle
107
+ icon={icons.autoplayAlt}
108
+ label={__('Autoplay', '%g_textdomain%')}
109
+ checked={videoAutoplay}
110
+ onChange={(value) => setAttributes({ [getAttrKey('videoAutoplay', attributes, manifest)]: value })}
111
+ hidden={hiddenOptions?.autoplay}
112
+ />
113
+
114
+ <Toggle
115
+ icon={icons.muteCentered}
116
+ label={__('Mute', '%g_textdomain%')}
117
+ checked={videoMuted}
118
+ onChange={(value) => setAttributes({ [getAttrKey('videoMuted', attributes, manifest)]: value })}
119
+ hidden={hiddenOptions?.mute}
120
+ />
121
+
122
+ <AnimatedVisibility
123
+ visible={videoAutoplay && !videoMuted && !videoControls}
124
+ noInitial
125
+ >
126
+ <Notice
127
+ type='warning'
128
+ label={__('Video plays automatically, with sound, and without controls', '%g_textdomain%')}
129
+ subtitle={__(
130
+ 'This will bother most users and is an accessibility issue. Consider changing some of the options.',
131
+ '%g_textdomain%',
132
+ )}
133
+ icon={icons.a11yWarning}
134
+ alignIconToTitle
135
+ />
136
+ </AnimatedVisibility>
137
+
138
+ <Spacer />
139
+
140
+ <Spacer
141
+ icon={icons.a11y}
142
+ text={__('Accessibility', '%g_textdomain%')}
143
+ border
144
+ />
145
+
146
+ <Repeater
147
+ icon={icons.videoSubtitleAlt}
148
+ label={__('Captions', '%g_textdomain%')}
149
+ items={videoSubtitleTracks}
150
+ onChange={(value) => setAttributes({ [getAttrKey('videoSubtitleTracks', attributes, manifest)]: value })}
151
+ >
152
+ {(item) => {
153
+ const { trackId, trackFileName, kind, srclang, label, updateData, itemIndex: index } = item;
154
+
155
+ return (
156
+ <RepeaterItem
157
+ icon={getTrackIcon(kind)}
158
+ label={
159
+ label ? sprintf(__('Track %d', '%g_textdomain%'), index + 1) : __('New track', '%g_textdomain%')
160
+ }
161
+ subtitle={label}
162
+ >
163
+ <FileSelector
164
+ onChange={({ id, url }) =>
165
+ updateData({
166
+ trackId: id,
167
+ trackFileName: url,
168
+ })
169
+ }
170
+ fileId={trackId}
171
+ fileName={trackFileName?.slice(trackFileName?.lastIndexOf('/') + 1)}
172
+ allowedTypes={['text/vtt']}
173
+ kind='subtitle'
174
+ >
175
+ {__('Upload a VTT file containing captions, subtitles, descriptions or chapters', '%g_textdomain%')}
176
+ </FileSelector>
177
+
178
+ <Spacer />
179
+
180
+ <OptionSelect
181
+ icon={icons.optionListAlt}
182
+ label={__('Type', '%g_textdomain%')}
183
+ value={kind}
184
+ options={getOption('videoSubtitleTrackKind', attributes, manifest)}
185
+ onChange={(value) => updateData({ kind: value })}
186
+ vertical
187
+ />
188
+
189
+ <Spacer />
190
+
191
+ <InputField
192
+ icon={icons.titleGeneric}
193
+ label={__('Label', '%g_textdomain%')}
194
+ help={__('Shows in the list of available tracks', '%g_textdomain%')}
195
+ value={label}
196
+ onChange={(value) => updateData({ label: value })}
197
+ />
198
+
199
+ <InputField
200
+ icon={icons.flag}
201
+ label={__('Language code', '%g_textdomain%')}
202
+ help={
203
+ <>
204
+ {__('Should follow IETF (BCP47).', '%g_textdomain%')}
205
+ {kind === 'subtitles' && ' ' + __('Required.', '%g_textdomain%')}
206
+ </>
207
+ }
208
+ value={srclang}
209
+ onChange={(value) => updateData({ srclang: value })}
210
+ />
211
+
212
+ <Spacer />
213
+
214
+ <div className='es-uic-space-y-1'>
215
+ <Spacer text={__('List of language tags', '%g_textdomain%')} />
216
+
217
+ <a
218
+ href='https://en.wikipedia.org/wiki/IETF_language_tag#List_of_major_primary_language_subtags'
219
+ target='_blank'
220
+ rel='external'
221
+ className='es-uic-flex es-uic-items-center es-uic-gap-1.5 es-uic-text-sm [&>svg]:es-uic-size-4 [&>svg]:es-uic-stroke-[1.5]'
222
+ >
223
+ {__('Common languages', '%g_textdomain%')}
224
+ {icons.externalLink}
225
+ </a>
226
+
227
+ <a
228
+ href='https://r12a.github.io/app-subtags/'
229
+ target='_blank'
230
+ rel='external'
231
+ className='es-uic-flex es-uic-items-center es-uic-gap-1.5 es-uic-text-sm [&>svg]:es-uic-size-4 [&>svg]:es-uic-stroke-[1.5]'
232
+ >
233
+ {__('All languages', '%g_textdomain%')}
234
+ {icons.externalLink}
235
+ </a>
236
+ </div>
237
+ </RepeaterItem>
238
+ );
239
+ }}
240
+ </Repeater>
241
+
242
+ <Spacer />
243
+
244
+ <Expandable
245
+ icon={icons.moreHCircle}
246
+ label={__('Advanced', '%g_textdomain%')}
247
+ >
248
+ <BaseControl
249
+ icon={icons.videoPosterImage}
250
+ label={__('Poster image', '%g_textdomain%')}
251
+ subtitle={__('Visible before the video is played', '%g_textdomain%')}
252
+ hidden={hiddenOptions?.posterImage}
253
+ >
254
+ <MediaPicker
255
+ onChange={({ id, url }) =>
256
+ setAttributes({
257
+ [getAttrKey('videoPosterId', attributes, manifest)]: id,
258
+ [getAttrKey('videoPosterUrl', attributes, manifest)]: url,
259
+ })
260
+ }
261
+ imageId={videoPosterId}
262
+ imageUrl={videoPosterUrl}
263
+ />
264
+ </BaseControl>
265
+
266
+ <Spacer />
267
+
268
+ <OptionSelect
269
+ icon={icons.preload}
270
+ label={__('Preload', '%g_textdomain%')}
271
+ value={videoPreload}
272
+ options={getOption('videoPreload', attributes, manifest)}
273
+ alignment='vertical'
274
+ onChange={(value) => setAttributes({ [getAttrKey('videoPreload', attributes, manifest)]: value })}
275
+ hidden={hiddenOptions?.preload}
276
+ />
277
+ </Expandable>
278
+ </>
279
+ );
280
+ };
@@ -0,0 +1,116 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/component.json",
3
+ "componentName": "video",
4
+ "title": "Video",
5
+ "componentClass": "video",
6
+ "example": {
7
+ "attributes": {
8
+ "videoUrl": [
9
+ {
10
+ "url": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
11
+ "mime": "video/mp4"
12
+ }
13
+ ],
14
+ "videoPoster": "https://loremflickr.com/300/200",
15
+ "videoAccept": ".mp4,.webm",
16
+ "videoAllowedTypes": [
17
+ "video/mp4",
18
+ "video/webm"
19
+ ],
20
+ "videoUse": true
21
+ }
22
+ },
23
+ "attributes": {
24
+ "videoUrl": {
25
+ "type": "string"
26
+ },
27
+ "videoId": {
28
+ "type": "string"
29
+ },
30
+ "videoMimeType": {
31
+ "type": "string"
32
+ },
33
+ "videoLoop": {
34
+ "type": "boolean",
35
+ "default": true
36
+ },
37
+ "videoAutoplay": {
38
+ "type": "boolean",
39
+ "default": true
40
+ },
41
+ "videoControls": {
42
+ "type": "boolean",
43
+ "default": false
44
+ },
45
+ "videoMuted": {
46
+ "type": "boolean",
47
+ "default": true
48
+ },
49
+ "videoPreload": {
50
+ "type": "string",
51
+ "default": "metadata"
52
+ },
53
+ "videoPosterId": {
54
+ "type": "string"
55
+ },
56
+ "videoPosterUrl": {
57
+ "type": "string"
58
+ },
59
+ "videoUse": {
60
+ "type": "boolean",
61
+ "default": true
62
+ },
63
+ "videoSubtitleTracks": {
64
+ "type": "array",
65
+ "items": {
66
+ "type": "object"
67
+ },
68
+ "default": []
69
+ }
70
+ },
71
+ "options": {
72
+ "videoPreload": [
73
+ {
74
+ "label": "Video & metadata",
75
+ "value": "auto"
76
+ },
77
+ {
78
+ "label": "Metadata",
79
+ "value": "metadata"
80
+ },
81
+ {
82
+ "label": "Nothing",
83
+ "value": "none"
84
+ }
85
+ ],
86
+ "videoSubtitleTrackKind": [
87
+ {
88
+ "label": "Subtitles",
89
+ "value": "subtitles",
90
+ "icon": "videoSubtitle"
91
+ },
92
+ {
93
+ "label": "Captions",
94
+ "value": "captions",
95
+ "icon": "closedCaptions"
96
+ },
97
+ {
98
+ "label": "Descriptions",
99
+ "value": "descriptions",
100
+ "icon": "hide"
101
+ },
102
+ {
103
+ "label": "Chapters",
104
+ "value": "chapters",
105
+ "icon": "videoChapters"
106
+ }
107
+ ]
108
+ },
109
+ "tailwind":{
110
+ "parts": {
111
+ "video": {
112
+ "twClasses": "aspect-video w-full rounded-xl border border-gray-800 bg-gradient-to-br from-gray-800 to-black shadow-md"
113
+ }
114
+ }
115
+ }
116
+ }
@@ -0,0 +1,72 @@
1
+ <?php
2
+
3
+ /**
4
+ * Video 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
+ $componentName = $attributes['componentName'] ?? $manifest['componentName'];
13
+
14
+ $videoUse = Helpers::checkAttr('videoUse', $attributes, $manifest);
15
+
16
+ if (!$videoUse) {
17
+ return;
18
+ }
19
+
20
+ $additionalClass = $attributes['additionalClass'] ?? '';
21
+
22
+ $videoUrl = Helpers::checkAttr('videoUrl', $attributes, $manifest, true);
23
+
24
+ if (empty($videoUrl)) {
25
+ return;
26
+ }
27
+
28
+ $videoMimeType = Helpers::checkAttr('videoMimeType', $attributes, $manifest);
29
+ $videoPosterId = Helpers::checkAttr('videoPosterId', $attributes, $manifest);
30
+ $videoPosterUrl = Helpers::checkAttr('videoPosterUrl', $attributes, $manifest);
31
+ $videoLoop = Helpers::checkAttr('videoLoop', $attributes, $manifest);
32
+ $videoAutoplay = Helpers::checkAttr('videoAutoplay', $attributes, $manifest);
33
+ $videoControls = Helpers::checkAttr('videoControls', $attributes, $manifest);
34
+ $videoMuted = Helpers::checkAttr('videoMuted', $attributes, $manifest);
35
+ $videoPreload = Helpers::checkAttr('videoPreload', $attributes, $manifest);
36
+ $videoSubtitleTracks = Helpers::checkAttr('videoSubtitleTracks', $attributes, $manifest) ?? [];
37
+
38
+ $additionalAttributes = Helpers::classnames([
39
+ $videoLoop ? 'loop' : '',
40
+ $videoAutoplay ? 'autoplay playsinline' : '',
41
+ $videoControls ? 'controls' : '',
42
+ $videoMuted ? 'muted' : '',
43
+ ]);
44
+ ?>
45
+
46
+ <video
47
+ class="<?php echo esc_attr(Helpers::getTwPart('video', $manifest)); ?>"
48
+ <?php echo esc_attr($additionalAttributes); ?>
49
+ preload="<?php echo esc_attr($videoPreload); ?>"
50
+ poster="<?php echo esc_attr($videoPosterUrl); ?>"
51
+ <?php if ($videoPosterUrl) { ?>
52
+ poster="<?php echo esc_attr($videoPosterUrl); ?>"
53
+ <?php } ?>
54
+ >
55
+ <source src="<?php echo esc_url($videoUrl); ?>" type="<?php echo esc_attr($videoMimeType); ?>" />
56
+
57
+ <?php foreach ($videoSubtitleTracks as $track) {
58
+ if (!($track['trackFileName'] ?? '') || !($track['kind'] ?? '') || !($track['label'])) {
59
+ continue;
60
+ }
61
+ ?>
62
+
63
+ <track
64
+ src="<?php echo esc_url($track['trackFileName']); ?>"
65
+ kind="<?php echo esc_attr($track['kind']); ?>"
66
+ label="<?php echo esc_attr($track['label']); ?>"
67
+ <?php if ($track['srclang']) { ?>
68
+ srclang="<?php echo esc_attr($track['srclang']); ?>"
69
+ <?php } ?>
70
+ >
71
+ <?php } ?>
72
+ </video>
@@ -0,0 +1,15 @@
1
+ import { GutenbergBlock } from '@eightshift/frontend-libs-tailwind/scripts';
2
+ import { AccordionEditor } from './components/accordion-editor';
3
+ import { AccordionOptions } from './components/accordion-options';
4
+ import manifest from './manifest.json';
5
+
6
+ export const Accordion = (props) => {
7
+ return (
8
+ <GutenbergBlock
9
+ {...props}
10
+ options={AccordionOptions}
11
+ editor={AccordionEditor}
12
+ title={manifest.title}
13
+ />
14
+ );
15
+ };
@@ -0,0 +1,28 @@
1
+ <?php
2
+
3
+ /**
4
+ * Accordion 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
+ $accordionCloseAdjacent = Helpers::checkAttr('accordionCloseAdjacent', $attributes, $manifest);
16
+ ?>
17
+
18
+ <div
19
+ class="<?php echo esc_attr($blockJsClass); ?>"
20
+ <?php if ($accordionCloseAdjacent) {
21
+ ?> data-close-adjacent <?php
22
+ } ?>
23
+ >
24
+ <?php
25
+ // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
26
+ echo $renderContent;
27
+ ?>
28
+ </div>
@@ -0,0 +1,37 @@
1
+ import domReady from '@wordpress/dom-ready';
2
+
3
+ domReady(async () => {
4
+ const selector = '.js-block-accordion';
5
+ const elements = document.querySelectorAll(selector);
6
+
7
+ if (elements?.length < 1) {
8
+ return;
9
+ }
10
+
11
+ elements.forEach((element) => {
12
+ let activeElement;
13
+
14
+ const accordionTriggers = element.querySelectorAll('[data-accordion-header]');
15
+
16
+ const closeAdjacent = element.hasAttribute('data-close-adjacent');
17
+
18
+ accordionTriggers.forEach((trigger) => {
19
+ const target = trigger.nextElementSibling;
20
+
21
+ trigger.addEventListener('click', () => {
22
+ if (closeAdjacent) {
23
+ if (activeElement) {
24
+ activeElement.setAttribute('aria-expanded', false);
25
+ activeElement.nextElementSibling.hidden = true;
26
+ }
27
+
28
+ activeElement = trigger;
29
+ }
30
+
31
+ const expanded = trigger.getAttribute('aria-expanded') === 'true' ?? false;
32
+ trigger.setAttribute('aria-expanded', !expanded);
33
+ target.hidden = expanded;
34
+ });
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,17 @@
1
+ import { BlockInserter } from '@eightshift/frontend-libs-tailwind/scripts';
2
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
3
+
4
+ export const AccordionEditor = ({ clientId }) => {
5
+ const blockProps = useBlockProps();
6
+ const innerBlocksProps = useInnerBlocksProps(blockProps, {
7
+ allowedBlocks: ['eightshift-boilerplate/accordion-item'],
8
+ renderAppender: () => (
9
+ <BlockInserter
10
+ clientId={clientId}
11
+ label
12
+ />
13
+ ),
14
+ });
15
+
16
+ return <div {...innerBlocksProps} className='space-y-0 *:!m-0' />;
17
+ };
@@ -0,0 +1,18 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { checkAttr, getAttrKey } from '@eightshift/frontend-libs-tailwind/scripts';
3
+ import { Toggle } from '@eightshift/ui-components';
4
+ import { icons } from '@eightshift/ui-components/icons';
5
+ import manifest from '../manifest.json';
6
+
7
+ export const AccordionOptions = ({ attributes, setAttributes }) => {
8
+ const accordionCloseAdjacent = checkAttr('accordionCloseAdjacent', attributes, manifest);
9
+
10
+ return (
11
+ <Toggle
12
+ icon={icons.dropdownClose}
13
+ label={__('Allow only one panel to be open', '%g_textdomain%')}
14
+ checked={accordionCloseAdjacent}
15
+ onChange={(value) => setAttributes({ [getAttrKey('accordionCloseAdjacent', attributes, manifest)]: value })}
16
+ />
17
+ );
18
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/block.json",
3
+ "blockName": "accordion",
4
+ "blockJsClass": "js-block-accordion",
5
+ "title": "Accordion",
6
+ "description" : "Hide and show additional content.",
7
+ "category": "eightshift",
8
+ "icon": {
9
+ "src": "es-accordion"
10
+ },
11
+ "keywords": [
12
+ "accordion"
13
+ ],
14
+ "example": {
15
+ "innerBlocks": [
16
+ {
17
+ "name": "eightshift-boilerplate/accordion-item",
18
+ "attributes": {
19
+ "accordionItemAccordionItemTitle": "Demo accordion",
20
+ "accordionItemAccordionItemContent": "Demo accordion content"
21
+ }
22
+ }
23
+ ]
24
+ },
25
+ "hasInnerBlocks": true,
26
+ "attributes": {
27
+ "accordionCloseAdjacent": {
28
+ "type": "boolean",
29
+ "default": false
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,19 @@
1
+ import { useSelect } from '@wordpress/data';
2
+ import { GutenbergBlock, overrideInnerBlockAttributes } from '@eightshift/frontend-libs-tailwind/scripts/editor';
3
+ import { AccordionItemEditor } from './components/accordion-item-editor';
4
+
5
+ export const AccordionItem = (props) => {
6
+ useSelect((select) => {
7
+ overrideInnerBlockAttributes(select, props.clientId, {
8
+ wrapperNoWidthControls: true,
9
+ wrapperWidth: 'none',
10
+ });
11
+ });
12
+
13
+ return (
14
+ <GutenbergBlock
15
+ {...props}
16
+ editor={AccordionItemEditor}
17
+ />
18
+ );
19
+ };
@@ -0,0 +1,46 @@
1
+ <?php
2
+
3
+ /**
4
+ * Accordion item 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
+ $uniqueId = Helpers::getUnique();
16
+
17
+ $panelId = "{$uniqueId}-panel";
18
+ $triggerId = "{$uniqueId}-header";
19
+
20
+ $accordionItemLabel = Helpers::checkAttr('accordionItemLabel', $attributes, $manifest);
21
+ ?>
22
+
23
+ <button
24
+ id="<?php echo esc_attr($triggerId); ?>"
25
+ aria-expanded="false"
26
+ aria-controls="<?php echo esc_attr($panelId); ?>"
27
+ class="<?php echo esc_attr(Helpers::getTwPart('trigger', $manifest)); ?>"
28
+ data-accordion-header
29
+ >
30
+ <?php
31
+ echo esc_attr($accordionItemLabel),
32
+ // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
33
+ $manifest['resources']['icon'];
34
+ ?>
35
+ </button>
36
+ <section
37
+ id="<?php echo esc_attr($panelId); ?>"
38
+ aria-labelledby="<?php echo esc_attr($triggerId); ?>"
39
+ class="<?php echo esc_attr(Helpers::getTwPart('content-container', $manifest)); ?>"
40
+ hidden
41
+ >
42
+ <?php
43
+ // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
44
+ echo $renderContent;
45
+ ?>
46
+ </section>