@storybook/addon-highlight
Advanced tools
Comparing version 0.0.0-pr-26243-sha-393e9350 to 0.0.0-pr-26243-sha-c7b1761e
@@ -1,13 +0,13 @@ | ||
import { global } from '@storybook/global'; | ||
import { addons } from '@storybook/preview-api'; | ||
import { STORY_CHANGED } from '@storybook/core-events'; | ||
'use strict'; | ||
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")=>` | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var previewApi = require('storybook/internal/preview-api'); | ||
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); | ||
`,highlightObject=color=>({outline:`2px dashed ${color}`,outlineOffset:2,boxShadow:"0 0 0 6px rgba(255,255,255,0.6)"}),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}{ | ||
`,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(STORY_CHANGED,resetHighlight);channel.on(RESET_HIGHLIGHT,resetHighlight);channel.on(HIGHLIGHT,highlight); | ||
export { highlightObject, highlightStyle }; | ||
}`).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); |
{ | ||
"name": "@storybook/addon-highlight", | ||
"version": "0.0.0-pr-26243-sha-393e9350", | ||
"version": "0.0.0-pr-26243-sha-c7b1761e", | ||
"description": "Highlight DOM nodes within your stories", | ||
@@ -29,7 +29,10 @@ "keywords": [ | ||
"types": "./dist/index.d.ts", | ||
"node": "./dist/index.js", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs" | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
}, | ||
"./preview": "./dist/preview.js", | ||
"./preview": { | ||
"types": "./dist/preview.d.ts", | ||
"import": "./dist/preview.mjs", | ||
"require": "./dist/preview.js" | ||
}, | ||
"./package.json": "./package.json" | ||
@@ -48,4 +51,4 @@ }, | ||
"scripts": { | ||
"check": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts", | ||
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/addon-bundle.ts" | ||
"check": "jiti ../../../scripts/prepare/check.ts", | ||
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts" | ||
}, | ||
@@ -56,7 +59,8 @@ "dependencies": { | ||
"devDependencies": { | ||
"@storybook/core-events": "0.0.0-pr-26243-sha-393e9350", | ||
"@storybook/preview-api": "0.0.0-pr-26243-sha-393e9350", | ||
"@types/webpack-env": "^1.16.0", | ||
"typescript": "^5.3.2" | ||
}, | ||
"peerDependencies": { | ||
"storybook": "^0.0.0-pr-26243-sha-c7b1761e" | ||
}, | ||
"publishConfig": { | ||
@@ -73,3 +77,3 @@ "access": "public" | ||
}, | ||
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17", | ||
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16", | ||
"sbmodern": "dist/modern/index.js", | ||
@@ -76,0 +80,0 @@ "storybook": { |
@@ -11,3 +11,3 @@ # Storybook Addon Highlight | ||
This addon requires Storybook 6.5 or later. Highlight is part of [essentials](https://storybook.js.org/docs/react/essentials) and so is installed in all new Storybooks by default. If you need to add it to your Storybook, you can run the following command: | ||
This addon requires Storybook 6.5 or later. Highlight is part of [essentials](https://storybook.js.org/docs/essentials) and so is installed in all new Storybooks by default. If you need to add it to your Storybook, you can run the following command: | ||
@@ -36,3 +36,2 @@ yarn: | ||
// .storybook/main.ts | ||
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite) | ||
@@ -54,7 +53,5 @@ import type { StorybookConfig } from '@storybook/your-framework'; | ||
// MyComponent.stories.ts | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { useChannel } from '@storybook/preview-api'; | ||
import { HIGHLIGHT } from '@storybook/addon-highlight'; | ||
import { MyComponent } from './MyComponent'; | ||
@@ -88,7 +85,5 @@ | ||
// MyComponent.stories.ts|tsx | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { useChannel } from '@storybook/preview-api'; | ||
import { HIGHLIGHT, RESET_HIGHLIGHT } from '@storybook/addon-highlight'; | ||
import { MyComponent } from './MyComponent'; | ||
@@ -123,7 +118,5 @@ | ||
// MyComponent.stories.ts | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { useChannel } from '@storybook/preview-api'; | ||
import { HIGHLIGHT } from '@storybook/addon-highlight'; | ||
import { MyComponent } from './MyComponent'; | ||
@@ -130,0 +123,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9083
2
9
38
2
140