Skip to content

Commit

Permalink
NSW DS updates and fixes from LWR page templates (#348)
Browse files Browse the repository at this point in the history
* Updates and fixes from LWR page templates

* Typo
  • Loading branch information
eschweitzer78 authored Jun 2, 2024
1 parent 7970df8 commit 6a9bcf8
Show file tree
Hide file tree
Showing 61 changed files with 1,172 additions and 406 deletions.
5 changes: 5 additions & 0 deletions sfGpsDs/main/default/lwc/sfGpsDsMarkdown/sfGpsDsMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getFirstChild } from "c/sfGpsDsHelpers";
import Parser from "./blocks.js";
import HtmlRenderer from "./htmlRenderer.js";
import HtmlUnpackFirstPRenderer from "./htmlUnpackFirstPRenderer.js";
import { decodeHTMLStrict } from "./entitiesDecode.js";

class sfGpsDsMarkdown {
reader = new Parser();
Expand Down Expand Up @@ -176,6 +177,10 @@ class sfGpsDsMarkdown {

return h1s;
}

decodeEntities(str) {
return decodeHTMLStrict(str);
}
}

const renderer = new sfGpsDsMarkdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import getNavigationItems from "@salesforce/apex/SfGpsDsNavigationORA.getNavigat

import cBasePath from "@salesforce/community/basePath";
import { NavigationMixin } from "lightning/navigation";
import mdEngine from "c/sfGpsDsMarkdown";

