UNPKG

storybook-addon-rtl

Version:
2 lines 2.42 kB
import {addons,types,useGlobals,useStorybookApi}from'storybook/manager-api';import o from'react';import {IconButton}from'storybook/internal/components';import {useTheme}from'storybook/theming';var l="storybook/rtl",i=`${l}/rtl-tool`;var s=({direction:t})=>{let r=useTheme();return o.createElement("div",{"aria-label":t==="ltr"?"Switch direction to right-to-left.":"Switch Direction to left-to-right",style:{width:"20px",height:"20px",position:"relative"}},o.createElement("div",{style:{marginBottom:"-45%",top:0,display:"flex",justifyContent:"center",backgroundColor:"transparent",width:"100%",transition:"transform 0.3s",transform:t==="rtl"?"scale(0.5) translate(0, -35%)":"scale(1)"}},o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",style:{transition:"fill 0.3s",fill:t==="ltr"?r.barSelectedColor:r.barTextColor,height:"100%",width:"80%"}},o.createElement("path",{d:"M502.6 278.6l-128 128c-12.51 12.51-32.76 12.49-45.25 0c-12.5-12.5-12.5-32.75 0-45.25L402.8 288H32C14.31 288 0 273.7 0 255.1S14.31 224 32 224h370.8l-73.38-73.38c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l128 128C515.1 245.9 515.1 266.1 502.6 278.6z"}))),o.createElement("div",{style:{display:"flex",justifyContent:"center",backgroundColor:"transparent",width:"100%",scale:t==="rtl"?1:.5,transition:"transform 0.3s",transform:t==="ltr"?"scale(0.5) translate(0, -1px)":"scale(1) translate(0, -20%)"}},o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",style:{transition:"fill 0.3s",fill:t==="rtl"?r.barSelectedColor:r.barTextColor,transform:"rotate(180deg)",height:"100%",width:"80%"}},o.createElement("path",{d:"M502.6 278.6l-128 128c-12.51 12.51-32.76 12.49-45.25 0c-12.5-12.5-12.5-32.75 0-45.25L402.8 288H32C14.31 288 0 273.7 0 255.1S14.31 224 32 224h370.8l-73.38-73.38c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l128 128C515.1 245.9 515.1 266.1 502.6 278.6z"}))))};var a=()=>{let[t,r]=useGlobals(),e=useStorybookApi().getStoryGlobals(),c=t.addonRtl==="ltr"?"Switch direction to right-to-left.":"Switch direction to left-to-right";return o.createElement(IconButton,{title:c,disabled:e.addonRtl!==void 0,onClick:()=>{let p=t.addonRtl==="rtl"?"ltr":"rtl";r({addonRtl:p});}},o.createElement(s,{direction:t.addonRtl}))};addons.register(l,()=>{addons.add(i,{id:"rtl-tool",type:types.TOOL,title:"RTL",render:a});});//# sourceMappingURL=manager.mjs.map //# sourceMappingURL=manager.mjs.map