{"version":3,"file":"CustomButton.J9QSxkgV.mjs","names":["IconType","SrcType"],"sources":["https:/framerusercontent.com/modules/u3dwKaaj1MpcY9x5oA1Z/39MViC8Dv19BuSoJOXzL/CustomButton.js"],"sourcesContent":["// This component renders a customizable button for Framer, allowing users to download a file or open a link with various style and hover effects.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsOnFramerCanvas}from\"framer\";import{isBrowser,motion}from\"framer-motion\";var IconType;// Enumeration for icon types: Default or Custom.\n(function(IconType){IconType[\"Default\"]=\"Default\";IconType[\"Custom\"]=\"Custom\";})(IconType||(IconType={}));var SrcType;// Enumeration for source types: Upload or URL.\n(function(SrcType){SrcType[\"Upload\"]=\"Upload\";SrcType[\"URL\"]=\"URL\";})(SrcType||(SrcType={}));// Selector for the meta tag used to determine if the site is published or statically generated.\nconst metaTagSelector='meta[name=\"framer-search-index\"]';// Function to check if the current environment is a published site or SSG.\nfunction isPublishedSiteOrSSG(){if(typeof document===\"undefined\"){return true;}const metaTag=document.querySelector(metaTagSelector);return metaTag!==null;}export default function CustomButton(props){// Destructure properties from props for easier access.\nconst{text,srcType,srcURL,srcFile,autoOpen,openInNewTab,showIcon,iconOptions,styleOptions,hoverOptions,style}=props;// Destructure style options.\nconst{backgroundColor,color,borderRadius,padding,paddingPerSide,paddingTop,paddingRight,paddingBottom,paddingLeft,gap,fontControl,underline}=styleOptions;// Determine if the component is being rendered on the Framer Canvas.\nconst isOnFramerCanvas=useIsOnFramerCanvas();// Check if the site is published or statically generated.\nconst isInPublishedSiteOrSSG=isPublishedSiteOrSSG();// Determine the action URL based on the source type and publication status.\nlet actionURL=undefined;if(isInPublishedSiteOrSSG){if(srcType===\"URL\"){actionURL=srcURL;}else if(srcType===\"Upload\"){actionURL=srcFile;}}// Automatically open the URL if the autoOpen flag is true and conditions are met.\nif(autoOpen&&isBrowser&&!isOnFramerCanvas&&actionURL){window.location.href=actionURL;}// Calculate the padding value based on whether padding per side is enabled.\nconst paddingValue=paddingPerSide?`${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`:`${padding}px`;// Function to get the icon element based on the icon options.\nconst getIcon=()=>{if(!iconOptions||!showIcon){return null;}const iconStyle={order:iconOptions.alignment===\"start\"?0:2,flexShrink:0};if(iconOptions.type===\"Custom\"&&iconOptions.image.src){return /*#__PURE__*/_jsx(\"img\",{style:iconStyle,alt:iconOptions.image.alt&&iconOptions.image.alt.length>0?iconOptions.image.alt:\"Download icon\",src:iconOptions.image.src,width:iconOptions.size,height:iconOptions.size});}else{return /*#__PURE__*/_jsx(\"svg\",{style:iconStyle,xmlns:\"http://www.w3.org/2000/svg\",width:iconOptions.size,height:iconOptions.size,fill:iconOptions.color,viewBox:\"0 0 256 256\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M228 152v56a20 20 0 0 1-20 20H48a20 20 0 0 1-20-20v-56a12 12 0 0 1 24 0v52h152v-52a12 12 0 0 1 24 0Zm-108.49 8.49a12 12 0 0 0 17 0l40-40a12 12 0 0 0-17-17L140 123V40a12 12 0 0 0-24 0v83l-19.51-19.49a12 12 0 0 0-17 17Z\"})});}};// Function to determine the cursor style based on the availability of the action URL.\nconst getCursor=()=>{return actionURL?\"pointer\":\"auto\";};// Set the button title based on the publication status.\nconst buttonTitle=isInPublishedSiteOrSSG?\"Download File\":\"Publish to Download\";// Consolidated styles for the button.\nconst buttonStyle={gap:gap,fontSize:18,lineHeight:1.5,fontFamily:\"Montserrat\",fontWeight:700,width:\"max-content\",...style,...buttonStyles,...fontControl,padding:paddingValue,color:color,backgroundColor:backgroundColor,borderRadius:borderRadius,userSelect:\"none\",placeContent:flexAlignSwitch(fontControl),whiteSpace:\"nowrap\",cursor:getCursor(),textDecoration:underline?\"underline\":\"none\"};// Consolidated hover effects.\nconst hoverEffect={scale:hoverOptions.scale,backgroundColor:hoverOptions.backgroundColor,color:hoverOptions.color,cursor:\"pointer\"};// Render the download button with styles and hover effects.\nreturn /*#__PURE__*/_jsxs(motion.a,{target:openInNewTab?\"_blank\":\"_self\",href:actionURL,download:srcType===\"Upload\"?true:undefined,title:buttonTitle,style:buttonStyle,whileHover:hoverEffect,transition:hoverOptions.transition,children:[getIcon(),text]});}CustomButton.displayName=\"Button (Custom) CC\";CustomButton.defaultProps={text:\"Download\",srcType:\"Upload\",srcURL:\"\",srcFile:\"\",autoOpen:false,openInNewTab:true,showIcon:true,iconOptions:{type:\"Default\",color:\"#FFF\",image:{src:\"\",alt:\"\"},size:16,alignment:\"start\"},styleOptions:{backgroundColor:\"#000000\",color:\"#FFF\",borderRadius:32,padding:10,paddingPerSide:false,paddingTop:10,paddingRight:10,paddingBottom:10,paddingLeft:10,gap:8,fontControl:{fontFamily:\"Arial\",fontSize:18,fontWeight:700,textAlign:\"center\",color:\"#FFF\"},underline:false},hoverOptions:{scale:1.1,backgroundColor:\"#333\",color:\"#FFF\",transition:{type:\"spring\",stiffness:400,damping:30}}};addPropertyControls(CustomButton,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Download\",description:\"Button label text.\"},srcType:{type:ControlType.Enum,displaySegmentedControl:true,title:\"Source\",options:[\"URL\",\"Upload\"],description:\"Choose the source of the file or link.\"},srcURL:{type:ControlType.String,title:\"URL\",placeholder:\"https://example.com\",hidden(props){return props.srcType===\"Upload\";},description:\"URL to open or download.\"},srcFile:{type:ControlType.File,title:\"File\",allowedFileTypes:[],hidden(props){return props.srcType===\"URL\";},description:\"Upload the file to be downloaded.\"},autoOpen:{type:ControlType.Boolean,title:\"Auto Open\",defaultValue:false,description:\"Automatically open the link or start the download on page load.\"},openInNewTab:{type:ControlType.Boolean,title:\"Open in New Tab\",defaultValue:true,description:\"Open the link in a new tab.\"},showIcon:{type:ControlType.Boolean,title:\"Show Icon\",defaultValue:true,description:\"Display an icon next to the button text.\"},iconOptions:{type:ControlType.Object,optional:true,title:\"Icon\",buttonTitle:\"Customize Icon\",controls:{type:{title:\"Type\",type:ControlType.Enum,options:Object.values(IconType),optionTitles:Object.values(IconType),displaySegmentedControl:true,description:\"Choose between default or custom icon.\"},color:{title:\"Color\",type:ControlType.Color,defaultValue:\"#FFF\",hidden(props){return props.type===\"Custom\";},description:\"Color of the default icon.\"},image:{title:\"File\",type:ControlType.ResponsiveImage,allowedFileTypes:[\"jpg\",\"png\",\"svg\"],hidden(props){return props.type===\"Default\";},description:\"Upload a custom icon image.\"},size:{type:ControlType.Number,displayStepper:true,min:5,defaultValue:16,max:250,title:\"Size\",description:\"Size of the icon.\"},alignment:{title:\"Align\",type:ControlType.Enum,displaySegmentedControl:true,options:[\"start\",\"end\"],optionTitles:[\"Start\",\"End\"],description:\"Alignment of the icon relative to the text.\"}},hidden(props){return!props.showIcon;}},styleOptions:{type:ControlType.Object,title:\"Styles\",buttonTitle:\"Customize Styles\",controls:{fontControl:{type:ControlType.Font,title:\"Font\",controls:\"extended\",description:\"Customize the font style.\"},backgroundColor:{type:ControlType.Color,title:\"Fill\",defaultValue:\"#000000\",description:\"Background color of the button.\"},color:{type:ControlType.Color,defaultValue:\"#FFF\",title:\"Text Color\",description:\"Color of the button text.\"},borderRadius:{type:ControlType.Number,title:\"Radius\",displayStepper:true,defaultValue:32,description:\"Border radius of the button.\"},padding:{title:\"Padding\",type:ControlType.FusedNumber,toggleKey:\"paddingPerSide\",toggleTitles:[\"Padding\",\"Padding per side\"],defaultValue:10,valueKeys:[\"paddingTop\",\"paddingRight\",\"paddingBottom\",\"paddingLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0,description:\"Padding inside the button.\"},gap:{title:\"Gap\",type:ControlType.Number,displayStepper:true,defaultValue:8,description:\"Gap between the icon and text.\"},underline:{type:ControlType.Boolean,title:\"Underline\",defaultValue:false,description:\"Toggle underline on/off\"}}},hoverOptions:{type:ControlType.Object,title:\"Hover Effect\",buttonTitle:\"Customize Hover\",optional:true,controls:{scale:{type:ControlType.Number,title:\"Scale\",min:0,max:10,displayStepper:true,step:.01,defaultValue:1.1,description:\"Scale of the button on hover.\"},backgroundColor:{type:ControlType.Color,title:\"Fill\",defaultValue:\"#333\",optional:true,description:\"Background color on hover.\"},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFF\",optional:true,description:\"Text color on hover.\"},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{type:\"spring\",stiffness:400,damping:30},description:\"Transition effect for the hover state.\"}}}});const buttonStyles={display:\"flex\",placeItems:\"center\",placeContent:\"center\",textDecoration:\"none\"};// Function to match flex content alignment with text alignment.\nfunction flexAlignSwitch(fontControlStyles){if(fontControlStyles?.textAlign===\"left\"){return\"flex-start\";}if(fontControlStyles?.textAlign===\"right\"){return\"flex-end\";}return\"center\";}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomButton.map"],"mappings":"2VAKA,SAAS,GAAsB,CAAC,UAAU,SAAW,IAAa,OAAO,EAAM,IAAM,EAAQ,SAAS,cAAc,EAAgB,CAAC,OAAO,IAAU,IAAM,CAAe,SAAS,EAAa,EAAM,CAKvM,GAJK,CAAC,OAAK,UAAQ,SAAO,UAAQ,WAAS,eAAa,WAAS,cAAY,eAAa,eAAa,QAAM,CAAC,EACzG,CAAC,kBAAgB,QAAM,eAAa,UAAQ,iBAAe,aAAW,eAAa,gBAAc,cAAY,MAAI,cAAY,YAAU,CAAC,EACvI,EAAiB,GAAqB,CACtC,EAAuB,GAAsB,CAC/C,EACJ,AAD2B,IAA2B,IAAU,MAAO,EAAU,EAAgB,IAAU,WAAU,EAAU,IAC5H,GAAU,IAAY,GAAkB,IAAW,EAAO,SAAS,KAAK,GAM3E,IALM,EAAa,GAAgB,EAAE,EAAW,KAAK,EAAa,KAAK,EAAc,KAAK,EAAY,KAAK,EAAE,EAAQ,IAC/G,EAAQ,IAAI,CAAC,IAAI,IAAc,EAAU,OAAO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