@astronox/core 0.1.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 (259) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -0
  3. package/package.json +77 -0
  4. package/src/client/clipboard.ts +7 -0
  5. package/src/client/focus.ts +17 -0
  6. package/src/client/index.ts +3 -0
  7. package/src/client/scroll.ts +15 -0
  8. package/src/components/actions/ActionListItem/ActionListItem.astro +78 -0
  9. package/src/components/actions/ActionListItem/ActionListItem.css +43 -0
  10. package/src/components/actions/Button/Button.astro +100 -0
  11. package/src/components/actions/Button/Button.css +165 -0
  12. package/src/components/actions/CardAction/CardAction.astro +97 -0
  13. package/src/components/actions/CardAction/CardAction.css +188 -0
  14. package/src/components/actions/MediaTrigger/MediaTrigger.astro +55 -0
  15. package/src/components/actions/MediaTrigger/MediaTrigger.css +175 -0
  16. package/src/components/actions/ScrollToTop/ScrollToTop.astro +36 -0
  17. package/src/components/actions/ScrollToTop/ScrollToTop.css +19 -0
  18. package/src/components/actions/ScrollToTop/scrollToTopController.ts +32 -0
  19. package/src/components/content/CardBody/CardBody.astro +31 -0
  20. package/src/components/content/CardBody/CardBody.css +74 -0
  21. package/src/components/content/CardFooter/CardFooter.astro +58 -0
  22. package/src/components/content/CardFooter/CardFooter.css +102 -0
  23. package/src/components/content/CardHeader/CardHeader.astro +96 -0
  24. package/src/components/content/CardHeader/CardHeader.css +164 -0
  25. package/src/components/content/CardLink/CardLink.astro +138 -0
  26. package/src/components/content/CardLink/CardLink.css +362 -0
  27. package/src/components/content/CodeBlock/CodeBlock.astro +102 -0
  28. package/src/components/content/CodeBlock/CodeBlock.css +85 -0
  29. package/src/components/content/CodeBlock/codeBlockController.ts +60 -0
  30. package/src/components/content/CodeBlock/contracts.ts +8 -0
  31. package/src/components/content/InlineDefinition/InlineDefinition.astro +31 -0
  32. package/src/components/content/InlineDefinition/InlineDefinition.css +9 -0
  33. package/src/components/content/MarkdownContent/MarkdownContent.astro +32 -0
  34. package/src/components/content/MarkdownContent/MarkdownContent.css +358 -0
  35. package/src/components/content/MarkdownContent/MarkdownInline.astro +44 -0
  36. package/src/components/content/MarkdownContent/MarkdownNode.astro +280 -0
  37. package/src/components/content/MarkdownContent/MarkdownSymbol.astro +47 -0
  38. package/src/components/content/MarkdownContent/contracts.ts +181 -0
  39. package/src/components/data-display/BadgeList/BadgeList.astro +54 -0
  40. package/src/components/data-display/BadgeList/BadgeList.css +29 -0
  41. package/src/components/data-display/IconList/IconList.astro +64 -0
  42. package/src/components/data-display/IconList/IconList.css +55 -0
  43. package/src/components/data-display/MetricTile/MetricTile.astro +68 -0
  44. package/src/components/data-display/MetricTile/MetricTile.css +103 -0
  45. package/src/components/data-display/MetricTile/MetricTileContent.astro +70 -0
  46. package/src/components/data-display/MetricTile/metricTileController.ts +9 -0
  47. package/src/components/data-display/Tag/Tag.astro +67 -0
  48. package/src/components/data-display/Tag/Tag.css +134 -0
  49. package/src/components/data-display/Tag/TagAffix.astro +33 -0
  50. package/src/components/data-display/TextPair/TextPair.astro +63 -0
  51. package/src/components/data-display/TextPair/TextPair.css +99 -0
  52. package/src/components/feedback/Spinner/Spinner.astro +32 -0
  53. package/src/components/feedback/Spinner/Spinner.css +37 -0
  54. package/src/components/feedback/Tooltip/Tooltip.astro +66 -0
  55. package/src/components/feedback/Tooltip/Tooltip.css +67 -0
  56. package/src/components/feedback/Tooltip/tooltipController.ts +371 -0
  57. package/src/components/forms/FieldError/FieldError.astro +31 -0
  58. package/src/components/forms/FieldError/FieldError.css +12 -0
  59. package/src/components/forms/FieldError/fieldErrorState.ts +21 -0
  60. package/src/components/forms/FieldLabel/FieldLabel.astro +32 -0
  61. package/src/components/forms/FieldLabel/FieldLabel.css +17 -0
  62. package/src/components/forms/TextInput/TextInput.astro +79 -0
  63. package/src/components/forms/TextInput/TextInput.css +121 -0
  64. package/src/components/forms/TextInput/textInputController.ts +53 -0
  65. package/src/components/icons/ArrowDownIcon.astro +26 -0
  66. package/src/components/icons/ArrowLeftIcon.astro +26 -0
  67. package/src/components/icons/ArrowRightIcon.astro +26 -0
  68. package/src/components/icons/ArrowUpDownIcon.astro +26 -0
  69. package/src/components/icons/ArrowUpIcon.astro +26 -0
  70. package/src/components/icons/BulletIcon.astro +21 -0
  71. package/src/components/icons/BurnIcon.astro +24 -0
  72. package/src/components/icons/CircleSymbolIcon.css +66 -0
  73. package/src/components/icons/ClearIcon.astro +28 -0
  74. package/src/components/icons/CloseIcon.astro +21 -0
  75. package/src/components/icons/CopyIcon.astro +30 -0
  76. package/src/components/icons/CurrencyIcon.css +9 -0
  77. package/src/components/icons/DayIcon.astro +33 -0
  78. package/src/components/icons/DollarIcon.astro +28 -0
  79. package/src/components/icons/DownloadIcon.astro +22 -0
  80. package/src/components/icons/EnterFullscreenIcon.astro +22 -0
  81. package/src/components/icons/EqualIcon.astro +25 -0
  82. package/src/components/icons/ExitFullscreenIcon.astro +22 -0
  83. package/src/components/icons/ExternalLinkIcon.astro +22 -0
  84. package/src/components/icons/FieldIcon.astro +28 -0
  85. package/src/components/icons/GrassIcon.astro +29 -0
  86. package/src/components/icons/InfoIcon.astro +24 -0
  87. package/src/components/icons/MinusIcon.astro +21 -0
  88. package/src/components/icons/MountainIcon.astro +31 -0
  89. package/src/components/icons/NightIcon.astro +32 -0
  90. package/src/components/icons/PlayIcon.astro +22 -0
  91. package/src/components/icons/PlusIcon.astro +21 -0
  92. package/src/components/icons/PoisonIcon.astro +24 -0
  93. package/src/components/icons/RibbonIcon.astro +25 -0
  94. package/src/components/icons/SlashIcon.astro +22 -0
  95. package/src/components/icons/SlowIcon.astro +25 -0
  96. package/src/components/icons/StarIcon.astro +28 -0
  97. package/src/components/icons/StunIcon.astro +22 -0
  98. package/src/components/icons/TableSortIcon.astro +34 -0
  99. package/src/components/icons/WaterIcon.astro +30 -0
  100. package/src/components/index.ts +83 -0
  101. package/src/components/media/CanvasFrame/CanvasFrame.astro +130 -0
  102. package/src/components/media/CanvasFrame/CanvasFrame.css +59 -0
  103. package/src/components/media/CanvasFrame/canvasFrameController.ts +104 -0
  104. package/src/components/media/EmbedFrame/EmbedFrame.astro +147 -0
  105. package/src/components/media/EmbedFrame/EmbedFrame.css +51 -0
  106. package/src/components/media/EmbedFrame/embedFrameController.ts +66 -0
  107. package/src/components/media/MediaFrame/MediaFrame.astro +34 -0
  108. package/src/components/media/MediaFrame/MediaFrame.css +66 -0
  109. package/src/components/navigation/Breadcrumbs/Breadcrumbs.astro +55 -0
  110. package/src/components/navigation/Breadcrumbs/Breadcrumbs.css +89 -0
  111. package/src/components/navigation/DesktopNavigation.astro +92 -0
  112. package/src/components/navigation/DesktopNavigation.css +99 -0
  113. package/src/components/navigation/Header.astro +73 -0
  114. package/src/components/navigation/Header.css +20 -0
  115. package/src/components/navigation/MobileNavigation.astro +124 -0
  116. package/src/components/navigation/MobileNavigation.css +177 -0
  117. package/src/components/navigation/NavigationBrand.astro +63 -0
  118. package/src/components/navigation/NavigationBrand.css +52 -0
  119. package/src/components/navigation/NavigationControl.css +166 -0
  120. package/src/components/navigation/NavigationItemContent.astro +24 -0
  121. package/src/components/navigation/NavigationLink.astro +121 -0
  122. package/src/components/navigation/NavigationLinks.astro +27 -0
  123. package/src/components/navigation/NavigationMenuList.astro +37 -0
  124. package/src/components/navigation/NavigationMenuList.css +6 -0
  125. package/src/components/navigation/SkipLink/SkipLink.astro +18 -0
  126. package/src/components/navigation/SkipLink/SkipLink.css +26 -0
  127. package/src/components/navigation/SubNavigation/SubNavigation.astro +124 -0
  128. package/src/components/navigation/SubNavigation/SubNavigation.css +211 -0
  129. package/src/components/navigation/mobileNavigationController.ts +122 -0
  130. package/src/components/navigation/navigationState.ts +35 -0
  131. package/src/components/navigation/navigationTypes.ts +18 -0
  132. package/src/components/seo/SeoHead.astro +194 -0
  133. package/src/components/widgetTypes.ts +3 -0
  134. package/src/composition/Grid/Grid.astro +82 -0
  135. package/src/composition/Grid/Grid.css +314 -0
  136. package/src/composition/GridItem/GridItem.astro +50 -0
  137. package/src/composition/GridItem/GridItem.css +95 -0
  138. package/src/composition/Inline/Inline.astro +48 -0
  139. package/src/composition/Inline/Inline.css +65 -0
  140. package/src/composition/Stack/Stack.astro +37 -0
  141. package/src/composition/Stack/Stack.css +31 -0
  142. package/src/composition/SurfaceGroup/SurfaceGroup.astro +44 -0
  143. package/src/composition/SurfaceGroup/SurfaceGroup.css +76 -0
  144. package/src/composition/SurfaceGroup/stickySurfaceGroupController.ts +89 -0
  145. package/src/composition/index.ts +6 -0
  146. package/src/config/index.ts +2 -0
  147. package/src/config/pageMeta.ts +55 -0
  148. package/src/config/siteConfig.ts +90 -0
  149. package/src/data/collectionValidation.ts +61 -0
  150. package/src/data/index.ts +1 -0
  151. package/src/display/contracts.ts +284 -0
  152. package/src/display/index.ts +1 -0
  153. package/src/index.ts +6 -0
  154. package/src/layouts/BaseLayout.astro +74 -0
  155. package/src/layouts/PageSurface.astro +15 -0
  156. package/src/layouts/PageSurface.css +24 -0
  157. package/src/layouts/index.ts +2 -0
  158. package/src/patterns/CircuitPuzzle/CircuitPuzzle.astro +93 -0
  159. package/src/patterns/CircuitPuzzle/CircuitPuzzle.css +118 -0
  160. package/src/patterns/CircuitPuzzle/circuitPuzzleController.ts +205 -0
  161. package/src/patterns/CircuitPuzzle/contracts.ts +42 -0
  162. package/src/patterns/Combobox/Combobox.astro +462 -0
  163. package/src/patterns/Combobox/Combobox.css +403 -0
  164. package/src/patterns/Combobox/comboboxController.ts +788 -0
  165. package/src/patterns/Combobox/contracts.ts +18 -0
  166. package/src/patterns/Dropdown/Dropdown.astro +127 -0
  167. package/src/patterns/Dropdown/Dropdown.css +100 -0
  168. package/src/patterns/Dropdown/dropdownController.ts +157 -0
  169. package/src/patterns/Fullscreen/FullscreenControl.astro +103 -0
  170. package/src/patterns/Fullscreen/FullscreenControl.css +49 -0
  171. package/src/patterns/Fullscreen/fullscreenController.ts +73 -0
  172. package/src/patterns/GlitchOverlay/GlitchOverlay.astro +50 -0
  173. package/src/patterns/GlitchOverlay/GlitchOverlay.css +234 -0
  174. package/src/patterns/GlitchOverlay/glitchOverlayController.ts +152 -0
  175. package/src/patterns/GuidedFlow/GuidedFlow.astro +60 -0
  176. package/src/patterns/GuidedFlow/GuidedFlow.css +82 -0
  177. package/src/patterns/GuidedFlow/contracts.ts +3 -0
  178. package/src/patterns/GuidedFlow/guidedFlowController.ts +49 -0
  179. package/src/patterns/MagneticFieldPuzzle/MagneticFieldPuzzle.astro +217 -0
  180. package/src/patterns/MagneticFieldPuzzle/MagneticFieldPuzzle.css +383 -0
  181. package/src/patterns/MagneticFieldPuzzle/contracts.ts +81 -0
  182. package/src/patterns/MagneticFieldPuzzle/magneticFieldPuzzleController.ts +802 -0
  183. package/src/patterns/MagneticFieldPuzzle/simulation.ts +244 -0
  184. package/src/patterns/MapViewport/MapViewport.astro +296 -0
  185. package/src/patterns/MapViewport/MapViewport.css +257 -0
  186. package/src/patterns/MapViewport/contracts.ts +79 -0
  187. package/src/patterns/MapViewport/geometry.ts +80 -0
  188. package/src/patterns/MapViewport/mapViewportController.ts +636 -0
  189. package/src/patterns/Modal/Modal.astro +64 -0
  190. package/src/patterns/Modal/Modal.css +87 -0
  191. package/src/patterns/Modal/ModalClose.astro +37 -0
  192. package/src/patterns/Modal/ModalOpen.astro +36 -0
  193. package/src/patterns/Modal/modalController.ts +118 -0
  194. package/src/patterns/PuzzleGrid/PuzzleGrid.astro +22 -0
  195. package/src/patterns/PuzzleGrid/PuzzleGrid.css +149 -0
  196. package/src/patterns/PuzzleGrid/contracts.ts +2 -0
  197. package/src/patterns/PuzzleGrid/selectionDismissal.ts +27 -0
  198. package/src/patterns/PuzzleGrid/state.ts +25 -0
  199. package/src/patterns/SpriteProjectilePreview/SpriteProjectilePreview.astro +65 -0
  200. package/src/patterns/SpriteProjectilePreview/SpriteProjectilePreview.css +35 -0
  201. package/src/patterns/SpriteProjectilePreview/contracts.ts +33 -0
  202. package/src/patterns/SpriteProjectilePreview/spriteProjectilePreviewController.ts +586 -0
  203. package/src/patterns/StageFlow/StageFlow.astro +57 -0
  204. package/src/patterns/StageFlow/StageFlow.css +54 -0
  205. package/src/patterns/StageFlow/StageFlowAlternative.astro +23 -0
  206. package/src/patterns/StageFlow/StageFlowArrow.astro +22 -0
  207. package/src/patterns/StageFlow/StageFlowConnector.astro +7 -0
  208. package/src/patterns/StageFlow/StageFlowConnector.css +4 -0
  209. package/src/patterns/StageFlow/StageFlowStage.astro +51 -0
  210. package/src/patterns/StageFlow/StageFlowStage.css +106 -0
  211. package/src/patterns/StageFlow/StageFlowStep.astro +24 -0
  212. package/src/patterns/StageFlow/StageFlowStep.css +19 -0
  213. package/src/patterns/StageFlow/StageFlowSymbol.css +28 -0
  214. package/src/patterns/Table/Table.astro +176 -0
  215. package/src/patterns/Table/Table.css +70 -0
  216. package/src/patterns/Table/TableBody.astro +185 -0
  217. package/src/patterns/Table/TableBody.css +262 -0
  218. package/src/patterns/Table/TableCell.astro +59 -0
  219. package/src/patterns/Table/TableCell.css +99 -0
  220. package/src/patterns/Table/TableCellValue.astro +86 -0
  221. package/src/patterns/Table/TableFooter.astro +32 -0
  222. package/src/patterns/Table/TableFooter.css +31 -0
  223. package/src/patterns/Table/TableHeader.astro +118 -0
  224. package/src/patterns/Table/TableHeader.css +209 -0
  225. package/src/patterns/Table/TablePagination.astro +70 -0
  226. package/src/patterns/Table/TablePagination.css +133 -0
  227. package/src/patterns/Table/TableSkeleton.astro +36 -0
  228. package/src/patterns/Table/TableSkeleton.css +81 -0
  229. package/src/patterns/Table/tableCellController.ts +11 -0
  230. package/src/patterns/Table/tableFilterController.ts +206 -0
  231. package/src/patterns/Table/tableHeaderOverflowController.ts +105 -0
  232. package/src/patterns/Table/tableLayout.ts +113 -0
  233. package/src/patterns/Table/tableProgressiveController.ts +319 -0
  234. package/src/patterns/Table/tableRowNavigationController.ts +91 -0
  235. package/src/patterns/Table/tableScrollController.ts +192 -0
  236. package/src/patterns/Table/tableSortController.ts +272 -0
  237. package/src/patterns/index.ts +46 -0
  238. package/src/primitives/index.ts +4 -0
  239. package/src/primitives/layout/Separator/Separator.astro +29 -0
  240. package/src/primitives/layout/Separator/Separator.css +20 -0
  241. package/src/primitives/media/AmbientAudio/AmbientAudio.astro +28 -0
  242. package/src/primitives/media/Media/Media.astro +122 -0
  243. package/src/primitives/media/Media/Media.css +161 -0
  244. package/src/primitives/text/TextBlock/TextBlock.astro +46 -0
  245. package/src/primitives/text/TextBlock/TextBlock.css +21 -0
  246. package/src/seo/StaticRedirect.astro +32 -0
  247. package/src/seo/index.ts +6 -0
  248. package/src/seo/pageSeo.ts +99 -0
  249. package/src/seo/robots.ts +16 -0
  250. package/src/seo/sitemap.ts +38 -0
  251. package/src/seo/structuredData.ts +133 -0
  252. package/src/seo/url.ts +64 -0
  253. package/src/styles/base.css +148 -0
  254. package/src/styles/interaction.css +108 -0
  255. package/src/styles/style.css +93 -0
  256. package/src/styles/tokens.css +256 -0
  257. package/src/theme/contracts.ts +7 -0
  258. package/src/theme/index.ts +1 -0
  259. package/tsconfig.json +20 -0
