UNPKG

@rocketspark/domain-checker

Version:
13 lines 8.01 kB
/*! * * @rocketspark/domain-checker v1.0.12 * git+https://github.com/rocketspark/domain-checker.git * * Copyright (c) Lee Reichardt and project contributors. * * This source code is licensed under the no license license found in the * LICENSE file in the root directory of this source tree. * */ "use strict";(self.webpackChunkDomainChecker=self.webpackChunkDomainChecker||[]).push([[899],{9899:function(e,t,r){r.r(t),r.d(t,{rs_template_picker:function(){return s}});var i=r(6919);const s=class{constructor(e){(0,i.r)(this,e),this.templateChosen=(0,i.c)(this,"templateChosen",7),this.requestUri=null,this.templates="[]",this.empty="end",this.industry=null,this.templateData=[],this.previewVisible=!1,this.useTemplateFromPreviewHandler=()=>{this.templateChosen.emit({id:this.previewTemplate.id,filter:this.industry}),this.closePreviewHandler()},this.closePreviewHandler=()=>{this.previewVisible=!1,this.previewTemplate=null},this.selectIndustryHandler=e=>{const t=e.target.closest(".industry-button").dataset.handle;this.industry=this.industry===t?null:t}}render(){document.body.style.overflow=this.previewVisible?"hidden":this.originalBodyOverflow;const e=this.industries();return(0,i.h)(i.H,{key:"2e046bf0e5c25fcafefc6e867be07693035c3ade"},(0,i.h)("div",{key:"31fb4482805d7f4bda7bc3b8477db171c4d1d0c1",class:"industry-filter__container",style:{display:0===e.length?"none":null}},(0,i.h)("rs-subtitle",{key:"ecbf405171ffc0bf133141d56fa634e432ec9ed6",subtitle:"2",color:"grey-700"},"Filter by industry"),(0,i.h)("div",{key:"a3df16771b6af0020e28342f4c4f75638f46f201",class:"industry-filter industry-filter--desktop"},this.industries().map(this.industryButton.bind(this))),(0,i.h)("rs-select",{key:"3370db9a5cac4fee5d2a029f40e0617662cc80b3",class:"industry-filter--mobile",items:e.map((({handle:e,name:t})=>({value:e,label:t})))})),this.templateAreaContents(),this.previewArea())}async componentWillLoad(){this.templateData=null!==this.requestUri?await this.fetchTemplates():JSON.parse(this.templates),this.originalBodyOverflow=document.body.style.overflow}componentDidLoad(){document.body.append(this.popup)}previewTemplateHandler(e){this.previewVisible=!0,this.previewTemplate=this.templateData.find((t=>t.id===e.detail))}useTemplateHandler(e){this.templateChosen.emit({id:e.detail,filter:this.industry})}selectChangeHandler(e){this.industry=e.detail}industries(){return this.templateData.map((({industry:e})=>e)).filter((e=>null!==e)).filter(((e,t,r)=>t===r.findIndex((({handle:t})=>t===e.handle)))).sort(this.industrySortOrder)}industryButton({handle:e,name:t,iconName:r}){return(0,i.h)("div",{class:"industry-button "+(this.industry===e?"industry-button--selected":""),onClick:this.selectIndustryHandler,"data-handle":e},(0,i.h)("rs-icon",{name:r,size:18}),t)}templateCard(e){return({id:t,name:r,thumbnail:s,industry:a,isFlintOptimised:l})=>(0,i.h)("rs-template-card",{isFlintOptimised:l,key:t,"template-id":t,name:r,thumbnail:s,style:{display:e(null==a?void 0:a.handle)?null:"none"}})}templateAreaContents(){const e=this.templateData.map(this.templateCard((e=>this.industry===e))),t=this.templateData.map(this.templateCard((e=>this.industry!==e))),r=(0,i.h)("rs-template-card",{empty:!0});return"start"===this.empty?t.unshift(r):"end"===this.empty&&t.push(r),(0,i.h)("div",null,(0,i.h)("rs-header",{heading:"4",color:"secondary",style:{display:null===this.industry?"none":null}},"Best matches for your industry"),(0,i.h)("div",{class:"template-area",style:{display:null===this.industry?"none":null}},e),(0,i.h)("rs-header",{heading:"4",color:"secondary",style:{marginTop:"60px"}},null===this.industry?"Popular designs":"All templates"),(0,i.h)("div",{class:"template-area"},t))}previewArea(){var e,t,r,s;const a=null!==(t=null===(e=this.previewTemplate)||void 0===e?void 0:e.previewUrl)&&void 0!==t?t:"";return(0,i.h)("div",{class:"preview-area",style:{display:this.previewVisible?"flex":"none"},ref:e=>this.popup=e},(0,i.h)("div",{class:"preview-header"},(0,i.h)("rs-icon",{name:"x",size:32,color:"secondary-300",onClick:this.closePreviewHandler}),(0,i.h)("rs-button",{onClick:this.useTemplateFromPreviewHandler},"Start with this design")),(0,i.h)("div",{class:"browser"},(0,i.h)("div",{class:"browser-bar"},(0,i.h)("div",{class:"browser-dot"}),(0,i.h)("div",{class:"browser-dot"}),(0,i.h)("div",{class:"browser-dot"})),(0,i.h)("div",{class:"browser-area"},(0,i.h)("div",{class:"loading-area"},(0,i.h)("rs-spinner",{style:{display:""!==a?null:"none"}}),(0,i.h)("rs-subtitle",{class:"preview-message"},""!==a?"loading preview":"no preview available")),(0,i.h)("iframe",{src:null!==(s=null===(r=this.previewTemplate)||void 0===r?void 0:r.previewUrl)&&void 0!==s?s:""}))))}async fetchTemplates(){return(await fetch(this.requestUri).then((e=>e.json()))).templates}industrySortOrder(e,t){const r=["buildingConstruction","professionalServices","retailEcommerce","healthBeauty","hospitalityFoodService","designPhotography","primaryIndustries","education","artEntertainment","tourism","communitySport","automotiveAviation","manufacturing"];return r.indexOf(e.handle)-r.indexOf(t.handle)}};s.style=".sc-rs-template-picker-h{text-align:left}.industry-filter__container.sc-rs-template-picker{margin-left:2px;margin-bottom:60px}.industry-filter__container.sc-rs-template-picker rs-subtitle.sc-rs-template-picker{margin-bottom:18px}.industry-filter.sc-rs-template-picker{display:flex;flex-wrap:wrap;gap:10px}.industry-filter--mobile.sc-rs-template-picker{display:none}.industry-button.sc-rs-template-picker{display:flex;align-items:center;gap:10px;width:min-content;height:33px;padding:0 15px;border-radius:5px;background:var(--rs-color-select-background);color:var(--rs-color-secondary);cursor:pointer;white-space:nowrap;transition:0.2s ease-in;font-family:soleil, sans-serif}.industry-button.sc-rs-template-picker:hover{background:var(--rs-color-select-secondary)}.industry-button--selected.sc-rs-template-picker{background:var(--rs-color-primary-700);color:var(--rs-color-white)}.industry-button--selected.sc-rs-template-picker:hover{background:var(--rs-color-primary)}.template-area.sc-rs-template-picker{display:grid;grid-template-columns:repeat(3, 1fr);gap:4vw;justify-content:space-between;margin-top:40px}rs-template-card.sc-rs-template-picker{width:100%}.preview-area.sc-rs-template-picker{flex-direction:column;justify-content:space-between;align-items:center;z-index:99999;position:fixed;top:0;left:0;width:100%;height:100%;box-sizing:border-box;padding:24px;background:var(--rs-color-light)}.preview-header.sc-rs-template-picker{display:flex;justify-content:space-between;align-items:center;width:100%;height:min-content}.preview-header.sc-rs-template-picker rs-icon.sc-rs-template-picker{margin:8px;cursor:pointer}.browser.sc-rs-template-picker{width:100%;max-width:1920px;height:100%;box-sizing:border-box;padding:37px 77px 48px}.loading-area.sc-rs-template-picker{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:flex;flex-direction:column;justify-content:center;align-items:center;row-gap:19px}.browser-bar.sc-rs-template-picker{display:flex;justify-content:start;width:100%;height:24px;box-sizing:border-box;padding:8px 6px;border-radius:8px 8px 0 0;background:var(--rs-color-white)}.browser-dot.sc-rs-template-picker{width:8px;height:8px;margin:0 2px;border-radius:8px;border:1px solid var(--rs-color-select-border)}.browser-area.sc-rs-template-picker{width:100%;height:100%;background:white}.browser.sc-rs-template-picker iframe.sc-rs-template-picker{width:100%;height:100%;border:none;position:relative;z-index:1}@media only screen and (max-width: 1339px){.template-area.sc-rs-template-picker{gap:16px}}@media only screen and (max-width: 667px){.industry-filter--desktop.sc-rs-template-picker{display:none}.industry-filter--mobile.sc-rs-template-picker{display:block}.template-area.sc-rs-template-picker{grid-template-columns:repeat(2, 1fr)}.browser.sc-rs-template-picker{padding-left:0;padding-right:0}}"}}]); //# sourceMappingURL=899.index.js.map