@inizioevoke/astro-core 2.2.2 → 2.2.4

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.
@@ -0,0 +1,361 @@
1
+ ---
2
+ name: astro-core
3
+ description: >
4
+ Reference and implementation guide for @inizioevoke/astro-core — a library of reusable Astro components,
5
+ build integrations, and client-side gesture scripts. Use this skill whenever the user asks how to use,
6
+ add, configure, or troubleshoot anything from this library. Triggers on: component names (CssBackgroundImage,
7
+ CssVariables, FlipCard, RightISI, Modal, ModalTrigger, PdfViewer, ScrollContainer, Tabs, TabItem, Zoom),
8
+ integration names (pruneBuild, relativeLinks), script names (createSwipeListener, createPinchListener),
9
+ the package name @inizioevoke/astro-core, or any request to add/use one of these items in an Astro or
10
+ TypeScript file. Do NOT wait for the user to explicitly name the package — if they're working on an Astro
11
+ project and ask about a flip card, ISI panel, modal, PDF viewer, scroll container, tabs, or swipe/pinch
12
+ gesture, consult this skill.
13
+ ---
14
+
15
+ # @inizioevoke/astro-core
16
+
17
+ A library of reusable Astro components, build integrations, and client-side scripts for Evoke projects.
18
+
19
+ **Install:** `npm install @inizioevoke/astro-core`
20
+
21
+ ## Behavior guide
22
+
23
+ - For a general "how do I use X" question — answer from the quick-reference below (import path, key props, basic example).
24
+ - If the user asks about specific props, all available slots, CSS variables, or the full JS API — read the relevant doc file (paths listed in each section) and answer from it.
25
+ - When adding to a file — use the correct import path, include required props, and add relevant slots.
26
+
27
+ ---
28
+
29
+ ## Export paths
30
+
31
+ | What | Import from |
32
+ |---|---|
33
+ | All Astro components | `@inizioevoke/astro-core` |
34
+ | Build integrations | `@inizioevoke/astro-core/integrations` |
35
+ | FlipCard JS lib | `@inizioevoke/astro-core/lib/FlipCard` |
36
+ | ISI JS lib | `@inizioevoke/astro-core/lib/ISI` |
37
+ | Modal JS lib | `@inizioevoke/astro-core/lib/Modal` |
38
+ | PdfViewer JS lib | `@inizioevoke/astro-core/lib/PdfViewer` |
39
+ | ScrollContainer JS lib | `@inizioevoke/astro-core/lib/ScrollContainer` |
40
+ | Gesture scripts | `@inizioevoke/astro-core/lib/gestures` |
41
+
42
+ ---
43
+
44
+ ## Components
45
+
46
+ ### CssBackgroundImage
47
+
48
+ Renders a `<style>` tag that sets `background-image` on a CSS selector. Optimizes images via Astro's `getImage` (webp, quality 80 by default). Supports responsive breakpoints via media queries. No client JS.
49
+
50
+ ```astro
51
+ ---
52
+ import { CssBackgroundImage } from '@inizioevoke/astro-core';
53
+ import heroImg from '../assets/hero.jpg';
54
+ ---
55
+ <CssBackgroundImage image={heroImg} selector=".hero" size="cover" position="center" />
56
+ ```
57
+
58
+ Key props: `image` (ImageMetadata, required), `selector` (default `body`), `size`, `position`, `repeat`, `optimize`, `format`, `quality`, `width`, `height`, `breakpoints[]`
59
+
60
+ > For full prop details and breakpoint examples → read `docs/components/CssBackgroundImage.md`
61
+
62
+ ---
63
+
64
+ ### CssVariables
65
+
66
+ Injects CSS custom properties (`--name: value`) into a selector. Supports `image` (optimized), `url`, or plain string/number values. Supports responsive breakpoints.
67
+
68
+ ```astro
69
+ ---
70
+ import { CssVariables } from '@inizioevoke/astro-core';
71
+ import bg from '../assets/bg.jpg';
72
+ ---
73
+ <CssVariables
74
+ selector=":root"
75
+ variables={[
76
+ { name: '--brand-color', value: '#ff0000' },
77
+ { name: '--hero-bg', type: 'image', value: bg },
78
+ ]}
79
+ />
80
+ ```
81
+
82
+ Key props: `selector` (default `:root`), `variables[]` (each with `name`, `value`, optional `type`, optional `breakpoints`)
83
+
84
+ > For full variable type options and breakpoint examples → read `docs/components/CssVariables.md`
85
+
86
+ ---
87
+
88
+ ### FlipCard
89
+
90
+ A 3D CSS flip card rendered as the `<evo-flip-card>` custom element. Uses `front` and `back` slots.
91
+
92
+ ```astro
93
+ ---
94
+ import { FlipCard } from '@inizioevoke/astro-core';
95
+ ---
96
+ <FlipCard width={300} height={200}>
97
+ <div slot="front">Front content</div>
98
+ <div slot="back">Back content</div>
99
+ <button slot="trigger">Flip</button>
100
+ </FlipCard>
101
+ ```
102
+
103
+ Slots: `front`, `back`, `trigger`, `front-trigger`, `back-trigger`
104
+ Props: `width?`, `height?`, plus any `div` HTML attributes
105
+
106
+ **Client-side JS** (in a `<script>` block):
107
+ ```ts
108
+ import type { EvoFlipCardElement } from '@inizioevoke/astro-core/lib/FlipCard';
109
+ const card = document.querySelector('evo-flip-card') as EvoFlipCardElement;
110
+ card.toggle(); // or flipFront() / flipBack()
111
+ ```
112
+
113
+ > For full CSS variable list and JS API details → read `docs/components/FlipCard.md`
114
+
115
+ ---
116
+
117
+ ### RightISI
118
+
119
+ A sticky ISI (Important Safety Information) right-side drawer rendered as `<evo-isi>`. Embeds a `ScrollContainer` internally.
120
+
121
+ ```astro
122
+ ---
123
+ import { RightISI } from '@inizioevoke/astro-core';
124
+ ---
125
+ <RightISI transitionDuration={400} headerButton>
126
+ <div slot="header">ISI Title</div>
127
+ <p>Important safety information content goes here.</p>
128
+ </RightISI>
129
+ ```
130
+
131
+ Slots: `header`, `header-button`, `footer`, default (body content)
132
+ Props: `transitionDuration?` (ms, default 500), `headerButton?` (boolean), `scrollContainer?` (ScrollContainerProps)
133
+
134
+ **Client-side JS**:
135
+ ```ts
136
+ import type { EvoIsiElement } from '@inizioevoke/astro-core/lib/ISI';
137
+ const isi = document.querySelector('evo-isi') as EvoIsiElement;
138
+ await isi.expand(); // toggle() / collapse() also available — all return Promise<void>
139
+ ```
140
+
141
+ > For full slot and prop details → read `docs/components/ISI/RightISI.md` (if available) or check the source
142
+
143
+ ---
144
+
145
+ ### Modal
146
+
147
+ A modal system with `<evo-modal>`, `ModalTrigger`, and `ModalOverlay` components. Supports `fade` and `none` animations.
148
+
149
+ ```astro
150
+ ---
151
+ import { Modal, ModalTrigger } from '@inizioevoke/astro-core';
152
+ ---
153
+ <ModalTrigger modal="my-modal" animation="fade">Open</ModalTrigger>
154
+
155
+ <Modal id="my-modal" closeButton="default">
156
+ <h2>Modal Title</h2>
157
+ <p>Modal content here.</p>
158
+ </Modal>
159
+ ```
160
+
161
+ **Modal props:** `id` (required), `closeButton` (`'default'|'minimal'|'none'|false`), `closeButtonAtts`
162
+ **ModalTrigger props:** `modal` (id, required), `animation?`
163
+ Slots: default (inside wrapper), `close` (close button label), `outer` (full-bleed outside wrapper)
164
+
165
+ **Client-side JS**:
166
+ ```ts
167
+ import { showModal, hideModal, hideModals } from '@inizioevoke/astro-core/lib/Modal';
168
+ showModal('#my-modal');
169
+ hideModal('#my-modal', 'fade');
170
+ ```
171
+
172
+ Custom events: `evomodal-visible`, `evomodal-hidden` (both bubble + composed)
173
+
174
+ > For full CSS variable list, all JS functions, and data attributes → read `docs/components/Modal.md`
175
+
176
+ ---
177
+
178
+ ### PdfViewer
179
+
180
+ A full-featured PDF viewer rendered as `<evo-pdf-viewer>`. Uses a bundled copy of pdf.js. Features lazy page rendering, pinch-to-zoom, toolbar, and vertical/horizontal layout.
181
+
182
+ ```astro
183
+ ---
184
+ import { PdfViewer } from '@inizioevoke/astro-core';
185
+ ---
186
+ <PdfViewer id="viewer" pdf="/documents/file.pdf" height="600px" theme="light" />
187
+ ```
188
+
189
+ Props: `id` (required), `pdf` (URL, required), `height?`, `theme?` (`'light'|'dark'|'black'`), `zoom?`, `page?`, `layout?` (`'vertical'|'horizontal'`), `fit?`, `quality?`, `toolbar?`
190
+
191
+ **Client-side JS**:
192
+ ```ts
193
+ import type { EvoPdfViewerElement } from '@inizioevoke/astro-core/lib/PdfViewer';
194
+ const viewer = document.querySelector('evo-pdf-viewer') as EvoPdfViewerElement;
195
+ viewer.scrollToPage(3);
196
+ viewer.zoom(1); // 1 = zoom in, -1 = zoom out, 0 = reset
197
+ ```
198
+
199
+ Custom event: `evopdfviewer-click` (fires when a custom `http://pdfviewer.evo` protocol link is clicked)
200
+
201
+ > For full prop details, fit modes, and toolbar options → read `docs/components/PdfViewer.md` (if available) or source
202
+
203
+ ---
204
+
205
+ ### ScrollContainer
206
+
207
+ Wraps content in `<evo-scroll-container>` with a custom draggable scrollbar. Supports `vertical`, `horizontal`, or `both` axes.
208
+
209
+ ```astro
210
+ ---
211
+ import { ScrollContainer } from '@inizioevoke/astro-core';
212
+ ---
213
+ <ScrollContainer height="400px" scrolling="vertical">
214
+ <p>Long scrollable content here...</p>
215
+ </ScrollContainer>
216
+ ```
217
+
218
+ Props: `width?`, `height?`, `scrolling?` (default `'vertical'`), plus any `div` attributes
219
+
220
+ **Client-side JS**:
221
+ ```ts
222
+ import { scroll, refresh, getScroll } from '@inizioevoke/astro-core/lib/ScrollContainer';
223
+ scroll('evo-scroll-container', { top: 0 });
224
+ refresh(); // recalculate all scroll containers
225
+ ```
226
+
227
+ > For full CSS variable list, element API, and all utility functions → read `docs/components/ScrollContainer.md`
228
+
229
+ ---
230
+
231
+ ### Tabs + TabItem
232
+
233
+ Build-time tabbed panels. `Tabs` processes its slot at build time, extracting metadata from `TabItem` children to generate the tab list and panels.
234
+
235
+ ```astro
236
+ ---
237
+ import { Tabs, TabItem } from '@inizioevoke/astro-core';
238
+ ---
239
+ <Tabs>
240
+ <TabItem active>
241
+ <span slot="title">Tab One</span>
242
+ <p>Content for tab one.</p>
243
+ </TabItem>
244
+ <TabItem>
245
+ <span slot="title">Tab Two</span>
246
+ <p>Content for tab two.</p>
247
+ </TabItem>
248
+ </Tabs>
249
+ ```
250
+
251
+ **Tabs props:** `listType?` (`'ul'|'none'`)
252
+ **TabItem props:** `active?`, `tabAttrs?`, `panelAttrs?`
253
+ **TabItem slots:** `title`, default (panel content)
254
+
255
+ > For full styling details → read `docs/components/Tabs.md`
256
+
257
+ ---
258
+
259
+ ### Zoom
260
+
261
+ A convenience wrapper combining a content card with a `ModalTrigger` button and a `Modal`. Auto-generates the modal ID.
262
+
263
+ ```astro
264
+ ---
265
+ import { Zoom } from '@inizioevoke/astro-core';
266
+ ---
267
+ <Zoom animation="fade" modalIncludeTitle modalIncludeFooter>
268
+ <div slot="content">Card preview content</div>
269
+ <span slot="trigger">View full</span>
270
+ <div slot="modal-content">Full modal content here</div>
271
+ </Zoom>
272
+ ```
273
+
274
+ Slots: `content`, `trigger`, `header`, `footer`, `modal-header`, `modal-content`, `modal-footer`
275
+ Props: `animation?`, `modalIncludeTitle?` (default true), `modalIncludeFooter?` (default true), `modalSlot?`
276
+
277
+ ---
278
+
279
+ ## Integrations
280
+
281
+ ### pruneBuild
282
+
283
+ Deletes unreferenced asset files after build by scanning HTML/CSS/JS output for filename references.
284
+
285
+ ```ts
286
+ // astro.config.mjs
287
+ import { pruneBuild } from '@inizioevoke/astro-core/integrations';
288
+
289
+ export default defineConfig({
290
+ integrations: [
291
+ pruneBuild({ keep: ['favicon.ico', /fonts\//] })
292
+ ]
293
+ });
294
+ ```
295
+
296
+ Options: `enabled?` (boolean), `keep?` (array of strings or RegExp)
297
+
298
+ > For behavior details and edge cases → read `docs/integrations/prune-build.md`
299
+
300
+ ---
301
+
302
+ ### relativeLinks
303
+
304
+ Rewrites absolute asset paths in `.html` and `.css` build output to relative paths (relative to each file's location). Useful for static deployments without a fixed root.
305
+
306
+ ```ts
307
+ // astro.config.mjs
308
+ import { relativeLinks } from '@inizioevoke/astro-core/integrations';
309
+
310
+ export default defineConfig({
311
+ integrations: [relativeLinks()]
312
+ });
313
+ ```
314
+
315
+ Options: `enabled?` (default true)
316
+
317
+ > For details on which attributes/properties are rewritten → read `docs/integrations/relative-links.md`
318
+
319
+ ---
320
+
321
+ ## Client-side gesture scripts
322
+
323
+ Use inside Astro `<script>` blocks or in `.ts` client files.
324
+
325
+ ### createSwipeListener
326
+
327
+ ```ts
328
+ import { createSwipeListener } from '@inizioevoke/astro-core/lib/gestures';
329
+
330
+ const swipe = createSwipeListener(({ direction, distance, duration }) => {
331
+ if (direction === 'left') nextSlide();
332
+ });
333
+
334
+ // threshold can be '1/4', '1/3', '1/2' (fraction of screen) or a pixel number
335
+ const swipe = createSwipeListener(handler, { threshold: '1/3' });
336
+
337
+ swipe.disable();
338
+ swipe.enable();
339
+ swipe.dispose(); // remove listeners entirely
340
+ ```
341
+
342
+ > For all threshold options and handler argument details → read `docs/lib/swipe.md`
343
+
344
+ ---
345
+
346
+ ### createPinchListener
347
+
348
+ ```ts
349
+ import { createPinchListener } from '@inizioevoke/astro-core/lib/gestures';
350
+
351
+ const pinch = createPinchListener((scale, gesture) => {
352
+ // gesture is 'pinch' or 'spread'
353
+ element.style.transform = `scale(${scale})`;
354
+ });
355
+
356
+ pinch.disable();
357
+ pinch.enable();
358
+ pinch.dispose();
359
+ ```
360
+
361
+ > For cumulative scale behavior details → read `docs/lib/pinch.md`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inizioevoke/astro-core",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -17,10 +17,15 @@
17
17
  "./lib/ScrollContainer": "./src/components/ScrollContainer/index.ts",
18
18
  "./lib/gestures": "./src/lib/gestures/index.ts"
19
19
  },
