@storybook/addon-highlight
Advanced tools
Comparing version 0.0.0-pr-30197-sha-3a606792 to 0.0.0-pr-30197-sha-7e96e461
@@ -0,6 +1,21 @@ | ||
import * as core_dist_types from 'storybook/internal/types'; | ||
import * as _storybook_csf from '@storybook/csf'; | ||
declare const HIGHLIGHT = "storybook/highlight/add"; | ||
declare const RESET_HIGHLIGHT = "storybook/highlight/reset"; | ||
declare const _default: {}; | ||
interface HighlightParameters { | ||
/** | ||
* Highlight configuration | ||
* | ||
* @see https://storybook.js.org/docs/essentials/highlight#parameters | ||
*/ | ||
highlight: { | ||
/** Remove the addon panel and disable the addon's behavior */ | ||
disable?: boolean; | ||
}; | ||
} | ||
export { HIGHLIGHT, RESET_HIGHLIGHT, _default as default }; | ||
declare const _default: () => core_dist_types.ProjectAnnotations<_storybook_csf.Renderer>; | ||
export { HIGHLIGHT, HighlightParameters, RESET_HIGHLIGHT, _default as default }; |
@@ -5,6 +5,16 @@ 'use strict'; | ||
var ADDON_ID="storybook/highlight";var HIGHLIGHT=`${ADDON_ID}/add`,RESET_HIGHLIGHT=`${ADDON_ID}/reset`;var src_default={}; | ||
var previewApi = require('storybook/internal/preview-api'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var global = require('@storybook/global'); | ||
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")=>` | ||
outline: 2px ${style} ${color}; | ||
outline-offset: 2px; | ||
box-shadow: 0 0 0 6px rgba(255,255,255,0.6); | ||
`,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}{ | ||
${highlightStyle(infos.color,infos.style)} | ||
}`).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);var src_default=()=>previewApi.definePreview({}); | ||
exports.HIGHLIGHT = HIGHLIGHT; | ||
exports.RESET_HIGHLIGHT = RESET_HIGHLIGHT; | ||
exports.default = src_default; |
{ | ||
"name": "@storybook/addon-highlight", | ||
"version": "0.0.0-pr-30197-sha-3a606792", | ||
"version": "0.0.0-pr-30197-sha-7e96e461", | ||
"description": "Highlight DOM nodes within your stories", | ||
@@ -42,2 +42,12 @@ "keywords": [ | ||
"types": "dist/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"dist/index.d.ts" | ||
], | ||
"preview": [ | ||
"dist/preview.d.ts" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
@@ -62,3 +72,3 @@ "dist/**/*", | ||
"peerDependencies": { | ||
"storybook": "^0.0.0-pr-30197-sha-3a606792" | ||
"storybook": "^0.0.0-pr-30197-sha-7e96e461" | ||
}, | ||
@@ -65,0 +75,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
11861
72