@govtechsg/sgds-web-component 3.2.0-rc.3 → 3.2.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Footer/index.umd.js +84 -40
- package/components/Footer/index.umd.js.map +1 -1
- package/components/Footer/sgds-footer.js +36 -41
- package/components/Footer/sgds-footer.js.map +1 -1
- package/components/index.umd.js +34 -40
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +34 -40
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Footer/sgds-footer.cjs.js +35 -40
- package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
- package/react/components/Footer/sgds-footer.js +36 -41
- package/react/components/Footer/sgds-footer.js.map +1 -1
- package/scripts/figma/sync-figma-to-tokens/__tests__/write-tokens-to-css-var.test.d.ts +0 -1
- package/src/components/Footer/sgds-footer.d.ts +1 -1
|
@@ -4136,6 +4136,56 @@
|
|
|
4136
4136
|
/** @internal */
|
|
4137
4137
|
SgdsElement.dependencies = {};
|
|
4138
4138
|
|
|
4139
|
+
class HasSlotController {
|
|
4140
|
+
constructor(host, ...slotNames) {
|
|
4141
|
+
this.slotNames = [];
|
|
4142
|
+
(this.host = host).addController(this);
|
|
4143
|
+
this.slotNames = slotNames;
|
|
4144
|
+
this.handleSlotChange = this.handleSlotChange.bind(this);
|
|
4145
|
+
}
|
|
4146
|
+
hasDefaultSlot() {
|
|
4147
|
+
return [...this.host.childNodes].some(node => {
|
|
4148
|
+
var _a;
|
|
4149
|
+
if (node.nodeType === node.TEXT_NODE && ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== "") {
|
|
4150
|
+
return true;
|
|
4151
|
+
}
|
|
4152
|
+
if (node.nodeType === node.ELEMENT_NODE) {
|
|
4153
|
+
const el = node;
|
|
4154
|
+
const tagName = el.tagName.toLowerCase();
|
|
4155
|
+
// Ignore visually hidden elements since they aren't rendered
|
|
4156
|
+
if (tagName === "sl-visually-hidden") {
|
|
4157
|
+
return false;
|
|
4158
|
+
}
|
|
4159
|
+
// If it doesn't have a slot attribute, it's part of the default slot
|
|
4160
|
+
if (!el.hasAttribute("slot")) {
|
|
4161
|
+
return true;
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
return false;
|
|
4165
|
+
});
|
|
4166
|
+
}
|
|
4167
|
+
hasNamedSlot(name) {
|
|
4168
|
+
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
4169
|
+
}
|
|
4170
|
+
test(slotName) {
|
|
4171
|
+
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
4172
|
+
}
|
|
4173
|
+
hostConnected() {
|
|
4174
|
+
var _a;
|
|
4175
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener("slotchange", this.handleSlotChange);
|
|
4176
|
+
}
|
|
4177
|
+
hostDisconnected() {
|
|
4178
|
+
var _a;
|
|
4179
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener("slotchange", this.handleSlotChange);
|
|
4180
|
+
}
|
|
4181
|
+
handleSlotChange(event) {
|
|
4182
|
+
const slot = event.target;
|
|
4183
|
+
if ((this.slotNames.includes("[default]") && !slot.name) || (slot.name && this.slotNames.includes(slot.name))) {
|
|
4184
|
+
this.host.requestUpdate();
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4139
4189
|
var css_248z$1 = css`.footer{container:footer/inline-size;height:auto}.footer-top{background-color:var(--sgds-bg-fixed-dark);border-bottom:var(--sgds-border-width-1) solid var(--sgds-border-color-default);gap:var(--sgds-gap-md);padding:var(--sgds-padding-xl) var(--sgds-padding-2-xl)}.footer-header,.footer-top{display:flex;flex-direction:column}.footer-header{gap:var(--sgds-gap-xs);margin:var(--sgds-margin-3-xs) 0}slot[name=title]::slotted(*){--sgds-header-color-default:var(--sgds-color-fixed-light);--sgds-font-size-6:var(--sgds-font-size-5);--sgds-margin-2-xs:var(--sgds-margin-none);color:var(--sgds-header-color-default,--sgds-color-fixed-light);font-size:var(--sgds-font-size-6,--sgds-font-size-5);font-weight:var(--sgds-font-weight-bold);letter-spacing:var(--sgds-letter-spacing-tight);line-height:var(--sgds-line-height-heading);margin-bottom:var(--sgds-margin-2-xs,--sgds-margin-none);margin-top:var(--sgds-margin-none)}slot[name=description]::slotted(*){--sgds-font-size-2:var(--sgds-font-size-3);--sgds-paragraph-spacing-xl:var(--sgds-margin-none);color:var(--sgds-color-fixed-light);font-size:var(--sgds-font-size-2,--sgds-font-size-3);margin-bottom:var(--sgds-paragraph-spacing-xl,--sgds-margin-none);margin-top:var(--sgds-margin-none)}.footer-items{display:grid;gap:var(--sgds-gap-md) var(--sgds-gap-lg);grid-template-columns:repeat(auto-fit,minmax(240px,1fr))}.footer ul{margin:0;padding:0}.footer ul li{list-style-type:none}.footer-mandatory-links ul li a{text-decoration:none}.footer-mandatory-links ul li a,.footer-mandatory-links ul li a:focus,.footer-mandatory-links ul li a:hover{color:var(--sgds-color-fixed-light)}.footer-mandatory-links ul li a:focus,.footer-mandatory-links ul li a:focus-visible{box-shadow:var(--sgds-box-shadow-focus);outline:0}.footer-bottom{background-color:var(--sgds-bg-fixed-dark);display:flex;flex-direction:column;gap:var(--sgds-gap-md);padding:var(--sgds-padding-xl) var(--sgds-padding-2-xl)}.social-media{display:flex;gap:var(--sgds-gap-sm)}slot[name=social-media]::slotted(a){--sgds-link-color-default:var(--sgds-color-fixed-light);--sgds-body-color-default:var(--sgds-color-fixed-light);color:var(--sgds-body-color-default,--sgds-link-color-default);display:inline-flex}slot[name=social-media]::slotted(a:hover){--sgds-link-color-emphasis:var(--sgds-color-fixed-light);color:var(--sgds-link-color-emphasis)}slot[name=social-media]::slotted(a:focus),slot[name=social-media]::slotted(a:focus-visible){--sgds-link-color-emphasis:var(--sgds-color-fixed-light);box-shadow:var(--sgds-box-shadow-focus);color:var(--sgds-link-color-emphasis);outline:0}.footer-mandatory-links{display:flex;flex-wrap:wrap;gap:var(--sgds-gap-xl) var(--sgds-gap-lg);justify-content:space-between}.footer-mandatory-links ul{display:flex;flex-wrap:wrap;gap:var(--sgds-gap-xs) var(--sgds-gap-xl)}.footer-copyrights{color:var(--sgds-color-fixed-light)}@container footer (max-width: 711px){.footer-bottom,.footer-top{padding:var(--sgds-padding-lg)}.footer-top{gap:var(--sgds-gap-lg)}.footer-mandatory-links,.footer-mandatory-links ul{flex-direction:column}}`;
|
|
4140
4190
|
|
|
4141
4191
|
/**
|
|
@@ -4174,51 +4224,45 @@
|
|
|
4174
4224
|
* href link for terms of use
|
|
4175
4225
|
*/
|
|
4176
4226
|
this.termsOfUseHref = "#";
|
|
4177
|
-
|
|
4178
|
-
firstUpdated() {
|
|
4179
|
-
const socialMediaSlot = this.shadowRoot.querySelector("slot[name='social-media']");
|
|
4180
|
-
const footerTitleSlot = this.shadowRoot.querySelector("slot[name='title']");
|
|
4181
|
-
const footerDescriptionSlot = this.shadowRoot.querySelector("slot[name='description']");
|
|
4182
|
-
const footerItemsSlot = this.shadowRoot.querySelector("slot[name='items']");
|
|
4183
|
-
const socialMediaChildNodes = socialMediaSlot.assignedNodes({ flatten: true });
|
|
4184
|
-
const footerTitleChildNodes = footerTitleSlot.assignedNodes({ flatten: true });
|
|
4185
|
-
const footerDescriptionChildNodes = footerDescriptionSlot.assignedNodes({ flatten: true });
|
|
4186
|
-
const footerItemsChildNodes = footerItemsSlot.assignedNodes({ flatten: true });
|
|
4187
|
-
if (socialMediaChildNodes.length === 0) {
|
|
4188
|
-
const socialMediaContainer = this.shadowRoot.querySelector(".social-media");
|
|
4189
|
-
socialMediaContainer.style.display = "none";
|
|
4190
|
-
}
|
|
4191
|
-
if (footerTitleChildNodes.length === 0 && footerDescriptionChildNodes.length === 0) {
|
|
4192
|
-
const footerHeaderContainer = this.shadowRoot.querySelector(".footer-header");
|
|
4193
|
-
footerHeaderContainer.style.display = "none";
|
|
4194
|
-
}
|
|
4195
|
-
if (footerItemsChildNodes.length === 0) {
|
|
4196
|
-
const footerItemsContainer = this.shadowRoot.querySelector(".footer-items");
|
|
4197
|
-
footerItemsContainer.style.display = "none";
|
|
4198
|
-
}
|
|
4199
|
-
if (footerTitleChildNodes.length === 0 &&
|
|
4200
|
-
footerDescriptionChildNodes.length === 0 &&
|
|
4201
|
-
footerItemsChildNodes.length === 0) {
|
|
4202
|
-
const footerTopContainer = this.shadowRoot.querySelector(".footer-top");
|
|
4203
|
-
footerTopContainer.style.display = "none";
|
|
4204
|
-
}
|
|
4227
|
+
this.hasSlotController = new HasSlotController(this, "social-media", "title", "description", "items");
|
|
4205
4228
|
}
|
|
4206
4229
|
render() {
|
|
4230
|
+
const hasSocialMediaSlot = this.hasSlotController.test("social-media");
|
|
4231
|
+
const hasTitleSlot = this.hasSlotController.test("title");
|
|
4232
|
+
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
4233
|
+
const hasItemsSlot = this.hasSlotController.test("items");
|
|
4234
|
+
const displayFooterHeader = hasTitleSlot || hasDescriptionSlot;
|
|
4235
|
+
const displayFooterItems = hasItemsSlot;
|
|
4236
|
+
const displaySocialMedia = hasSocialMediaSlot;
|
|
4237
|
+
const displayFooterTop = displayFooterHeader || displayFooterItems;
|
|
4207
4238
|
return html `
|
|
4208
4239
|
<footer class="footer">
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4240
|
+
${displayFooterTop
|
|
4241
|
+
? html ` <section class="footer-top">
|
|
4242
|
+
${displayFooterHeader
|
|
4243
|
+
? html `
|
|
4244
|
+
<div class="footer-header">
|
|
4245
|
+
<slot name="title"></slot>
|
|
4246
|
+
<slot name="description"></slot>
|
|
4247
|
+
</div>
|
|
4248
|
+
`
|
|
4249
|
+
: nothing}
|
|
4250
|
+
${displayFooterItems
|
|
4251
|
+
? html ` <div class="footer-items">
|
|
4252
|
+
<slot name="items"></slot>
|
|
4253
|
+
</div>`
|
|
4254
|
+
: nothing}
|
|
4255
|
+
</section>`
|
|
4256
|
+
: nothing}
|
|
4257
|
+
|
|
4218
4258
|
<section class="footer-bottom">
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4259
|
+
${displaySocialMedia
|
|
4260
|
+
? html `
|
|
4261
|
+
<div class="social-media">
|
|
4262
|
+
<slot name="social-media"></slot>
|
|
4263
|
+
</div>
|
|
4264
|
+
`
|
|
4265
|
+
: nothing}
|
|
4222
4266
|
<div class="footer-mandatory-links">
|
|
4223
4267
|
<ul>
|
|
4224
4268
|
<li><a href=${this.contactHref}>Contact</a></li>
|