20
+ "scripts": {
21
+ "postinstall": "node postinstall.mjs"
22
+ },
20
23
  "files": [
24
+ "agents",
21
25
  "docs",
22
26
  "src",
23
- "index.ts"
27
+ "index.ts",
28
+ "postinstall.mjs"
24
29
  ],
25
30
  "peerDependencies": {
26
31
  "astro": ">=5.0.0",
@@ -0,0 +1,18 @@
1
+ import { copyFileSync, mkdirSync, existsSync } from 'fs';
2
+ import { join, dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ // Resolve the consuming project's root (three levels up from node_modules/@inizioevoke/astro-core)
8
+ const projectRoot = join(__dirname, '..', '..', '..');
9
+ const destDir = join(projectRoot, '.claude', 'skills');
10
+ const src = join(__dirname, 'agents', 'claude', 'astro-core', 'SKILL.md');
11
+ const dest = join(destDir, 'inizioevoke-astro-core.md');
12
+
13
+ if (!existsSync(destDir)) {
14
+ mkdirSync(destDir, { recursive: true });
15
+ }
16
+
17
+ copyFileSync(src, dest);
18
+ console.log(`[@inizioevoke/astro-core] Copied skill to ${dest}`);
@@ -50,8 +50,8 @@ async function getImageSrc({image, format, quality, width, height, optimize}: Im
50
50
  if (optimize !== false) {
51
51
  const img = await getImage({
52
52
  src: image,
53
- format: format ?? image.format,
54
- quality: quality,
53
+ format: format ?? 'webp',
54
+ quality: quality ?? 80,
55
55
  width,
56
56
  height
57
57
  });
@@ -80,8 +80,8 @@ async function createVariable(v: CssImageVariable | CssVariable) {
80
80
  if (iv.optimize !== false) {
81
81
  const img = await getImage({
82
82
  src: iv.value,
83
- format: iv.format ?? iv.value.format,
84
- quality: iv.quality,
83
+ format: iv.format ?? 'webp',
84
+ quality: iv.quality ?? 80,
85
85
  width: iv.width,
86
86
  height: iv.height
87
87
  });