erudit 2.0.0-dev.7

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 (314) hide show
  1. package/.nuxtrc +1 -0
  2. package/app/app.vue +172 -0
  3. package/app/assets/icons/alert.svg +3 -0
  4. package/app/assets/icons/angle-right.svg +3 -0
  5. package/app/assets/icons/arrow-in-text.svg +3 -0
  6. package/app/assets/icons/arrow-left.svg +3 -0
  7. package/app/assets/icons/arrow-up-to-right.svg +3 -0
  8. package/app/assets/icons/aside-open.svg +3 -0
  9. package/app/assets/icons/asterisk.svg +3 -0
  10. package/app/assets/icons/book-question.svg +3 -0
  11. package/app/assets/icons/book.svg +3 -0
  12. package/app/assets/icons/bug.svg +3 -0
  13. package/app/assets/icons/chip.svg +3 -0
  14. package/app/assets/icons/circle-help.svg +3 -0
  15. package/app/assets/icons/construction.svg +3 -0
  16. package/app/assets/icons/cross.svg +3 -0
  17. package/app/assets/icons/draw.svg +3 -0
  18. package/app/assets/icons/ellipsis-vertical.svg +3 -0
  19. package/app/assets/icons/file-check.svg +3 -0
  20. package/app/assets/icons/file-lines.svg +3 -0
  21. package/app/assets/icons/file-star.svg +3 -0
  22. package/app/assets/icons/folder-open.svg +3 -0
  23. package/app/assets/icons/folder.svg +3 -0
  24. package/app/assets/icons/globe.svg +3 -0
  25. package/app/assets/icons/house.svg +3 -0
  26. package/app/assets/icons/link-external.svg +3 -0
  27. package/app/assets/icons/link.svg +3 -0
  28. package/app/assets/icons/moon.svg +3 -0
  29. package/app/assets/icons/outline/book.svg +3 -0
  30. package/app/assets/icons/outline/file-lines.svg +3 -0
  31. package/app/assets/icons/pirate.svg +3 -0
  32. package/app/assets/icons/plus-circle.svg +3 -0
  33. package/app/assets/icons/plus.svg +3 -0
  34. package/app/assets/icons/puzzle.svg +3 -0
  35. package/app/assets/icons/search.svg +3 -0
  36. package/app/assets/icons/shuffle.svg +3 -0
  37. package/app/assets/icons/star.svg +3 -0
  38. package/app/assets/icons/sun-moon.svg +3 -0
  39. package/app/assets/icons/sun.svg +3 -0
  40. package/app/assets/icons/user.svg +3 -0
  41. package/app/assets/icons/users.svg +3 -0
  42. package/app/components/Loading.vue +23 -0
  43. package/app/components/SiteAside.vue +382 -0
  44. package/app/components/SiteMain.vue +35 -0
  45. package/app/components/ads/BannerTemplate.vue +51 -0
  46. package/app/components/ads/BottomBanner.vue +45 -0
  47. package/app/components/ads/LeftBanner.vue +50 -0
  48. package/app/components/aside/AsideListItem.vue +74 -0
  49. package/app/components/aside/AsideMajor.vue +56 -0
  50. package/app/components/aside/AsideMinor.vue +71 -0
  51. package/app/components/aside/major/PaneContentScroll.vue +23 -0
  52. package/app/components/aside/major/PaneSwitch.vue +54 -0
  53. package/app/components/aside/major/PaneSwitchButton.vue +63 -0
  54. package/app/components/aside/major/SiteInfo.vue +85 -0
  55. package/app/components/aside/major/panes/Language.vue +79 -0
  56. package/app/components/aside/major/panes/Pages.vue +34 -0
  57. package/app/components/aside/major/panes/Search.vue +3 -0
  58. package/app/components/aside/major/panes/nav/Nav.vue +91 -0
  59. package/app/components/aside/major/panes/nav/NavBook.vue +86 -0
  60. package/app/components/aside/major/panes/nav/NavBookLoading.vue +24 -0
  61. package/app/components/aside/major/panes/nav/NavGlobal.vue +16 -0
  62. package/app/components/aside/major/panes/nav/fnav/FNav.vue +105 -0
  63. package/app/components/aside/major/panes/nav/fnav/FNavBook.vue +32 -0
  64. package/app/components/aside/major/panes/nav/fnav/FNavFlags.vue +40 -0
  65. package/app/components/aside/major/panes/nav/fnav/FNavFolder.vue +60 -0
  66. package/app/components/aside/major/panes/nav/fnav/FNavItem.vue +34 -0
  67. package/app/components/aside/major/panes/nav/fnav/FNavSeparator.vue +80 -0
  68. package/app/components/aside/major/panes/nav/fnav/FNavTopic.vue +24 -0
  69. package/app/components/aside/major/panes/other/ItemContent.vue +29 -0
  70. package/app/components/aside/major/panes/other/ItemGenerator.vue +15 -0
  71. package/app/components/aside/major/panes/other/ItemTheme.vue +54 -0
  72. package/app/components/aside/major/panes/other/Other.vue +16 -0
  73. package/app/components/aside/minor/AsideMinorContributor.vue +5 -0
  74. package/app/components/aside/minor/AsideMinorNews.vue +11 -0
  75. package/app/components/aside/minor/AsideMinorPane.vue +16 -0
  76. package/app/components/aside/minor/AsideMinorTopLink.vue +67 -0
  77. package/app/components/aside/minor/Contribute.vue +145 -0
  78. package/app/components/aside/minor/content/AsideMinorContent.vue +92 -0
  79. package/app/components/aside/minor/topic/AsideMinorTopic.vue +32 -0
  80. package/app/components/aside/minor/topic/TopicContributors.vue +177 -0
  81. package/app/components/aside/minor/topic/TopicNav.vue +49 -0
  82. package/app/components/aside/minor/topic/TopicToc.vue +202 -0
  83. package/app/components/aside/minor/topic/TopicTocItem.vue +31 -0
  84. package/app/components/aside/utils/AsideOverlayPane.vue +40 -0
  85. package/app/components/bitran/BitranContent.vue +64 -0
  86. package/app/components/bitran/RenderWrapper.vue +12 -0
  87. package/app/components/contributor/ContributorAvatar.vue +43 -0
  88. package/app/components/contributor/ContributorListItem.vue +35 -0
  89. package/app/components/main/topic/MainTopic.vue +79 -0
  90. package/app/components/main/topic/TopicPartSwitch.vue +118 -0
  91. package/app/components/main/utils/Breadcrumb.vue +75 -0
  92. package/app/components/main/utils/ContentDecoration.vue +29 -0
  93. package/app/components/main/utils/ContentDescription.vue +20 -0
  94. package/app/components/main/utils/ContentFlag.vue +16 -0
  95. package/app/components/main/utils/ContentPopover.vue +176 -0
  96. package/app/components/main/utils/ContentPopovers.vue +105 -0
  97. package/app/components/main/utils/ContentReferences.vue +76 -0
  98. package/app/components/main/utils/ContentSection.vue +42 -0
  99. package/app/components/main/utils/ContentTitle.vue +37 -0
  100. package/app/components/main/utils/reference/ReferenceGroup.vue +41 -0
  101. package/app/components/main/utils/reference/ReferenceItem.vue +64 -0
  102. package/app/components/main/utils/reference/ReferenceSource.vue +110 -0
  103. package/app/components/preview/Preview.vue +177 -0
  104. package/app/components/preview/PreviewDisplay.vue +139 -0
  105. package/app/components/preview/PreviewFooterAction.vue +73 -0
  106. package/app/components/preview/PreviewLoading.vue +15 -0
  107. package/app/components/preview/PreviewScreen.vue +99 -0
  108. package/app/components/preview/display/Alert.vue +50 -0
  109. package/app/components/preview/display/Custom.vue +18 -0
  110. package/app/components/preview/display/GenericLink.vue +48 -0
  111. package/app/components/preview/display/PageLink.vue +20 -0
  112. package/app/components/preview/display/Unique.vue +49 -0
  113. package/app/components/transition/Fade.vue +22 -0
  114. package/app/components/tree/TreeContainer.vue +12 -0
  115. package/app/components/tree/TreeItem.vue +89 -0
  116. package/app/composables/bitran.ts +132 -0
  117. package/app/composables/bitranContent.ts +36 -0
  118. package/app/composables/bitranLocation.ts +7 -0
  119. package/app/composables/contentData.ts +36 -0
  120. package/app/composables/contentPage.ts +156 -0
  121. package/app/composables/contentRoute.ts +45 -0
  122. package/app/composables/darkMagic.ts +24 -0
  123. package/app/composables/externalApi.ts +63 -0
  124. package/app/composables/favicon.ts +8 -0
  125. package/app/composables/formatText.ts +86 -0
  126. package/app/composables/majorPane.ts +60 -0
  127. package/app/composables/phrases.ts +80 -0
  128. package/app/composables/theme.ts +29 -0
  129. package/app/composables/url.ts +33 -0
  130. package/app/pages/_test/preview.vue +110 -0
  131. package/app/pages/article/[...articleId].vue +3 -0
  132. package/app/pages/book/[...bookId].vue +47 -0
  133. package/app/pages/group/[...groupId].vue +64 -0
  134. package/app/pages/index.vue +32 -0
  135. package/app/pages/members.vue +7 -0
  136. package/app/pages/practice/[...practice].vue +3 -0
  137. package/app/pages/summary/[...summaryId].vue +3 -0
  138. package/app/public/favicon/article.svg +10 -0
  139. package/app/public/favicon/default.svg +10 -0
  140. package/app/public/favicon/practice.svg +10 -0
  141. package/app/public/favicon/summary.svg +10 -0
  142. package/app/public/logotype.svg +17 -0
  143. package/app/public/og-default.png +0 -0
  144. package/app/public/user.svg +10 -0
  145. package/app/scripts/_immediate.js +4 -0
  146. package/app/scripts/aside/index.ts +59 -0
  147. package/app/scripts/aside/major/nav.ts +26 -0
  148. package/app/scripts/aside/minor/state.ts +37 -0
  149. package/app/scripts/aside/minor/topic.ts +3 -0
  150. package/app/scripts/flag.ts +28 -0
  151. package/app/scripts/og.ts +27 -0
  152. package/app/scripts/preview/build.ts +84 -0
  153. package/app/scripts/preview/data/alert.ts +19 -0
  154. package/app/scripts/preview/data/custom.ts +8 -0
  155. package/app/scripts/preview/data/genericLink.ts +24 -0
  156. package/app/scripts/preview/data/pageLink.ts +20 -0
  157. package/app/scripts/preview/data/unique.ts +70 -0
  158. package/app/scripts/preview/data.ts +26 -0
  159. package/app/scripts/preview/display.ts +39 -0
  160. package/app/scripts/preview/footer.ts +9 -0
  161. package/app/scripts/preview/request.ts +51 -0
  162. package/app/scripts/preview/state.ts +63 -0
  163. package/app/styles/_immediate.css +3 -0
  164. package/app/styles/_util.scss +50 -0
  165. package/app/styles/_utils.scss +44 -0
  166. package/app/styles/app.scss +91 -0
  167. package/app/styles/def/_bp.scss +24 -0
  168. package/app/styles/def/_size.scss +7 -0
  169. package/app/styles/def/_z.scss +5 -0
  170. package/app/styles/default.scss +85 -0
  171. package/app/styles/normalize.scss +63 -0
  172. package/app/styles/partials/_darkMagic.scss +7 -0
  173. package/app/styles/partials/_fnav.scss +18 -0
  174. package/app/styles/partials/_preview.scss +7 -0
  175. package/globalPath.ts +24 -0
  176. package/globals/bitran.ts +39 -0
  177. package/globals/content.ts +22 -0
  178. package/globals/contributor.ts +5 -0
  179. package/globals/erudit.ts +5 -0
  180. package/globals/register.ts +18 -0
  181. package/languages/en.ts +95 -0
  182. package/languages/ru.ts +99 -0
  183. package/module/bitran.ts +34 -0
  184. package/module/config.ts +34 -0
  185. package/module/imports.ts +46 -0
  186. package/module/index.ts +35 -0
  187. package/module/logger.ts +10 -0
  188. package/module/paths.ts +22 -0
  189. package/module/restart.ts +61 -0
  190. package/nuxt.config.ts +96 -0
  191. package/package.json +32 -0
  192. package/server/api/aside/major/nav/bookIds.ts +5 -0
  193. package/server/api/aside/major/nav/bookNav/[...bookId].ts +20 -0
  194. package/server/api/aside/major/nav/global.ts +7 -0
  195. package/server/api/aside/minor/news.ts +7 -0
  196. package/server/api/aside/minor/path.ts +78 -0
  197. package/server/api/bitran/content/[location].ts +7 -0
  198. package/server/api/bitran/toc/[location].ts +7 -0
  199. package/server/api/content/data.ts +72 -0
  200. package/server/api/contributor/count.ts +6 -0
  201. package/server/api/fake/content.ts +11 -0
  202. package/server/api/fake/shared/languages.ts +12 -0
  203. package/server/api/language/functions.ts +12 -0
  204. package/server/api/language/phrase/[phraseId].ts +19 -0
  205. package/server/api/language/phraseIds.ts +8 -0
  206. package/server/api/preview/page/[...parts].ts +51 -0
  207. package/server/api/preview/unique/[location].ts +55 -0
  208. package/server/plugin/bitran/content.ts +176 -0
  209. package/server/plugin/bitran/core.ts +51 -0
  210. package/server/plugin/bitran/location.ts +25 -0
  211. package/server/plugin/bitran/products/include.ts +229 -0
  212. package/server/plugin/bitran/products/link.ts +114 -0
  213. package/server/plugin/bitran/setup.ts +10 -0
  214. package/server/plugin/bitran/toc.ts +82 -0
  215. package/server/plugin/build/close.ts +10 -0
  216. package/server/plugin/build/jobs/content/builderArgs.ts +8 -0
  217. package/server/plugin/build/jobs/content/generic.ts +176 -0
  218. package/server/plugin/build/jobs/content/parse.ts +90 -0
  219. package/server/plugin/build/jobs/content/path.ts +6 -0
  220. package/server/plugin/build/jobs/content/type/book.ts +9 -0
  221. package/server/plugin/build/jobs/content/type/group.ts +37 -0
  222. package/server/plugin/build/jobs/content/type/topic.ts +36 -0
  223. package/server/plugin/build/jobs/contributors.ts +66 -0
  224. package/server/plugin/build/jobs/language.ts +36 -0
  225. package/server/plugin/build/jobs/nav.ts +209 -0
  226. package/server/plugin/build/process.ts +25 -0
  227. package/server/plugin/build/rebuild.ts +55 -0
  228. package/server/plugin/build/setup.ts +21 -0
  229. package/server/plugin/content/absoluteId.ts +94 -0
  230. package/server/plugin/content/context.ts +112 -0
  231. package/server/plugin/db/entities/Book.ts +7 -0
  232. package/server/plugin/db/entities/Content.ts +49 -0
  233. package/server/plugin/db/entities/Contribution.ts +10 -0
  234. package/server/plugin/db/entities/Contributor.ts +16 -0
  235. package/server/plugin/db/entities/Group.ts +14 -0
  236. package/server/plugin/db/entities/Hash.ts +15 -0
  237. package/server/plugin/db/entities/Topic.ts +20 -0
  238. package/server/plugin/db/entities/Unique.ts +21 -0
  239. package/server/plugin/db/setup.ts +34 -0
  240. package/server/plugin/global.ts +18 -0
  241. package/server/plugin/importer.ts +12 -0
  242. package/server/plugin/index.ts +9 -0
  243. package/server/plugin/logger.ts +23 -0
  244. package/server/plugin/nav/node.ts +26 -0
  245. package/server/plugin/nav/utils.ts +129 -0
  246. package/server/plugin/repository/book.ts +21 -0
  247. package/server/plugin/repository/content.ts +238 -0
  248. package/server/plugin/repository/contributor.ts +8 -0
  249. package/server/plugin/repository/frontNav.ts +148 -0
  250. package/server/plugin/repository/topic.ts +32 -0
  251. package/server/tsconfig.json +7 -0
  252. package/shared/aside/minor.ts +50 -0
  253. package/shared/asset.ts +15 -0
  254. package/shared/bitran/alias.ts +17 -0
  255. package/shared/bitran/context.ts +7 -0
  256. package/shared/bitran/location.ts +166 -0
  257. package/shared/bitran/products/alias/core/factory.ts +46 -0
  258. package/shared/bitran/products/alias/core/index.ts +13 -0
  259. package/shared/bitran/products/alias/render/Alias.vue +10 -0
  260. package/shared/bitran/products/alias/render/icon.svg +3 -0
  261. package/shared/bitran/products/alias/render/index.ts +17 -0
  262. package/shared/bitran/products/alias/render/languages/en.ts +5 -0
  263. package/shared/bitran/products/alias/render/languages/ru.ts +5 -0
  264. package/shared/bitran/products/alias/shared.ts +11 -0
  265. package/shared/bitran/products/heading/core/factory.ts +53 -0
  266. package/shared/bitran/products/heading/core/index.ts +19 -0
  267. package/shared/bitran/products/heading/render/Heading.vue +47 -0
  268. package/shared/bitran/products/heading/render/icon.svg +3 -0
  269. package/shared/bitran/products/heading/render/index.ts +17 -0
  270. package/shared/bitran/products/heading/render/languages/en.ts +5 -0
  271. package/shared/bitran/products/heading/render/languages/ru.ts +5 -0
  272. package/shared/bitran/products/heading/shared.ts +13 -0
  273. package/shared/bitran/products/include/core/factory.ts +61 -0
  274. package/shared/bitran/products/include/core/index.ts +13 -0
  275. package/shared/bitran/products/include/render/Include.vue +13 -0
  276. package/shared/bitran/products/include/render/icon.svg +3 -0
  277. package/shared/bitran/products/include/render/index.ts +18 -0
  278. package/shared/bitran/products/include/render/languages/en.ts +5 -0
  279. package/shared/bitran/products/include/render/languages/ru.ts +5 -0
  280. package/shared/bitran/products/include/shared.ts +15 -0
  281. package/shared/bitran/products/link/core/factory.ts +20 -0
  282. package/shared/bitran/products/link/core/index.ts +17 -0
  283. package/shared/bitran/products/link/render/Link.vue +174 -0
  284. package/shared/bitran/products/link/render/icon.svg +3 -0
  285. package/shared/bitran/products/link/render/index.ts +17 -0
  286. package/shared/bitran/products/link/render/languages/en.ts +5 -0
  287. package/shared/bitran/products/link/render/languages/ru.ts +5 -0
  288. package/shared/bitran/products/link/shared.ts +15 -0
  289. package/shared/bitran/products/link/target.ts +134 -0
  290. package/shared/bitran/toc.ts +8 -0
  291. package/shared/content/context.ts +9 -0
  292. package/shared/content/data/base.ts +32 -0
  293. package/shared/content/data/index.ts +5 -0
  294. package/shared/content/data/type/book.ts +5 -0
  295. package/shared/content/data/type/group.ts +6 -0
  296. package/shared/content/data/type/topic.ts +11 -0
  297. package/shared/content/previousNext.ts +9 -0
  298. package/shared/contributor.ts +5 -0
  299. package/shared/frontNav.ts +41 -0
  300. package/shared/icons.ts +38 -0
  301. package/shared/image.ts +5 -0
  302. package/shared/link.ts +25 -0
  303. package/shared/types/language.ts +75 -0
  304. package/shared/utils/objectsEqual.ts +4 -0
  305. package/shared/utils/stringColor.ts +9 -0
  306. package/test/bitran/alias.test.ts +44 -0
  307. package/test/bitran/location.test.ts +143 -0
  308. package/test/bitran/products/alias.test.ts +83 -0
  309. package/test/bitran/products/heading.test.ts +119 -0
  310. package/test/bitran/products/include.test.ts +77 -0
  311. package/test/bitran/products/link/factory.test.ts +30 -0
  312. package/test/bitran/products/link/target.test.ts +138 -0
  313. package/tsconfig.json +8 -0
  314. package/utils/stress.ts +9 -0
