-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from cesarParra/logos
Logos LWC component
- Loading branch information
Showing
7 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template> | ||
<div if:true={ready} class="relative isolate overflow-hidden bg-dxp-bg-root"> | ||
<div class="bg-dxp-bg-root py-24 sm:py-32"> | ||
<div class="mx-auto max-w-7xl px-6 lg:px-8"> | ||
<h2 class="text-center text-lg font-semibold leading-8 text-gray-900">{computed.title}</h2> | ||
<div | ||
class="mx-auto mt-10 grid max-w-lg auto-cols-max grid-flow-row place-content-center items-center gap-x-8 | ||
gap-y-10 sm:max-w-xl sm:gap-x-10 md:grid-flow-col md:auto-cols-auto lg:mx-0 lg:max-w-none"> | ||
<template for:each={computed.logos} for:item="logo"> | ||
<img key={logo.name} class="max-h-12 w-full object-contain" | ||
src={logo.src} alt={logo.name} width="158" | ||
height="48"> | ||
</template> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div if:true={error}> | ||
<c-alert title="Error parsing expression" message={error}></c-alert> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import TwElement from "c/twElement"; | ||
import evaluate from '@salesforce/apex/FormulaEvaluatorUiController.evaluate'; | ||
import { api, wire } from "lwc"; | ||
|
||
export default class Logos extends TwElement { | ||
@api expr; | ||
|
||
computed; | ||
error; | ||
|
||
@wire(evaluate, {recordId: '', formula: '$expr'}) | ||
evaluate({error, data}) { | ||
if (error) { | ||
console.error(error); | ||
this.error = error.body.message; | ||
} else { | ||
this.computed = data; | ||
this._validate(); | ||
} | ||
} | ||
|
||
get loading() { | ||
return !this.computed && !this.error; | ||
} | ||
|
||
get hasError() { | ||
return this.error; | ||
} | ||
|
||
get ready() { | ||
return !this.loading && !this.hasError; | ||
} | ||
|
||
_validate() { | ||
if (!this.computed) { | ||
return; | ||
} | ||
// Computed should contain a "title" property. | ||
if (!("title" in this.computed)) { | ||
this.error = 'Hero component requires a title.'; | ||
} | ||
|
||
// Computed should contain a "logos" property. | ||
if (!("logos" in this.computed)) { | ||
this.error = 'Hero component requires a "logos" key.'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<description>Logos</description> | ||
<isExposed>true</isExposed> | ||
<masterLabel>Logos</masterLabel> | ||
<targets> | ||
<target>lightningCommunity__Default</target> | ||
<target>lightningCommunity__Page</target> | ||
</targets> | ||
<targetConfigs> | ||
<targetConfig targets="lightningCommunity__Default"> | ||
<property name="expr" type="String" placeholder="1 + 1" required="true" label="Formula Expression" | ||
description="Formula expression to be evaluated." default="" /> | ||
</targetConfig> | ||
</targetConfigs> | ||
</LightningComponentBundle> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters