@phun-ky/speccer 11.2.30 → 11.2.31

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.
package/README.md CHANGED
@@ -272,12 +272,48 @@ export const MyComponent = () => {
272
272
 
273
273
  ### Storybook
274
274
 
275
- With the same approach mentioned above, you can add **SPECCER** to your stories!
275
+ You can add **SPECCER** to your stories!
276
276
 
277
277
  ![Image of the Storybook implementation](./public/storybook.png)
278
278
 
279
+ In `preview.tsx`:
280
+
281
+ ```typescript
282
+ import '@phun-ky/speccer/dist/speccer.min.css';
283
+ import { addons } from '@storybook/preview-api';
284
+ import { debounce } from '@mui/material'; // or any other debounce function
285
+
286
+ let speccerEventFunc: (() => void) | undefined;
287
+
288
+ addons.getChannel().on('docsRendered', async () => {
289
+ const { default: speccer } = await import('@phun-ky/speccer');
290
+
291
+ speccer();
292
+ speccerEventFunc = debounce(() => {
293
+ speccer();
294
+ }, 100);
295
+
296
+ window.addEventListener('resize', speccerEventFunc);
297
+ });
298
+
299
+ addons.getChannel().on('storyChanged', () => {
300
+ if (speccerEventFunc) {
301
+ window.removeEventListener('resize', speccerEventFunc);
302
+ speccerEventFunc = undefined;
303
+ }
304
+
305
+ // Remove all pinned elements
306
+ document.querySelectorAll('.ph-speccer')?.forEach((el) => {
307
+ if (el instanceof HTMLElement) {
308
+ el.remove();
309
+ }
310
+ });
311
+ });
312
+ ```
313
+
314
+ And then in your `*.stories.tsx`:
315
+
279
316
  ```typescript
280
- import "@phun-ky/speccer/dist/speccer.min.css";
281
317
  import { ComponentMeta, ComponentStory } from "@storybook/react";
282
318
  import { MyComponent } from '../path-to-component/MyComponent';
283
319
 
@@ -290,8 +326,9 @@ export default {
290
326
  } as ComponentMeta<typeof MyComponent>
291
327
 
292
328
  const Template: ComponentStory<typeof MyComponent> = (args) => {
293
- useSpeccer();
329
+
294
330
 
331
+ // you need `data-speccer="pin-area"` on the container of the elements you want to spec
295
332
  return (
296
333
  <div data-speccer="pin-area">
297
334
  <MyComponent {...args} />
@@ -807,7 +844,7 @@ Full API documentation is available
807
844
 
808
845
  ## Development
809
846
 
810
- ```
847
+ ```shell-session
811
848
  // Build
812
849
  $ npm run build
813
850
  // Run dev
@@ -2,7 +2,7 @@
2
2
  * @phun-ky/speccer
3
3
  * A script to annotate, show spacing specs and to display typography information in documentation/website on HTML elements
4
4
  * @author Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>
5
- * @version 11.2.30
5
+ * @version 11.2.31
6
6
  * @license
7
7
  * Copyright (c) 2018-2025 Alexander Vassbotn Røyne-Helgesen
8
8
  *
package/dist/speccer.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @phun-ky/speccer
3
3
  * A script to annotate, show spacing specs and to display typography information in documentation/website on HTML elements
4
4
  * @author Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>
5
- * @version 11.2.30
5
+ * @version 11.2.31
6
6
  * @license
7
7
  * Copyright (c) 2018-2025 Alexander Vassbotn Røyne-Helgesen
8
8
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phun-ky/speccer",
3
- "version": "11.2.30",
3
+ "version": "11.2.31",
4
4
  "description": "A script to annotate, show spacing specs and to display typography information in documentation/website on HTML elements",
5
5
  "keywords": [
6
6
  "a11y",