const MODE_IP = "Integration Procedure";
const MODE_NAV = "Experience Cloud Navigation";
Expand Down Expand Up @@ -133,7 +134,7 @@ export default class SfGpsDsNavigation extends NavigationMixin(SfGpsDsIpLwc) {
return data.reduce((m, item, index) => {
let itemKey = `${key}-${index + 1}`;
let amik = {
text: item.label,
text: mdEngine.decodeEntities(item.label),
url: item.actionValue,
index: itemKey,
position: index
Expand Down
6 changes: 6 additions & 0 deletions sfGpsDsAuNsw/main/default/lwc/.osfilegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@
},
"sfGpsDsAuNswMarkdownElementComm": {
"target": "!Os",
"!.css": {
"target": "!Os.css"
},
"!.html": {
"target": "!Os.html"
},
Expand All @@ -567,6 +570,9 @@
},
"sfGpsDsAuNswMarkupElementComm": {
"target": "!Os",
"!.css": {
"target": "!Os.css"
},
"!.html": {
"target": "!Os.html"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ export default class SfGpsDsAuNswAccordion extends LightningElement {
static renderMode = "light";

@api header;
@api index;
@api className;

/* api: closed */

@api get closed() {
return !this.isOpen;
}
Expand All @@ -23,6 +26,8 @@ export default class SfGpsDsAuNswAccordion extends LightningElement {

@track isOpen = false;

/* getters */

get computedClassName() {
return computeClass({
"nsw-accordion__title": true,
Expand Down Expand Up @@ -54,6 +59,8 @@ export default class SfGpsDsAuNswAccordion extends LightningElement {
return this._controlsId;
}

/* event management */

handleClick() {
this.dispatchEvent(new CustomEvent(this.isOpen ? "collapse" : "expand"));
this.isOpen = !this.isOpen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<c-sf-gps-ds-au-nsw-accordion
lwc:else
index={index}
header={header}
closed={closed}
class-name={className}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template lwc:render-mode="light">
<div lwc:if={showButtons} class="nsw-accordion__toggle">
<button type="button" disabled={isFullyExpanded} onclick={handleExpandAll}>
<button type="button" disabled={_isFullyExpanded} onclick={handleExpandAll}>
{expandAllLabel}
</button>
<button
type="button"
disabled={isFullyCollapsed}
disabled={_isFullyCollapsed}
onclick={handleCollapseAll}
>
{collapseAllLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,51 @@
*/

import { LightningElement, api } from "lwc";
import { normaliseBoolean } from "c/sfGpsDsHelpers";

export default class sfGpsDsAuNswAccordionGroupHead extends LightningElement {
static renderMode = "light";

@api showButtons;
@api isFullyExpanded;
@api isFullyCollapsed;
@api expandAllLabel;
@api collapseAllLabel;

/* api: isFullyExpanded */

_isFullyExpandedOriginal;
_isFullyExpanded;

@api
get isFullyExpanded() {
return this._isFullyExpandedOriginal;
}

set isFullyExpanded(value) {
this._isFullyExpandedOriginal = value;
this._isFullyExpanded = normaliseBoolean(value, {
acceptString: true,
fallbackValue: false
});
}

/* api: isFullyCollapsed */

_isFullyCollapsedOriginal;
_isFullyCollapsed;

@api
get isFullyCollapsed() {
return this._isFullyCollapsedOriginal;
}

set isFullyCollapsed(value) {
this._isFullyCollapsedOriginal = value;
this._isFullyCollapsed = normaliseBoolean(value, {
acceptString: true,
fallbackValue: false
});
}

/* event management */

handleCollapseAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template>
<span if:false={firstChild}></span>
<c-sf-gps-ds-configuration-error
lwc:if={_sfGpsDsErrors}
errors={_sfGpsDsErrors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,24 @@ import { computeClass } from "c/sfGpsDsHelpers";
*/
export default class SfGpsDsAuNswAccordionGroupLwr extends SfGpsDsLwc {
@track items = [
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false },
{ title: "", closed: false }
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true },
{ title: "", closed: true }
];

_numberOpen = this.items.filter((item) => !item.closed).length;

@api firstChild;

@api
set item1title(value) {
this.items[0].title = value;
Expand Down Expand Up @@ -191,15 +195,13 @@ export default class SfGpsDsAuNswAccordionGroupLwr extends SfGpsDsLwc {
@api showButtons;
@api className;

_numberOpen = 0;

handleExpand(event) {
this.items[event.target.index].closed = false;
this.items[Number(event.target.index)].closed = false;
this._numberOpen++;
}

handleCollapse(event) {
this.items[event.target.index].closed = true;
this.items[Number(event.target.index)].closed = true;
this._numberOpen--;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@
label="Show buttons"
description="Show expand and collapse all buttons."
/>
<property
name="firstChild"
type="Boolean"
label="Render as first child"
description="Render as first child for margin purposes."
default="false"
/>
<property
name="className"
type="String"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</c-sf-gps-ds-configuration-error>

<template lwc:else>
<span if:false={firstChild}></span>
<div class={computedClassName}>
<span if:false={firstChild}></span>
<slot name="Block"></slot>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lwc:render-mode="light">
<div class="nsw-p-bottom-xs nsw-m-bottom-sm">
<div class={containerClassName}>
<nav class={computedClassName} aria-label={label}>
<ol class="nsw-breadcrumb__list nsw-breadcrumb__list--inline">
<template for:each={items} for:item="item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class SfGpsDsAuNswBreadcrumbs extends LightningElement {
static renderMode = "light";

@api label = "breadcrumbs";
@api containerClassName = "nsw-p-bottom-xs nsw-m-bottom-sm";
@api className = "";
@api items = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<c-sf-gps-ds-configuration-error
lwc:if={_sfGpsDsErrors}
errors={_sfGpsDsErrors}
>
</c-sf-gps-ds-configuration-error>

<c-sf-gps-ds-au-nsw-breadcrumbs
lwc:else
label={label}
items={_itemsArray}
container-class-name={containerClassName}
class-name={className}
>
</c-sf-gps-ds-au-nsw-breadcrumbs>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022, Emmanuel Schweitzer and salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { api, track } from "lwc";
import SfGpsDsLwc from "c/sfGpsDsLwc";
import mdEngine from "c/sfGpsDsMarkdown";

export default class extends SfGpsDsLwc {
@api label = "Breadcrumb";
@api linkComponent = "a";
@api containerClassName = "nsw-container nsw-p-bottom-sm";
@api className = "";

_items;
@track _itemsArray = [];

@api set items(markdown) {
this._items = markdown;
try {
this._itemsArray = mdEngine.extractLinks(markdown);
} catch (e) {
this.addError("IT-MD", "Issue when parsing Items markdown");
}
}

get items() {
return this._items;
}

/* lifecycle */

connectedCallback() {
super.connectedCallback();
this.classList.add("nsw-scope");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>NSW DS LWR Breadcrumbs</masterLabel>
<targets>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
<targetConfigs>
<targetConfig targets="lightningCommunity__Default">
<property
name="label"
type="String"
label="Aria label"
description="Label used for accessibility."
required="true"
default="Breadcrumbs"
/>
<property
name="items"
type="String"
label="Items"
description="Links to parent and current pages in Markdown format."
default="[Home](#)[Parent](#)[Current page]()"
/>
<property
name="linkComponent"
type="String"
label="Link component"
description="Component used to render the link."
datasource="a"
required="true"
default="a"
/>
<property
name="containerClassName"
type="String"
label="Class name"
description="Additional CSS class to be applied."
default="nsw-container nsw-p-bottom-sm"
/>
<property
name="className"
type="String"
label="Class name"
description="Additional CSS class to be applied."
/>
</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.
Loading

0 comments on commit 6a9bcf8

Please sign in to comment.