@@ -0,0 +1,234 @@
1
+ .glitch-overlay {
2
+ position: fixed;
3
+ z-index: 90;
4
+ inset: 0;
5
+ overflow: hidden;
6
+ pointer-events: none;
7
+ }
8
+
9
+ .glitch-overlay[hidden] {
10
+ display: none;
11
+ }
12
+
13
+ .glitch-overlay__scanlines,
14
+ .glitch-overlay__pixels {
15
+ position: absolute;
16
+ inset: 0;
17
+ }
18
+
19
+ .glitch-overlay__scanlines {
20
+ background-image: repeating-linear-gradient(
21
+ to bottom,
22
+ transparent 0,
23
+ transparent 3px,
24
+ color-mix(in srgb, var(--nox-text) 8%, transparent) 3px,
25
+ color-mix(in srgb, var(--nox-text) 8%, transparent) 4px
26
+ );
27
+ }
28
+
29
+ .glitch-overlay__pixel {
30
+ position: absolute;
31
+ inset-block-start: var(--glitch-y);
32
+ inset-inline-start: var(--glitch-x);
33
+ inline-size: var(--glitch-width);
34
+ block-size: var(--glitch-height);
35
+ background: var(--nox-tone-color);
36
+ opacity: 0.28;
37
+ }
38
+
39
+ html[data-visual-effect='glitch'] [data-site-viewport] {
40
+ background:
41
+ repeating-linear-gradient(
42
+ 90deg,
43
+ transparent 0,
44
+ transparent 7rem,
45
+ color-mix(in srgb, var(--nox-tone-color) 3%, transparent) 7rem,
46
+ color-mix(in srgb, var(--nox-tone-color) 3%, transparent) 7.125rem
47
+ ),
48
+ var(--nox-page-background);
49
+ }
50
+
51
+ html[data-visual-effect='glitch'] body {
52
+ text-shadow:
53
+ 0.045em 0 color-mix(in srgb, var(--nox-source-tone-info) 44%, transparent),
54
+ -0.045em 0
55
+ color-mix(in srgb, var(--nox-source-tone-danger) 36%, transparent);
56
+ }
57
+
58
+ @media (prefers-reduced-motion: no-preference) {
59
+ .glitch-overlay__scanlines {
60
+ animation: glitch-scanlines 4.5s linear infinite;
61
+ }
62
+
63
+ .glitch-overlay__pixel {
64
+ animation: glitch-pixel var(--glitch-duration) steps(2, end) infinite;
65
+ animation-delay: var(--glitch-delay);
66
+ }
67
+
68
+ html[data-visual-effect='glitch'] [data-site-header],
69
+ html[data-visual-effect='glitch'] [data-site-viewport] {
70
+ transform-origin: 50% 20%;
71
+ animation: glitch-drift 9s ease-in-out infinite;
72
+ }
73
+
74
+ html[data-visual-effect='glitch'] [data-glitch-pulse='shift'] {
75
+ animation: glitch-pulse-shift 180ms steps(2, end);
76
+ }
77
+
78
+ html[data-visual-effect='glitch'] [data-glitch-pulse='slice'] {
79
+ animation: glitch-pulse-slice 200ms steps(2, end);
80
+ }
81
+
82
+ html[data-visual-effect='glitch'] [data-glitch-pulse='text'] {
83
+ animation: glitch-pulse-text 220ms steps(2, end);
84
+ }
85
+
86
+ html[data-visual-effect='glitch'] [data-glitch-pulse='media'] {
87
+ animation: glitch-pulse-media 240ms steps(2, end);
88
+ }
89
+ }
90
+
91
+ @keyframes glitch-scanlines {
92
+ to {
93
+ translate: 0 4px;
94
+ }
95
+ }
96
+
97
+ @keyframes glitch-pixel {
98
+ 0%,
99
+ 78%,
100
+ 100% {
101
+ opacity: 0;
102
+ scale: 0.4 1;
103
+ }
104
+
105
+ 80%,
106
+ 88% {
107
+ opacity: 0.38;
108
+ scale: 1 1;
109
+ }
110
+
111
+ 90% {
112
+ opacity: 0.16;
113
+ scale: 1.8 1;
114
+ }
115
+ }
116
+
117
+ @keyframes glitch-drift {
118
+ 0%,
119
+ 100% {
120
+ rotate: 0deg;
121
+ translate: 0 0;
122
+ }
123
+
124
+ 18% {
125
+ rotate: 0.12deg;
126
+ translate: 1px -2px;
127
+ }
128
+
129
+ 43% {
130
+ rotate: -0.16deg;
131
+ translate: -2px 1px;
132
+ }
133
+
134
+ 67% {
135
+ rotate: 0.1deg;
136
+ translate: 2px 2px;
137
+ }
138
+
139
+ 84% {
140
+ rotate: -0.08deg;
141
+ translate: -1px -1px;
142
+ }
143
+ }
144
+
145
+ @keyframes glitch-pulse-shift {
146
+ 0%,
147
+ 100% {
148
+ filter: none;
149
+ translate: 0;
150
+ }
151
+
152
+ 34% {
153
+ filter: saturate(1.3);
154
+ translate: 3px -1px;
155
+ }
156
+
157
+ 68% {
158
+ filter: saturate(0.75);
159
+ translate: -2px 1px;
160
+ }
161
+ }
162
+
163
+ @keyframes glitch-pulse-slice {
164
+ 0%,
165
+ 100% {
166
+ clip-path: inset(0);
167
+ translate: 0;
168
+ }
169
+
170
+ 32% {
171
+ clip-path: inset(0 0 47% 0);
172
+ translate: 2px 0;
173
+ }
174
+
175
+ 66% {
176
+ clip-path: inset(45% 0 0 0);
177
+ translate: -2px 0;
178
+ }
179
+ }
180
+
181
+ @keyframes glitch-pulse-text {
182
+ 0%,
183
+ 100% {
184
+ filter: none;
185
+ opacity: 1;
186
+ scale: 1 1;
187
+ translate: 0;
188
+ }
189
+
190
+ 16% {
191
+ opacity: 0.2;
192
+ scale: -1 1;
193
+ translate: 1px -1px;
194
+ }
195
+
196
+ 34% {
197
+ filter: contrast(1.35);
198
+ opacity: 0.9;
199
+ scale: 1 1;
200
+ translate: -1px 1px;
201
+ }
202
+
203
+ 52% {
204
+ opacity: 0.1;
205
+ translate: 2px 0;
206
+ }
207
+
208
+ 72% {
209
+ filter: hue-rotate(12deg);
210
+ opacity: 0.75;
211
+ translate: -2px 0;
212
+ }
213
+ }
214
+
215
+ @keyframes glitch-pulse-media {
216
+ 0%,
217
+ 100% {
218
+ filter: none;
219
+ scale: 1;
220
+ translate: 0;
221
+ }
222
+
223
+ 28% {
224
+ filter: contrast(1.4) saturate(1.25);
225
+ scale: 1.04 0.98;
226
+ translate: 2px -1px;
227
+ }
228
+
229
+ 64% {
230
+ filter: hue-rotate(-14deg) contrast(0.85);
231
+ scale: 0.98 1.03;
232
+ translate: -2px 1px;
233
+ }
234
+ }
@@ -0,0 +1,152 @@
1
+ const initializedAttribute = 'data-glitch-overlay-initialized';
2
+ const pulseAttribute = 'data-glitch-pulse';
3
+ const textSelector = [
4
+ 'a',
5
+ 'button',
6
+ 'dd',
7
+ 'dt',
8
+ 'h1',
9
+ 'h2',
10
+ 'h3',
11
+ 'label',
12
+ 'p',
13
+ '[data-text-weight]',
14
+ ].join(',');
15
+ const componentSelector = [
16
+ '[data-button-size]',
17
+ '[data-composition]',
18
+ '[data-layout]',
19
+ '[data-navigation-control]',
20
+ '[data-site-header]',
21
+ '[data-site-viewport]',
22
+ '[data-widget]',
23
+ ].join(',');
24
+ const mediaSelector = 'img,svg';
25
+ const noop = (): void => undefined;
26
+
27
+ function isVisible(element: HTMLElement): boolean {
28
+ return !element.closest('[hidden]') && element.getClientRects().length > 0;
29
+ }
30
+
31
+ function pickRandom<T>(items: readonly T[]): T | undefined {
32
+ return items[Math.floor(Math.random() * items.length)];
33
+ }
34
+
35
+ export function initGlitchOverlay(root: HTMLElement): () => void {
36
+ if (root.getAttribute(initializedAttribute) === 'true') return noop;
37
+
38
+ const documentRoot = root.ownerDocument.documentElement;
39
+ const viewport = root.ownerDocument.querySelector<HTMLElement>(
40
+ '[data-site-viewport]',
41
+ );
42
+ if (!viewport) return noop;
43
+
44
+ root.setAttribute(initializedAttribute, 'true');
45
+ const timers = new Set<number>();
46
+ let stopped = false;
47
+
48
+ const schedule = (callback: () => void, delay: number): number => {
49
+ const timer = window.setTimeout(() => {
50
+ timers.delete(timer);
51
+ callback();
52
+ }, delay);
53
+ timers.add(timer);
54
+ return timer;
55
+ };
56
+
57
+ const pulseText = (): void => {
58
+ const candidates = Array.from(
59
+ root.ownerDocument.querySelectorAll<HTMLElement>(textSelector),
60
+ ).filter(
61
+ (element) =>
62
+ isVisible(element) &&
63
+ !element.closest('[data-widget="code-block"]') &&
64
+ !element.hasAttribute(pulseAttribute) &&
65
+ Boolean(element.textContent?.trim()),
66
+ );
67
+ const target = pickRandom(candidates);
68
+ if (!target) return;
69
+
70
+ target.setAttribute(pulseAttribute, 'text');
71
+ schedule(
72
+ () => target.removeAttribute(pulseAttribute),
73
+ 170 + Math.random() * 120,
74
+ );
75
+ };
76
+
77
+ const pulseComponent = (): void => {
78
+ const candidates = Array.from(
79
+ root.ownerDocument.querySelectorAll<HTMLElement>(componentSelector),
80
+ ).filter(
81
+ (element) =>
82
+ isVisible(element) &&
83
+ element !== root &&
84
+ !element.closest('[data-widget="code-block"]') &&
85
+ !element.hasAttribute(pulseAttribute),
86
+ );
87
+ const target = pickRandom(candidates);
88
+ if (!target) return;
89
+
90
+ target.setAttribute(
91
+ pulseAttribute,
92
+ Math.random() > 0.45 ? 'shift' : 'slice',
93
+ );
94
+ schedule(
95
+ () => target.removeAttribute(pulseAttribute),
96
+ 150 + Math.random() * 130,
97
+ );
98
+ };
99
+
100
+ const pulseMedia = (): void => {
101
+ const candidates = Array.from(
102
+ root.ownerDocument.querySelectorAll<HTMLElement>(mediaSelector),
103
+ ).filter(
104
+ (element) =>
105
+ isVisible(element) &&
106
+ !element.closest('[data-widget="code-block"]') &&
107
+ !element.hasAttribute(pulseAttribute),
108
+ );
109
+ const target = pickRandom(candidates);
110
+ if (!target) return;
111
+
112
+ target.setAttribute(pulseAttribute, 'media');
113
+ schedule(
114
+ () => target.removeAttribute(pulseAttribute),
115
+ 180 + Math.random() * 150,
116
+ );
117
+ };
118
+
119
+ const queuePulse = (
120
+ pulse: () => void,
121
+ minimumDelay: number,
122
+ delayVariance: number,
123
+ ): void => {
124
+ if (stopped) return;
125
+
126
+ schedule(
127
+ () => {
128
+ if (documentRoot.getAttribute('data-visual-effect') === 'glitch') {
129
+ pulse();
130
+ }
131
+ queuePulse(pulse, minimumDelay, delayVariance);
132
+ },
133
+ minimumDelay + Math.random() * delayVariance,
134
+ );
135
+ };
136
+
137
+ queuePulse(pulseComponent, 500, 1000);
138
+ queuePulse(pulseText, 700, 1100);
139
+ queuePulse(pulseMedia, 900, 1500);
140
+
141
+ return () => {
142
+ stopped = true;
143
+ for (const timer of timers) window.clearTimeout(timer);
144
+ timers.clear();
145
+ for (const element of root.ownerDocument.querySelectorAll<HTMLElement>(
146
+ `[${pulseAttribute}]`,
147
+ )) {
148
+ element.removeAttribute(pulseAttribute);
149
+ }
150
+ root.removeAttribute(initializedAttribute);
151
+ };
152
+ }
@@ -0,0 +1,60 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+ import type { GuidedFlowStep, GuidedFlowSteps } from './contracts';
4
+
5
+ type Props = HTMLAttributes<'section'> & {
6
+ label: string;
7
+ steps: GuidedFlowSteps;
8
+ };
9
+
10
+ const { class: className, label, steps, ...attrs }: Props = Astro.props;
11
+ const stepEntries = Object.entries(steps) as [GuidedFlowStep, string][];
12
+ ---
13
+
14
+ <section
15
+ {...attrs}
16
+ class:list={['guided-flow', className]}
17
+ aria-label={label}
18
+ data-guided-flow
19
+ >
20
+ <ol class="guided-flow__progress" aria-label={label}>
21
+ {
22
+ stepEntries.map(([id, stepLabel], index) => (
23
+ <li
24
+ class="guided-flow__progress-item"
25
+ data-guided-flow-progress={id}
26
+ data-step-state={index === 0 ? 'current' : 'upcoming'}
27
+ aria-current={index === 0 ? 'step' : undefined}
28
+ >
29
+ <span aria-hidden="true">{index + 1}</span>
30
+ <span>{stepLabel}</span>
31
+ </li>
32
+ ))
33
+ }
34
+ </ol>
35
+
36
+ <slot name="feedback" />
37
+
38
+ <div class="guided-flow__panels">
39
+ <section data-guided-flow-panel="intro">
40
+ <slot name="intro" />
41
+ </section>
42
+ <section data-guided-flow-panel="tutorial" hidden>
43
+ <slot name="tutorial" />
44
+ </section>
45
+ <section data-guided-flow-panel="challenge" hidden>
46
+ <slot name="challenge" />
47
+ </section>
48
+ <section data-guided-flow-panel="result" hidden>
49
+ <slot name="result" />
50
+ </section>
51
+ </div>
52
+ </section>
53
+
54
+ <script>
55
+ import { initGuidedFlow } from './guidedFlowController';
56
+
57
+ for (const root of document.querySelectorAll('[data-guided-flow]')) {
58
+ if (root instanceof HTMLElement) initGuidedFlow(root);
59
+ }
60
+ </script>
@@ -0,0 +1,82 @@
1
+ .guided-flow {
2
+ container-type: inline-size;
3
+ display: grid;
4
+ min-inline-size: 0;
5
+ gap: var(--nox-space-4);
6
+ }
7
+
8
+ .guided-flow__progress {
9
+ display: grid;
10
+ grid-template-columns: repeat(4, minmax(0, 1fr));
11
+ overflow: hidden;
12
+ margin: 0;
13
+ padding: 0;
14
+ border: var(--nox-border-width) solid var(--nox-border);
15
+ border-radius: var(--nox-radius-md);
16
+ background: var(--nox-surface);
17
+ list-style: none;
18
+ }
19
+
20
+ .guided-flow__progress-item {
21
+ display: flex;
22
+ min-inline-size: 0;
23
+ block-size: var(--nox-navigation-block-size);
24
+ align-items: center;
25
+ justify-content: center;
26
+ box-sizing: border-box;
27
+ gap: var(--nox-space-2);
28
+ padding-inline: var(--nox-space-3);
29
+ color: var(--nox-text-muted);
30
+ font-size: var(--nox-font-size-sm);
31
+ font-weight: var(--nox-font-weight-medium);
32
+ text-align: center;
33
+ }
34
+
35
+ .guided-flow__progress-item + .guided-flow__progress-item {
36
+ border-inline-start: var(--nox-border-width) solid var(--nox-border);
37
+ }
38
+
39
+ .guided-flow__progress-item > span:first-child {
40
+ display: grid;
41
+ flex: 0 0 auto;
42
+ inline-size: 1.5rem;
43
+ block-size: 1.5rem;
44
+ place-items: center;
45
+ border: var(--nox-border-width) solid var(--nox-border);
46
+ border-radius: var(--nox-radius-pill);
47
+ background: var(--nox-surface-muted);
48
+ color: var(--nox-text);
49
+ }
50
+
51
+ .guided-flow__progress-item[data-step-state='current'] {
52
+ background: var(--nox-tone-hover-background);
53
+ color: var(--nox-tone-text);
54
+ }
55
+
56
+ .guided-flow__progress-item[data-step-state='complete'] {
57
+ color: var(--nox-tone-color);
58
+ }
59
+
60
+ .guided-flow__panels,
61
+ .guided-flow__panels > section {
62
+ min-inline-size: 0;
63
+ }
64
+
65
+ @container (width < 45rem) {
66
+ .guided-flow__progress-item {
67
+ block-size: var(--nox-navigation-compact-block-size);
68
+ padding-inline: var(--nox-space-2);
69
+ }
70
+ }
71
+
72
+ @container (width < 40rem) {
73
+ .guided-flow__progress-item > span:last-child {
74
+ position: absolute;
75
+ overflow: hidden;
76
+ inline-size: 1px;
77
+ block-size: 1px;
78
+ clip: rect(0 0 0 0);
79
+ clip-path: inset(50%);
80
+ white-space: nowrap;
81
+ }
82
+ }
@@ -0,0 +1,3 @@
1
+ export type GuidedFlowStep = 'intro' | 'tutorial' | 'challenge' | 'result';
2
+
3
+ export type GuidedFlowSteps = Readonly<Record<GuidedFlowStep, string>>;
@@ -0,0 +1,49 @@
1
+ import type { GuidedFlowStep } from './contracts';
2
+
3
+ const initialized = new WeakSet<HTMLElement>();
4
+ const steps: readonly GuidedFlowStep[] = [
5
+ 'intro',
6
+ 'tutorial',
7
+ 'challenge',
8
+ 'result',
9
+ ];
10
+
11
+ export function initGuidedFlow(root: HTMLElement): void {
12
+ if (initialized.has(root)) return;
13
+ initialized.add(root);
14
+ showGuidedFlowStep(root, 'intro');
15
+ }
16
+
17
+ export function showGuidedFlowStep(
18
+ root: HTMLElement,
19
+ activeStep: GuidedFlowStep,
20
+ ): void {
21
+ if (!initialized.has(root)) initialized.add(root);
22
+ const activeIndex = steps.indexOf(activeStep);
23
+ if (activeIndex < 0) return;
24
+
25
+ for (const panel of root.querySelectorAll<HTMLElement>(
26
+ '[data-guided-flow-panel]',
27
+ )) {
28
+ panel.hidden = panel.dataset.guidedFlowPanel !== activeStep;
29
+ }
30
+
31
+ for (const marker of root.querySelectorAll<HTMLElement>(
32
+ '[data-guided-flow-progress]',
33
+ )) {
34
+ const markerStep = marker.dataset.guidedFlowProgress as GuidedFlowStep;
35
+ const markerIndex = steps.indexOf(markerStep);
36
+ const state =
37
+ markerIndex < activeIndex
38
+ ? 'complete'
39
+ : markerIndex === activeIndex
40
+ ? 'current'
41
+ : 'upcoming';
42
+
43
+ marker.dataset.stepState = state;
44
+ if (state === 'current') marker.setAttribute('aria-current', 'step');
45
+ else marker.removeAttribute('aria-current');
46
+ }
47
+
48
+ root.dataset.guidedFlowStep = activeStep;
49
+ }