@storybook/addon-highlight 8.1.0-alpha.2 → 8.1.0-alpha.3
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/dist/preview.d.ts +2 -0
- package/dist/preview.js +8 -8
- package/dist/preview.mjs +11 -0
- package/package.json +8 -4
package/dist/preview.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import { addons } from '@storybook/preview-api';
|
|
3
|
-
import { STORY_CHANGED } from '@storybook/core-events';
|
|
1
|
+
'use strict';
|
|
4
2
|
|
|
5
|
-
var
|
|
3
|
+
var global = require('@storybook/global');
|
|
4
|
+
var previewApi = require('@storybook/preview-api');
|
|
5
|
+
var coreEvents = require('@storybook/core-events');
|
|
6
|
+
|
|
7
|
+
var ADDON_ID="storybook/highlight",HIGHLIGHT_STYLE_ID="storybookHighlight",HIGHLIGHT=`${ADDON_ID}/add`,RESET_HIGHLIGHT=`${ADDON_ID}/reset`;var{document}=global.global,highlightStyle=(color="#FF4785",style="dashed")=>`
|
|
6
8
|
outline: 2px ${style} ${color};
|
|
7
9
|
outline-offset: 2px;
|
|
8
10
|
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
|
|
9
|
-
`,
|
|
11
|
+
`,channel=previewApi.addons.getChannel(),highlight=infos=>{let id=HIGHLIGHT_STYLE_ID;resetHighlight();let elements=Array.from(new Set(infos.elements)),sheet=document.createElement("style");sheet.setAttribute("id",id),sheet.innerHTML=elements.map(target=>`${target}{
|
|
10
12
|
${highlightStyle(infos.color,infos.style)}
|
|
11
|
-
}`).join(" "),document.head.appendChild(sheet);},resetHighlight=()=>{let id=HIGHLIGHT_STYLE_ID,sheetToBeRemoved=document.getElementById(id);sheetToBeRemoved&&sheetToBeRemoved.parentNode?.removeChild(sheetToBeRemoved);};channel.on(STORY_CHANGED,resetHighlight);channel.on(RESET_HIGHLIGHT,resetHighlight);channel.on(HIGHLIGHT,highlight);
|
|
12
|
-
|
|
13
|
-
export { highlightObject, highlightStyle };
|
|
13
|
+
}`).join(" "),document.head.appendChild(sheet);},resetHighlight=()=>{let id=HIGHLIGHT_STYLE_ID,sheetToBeRemoved=document.getElementById(id);sheetToBeRemoved&&sheetToBeRemoved.parentNode?.removeChild(sheetToBeRemoved);};channel.on(coreEvents.STORY_CHANGED,resetHighlight);channel.on(RESET_HIGHLIGHT,resetHighlight);channel.on(HIGHLIGHT,highlight);
|
package/dist/preview.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { global } from '@storybook/global';
|
|
2
|
+
import { addons } from '@storybook/preview-api';
|
|
3
|
+
import { STORY_CHANGED } from '@storybook/core-events';
|
|
4
|
+
|
|
5
|
+
var ADDON_ID="storybook/highlight",HIGHLIGHT_STYLE_ID="storybookHighlight",HIGHLIGHT=`${ADDON_ID}/add`,RESET_HIGHLIGHT=`${ADDON_ID}/reset`;var{document}=global,highlightStyle=(color="#FF4785",style="dashed")=>`
|
|
6
|
+
outline: 2px ${style} ${color};
|
|
7
|
+
outline-offset: 2px;
|
|
8
|
+
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
|
|
9
|
+
`,channel=addons.getChannel(),highlight=infos=>{let id=HIGHLIGHT_STYLE_ID;resetHighlight();let elements=Array.from(new Set(infos.elements)),sheet=document.createElement("style");sheet.setAttribute("id",id),sheet.innerHTML=elements.map(target=>`${target}{
|
|
10
|
+
${highlightStyle(infos.color,infos.style)}
|
|
11
|
+
}`).join(" "),document.head.appendChild(sheet);},resetHighlight=()=>{let id=HIGHLIGHT_STYLE_ID,sheetToBeRemoved=document.getElementById(id);sheetToBeRemoved&&sheetToBeRemoved.parentNode?.removeChild(sheetToBeRemoved);};channel.on(STORY_CHANGED,resetHighlight);channel.on(RESET_HIGHLIGHT,resetHighlight);channel.on(HIGHLIGHT,highlight);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-highlight",
|
|
3
|
-
"version": "8.1.0-alpha.
|
|
3
|
+
"version": "8.1.0-alpha.3",
|
|
4
4
|
"description": "Highlight DOM nodes within your stories",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addons",
|
|
@@ -30,7 +30,11 @@
|
|
|
30
30
|
"require": "./dist/index.js",
|
|
31
31
|
"import": "./dist/index.mjs"
|
|
32
32
|
},
|
|
33
|
-
"./preview":
|
|
33
|
+
"./preview": {
|
|
34
|
+
"types": "./dist/preview.d.ts",
|
|
35
|
+
"require": "./dist/preview.js",
|
|
36
|
+
"import": "./dist/preview.mjs"
|
|
37
|
+
},
|
|
34
38
|
"./package.json": "./package.json"
|
|
35
39
|
},
|
|
36
40
|
"main": "dist/index.js",
|
|
@@ -51,8 +55,8 @@
|
|
|
51
55
|
"@storybook/global": "^5.0.0"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
|
-
"@storybook/core-events": "8.1.0-alpha.
|
|
55
|
-
"@storybook/preview-api": "8.1.0-alpha.
|
|
58
|
+
"@storybook/core-events": "8.1.0-alpha.3",
|
|
59
|
+
"@storybook/preview-api": "8.1.0-alpha.3",
|
|
56
60
|
"@types/webpack-env": "^1.16.0",
|
|
57
61
|
"typescript": "^5.3.2"
|
|
58
62
|
},
|