-
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 #58 from cesarParra/hero
Hero
- Loading branch information
Showing
14 changed files
with
243 additions
and
11 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
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,30 @@ | ||
<template> | ||
<div if:true={ready} class="relative isolate overflow-hidden bg-dxp-bg-root"> | ||
<div class={containerClasses}> | ||
<div class={mainClasses}> | ||
<h1 class="mt-10 text-4xl font-bold tracking-tight text-dxp-text-contrast sm:text-6xl">{computed.title}</h1> | ||
<p if:true={computed.description} class="mt-6 text-lg leading-8 text-dxp-text-contrast-2">{computed.description}</p> | ||
<div class={buttonClasses}> | ||
<a if:true={computed.callToAction} href={computed.callToAction.url} class="rounded-md bg-dxp-brand | ||
px-3.5 py-2.5 text-sm font-semibold text-dxp-brand-foreground shadow-sm hover:bg-dxp-brand-2 | ||
focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 | ||
focus-visible:outline-dxp-brand"> | ||
{computed.callToAction.label} | ||
</a> | ||
<a if:true={computed.secondaryAction} href={computed.secondaryAction.url} class="text-sm font-semibold | ||
leading-6 text-dxp-text-contrast">Learn more <span aria-hidden="true">→</span></a> | ||
</div> | ||
</div> | ||
<div if:true={computed.bannerImage} class="mx-auto mt-16 flex max-w-2xl sm:mt-24 lg:ml-10 lg:mr-0 lg:mt-0 lg:max-w-none lg:flex-none xl:ml-32"> | ||
<div class="max-w-3xl flex-none sm:max-w-5xl lg:max-w-none"> | ||
<div class="-m-2 rounded-xl bg-gray-900/5 p-2 ring-1 ring-inset ring-gray-900/10 lg:-m-4 lg:rounded-2xl lg:p-4"> | ||
<img src={computed.bannerImage} alt="Banner" width="2432" height="1442" class="w-[76rem] rounded-md shadow-2xl ring-1 ring-gray-900/10"> | ||
</div> | ||
</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,70 @@ | ||
import TwElement from "c/twElement"; | ||
import evaluate from '@salesforce/apex/FormulaEvaluatorUiController.evaluate'; | ||
import { api, wire } from "lwc"; | ||
import { classNames } from 'c/utils'; | ||
|
||
export default class Hero 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; | ||
} | ||
|
||
get containerClasses() { | ||
return classNames( | ||
'mx-auto max-w-7xl px-6 pb-24 pt-10 sm:pb-32 lg:px-8 lg:py-40', | ||
{'lg:flex': this.hasImage} | ||
); | ||
} | ||
|
||
get mainClasses() { | ||
return classNames( | ||
'mx-auto lg:mx-0 lg:flex-shrink-0 lg:pt-8', | ||
{'max-w-2xl lg:max-w-xl': this.hasImage}, | ||
{'text-center': !this.hasImage} | ||
); | ||
} | ||
|
||
get buttonClasses() { | ||
return classNames( | ||
'mt-10 flex items-center gap-x-6', | ||
{'justify-center': !this.hasImage} | ||
); | ||
} | ||
|
||
get hasImage() { | ||
return this.computed && this.computed.bannerImage; | ||
} | ||
|
||
_validate() { | ||
if (!this.computed) { | ||
return; | ||
} | ||
// Computed should contain a "title" property. | ||
if (!("title" in this.computed)) { | ||
this.error = 'Hero component requires a title.'; | ||
} | ||
} | ||
} |
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>Hero</description> | ||
<isExposed>true</isExposed> | ||
<masterLabel>Hero</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
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,47 @@ | ||
/*! | ||
Copyright (c) 2018 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
*/ | ||
|
||
const hasOwn = {}.hasOwnProperty; | ||
|
||
const classNames = (...args) => { | ||
const classes = []; | ||
|
||
for (let i = 0; i < args.length; i++) { | ||
const arg = args[i]; | ||
if (!arg) continue; | ||
|
||
const argType = typeof arg; | ||
|
||
if (argType === "string" || argType === "number") { | ||
classes.push(arg); | ||
} else if (Array.isArray(arg)) { | ||
if (arg.length) { | ||
const inner = classNames.apply(null, arg); | ||
if (inner) { | ||
classes.push(inner); | ||
} | ||
} | ||
} else if (argType === "object") { | ||
if ( | ||
arg.toString !== Object.prototype.toString && | ||
!arg.toString.toString().includes("[native code]") | ||
) { | ||
classes.push(arg.toString()); | ||
continue; | ||
} | ||
|
||
for (const key in arg) { | ||
if (hasOwn.call(arg, key) && arg[key]) { | ||
classes.push(key); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return classes.join(" "); | ||
}; | ||
|
||
export { classNames }; |
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 @@ | ||
export * from "./classnames.js"; |
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<isExposed>false</isExposed> | ||
</LightningComponentBundle> |
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 |
---|---|---|
|
@@ -5,20 +5,24 @@ | |
"package": "Expression (Unlocked)", | ||
"versionName": "Version 1.11", | ||
"versionNumber": "1.11.0.NEXT", | ||
"default": true | ||
"default": false | ||
}, | ||
{ | ||
"path": "expression-components", | ||
"package": "Expression Components", | ||
"versionName": "Version 0.1", | ||
"versionNumber": "0.1.0.NEXT", | ||
"versionName": "Version 0.2", | ||
"versionNumber": "0.2.0.NEXT", | ||
"default": false, | ||
"dependencies": [ | ||
{ | ||
"package": "Expression (Unlocked)", | ||
"versionNumber": "1.11.0.LATEST" | ||
} | ||
] | ||
}, | ||
{ | ||
"path": "src-pull", | ||
"default": true | ||
} | ||
], | ||
"name": "Expression", | ||
|
@@ -29,6 +33,7 @@ | |
"Expression (Unlocked)": "0HoDm000000XZKSKA4", | ||
"Expression Components": "0HoDm000000XZKhKAO", | ||
"Expression (Unlocked)@1.11.0-1": "04tDm0000011MfoIAE", | ||
"Expression [email protected]": "04tDm0000011MftIAE" | ||
"Expression [email protected]": "04tDm0000011MftIAE", | ||
"Expression [email protected]": "04tDm0000011MfyIAE" | ||
} | ||
} | ||
} |
Empty file.
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