-
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.
- Loading branch information
1 parent
f011650
commit fb8311c
Showing
45 changed files
with
653 additions
and
639 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.
12 changes: 7 additions & 5 deletions
12
expression-components/main/ui/components/base/lwc/alert/alert.html
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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
<template> | ||
<div class="rounded-md bg-red-50 p-4"> | ||
<div class={containerClasses}> | ||
<div class="flex"> | ||
<div class="flex-shrink-0"> | ||
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> | ||
<svg lwc:if={isError} class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd" /> | ||
</svg> | ||
<svg lwc:if={isWarning} class="h-5 w-5 text-yellow-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> | ||
<path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" /> | ||
</svg> | ||
</div> | ||
<div class="ml-3"> | ||
<h3 class="text-sm font-medium text-yellow-800">{title}</h3> | ||
<div class="mt-2 text-sm text-yellow-700"> | ||
<h3 class={titleTextClasses}>{title}</h3> | ||
<div class={messageTextClasses}> | ||
<p>{message}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</template> |
42 changes: 41 additions & 1 deletion
42
expression-components/main/ui/components/base/lwc/alert/alert.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 |
---|---|---|
@@ -1,6 +1,46 @@ | ||
import {api, LightningElement} from 'lwc'; | ||
import { api, LightningElement } from 'lwc'; | ||
import { classNames } from 'c/utils'; | ||
|
||
export default class Alert extends LightningElement { | ||
@api title; | ||
@api message; | ||
/** | ||
* The variant changes the appearance of the alert. | ||
* Accepted variants include: | ||
* - error | ||
* - warning | ||
*/ | ||
@api type; | ||
|
||
get containerClasses() { | ||
return classNames( | ||
'rounded-md p-4', | ||
{'bg-red-50': this.isError}, | ||
{'bg-yellow-50': this.isWarning}, | ||
); | ||
} | ||
|
||
get titleTextClasses() { | ||
return classNames( | ||
'text-sm font-medium', | ||
{'text-red-800': this.isError}, | ||
{'text-yellow-800': this.isWarning}, | ||
); | ||
} | ||
|
||
get messageTextClasses() { | ||
return classNames( | ||
'mt-2 text-sm', | ||
{'text-red-700': this.isError}, | ||
{'text-yellow-700': this.isWarning}, | ||
); | ||
} | ||
|
||
get isWarning() { | ||
return this.type === 'warning'; | ||
} | ||
|
||
get isError() { | ||
return this.type === 'error'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ts/main/ui/components/base/lwc/expressionElementContainer/expressionElementContainer.html
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,11 @@ | ||
<template> | ||
<slot></slot> | ||
<div if:true={cannotShowPreview}> | ||
<c-alert type="warning" title="Unable to show preview" | ||
message="To see a preview of the component, please provide a Preview Context ID when the Context URL Parameter is set."> | ||
</c-alert> | ||
</div> | ||
<div if:true={error}> | ||
<c-alert type="error" title="Error parsing expression" message={error}></c-alert> | ||
</div> | ||
</template> |
6 changes: 6 additions & 0 deletions
6
...ents/main/ui/components/base/lwc/expressionElementContainer/expressionElementContainer.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,6 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class ExpressionElementContainer extends LightningElement { | ||
@api cannotShowPreview = false; | ||
@api error = null; | ||
} |
7 changes: 7 additions & 0 deletions
7
.../ui/components/base/lwc/expressionElementContainer/expressionElementContainer.js-meta.xml
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<description>Expression Element Container</description> | ||
<isExposed>false</isExposed> | ||
<masterLabel>Expression Element Container</masterLabel> | ||
</LightningComponentBundle> |
68 changes: 68 additions & 0 deletions
68
...ion-components/main/ui/components/base/lwc/expressionSiteElement/expressionSiteElement.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,68 @@ | ||
import TwElement from "c/twElement"; | ||
import evaluate from '@salesforce/apex/FormulaEvaluatorUiController.evaluate'; | ||
import { CurrentPageReference } from "lightning/navigation"; | ||
import { wire } from "lwc"; | ||
|
||
export default class ExpressionSiteElement extends TwElement { | ||
// These 4 need to be set by the extending class as `@api` properties. | ||
contextUrlParam; | ||
previewContextId; | ||
expr; | ||
respectSharing; | ||
|
||
currentPageReference; | ||
computed; | ||
error; | ||
contextId = null | ||
|
||
@wire(CurrentPageReference) | ||
setCurrentPageReference(currentPageReference) { | ||
this.currentPageReference = currentPageReference; | ||
if (this.contextUrlParam) { | ||
this.contextId = this.isInBuilder ? this.previewContextId : this.currentPageReference.state[this.contextUrlParam]; | ||
} | ||
} | ||
|
||
@wire(evaluate, {recordId: '$contextId', formula: '$expr', respectSharing: '$respectSharing'}) | ||
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 && !this.cannotShowPreview; | ||
} | ||
|
||
get isInBuilder() { | ||
return this.currentPageReference?.state?.app === 'commeditor'; | ||
} | ||
|
||
get cannotShowPreview() { | ||
// If in the builder, and the contextUrlParam is set but the previewContextId is not, | ||
// then we cannot show the preview. | ||
if (!this.contextUrlParam) { | ||
return false; | ||
} | ||
|
||
if (this.isInBuilder) { | ||
return !this.previewContextId; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
validate() {} | ||
} |
7 changes: 7 additions & 0 deletions
7
...nents/main/ui/components/base/lwc/expressionSiteElement/expressionSiteElement.js-meta.xml
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<description>Expression Site Element</description> | ||
<isExposed>false</isExposed> | ||
<masterLabel>Expression Site Element</masterLabel> | ||
</LightningComponentBundle> |
11 changes: 5 additions & 6 deletions
11
expression-components/main/ui/components/exposed/lwc/button/button.html
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<template> | ||
<div if:true={ready}> | ||
<c-base-button action={computed} size="lg"></c-base-button> | ||
</div> | ||
<div if:true={error}> | ||
<c-alert title="Error parsing expression" message={error}></c-alert> | ||
</div> | ||
<c-expression-element-container cannot-show-preview={cannotShowPreview} error={error}> | ||
<div if:true={ready}> | ||
<c-base-button action={computed} size="lg"></c-base-button> | ||
</div> | ||
</c-expression-element-container> | ||
</template> |
38 changes: 6 additions & 32 deletions
38
expression-components/main/ui/components/exposed/lwc/button/button.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
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
39 changes: 19 additions & 20 deletions
39
expression-components/main/ui/components/exposed/lwc/features/features.html
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 |
---|---|---|
@@ -1,23 +1,22 @@ | ||
<template> | ||
<div if:true={ready} class="mx-auto max-w-7xl"> | ||
<div if:true={hasText} class="mx-auto max-w-2xl lg:mx-0"> | ||
<h2 if:true={computed.title} class="text-3xl font-bold tracking-tight text-dxp-text-contrast sm:text-4xl"> | ||
{computed.title} | ||
</h2> | ||
<p if:true={computed.description} class="mt-6 text-lg leading-8 text-dxp-text-contrast-3"> | ||
{computed.description} | ||
</p> | ||
<c-expression-element-container cannot-show-preview={cannotShowPreview} error={error}> | ||
<div lwc:if={ready} class="mx-auto max-w-7xl"> | ||
<div if:true={hasText} class="mx-auto max-w-2xl lg:mx-0"> | ||
<h2 if:true={computed.title} class="text-3xl font-bold tracking-tight text-dxp-text-contrast sm:text-4xl"> | ||
{computed.title} | ||
</h2> | ||
<p if:true={computed.description} class="mt-6 text-lg leading-8 text-dxp-text-contrast-3"> | ||
{computed.description} | ||
</p> | ||
</div> | ||
<dl class="mx-auto mt-16 grid max-w-2xl grid-cols-1 gap-x-8 gap-y-16 text-dxp-text-contrast leading-7 sm:grid-cols-2 lg:mx-0 lg:max-w-none lg:grid-cols-3"> | ||
<template for:each={computed.features} for:item="feature"> | ||
<div key={feature.title}> | ||
<dt class="font-semibold text-gray-900">{feature.title}</dt> | ||
<dd class="mt-1 text-dxp-text-contrast-3">{feature.description}</dd> | ||
</div> | ||
</template> | ||
</dl> | ||
</div> | ||
<dl class="mx-auto mt-16 grid max-w-2xl grid-cols-1 gap-x-8 gap-y-16 text-dxp-text-contrast leading-7 sm:grid-cols-2 lg:mx-0 lg:max-w-none lg:grid-cols-3"> | ||
<template for:each={computed.features} for:item="feature"> | ||
<div key={feature.title}> | ||
<dt class="font-semibold text-gray-900">{feature.title}</dt> | ||
<dd class="mt-1 text-dxp-text-contrast-3">{feature.description}</dd> | ||
</div> | ||
</template> | ||
</dl> | ||
</div> | ||
<div if:true={error}> | ||
<c-alert title="Error parsing expression" message={error}></c-alert> | ||
</div> | ||
</c-expression-element-container> | ||
</template> |
37 changes: 6 additions & 31 deletions
37
expression-components/main/ui/components/exposed/lwc/features/features.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
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
Oops, something went wrong.