@@ -0,0 +1,177 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewRequest } from '@app/scripts/preview/request';
3
+ import {
4
+ previewBlinkTrigger,
5
+ previewRequest,
6
+ previewTheme,
7
+ previewVisible,
8
+ unsetPreviewTheme,
9
+ } from '@app/scripts/preview/state';
10
+
11
+ import PreviewScreen from './PreviewScreen.vue';
12
+
13
+ const height = ref<number>(0);
14
+ const request = shallowRef<PreviewRequest>();
15
+ const screenKey = ref(0); // Need to change this every time for Vue transition to work
16
+
17
+ watch(previewRequest, () => {
18
+ if (previewRequest.value) {
19
+ request.value = structuredClone(toRaw(previewRequest.value));
20
+ unsetPreviewTheme();
21
+ screenKey.value++;
22
+ }
23
+ });
24
+ </script>
25
+
26
+ <template>
27
+ <div :class="$style.previewSticky">
28
+ <div :class="$style.previewOverlay">
29
+ <section
30
+ :class="[$style.preview, previewVisible && $style.visible]"
31
+ :style="{
32
+ '--_previewHeightInner': `min(${height}px, var(--_previewMaxHeight))`,
33
+ }"
34
+ :data-erudit-preview-theme="previewTheme"
35
+ >
36
+ <TransitionFade>
37
+ <PreviewScreen
38
+ v-if="request"
39
+ :request
40
+ :key="screenKey"
41
+ v-model:height="height"
42
+ />
43
+ </TransitionFade>
44
+ <div
45
+ :key="previewBlinkTrigger"
46
+ :class="$style.blinkOverlay"
47
+ ></div>
48
+ </section>
49
+ </div>
50
+ </div>
51
+ </template>
52
+
53
+ <style lang="scss" module>
54
+ @use '$/def/z';
55
+ @use '$/def/bp';
56
+
57
+ .previewSticky {
58
+ position: sticky;
59
+ top: 0;
60
+ z-index: z.$preview;
61
+ }
62
+
63
+ .previewOverlay {
64
+ position: absolute;
65
+ top: 0;
66
+ width: 100%;
67
+ height: 100dvh;
68
+ //background: rgba(255, 0, 0, 0.121);
69
+ overflow: hidden;
70
+ pointer-events: none;
71
+ touch-action: none;
72
+ }
73
+
74
+ .preview {
75
+ --previewBorderRadius: 15px;
76
+
77
+ --_previewMaxHeight: 70dvh;
78
+ --_previewHeightInner: 0px;
79
+ --_previewHeight: calc(var(--_previewHeightInner) + 1px /* Top border */);
80
+
81
+ pointer-events: initial;
82
+ touch-action: initial;
83
+
84
+ overflow: hidden;
85
+
86
+ position: absolute;
87
+ bottom: 0;
88
+ height: var(--_previewHeight);
89
+ max-height: var(--_previewMaxHeight);
90
+ width: 100%;
91
+ background: var(--_previewThemeBg, var(--bgAside));
92
+
93
+ border: 1px solid var(--_previewThemeBorder, var(--border));
94
+ border-bottom: none;
95
+ border-top-left-radius: var(--previewBorderRadius);
96
+ border-top-right-radius: var(--previewBorderRadius);
97
+
98
+ box-shadow: 0px -10px 12px 0px
99
+ light-dark(rgba(black, 0.11), rgba(white, 0.03));
100
+
101
+ @include transition(bottom, height, box-shadow, background);
102
+
103
+ @media (max-height: 500px) {
104
+ --_previewMaxHeight: 85dvh;
105
+ }
106
+
107
+ @include bp.below('aside2') {
108
+ border-right: transparent;
109
+ }
110
+ @include bp.below('aside1') {
111
+ border-left: transparent;
112
+ }
113
+
114
+ &:not(.visible) {
115
+ bottom: calc(-1 * var(--_previewHeight));
116
+ box-shadow: none;
117
+ overflow: hidden;
118
+ }
119
+ }
120
+
121
+ .blinkOverlay {
122
+ position: absolute;
123
+ z-index: 1000;
124
+ top: 0;
125
+ left: 0;
126
+ width: 100%;
127
+ height: 100%;
128
+ pointer-events: none;
129
+ touch-action: none;
130
+ background: var(--brand);
131
+ opacity: 0;
132
+ animation: blink 0.5s ease-out;
133
+ }
134
+
135
+ @keyframes blink {
136
+ 0% {
137
+ opacity: 0;
138
+ }
139
+ 50% {
140
+ opacity: 0.6;
141
+ }
142
+ 100% {
143
+ opacity: 0;
144
+ }
145
+ }
146
+
147
+ //
148
+ // Themes
149
+ //
150
+
151
+ .preview {
152
+ --_previewThemeBg: var(--bgAside);
153
+ --_previewThemeBorder: var(--border);
154
+ --_previewThemeText: var(--text);
155
+
156
+ @mixin previewTheme($themeName, $baseColor) {
157
+ &[data-erudit-preview-theme='#{$themeName}'] {
158
+ --_previewThemeBg: color-mix(
159
+ in srgb,
160
+ #{$baseColor},
161
+ var(--bgAside) 92%
162
+ );
163
+ --_previewThemeBorder: color-mix(
164
+ in srgb,
165
+ #{$baseColor},
166
+ var(--border) 80%
167
+ );
168
+ --_previewThemeText: #{$baseColor};
169
+ }
170
+ }
171
+
172
+ @include previewTheme(error, var(--error));
173
+ @include previewTheme(warn, var(--warn));
174
+ @include previewTheme(success, var(--success));
175
+ @include previewTheme(brand, var(--brand));
176
+ }
177
+ </style>
@@ -0,0 +1,139 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewFooter } from '@app/scripts/preview/footer';
3
+ import {
4
+ closePreview,
5
+ hasPreviewHistory,
6
+ showPreviousPreview,
7
+ } from '@app/scripts/preview/state';
8
+
9
+ const { footer } = defineProps<{ footer?: PreviewFooter }>();
10
+
11
+ const phrase = await usePhrases('close', 'back', 'goto');
12
+ </script>
13
+
14
+ <template>
15
+ <section :class="$style.display">
16
+ <div v-if="$slots.default" :class="$style.content">
17
+ <slot></slot>
18
+ </div>
19
+
20
+ <div v-if="footer" :class="$style.footer">
21
+ <div :class="$style.icon" v-if="footer.iconName || footer.iconSvg">
22
+ <MyIcon v-if="footer.iconName" :name="footer.iconName" />
23
+ <MyRuntimeIcon
24
+ v-else
25
+ name="preview-footer-icon"
26
+ :svg="footer.iconSvg!"
27
+ />
28
+ </div>
29
+
30
+ <div :class="$style.info">
31
+ <div v-if="footer.secondary" :class="$style.secondary">
32
+ {{ footer.secondary }}
33
+ </div>
34
+ <div :class="$style.primary">{{ footer.primary }}</div>
35
+ </div>
36
+
37
+ <div :class="$style.actions">
38
+ <TransitionFade>
39
+ <PreviewFooterAction
40
+ v-if="hasPreviewHistory"
41
+ icon="arrow-left"
42
+ @click="showPreviousPreview"
43
+ :title="phrase.back"
44
+ />
45
+ </TransitionFade>
46
+ <PreviewFooterAction
47
+ icon="cross"
48
+ @click="closePreview"
49
+ :title="phrase.close"
50
+ />
51
+ <PreviewFooterAction
52
+ v-if="footer.href"
53
+ :link="footer.href"
54
+ icon="arrow-in-text"
55
+ :brand="true"
56
+ :title="phrase.goto"
57
+ />
58
+ </div>
59
+ </div>
60
+ </section>
61
+ </template>
62
+
63
+ <style lang="scss" module>
64
+ @use '$/partials/preview';
65
+
66
+ .display {
67
+ --_previewFooterHeight: 0px;
68
+
69
+ &:has(> .footer) {
70
+ --_previewFooterHeight: 70px;
71
+ }
72
+ }
73
+
74
+ .content {
75
+ max-height: calc(var(--_previewMaxHeight) - var(--_previewFooterHeight));
76
+ overflow: auto;
77
+ @include scroll;
78
+ }
79
+
80
+ .content + .footer {
81
+ border-top: 1px solid var(--_previewThemeBorder, var(--border));
82
+ @include transition(border);
83
+ }
84
+
85
+ .footer {
86
+ display: flex;
87
+ gap: var(--gap);
88
+ align-items: center;
89
+ height: var(--_previewFooterHeight);
90
+ padding: 0 var(--gap);
91
+
92
+ .icon {
93
+ flex-shrink: 0;
94
+ font-size: 30px;
95
+ color: var(--textMuted);
96
+
97
+ @include preview.hasTheme() {
98
+ color: color-mix(
99
+ in srgb,
100
+ var(--_previewThemeText),
101
+ var(--textMuted) 30%
102
+ );
103
+ }
104
+
105
+ @include transition(color);
106
+ }
107
+
108
+ .info {
109
+ flex: 1;
110
+ overflow: hidden;
111
+
112
+ .secondary,
113
+ .primary {
114
+ text-overflow: ellipsis;
115
+ white-space: nowrap;
116
+ overflow: hidden;
117
+ @include transition(color);
118
+ }
119
+
120
+ .secondary {
121
+ color: var(--textMuted);
122
+ font-size: 0.775em;
123
+ margin-bottom: -2px;
124
+ }
125
+
126
+ .primary {
127
+ font-size: 0.9em;
128
+ font-weight: bold;
129
+ color: var(--_previewThemeText, var(--text));
130
+ }
131
+ }
132
+
133
+ .actions {
134
+ flex-shrink: 0;
135
+ display: flex;
136
+ gap: var(--gapSmall);
137
+ }
138
+ }
139
+ </style>
@@ -0,0 +1,73 @@
1
+ <script lang="ts" setup>
2
+ import type { MyIconName } from '#my-icons';
3
+
4
+ defineProps<{
5
+ icon: MyIconName;
6
+ link?: string;
7
+ brand?: boolean;
8
+ }>();
9
+
10
+ const nuxtLink = defineNuxtLink({ prefetch: false });
11
+ </script>
12
+
13
+ <template>
14
+ <component
15
+ :is="link ? nuxtLink : 'button'"
16
+ :to="link || null"
17
+ :class="[$style.uiAction, brand && $style.brand]"
18
+ target="_blank"
19
+ >
20
+ <MyIcon :name="icon" />
21
+ </component>
22
+ </template>
23
+
24
+ <style lang="scss" module>
25
+ @use '$/partials/preview';
26
+
27
+ .uiAction {
28
+ --size: 40px;
29
+
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+
34
+ width: var(--size);
35
+ height: var(--size);
36
+
37
+ border: none;
38
+ border-radius: 3px;
39
+ background: transparent;
40
+
41
+ color: var(--textMuted);
42
+ font-size: 22px;
43
+ text-decoration: none;
44
+
45
+ @include transition(color, background, opacity);
46
+
47
+ &:hover,
48
+ &:active {
49
+ cursor: pointer;
50
+ color: var(--textColor);
51
+ background: var(--bgAccent);
52
+
53
+ @include preview.hasTheme() {
54
+ background: color-mix(
55
+ in srgb,
56
+ var(--_previewThemeText),
57
+ var(--bgAccent) 85%
58
+ );
59
+ }
60
+
61
+ &.brand {
62
+ //color: color-mix(in srgb, var(--brand), black 20%);
63
+ background: color-mix(in srgb, var(--brand), transparent 80%);
64
+ }
65
+ }
66
+
67
+ //
68
+
69
+ &.brand {
70
+ color: var(--brand);
71
+ }
72
+ }
73
+ </style>
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <div :class="$style.loadingContainer">
3
+ <Loading />
4
+ </div>
5
+ </template>
6
+
7
+ <style lang="scss" module>
8
+ .loadingContainer
9
+ {
10
+ height: 225px;
11
+ display: grid;
12
+ place-items: center;
13
+ font-size: 50px;
14
+ }
15
+ </style>
@@ -0,0 +1,99 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewRequest } from '@app/scripts/preview/request';
3
+ import { type PreviewData } from '@app/scripts/preview/data';
4
+ import { buildPreviewData } from '@app/scripts/preview/build';
5
+ import { getPreviewDisplayComponent } from '@app/scripts/preview/display';
6
+ import { createPreviewError } from '@app/scripts/preview/data/alert';
7
+
8
+ import { PreviewDisplayAlert } from '#components';
9
+
10
+ const { request } = defineProps<{ request: PreviewRequest }>();
11
+ const height = defineModel<number>('height');
12
+
13
+ const loading = ref(true);
14
+
15
+ const screenElem = useTemplateRef('screenElem');
16
+ const screenSizeObserver = new ResizeObserver(updateContentHeight);
17
+
18
+ const DisplayComponent = shallowRef<Component>();
19
+ const previewData = shallowRef<PreviewData>();
20
+
21
+ const setupDisplay = setTimeout(async () => {
22
+ //await new Promise(resolve => setTimeout(resolve, 5000));
23
+
24
+ try {
25
+ previewData.value = await buildPreviewData(request);
26
+ DisplayComponent.value = getPreviewDisplayComponent(previewData.value);
27
+ } catch (error) {
28
+ console.error(error);
29
+
30
+ previewData.value = createPreviewError({
31
+ // @ts-ignore
32
+ message: error?.message || error,
33
+ });
34
+
35
+ DisplayComponent.value = PreviewDisplayAlert;
36
+ }
37
+
38
+ await nextTick();
39
+ loading.value = false;
40
+ });
41
+
42
+ function updateContentHeight() {
43
+ if (!screenElem.value) return;
44
+
45
+ height.value = screenElem.value.offsetHeight;
46
+ }
47
+
48
+ onMounted(() => {
49
+ height.value = screenElem.value?.offsetHeight ?? 0;
50
+
51
+ watch(
52
+ screenElem,
53
+ () => {
54
+ if (screenElem.value) {
55
+ screenSizeObserver.disconnect();
56
+ screenSizeObserver.observe(screenElem.value);
57
+ }
58
+ },
59
+ { immediate: true },
60
+ );
61
+ });
62
+
63
+ onUnmounted(() => {
64
+ clearTimeout(setupDisplay);
65
+ screenSizeObserver.disconnect();
66
+ });
67
+ </script>
68
+
69
+ <template>
70
+ <div :class="$style.screenContainer">
71
+ <TransitionFade>
72
+ <div
73
+ ref="screenElem"
74
+ :class="$style.screen"
75
+ :key="loading ? 'a' : 'b'"
76
+ >
77
+ <PreviewLoading v-if="loading" />
78
+ <component v-else :is="DisplayComponent" :data="previewData" />
79
+ </div>
80
+ </TransitionFade>
81
+ </div>
82
+ </template>
83
+
84
+ <style lang="scss" module>
85
+ .screenContainer {
86
+ position: absolute;
87
+ top: 0;
88
+ left: 0;
89
+ width: 100%;
90
+ height: 100%;
91
+ }
92
+
93
+ .screen {
94
+ position: absolute;
95
+ bottom: 0;
96
+ left: 0;
97
+ width: 100%;
98
+ }
99
+ </style>
@@ -0,0 +1,50 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewDataAlert } from '@app/scripts/preview/data/alert';
3
+ import type { PreviewDisplayProps } from '@app/scripts/preview/display';
4
+ import type { PreviewFooter } from '@app/scripts/preview/footer';
5
+ import { setPreviewTheme } from '@app/scripts/preview/state';
6
+
7
+ const { data } = defineProps<PreviewDisplayProps<PreviewDataAlert>>();
8
+
9
+ const phrase = await usePhrases('error');
10
+
11
+ setPreviewTheme(data.theme!);
12
+
13
+ const footer: PreviewFooter = {
14
+ iconName: 'alert',
15
+ primary: data.title || phrase.error,
16
+ };
17
+ </script>
18
+
19
+ <template>
20
+ <PreviewDisplay :footer>
21
+ <div :class="$style.alertContent">
22
+ <div v-html="data.message"></div>
23
+ <pre v-if="data.pre" v-html="data.pre"></pre>
24
+ </div>
25
+ </PreviewDisplay>
26
+ </template>
27
+
28
+ <style lang="scss" module>
29
+ .alertContent {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: var(--gap);
33
+ padding: var(--gapBig);
34
+
35
+ color: var(--_previewThemeText);
36
+ font-size: 0.9em;
37
+
38
+ @include transition(color);
39
+
40
+ div {
41
+ font-weight: 500;
42
+ }
43
+
44
+ pre {
45
+ max-height: 100px;
46
+ overflow: auto;
47
+ @include scroll;
48
+ }
49
+ }
50
+ </style>
@@ -0,0 +1,18 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewDataCustom } from '@app/scripts/preview/data/custom';
3
+ import type { PreviewDisplayProps } from '@app/scripts/preview/display';
4
+
5
+ const { data } = defineProps<PreviewDisplayProps<PreviewDataCustom>>();
6
+ </script>
7
+
8
+ <template>
9
+ <PreviewDisplay :footer="data.footer">
10
+ <div :class="$style.message">{{ data.message }}</div>
11
+ </PreviewDisplay>
12
+ </template>
13
+
14
+ <style lang="scss" module>
15
+ .message {
16
+ padding: var(--gapBig);
17
+ }
18
+ </style>
@@ -0,0 +1,48 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewDataGenericLink } from '@app/scripts/preview/data/genericLink';
3
+ import type { PreviewDisplayProps } from '@app/scripts/preview/display';
4
+ import type { PreviewFooter } from '@app/scripts/preview/footer';
5
+
6
+ const { data } = defineProps<PreviewDisplayProps<PreviewDataGenericLink>>();
7
+
8
+ const phrase = await usePhrases(
9
+ 'external_link',
10
+ 'external_link_warn',
11
+ 'internal_link',
12
+ 'internal_link_warn',
13
+ );
14
+
15
+ const footer: PreviewFooter = {
16
+ iconName: data.external ? 'link-external' : 'link',
17
+ href: data.href,
18
+ primary: data.external ? phrase.external_link : phrase.internal_link,
19
+ };
20
+
21
+ const warnMessage = data.external
22
+ ? phrase.external_link_warn
23
+ : phrase.internal_link_warn;
24
+ </script>
25
+
26
+ <template>
27
+ <PreviewDisplay :footer>
28
+ <div :class="$style.wrapper">
29
+ <div :class="$style.warn">{{ warnMessage }}</div>
30
+ <pre>{{ data.href }}</pre>
31
+ </div>
32
+ </PreviewDisplay>
33
+ </template>
34
+
35
+ <style lang="scss" module>
36
+ .wrapper {
37
+ padding: var(--gapBig);
38
+
39
+ pre {
40
+ font-family: monospace;
41
+ }
42
+ }
43
+
44
+ .warn {
45
+ color: var(--textMuted);
46
+ margin-bottom: var(--gap);
47
+ }
48
+ </style>
@@ -0,0 +1,20 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewDataPageLink } from '@app/scripts/preview/data/pageLink';
3
+ import type { PreviewDisplayProps } from '@app/scripts/preview/display';
4
+
5
+ const { data } = defineProps<PreviewDisplayProps<PreviewDataPageLink>>();
6
+
7
+ const phrase = await usePhrases('internal_link_warn');
8
+ </script>
9
+
10
+ <template>
11
+ <PreviewDisplay :footer="data.footer">
12
+ <div :class="$style.wrapper">{{ phrase.internal_link_warn }}</div>
13
+ </PreviewDisplay>
14
+ </template>
15
+
16
+ <style lang="scss" module>
17
+ .wrapper {
18
+ padding: var(--gapBig);
19
+ }
20
+ </style>
@@ -0,0 +1,49 @@
1
+ <script lang="ts" setup>
2
+ import type { PreviewDataUnique } from '@app/scripts/preview/data/unique';
3
+ import type { PreviewDisplayProps } from '@app/scripts/preview/display';
4
+
5
+ import { headingName } from '@shared/bitran/products/heading/shared';
6
+
7
+ const { data } = defineProps<PreviewDisplayProps<PreviewDataUnique>>();
8
+ </script>
9
+
10
+ <template>
11
+ <PreviewDisplay :footer="data.footer">
12
+ <div
13
+ :class="[
14
+ $style.bitranPreviewContent,
15
+ data.productName === headingName && $style.heading,
16
+ ]"
17
+ >
18
+ <BitranContent
19
+ :content="data.bitran.content"
20
+ :context="data.bitran.context"
21
+ />
22
+ </div>
23
+ </PreviewDisplay>
24
+ </template>
25
+
26
+ <style lang="scss" module>
27
+ .bitranPreviewContent {
28
+ position: relative;
29
+ padding: var(--gap) 0;
30
+ }
31
+
32
+ .heading {
33
+ max-height: 340px;
34
+ overflow: hidden;
35
+
36
+ &::after {
37
+ content: '';
38
+ position: absolute;
39
+ top: 0;
40
+ left: 0;
41
+ width: 100%;
42
+ height: 100%;
43
+ z-index: 10;
44
+ background: linear-gradient(to bottom, transparent, var(--bgAside) 95%);
45
+ pointer-events: none;
46
+ touch-action: none;
47
+ }
48
+ }
49
+ </style>