From 02bf866645e1b6a62ab7a90ee93db901ba66bd82 Mon Sep 17 00:00:00 2001 From: Mark Perry <124626043+markpadbe@users.noreply.github.com> Date: Mon, 9 Dec 2024 01:18:59 -0800 Subject: [PATCH 1/8] MWPW-161015 Adds new segment-timeline classes (#3328) * Initial updates to handle new UX requirements * Add segment udpates * Fix class * Fix center text * rtl updates for segments * Remove rtl test * Add back padding * Fix padding and columns * Add fix for bad class * Remove comment * Update tests * Fix test * Update libs/blocks/timeline/timeline.js --------- Co-authored-by: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> --- libs/blocks/timeline/timeline.css | 127 ++++++++++++++++-- libs/blocks/timeline/timeline.js | 30 ++++- .../timeline/mocks/brokensegmentclass.html | 22 +++ .../blocks/timeline/mocks/segmentclasses.html | 22 +++ test/blocks/timeline/timeline.test.js | 37 ++++- 5 files changed, 220 insertions(+), 18 deletions(-) create mode 100644 test/blocks/timeline/mocks/brokensegmentclass.html create mode 100644 test/blocks/timeline/mocks/segmentclasses.html diff --git a/libs/blocks/timeline/timeline.css b/libs/blocks/timeline/timeline.css index ebf0842787..58635b9bc8 100644 --- a/libs/blocks/timeline/timeline.css +++ b/libs/blocks/timeline/timeline.css @@ -4,6 +4,7 @@ width: 100%; margin: 0 auto; } + .dialog-modal .timeline { padding: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl); } @@ -12,6 +13,22 @@ display: grid; } +.timeline.segment-timeline-3-9 .row, +.timeline.segment-timeline-4-8 .row, +.timeline.segment-timeline-5-7 .row { + grid-template-columns: 1fr 58.3%; +} + +.timeline.segment-timeline-6-6 .row { + grid-template-columns: 50% 50%; +} + +.timeline.segment-timeline-7-5 .row, +.timeline.segment-timeline-8-4 .row, +.timeline.segment-timeline-9-3 .row { + grid-template-columns: 1fr 41.7%; +} + .timeline h1, .timeline h2, .timeline h3, @@ -40,7 +57,6 @@ .timeline .row:nth-of-type(1)>.left>div>* { max-width: 100px; - padding-right: var(--spacing-m); } .dark .timeline .row:nth-child(3)>div *, @@ -59,7 +75,68 @@ } .timeline .row:nth-of-type(1)>.right { - grid-template-columns: minmax(110px, 1fr) 1fr; + grid-template-columns: 1.5fr 1fr; + grid-gap: 8px; +} + +[dir="rtl"] .timeline .row:nth-of-type(1)>.right { + grid-template-columns: 1fr 1fr; +} + +.timeline.segment-timeline-3-9 .left-center, +.timeline.segment-timeline-4-8 .left-center, +.timeline.segment-timeline-5-7 .left-center, +.timeline.segment-timeline-6-6 .left-center { + display: none; +} +@media screen and (max-width: 599.99px) { + .timeline.segment-timeline-7-5 .row:nth-of-type(1)>.right, + .timeline.segment-timeline-8-4 .row:nth-of-type(1)>.right, + .timeline.segment-timeline-9-3 .row:nth-of-type(1)>.right { + grid-template-columns: 1fr; + } + + .timeline.segment-timeline-7-5 .row:nth-of-type(1)>.left, + .timeline.segment-timeline-8-4 .row:nth-of-type(1)>.left, + .timeline.segment-timeline-9-3 .row:nth-of-type(1)>.left { + grid-template-columns: 1fr 1.5fr; + display: grid; + justify-content: space-between; + grid-gap: 8px; + } + + .timeline.segment-timeline-7-5 .right-center, + .timeline.segment-timeline-8-4 .right-center, + .timeline.segment-timeline-9-3 .right-center { + display: none; + } + + .timeline.segment-timeline-7-5 .left-center, + .timeline.segment-timeline-8-4 .left-center, + .timeline.segment-timeline-9-3 .left-center { + text-align: right; + display: flex; + flex-direction: column; + align-items: flex-end; + } + + [dir="rtl"] .timeline.segment-timeline-7-5 .left-center, + [dir="rtl"] .timeline.segment-timeline-8-4 .left-center, + [dir="rtl"] .timeline.segment-timeline-9-3 .left-center { + text-align: left; + } + + .timeline .row:nth-of-type(1)>.left .left-center>* { + padding-right: 0; + } +} + +@media screen and (min-width: 600px) { + .timeline.segment-timeline-7-5 .left-center, + .timeline.segment-timeline-8-4 .left-center, + .timeline.segment-timeline-9-3 .left-center { + display: none; + } } .timeline .row:nth-of-type(2)>.right { @@ -68,7 +145,7 @@ .timeline .row:nth-of-type(1)>.right>div:nth-of-type(1) { max-width: 135px; - padding-right: var(--spacing-xxs); + /* padding-right: var(--spacing-xxs); */ } .timeline .bar { @@ -103,10 +180,18 @@ } [dir="rtl"] .timeline .row:nth-of-type(1)>.left>div>* { - padding: 0 0 0 var(--spacing-m); + /* padding: 0 0 0 var(--spacing-m); */ + padding: 0; text-align: right; } +[dir="rtl"] .timeline.timeline.segment-timeline-7-5 .row:nth-of-type(1)>.left>.left-center>*, +[dir="rtl"] .timeline.timeline.segment-timeline-8-4 .row:nth-of-type(1)>.left>.left-center>*, +[dir="rtl"] .timeline.timeline.segment-timeline-9-3 .row:nth-of-type(1)>.left>.left-center>* { + padding: 0; + text-align: left; +} + [dir="rtl"] .timeline .row:nth-of-type(1)>.right>div+div { padding: 0 0 var(--spacing-xxs) 0; text-align: left; @@ -120,15 +205,40 @@ margin: 0 3px 0 0; } -[dir="rtl"] .timeline .row:nth-of-type(1)>.right>div:nth-of-type(1) { - padding: 0 0 0 var(--spacing-xxs); -} - @media screen and (min-width: 600px) { .dialog-modal .timeline { padding: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl); } } +@media screen and (min-width: 1200px) { + .timeline.segment-timeline-3-9 .row { + grid-template-columns: 1fr 75% + } + + .timeline.segment-timeline-4-8 .row { + grid-template-columns: 1fr 66.69%; + } + + .timeline.segment-timeline-5-7 .row { + grid-template-columns: 1fr 58.3%; + } + + .timeline.segment-timeline-6-6 .row { + grid-template-columns: 1fr 50%; + } + + .timeline.segment-timeline-7-5 .row { + grid-template-columns: 1fr 41.7%; + } + + .timeline.segment-timeline-8-4 .row { + grid-template-columns: 1fr 33.3%; + } + + .timeline.segment-timeline-9-3 .row { + grid-template-columns: 1fr 25%; + } +} @media screen and (min-width:1120px) { .timeline { @@ -140,4 +250,3 @@ padding: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl); } } - diff --git a/libs/blocks/timeline/timeline.js b/libs/blocks/timeline/timeline.js index ba2ea4aacf..035ef739ac 100644 --- a/libs/blocks/timeline/timeline.js +++ b/libs/blocks/timeline/timeline.js @@ -14,7 +14,20 @@ function isColorOrGradient(str) { return isColor(str) || isGradient(str); } -function getColWidth(text, colWidths) { +function hasSegmentClass(el) { + const segmentClassRegex = /^segment-timeline-(3-9|4-8|5-7|6-6|7-5|8-4|9-3)$/; + const startsWithSegmentTimelineRegex = /^segment-timeline-/; + let hasValidSegmentClass = Array.from(el.classList).some((cls) => segmentClassRegex.test(cls)); + if (!hasValidSegmentClass + && Array.from(el.classList).some((cls) => startsWithSegmentTimelineRegex.test(cls))) { + el.classList.add('segment-timeline-6-6'); + hasValidSegmentClass = true; + } + return hasValidSegmentClass; +} + +function getColWidth(text, colWidths, hasSegment) { + if (hasSegment || colWidths.length === 2) return; const numRegex = /\b\d{1,3}\b/; colWidths.push((text.match(numRegex) || [])[0]); } @@ -109,8 +122,8 @@ function setColors(colors, fragment, el) { function colWidthsNotValid(colWidths) { return (colWidths.length !== 2 || colWidths.some((value) => Number.isNaN(value))); } -function updateColWidths(colWidths, fragment) { - if (colWidthsNotValid(colWidths)) return; +function updateColWidths(colWidths, fragment, hasSegment) { + if (colWidthsNotValid(colWidths) || hasSegment) return; const total = Number(colWidths[0]) + Number(colWidths[1]); const right = Math.floor((Number(colWidths[1]) / total) * 10000) / 100; const colString = `1fr minmax(${String(right)}%, 150px)`; @@ -123,6 +136,7 @@ export default function init(el) { const [textRow, left, right] = createRow(); const rows = el.querySelectorAll(':scope > div > div'); const colors = []; const periodText = []; const colWidths = []; + const hasSegment = hasSegmentClass(el); rows.forEach((row, index) => { const side = index === 0 ? left : right; const color = row.firstElementChild?.textContent?.trim(); @@ -131,7 +145,7 @@ export default function init(el) { const [text, period] = p.textContent.trim().split('|'); if (period) { periodText.push(period.trim()); - getColWidth(period, colWidths); + getColWidth(period, colWidths, hasSegment); } if (text) { p.textContent = text.trim(); @@ -143,11 +157,17 @@ export default function init(el) { row.firstElementChild.remove(); } row.parentElement.remove(); + if (index === 1 && hasSegment) { + const mobileCenterLeft = row.cloneNode(true); + mobileCenterLeft.classList.add('left-center'); + left.append(mobileCenterLeft); + row.classList.add('right-center'); + } side.append(row); }); textRow.append(left, right); [textRow, addBarRow(), addBottomRow(periodText)].forEach((row) => fragment.append(row)); - updateColWidths(colWidths, fragment, el); + updateColWidths(colWidths, fragment, hasSegment); setColors(colors, fragment, el); el.append(fragment); } diff --git a/test/blocks/timeline/mocks/brokensegmentclass.html b/test/blocks/timeline/mocks/brokensegmentclass.html new file mode 100644 index 0000000000..acba31bd95 --- /dev/null +++ b/test/blocks/timeline/mocks/brokensegmentclass.html @@ -0,0 +1,22 @@ +
+
+
+

linear-gradient(to right, #E63888 0, #E9740A 100%)

+

Day 1

+

If you start your free trial today | 14 -day free trial

+
+
+
+
+

#FFCE2E

+

Day 8

+

Your subscription starts and billing begins | 7 -day full refund period

+
+
+
+
+

Day 21

+

Full refund period ends

+
+
+
diff --git a/test/blocks/timeline/mocks/segmentclasses.html b/test/blocks/timeline/mocks/segmentclasses.html new file mode 100644 index 0000000000..f00d2e3dd3 --- /dev/null +++ b/test/blocks/timeline/mocks/segmentclasses.html @@ -0,0 +1,22 @@ +
+
+
+

linear-gradient(to right, #E63888 0, #E9740A 100%)

+

Day 1

+

If you start your free trial today | 14 -day free trial

+
+
+
+
+

#FFCE2E

+

Day 8

+

Your subscription starts and billing begins | 7 -day full refund period

+
+
+
+
+

Day 21

+

Full refund period ends

+
+
+
diff --git a/test/blocks/timeline/timeline.test.js b/test/blocks/timeline/timeline.test.js index 204f3719a6..17478d3794 100644 --- a/test/blocks/timeline/timeline.test.js +++ b/test/blocks/timeline/timeline.test.js @@ -41,7 +41,7 @@ describe('Timeline', () => { expect(trialPeriod.textContent).to.equal('7-day free trial'); expect(refundPeriod.textContent).to.equal('14-day full refund period'); - expect(trialPeriod.style.background.includes('to right')).to.true; + expect(trialPeriod.style.background.includes('to right')).to.be.true; }); it('it sets bar background colors based on colors in free trial and refund period section', async () => { const timelineEl = document.querySelector('.timeline'); @@ -59,19 +59,48 @@ describe('Timeline', () => { const trialPeriod = timelineEl.querySelector('.row .left .period'); expect(trialPeriod.style.background.includes('to left')).to.be.true; }); - describe('Timeline', () => { + describe('rtl ', () => { beforeEach(async () => { document.body.innerHTML = await readFile({ path: './mocks/switchcolors.html' }); }); afterEach(() => { document.body.innerHTML = ''; }); - it('handles linear-gradient for either side', async () => { + it('updates linear-gradient for rtl', async () => { const timelineEl = document.querySelector('.timeline'); init(timelineEl); const refundPeriod = timelineEl.querySelector('.row .right .period'); expect(refundPeriod.textContent).to.equal('14-day full refund period'); - expect(refundPeriod.style.background.includes('to left')).to.true; + expect(refundPeriod.style.background.includes('to left')).to.be.true; + }); + }); + describe('segment classes', () => { + beforeEach(async () => { + document.body.innerHTML = await readFile({ path: './mocks/segmentclasses.html' }); + }); + afterEach(() => { + document.body.innerHTML = ''; + }); + it('adds classes to handle center text alignment', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + const leftCenter = timelineEl.querySelector('.row .left-center'); + const rightCenter = timelineEl.querySelector('.row .right-center'); + expect(rightCenter).to.exist; + expect(leftCenter).to.exist; + }); + }); + describe('broken segment classes', () => { + beforeEach(async () => { + document.body.innerHTML = await readFile({ path: './mocks/brokensegmentclass.html' }); + }); + afterEach(() => { + document.body.innerHTML = ''; + }); + it('replaces broken segment class width segment-timeline-6-6', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + expect(timelineEl.classList.contains('segment-timeline-6-6')).to.be.true; }); }); }); From e9f0bf268301092d5174a6c0bf377c9506f58e4c Mon Sep 17 00:00:00 2001 From: Bandana Laishram Date: Mon, 9 Dec 2024 14:49:06 +0530 Subject: [PATCH 2/8] Adding Standalone gnav's default allowed origins (#3329) * Fix: Setting allowedOrigins for standalone gnav * Fix: Default handling --- libs/navigation/navigation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/navigation/navigation.js b/libs/navigation/navigation.js index 3c26aabb6d..9b3fc5ed67 100644 --- a/libs/navigation/navigation.js +++ b/libs/navigation/navigation.js @@ -65,7 +65,7 @@ export default async function loadBlock(configs, customLib) { env = 'prod', locale = '', theme, - allowedOrigins, + allowedOrigins = [], stageDomainsMap = {}, } = configs || {}; if (!header && !footer) { @@ -112,7 +112,7 @@ export default async function loadBlock(configs, customLib) { theme, ...paramConfigs, prodDomains, - allowedOrigins, + allowedOrigins: [...allowedOrigins, `https://main--federal--adobecom.aem.${env === 'prod' ? 'live' : 'page'}`], standaloneGnav: true, stageDomainsMap: getStageDomainsMap(stageDomainsMap), }; From 81a5770cecc2a17f07efe5229c65b71d2dbb9bb4 Mon Sep 17 00:00:00 2001 From: Ryan Parrish Date: Mon, 9 Dec 2024 02:19:13 -0700 Subject: [PATCH 3/8] MWPW-140452 - Icon authoring in milo using the federal repo and individual SVG assets (#3259) * updated features/icons to pull from federal and allow the icons set to be sharepoint authorable * bettter icon-spacing handling * preload federated.js instead of non used icons.svg on util decorateIcon() * Updated preload federated as script type not fetch * Minor clean up based on pr feedback * remove console * addressed some issues found w/ icons not rending in tables due to race condition w/ decorateIcon() * lana instead of console * no 100% height * coverage * full coverage * minor cleanup * minor cleanup * preload first section icons, spread syntax * no cons * Performace refactor - loadIcons to hold most related functionallity. Preloaded inView icons and defered others till postSectionLoad. * async decTooltips and refactor to not chain func calls * fix: icon alignment in georouting modal's button * move render blocking code to utils * fix import of test method * remove condition that causes error when no icon is in view * remove redundant link load * remove extra federated.js import * small change to push branch * Fed Icons - Table icon decoration and collapse icon wrapping (#3202) * reselect icons after area is decorated * fix inline margin issue in table collapse titles --------- Co-authored-by: Saugat Malla Co-authored-by: Saugat Malla Co-authored-by: Sartxi --- libs/blocks/table/table.css | 1 + libs/blocks/text/text.css | 7 +- libs/features/georoutingv2/georoutingv2.css | 1 + libs/features/georoutingv2/georoutingv2.js | 2 +- libs/features/icons/icons.css | 2 +- libs/features/icons/icons.js | 118 ++++++++++++++++---- libs/styles/styles.css | 30 +++-- libs/utils/utils.js | 43 ++++--- test/features/icons/icons.test.js | 61 +++++----- test/features/icons/mocks/body.html | 4 +- 10 files changed, 188 insertions(+), 81 deletions(-) diff --git a/libs/blocks/table/table.css b/libs/blocks/table/table.css index 19eb5beed9..d2476a42ce 100644 --- a/libs/blocks/table/table.css +++ b/libs/blocks/table/table.css @@ -360,6 +360,7 @@ width: 15px; height: 15px; cursor: pointer; + margin-inline: unset; } .table .section-head-title:hover .icon.expand { diff --git a/libs/blocks/text/text.css b/libs/blocks/text/text.css index 6242f50132..f8cbefd365 100644 --- a/libs/blocks/text/text.css +++ b/libs/blocks/text/text.css @@ -100,7 +100,7 @@ position: relative; } -.text-block .icon-list-item .icon.margin-right:not(.margin-left) { /* target first node only */ +.text-block .icon-list-item .icon.node-index-first { position: absolute; inset: 0 100% auto auto; } @@ -122,7 +122,6 @@ .text-block .icon-area { display: flex; - column-gap: var(--spacing-xs); } .text-block p.icon-area { /* NOT tags with icons in them */ @@ -218,10 +217,6 @@ max-width: unset; } -.text-block .icon-area.con-button { - column-gap: unset; -} - .text-block .icon-area picture { line-height: 0em; height: inherit; /* Safari + FF bug fix */ diff --git a/libs/features/georoutingv2/georoutingv2.css b/libs/features/georoutingv2/georoutingv2.css index 255ba3f301..09df2cba8b 100644 --- a/libs/features/georoutingv2/georoutingv2.css +++ b/libs/features/georoutingv2/georoutingv2.css @@ -83,6 +83,7 @@ } .dialog-modal.locale-modal-v2 span.icon { + display: inline; vertical-align: middle; } diff --git a/libs/features/georoutingv2/georoutingv2.js b/libs/features/georoutingv2/georoutingv2.js index 7213696f63..236e9b685a 100644 --- a/libs/features/georoutingv2/georoutingv2.js +++ b/libs/features/georoutingv2/georoutingv2.js @@ -194,7 +194,7 @@ function buildContent(currentPage, locale, geoData, locales) { { once: true }, ); img.src = `${config.miloLibs || config.codeRoot}/img/georouting/${flagFile}`; - const span = createTag('span', { class: 'icon margin-inline-end' }, img); + const span = createTag('span', { class: 'icon node-index-first' }, img); const mainAction = createTag('a', { class: 'con-button blue button-l', lang, role: 'button', 'aria-haspopup': !!locales, 'aria-expanded': false, href: '#', }, span); diff --git a/libs/features/icons/icons.css b/libs/features/icons/icons.css index f1a8ce53f9..1b095e97dc 100644 --- a/libs/features/icons/icons.css +++ b/libs/features/icons/icons.css @@ -4,7 +4,7 @@ border-bottom: none; } -.milo-tooltip::before { +.milo-tooltip::before { content: attr(data-tooltip); position: absolute; top: 50%; diff --git a/libs/features/icons/icons.js b/libs/features/icons/icons.js index 975c0625dc..a39ff61e06 100644 --- a/libs/features/icons/icons.js +++ b/libs/features/icons/icons.js @@ -1,5 +1,9 @@ +import { getFederatedContentRoot } from '../../utils/federated.js'; +import { loadLink, loadStyle } from '../../utils/utils.js'; + let fetchedIcons; let fetched = false; +const federalIcons = {}; async function getSVGsfromFile(path) { /* c8 ignore next */ @@ -22,6 +26,7 @@ async function getSVGsfromFile(path) { return miloIcons; } +// TODO: remove after all consumers have stopped calling this method // eslint-disable-next-line no-async-promise-executor export const fetchIcons = (config) => new Promise(async (resolve) => { /* c8 ignore next */ @@ -34,10 +39,10 @@ export const fetchIcons = (config) => new Promise(async (resolve) => { resolve(fetchedIcons); }); -function decorateToolTip(icon) { +async function decorateToolTip(icon) { const wrapper = icon.closest('em'); - wrapper.className = 'tooltip-wrapper'; if (!wrapper) return; + wrapper.className = 'tooltip-wrapper'; const conf = wrapper.textContent.split('|'); // Text is the last part of a tooltip const content = conf.pop().trim(); @@ -45,30 +50,101 @@ function decorateToolTip(icon) { icon.dataset.tooltip = content; // Position is the next to last part of a tooltip const place = conf.pop()?.trim().toLowerCase() || 'right'; - icon.className = `icon icon-info milo-tooltip ${place}`; + const defaultIcon = 'info-outline'; + icon.className = `icon icon-${defaultIcon} milo-tooltip ${place}`; + icon.dataset.name = defaultIcon; wrapper.parentElement.replaceChild(icon, wrapper); } -export default async function loadIcons(icons, config) { - const iconSVGs = await fetchIcons(config); - if (!iconSVGs) return; +export function getIconData(icon) { + const fedRoot = getFederatedContentRoot(); + const name = [...icon.classList].find((c) => c.startsWith('icon-'))?.substring(5); + const path = `${fedRoot}/federal/assets/icons/svgs/${name}.svg`; + return { path, name }; +} + +function preloadInViewIconResources(config) { + const { base } = config; + loadStyle(`${base}/features/icons/icons.css`); +} + +const preloadInViewIcons = async (icons = []) => icons.forEach((icon) => { + const { path } = getIconData(icon); + loadLink(path, { rel: 'preload', as: 'fetch', crossorigin: 'anonymous' }); +}); + +function filterDuplicatedIcons(icons) { + if (!icons.length) return []; + const uniqueIconKeys = new Set(); + const uniqueIcons = []; + for (const icon of icons) { + const key = [...icon.classList].find((c) => c.startsWith('icon-'))?.substring(5); + if (!uniqueIconKeys.has(key)) { + uniqueIconKeys.add(key); + uniqueIcons.push(icon); + } + } + return uniqueIcons; +} + +export async function decorateIcons(area, icons, config) { + if (!icons.length) return; + const uniqueIcons = filterDuplicatedIcons(icons); + if (!uniqueIcons.length) return; + preloadInViewIcons(uniqueIcons); + preloadInViewIconResources(config); + icons.forEach((icon) => { + const iconName = [...icon.classList].find((c) => c.startsWith('icon-'))?.substring(5); + if (!iconName) return; + icon.dataset.name = iconName; + }); +} + +export default async function loadIcons(icons) { + const fedRoot = getFederatedContentRoot(); + const iconRequests = []; + const iconsToFetch = new Map(); + icons.forEach(async (icon) => { - const { classList } = icon; - if (classList.contains('icon-tooltip')) decorateToolTip(icon); - const iconName = icon.classList[1].replace('icon-', ''); - const existingIcon = icon.querySelector('svg'); - if (!iconSVGs[iconName] || existingIcon) return; + const isToolTip = icon.classList.contains('icon-tooltip'); + if (isToolTip) decorateToolTip(icon); + const iconName = icon.dataset.name; + if (icon.dataset.svgInjected || !iconName) return; + if (!federalIcons[iconName] && !iconsToFetch.has(iconName)) { + const url = `${fedRoot}/federal/assets/icons/svgs/${iconName}.svg`; + iconsToFetch.set(iconName, fetch(url) + .then(async (res) => { + if (!res.ok) throw new Error(`Failed to fetch SVG for ${iconName}: ${res.statusText}`); + const text = await res.text(); + const parser = new DOMParser(); + const svgDoc = parser.parseFromString(text, 'image/svg+xml'); + const svgElement = svgDoc.querySelector('svg'); + if (!svgElement) { + window.lana?.log(`No SVG element found in fetched content for ${iconName}`); + return; + } + const svgClone = svgElement.cloneNode(true); + svgClone.classList.add('icon-milo', `icon-milo-${iconName}`); + federalIcons[iconName] = svgClone; + }) + /* c8 ignore next 3 */ + .catch((error) => { + window.lana?.log(`Error fetching SVG for ${iconName}:`, error); + })); + } + iconRequests.push(iconsToFetch.get(iconName)); const parent = icon.parentElement; - if (parent.childNodes.length > 1) { - if (parent.lastChild === icon) { - icon.classList.add('margin-inline-start'); - } else if (parent.firstChild === icon) { - icon.classList.add('margin-inline-end'); - if (parent.parentElement.tagName === 'LI') parent.parentElement.classList.add('icon-list-item'); - } else { - icon.classList.add('margin-inline-start', 'margin-inline-end'); - } + if (parent && parent.parentElement.tagName === 'LI') parent.parentElement.classList.add('icon-list-item'); + }); + + await Promise.all(iconRequests); + + icons.forEach((icon) => { + const iconName = icon.dataset.name; + if (iconName && federalIcons[iconName] && !icon.dataset.svgInjected) { + const svgClone = federalIcons[iconName].cloneNode(true); + icon.appendChild(svgClone); + icon.dataset.svgInjected = 'true'; } - icon.insertAdjacentHTML('afterbegin', iconSVGs[iconName].outerHTML); }); } diff --git a/libs/styles/styles.css b/libs/styles/styles.css index 839966a67e..66893a7c18 100644 --- a/libs/styles/styles.css +++ b/libs/styles/styles.css @@ -128,6 +128,7 @@ --icon-size-s: 32px; --icon-size-xs: 24px; --icon-size-xxs: 16px; + --icon-spacing: 8px; /* z-index */ --above-all: 9000; /* Used for page tools that overlay page content */ @@ -349,6 +350,7 @@ line-height: 20px; min-height: 21px; padding: 7px 18px 8px; + --icon-spacing: 12px; } .xl-button .con-button, @@ -358,6 +360,7 @@ line-height: 24px; min-height: 28px; padding: 10px 24px 8px; + --icon-spacing: 14px; } .xxl-button .con-button, @@ -367,6 +370,7 @@ line-height: 27px; min-height: 27px; padding: 14px 30px 15px; + --icon-spacing: 14px; } .con-button.button-justified { @@ -559,19 +563,23 @@ div[data-failed="true"]::before { color: var(--color-gray-300); } -span.icon.margin-right { margin-right: 8px; } - -span.icon.margin-left { margin-left: 8px; } - -span.icon.margin-inline-end { margin-inline-end: 8px; } - -span.icon.margin-inline-start { margin-inline-start: 8px; } +span.icon { + width: 1em; + display: inline-block; + margin-inline: var(--icon-spacing); +} -.button-l .con-button span.icon.margin-left, -.con-button.button-l span.icon.margin-left { margin-left: 12px; } +span.icon.node-index-first { margin-inline-start: unset; } +span.icon.node-index-middle { margin-inline: var(--icon-spacing); } +span.icon.node-index-last { margin-inline-end: unset; } +span.icon.node-index-only { margin-inline: unset; } -.button-xl .con-button span.icon.margin-left, -.con-button.button-xl span.icon.margin-left { margin-left: 14px; } +span.icon svg { + height: 1em; + position: relative; + top: .1em; + width: auto; +} /* Con Block Utils */ .con-block.xs-spacing { padding: var(--spacing-xs) 0; } diff --git a/libs/utils/utils.js b/libs/utils/utils.js index c96169a3de..1b8ab85f83 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -789,16 +789,6 @@ function decorateHeader() { if (promo?.length) header.classList.add('has-promo'); } -async function decorateIcons(area, config) { - const icons = area.querySelectorAll('span.icon'); - if (icons.length === 0) return; - const { base } = config; - loadStyle(`${base}/features/icons/icons.css`); - loadLink(`${base}/img/icons/icons.svg`, { rel: 'preload', as: 'fetch', crossorigin: 'anonymous' }); - const { default: loadIcons } = await import('../features/icons/icons.js'); - await loadIcons(icons, config); -} - export async function customFetch({ resource, withCacheRules }) { const options = {}; if (withCacheRules) { @@ -1275,9 +1265,8 @@ function decorateDocumentExtras() { decorateHeader(); } -async function documentPostSectionLoading(config) { +async function documentPostSectionLoading(area, config) { decorateFooterPromo(); - const appendage = getMetadata('title-append'); if (appendage) { import('../features/title-append/title-append.js').then((module) => module.default(appendage)); @@ -1341,6 +1330,18 @@ async function resolveInlineFrags(section) { section.preloadLinks = newlyDecoratedSection.preloadLinks; } +export function setIconsIndexClass(icons) { + [...icons].forEach((icon) => { + const parent = icon.parentNode; + const children = parent.childNodes; + const nodeIndex = [...children].indexOf.call(children, icon); + let indexClass = (nodeIndex === children.length - 1) ? 'last' : 'middle'; + if (nodeIndex === 0) indexClass = 'first'; + if (children.length === 1) indexClass = 'only'; + icon.classList.add(`node-index-${indexClass}`); + }); +} + async function processSection(section, config, isDoc) { await resolveInlineFrags(section); const firstSection = section.el.dataset.idx === '0'; @@ -1348,7 +1349,6 @@ async function processSection(section, config, isDoc) { preloadBlockResources(section.preloadLinks); await Promise.all([ decoratePlaceholders(section.el, config), - decorateIcons(section.el, config), ]); const loadBlocks = [...stylePromises]; if (section.preloadLinks.length) { @@ -1381,6 +1381,11 @@ export async function loadArea(area = document) { decorateDocumentExtras(); } + const allIcons = area.querySelectorAll('span.icon'); + if (allIcons.length) { + setIconsIndexClass(allIcons); + } + const sections = decorateSections(area, isDoc); const areaBlocks = []; @@ -1393,13 +1398,21 @@ export async function loadArea(area = document) { }); } + if (allIcons.length) { + const { default: loadIcons, decorateIcons } = await import('../features/icons/icons.js'); + const areaIcons = area.querySelectorAll('span.icon'); + await decorateIcons(area, areaIcons, config); + await loadIcons(areaIcons); + } + const currentHash = window.location.hash; if (currentHash) { scrollToHashedElement(currentHash); } - if (isDoc) await documentPostSectionLoading(config); - + if (isDoc) { + await documentPostSectionLoading(area, config); + } await loadDeferred(area, areaBlocks, config); } diff --git a/test/features/icons/icons.test.js b/test/features/icons/icons.test.js index cd355a0aff..cb3cb994db 100644 --- a/test/features/icons/icons.test.js +++ b/test/features/icons/icons.test.js @@ -1,45 +1,56 @@ import { readFile } from '@web/test-runner-commands'; import { expect } from '@esm-bundle/chai'; -import { stub } from 'sinon'; -import { setConfig, getConfig, createTag } from '../../../libs/utils/utils.js'; +import sinon, { stub } from 'sinon'; +import { waitForElement } from '../../helpers/waitfor.js'; -const { default: loadIcons } = await import('../../../libs/features/icons/icons.js'); - -const codeRoot = '/libs'; -const conf = { codeRoot }; -setConfig(conf); -const config = getConfig(); +const { default: loadIcons, getIconData } = await import('../../../libs/features/icons/icons.js'); +const { setIconsIndexClass } = await import('../../../libs/utils/utils.js'); +const mockRes = ({ payload, status = 200, ok = true } = {}) => new Promise((resolve) => { + resolve({ + status, + ok, + json: () => payload, + text: () => payload, + }); +}); document.body.innerHTML = await readFile({ path: './mocks/body.html' }); let icons; +const svgEx = ` + + +`; describe('Icon Suppprt', () => { - let paramsGetStub; - - before(() => { - paramsGetStub = stub(URLSearchParams.prototype, 'get'); - paramsGetStub.withArgs('cache').returns('off'); + beforeEach(() => { + stub(window, 'fetch').callsFake(() => mockRes({})); }); - after(() => { - paramsGetStub.restore(); + afterEach(() => { + sinon.restore(); }); - before(async () => { + it('Replaces span.icon', async () => { + const payload = svgEx; + window.fetch.returns(mockRes({ payload })); + icons = document.querySelectorAll('span.icon'); - await loadIcons(icons, config); - await loadIcons(icons, config); // Test duplicate icon not created if run twice - }); + icons.forEach((icon) => { + const { name } = getIconData(icon); + icon.dataset.name = name; + }); + await loadIcons(icons); - it('Fetches successfully with cache control enabled', async () => { - const otherIcons = [createTag('span', { class: 'icon icon-play' })]; - await loadIcons(otherIcons, config); + const selector = await waitForElement('span.icon svg'); + expect(selector).to.exist; }); - it('Replaces span.icon', async () => { - const selector = icons[0].querySelector(':scope svg'); - expect(selector).to.exist; + it('Sets icon index class', async () => { + icons = document.querySelectorAll('span.icon'); + setIconsIndexClass(icons); + const secondIconHasIndexClass = icons[2].classList.contains('node-index-last'); + expect(secondIconHasIndexClass).to.be.true; }); it('No duplicate icon', async () => { diff --git a/test/features/icons/mocks/body.html b/test/features/icons/mocks/body.html index 586013bf4f..2d908a81ca 100644 --- a/test/features/icons/mocks/body.html +++ b/test/features/icons/mocks/body.html @@ -1,4 +1,6 @@ -
+
+ +
From 93b846c43fccb8e0817c978c85b6d68991f4685e Mon Sep 17 00:00:00 2001 From: Rares Munteanu Date: Mon, 9 Dec 2024 10:58:31 +0100 Subject: [PATCH 4/8] [MWPW-163539] Update RCP workflow (#3296) --- .github/workflows/helpers.js | 11 +++++++++-- .github/workflows/merge-to-main.js | 3 ++- .github/workflows/merge-to-main.yaml | 1 + .github/workflows/merge-to-stage.js | 2 +- .github/workflows/rcp-notifier.js | 12 ++++++++---- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/helpers.js b/.github/workflows/helpers.js index dcc7b0025d..b8b733eb0c 100644 --- a/.github/workflows/helpers.js +++ b/.github/workflows/helpers.js @@ -43,7 +43,11 @@ const RCPDates = [ }, ]; -const isWithinRCP = (offset = 0) => { +const isShortRCP = (start, end) => { + return ((end - start) / (1000 * 60 * 60)) < 24; +}; + +const isWithinRCP = ({ offset = 0, excludeShortRCP = false } = {}) => { const now = new Date(); if (now.getFullYear() !== CURRENT_YEAR) { console.log(`ADD NEW RCPs for ${CURRENT_YEAR + 1}`); @@ -53,7 +57,9 @@ const isWithinRCP = (offset = 0) => { if (RCPDates.some(({ start, end }) => { const adjustedStart = new Date(start); adjustedStart.setDate(adjustedStart.getDate() - offset); - return start <= now && now <= end + const match = adjustedStart <= now && now <= end; + if (!match || (excludeShortRCP && isShortRCP(start, end))) return false; + return true; })) { console.log( 'Current date is within a RCP (2 days earlier for stage, to keep stage clean & make CSO contributions during an RCP easier). Stopping execution.' @@ -148,6 +154,7 @@ module.exports = { getLocalConfigs, slackNotification, pulls: { addLabels, addFiles, getChecks, getReviews }, + isShortRCP, isWithinRCP, RCPDates, }; diff --git a/.github/workflows/merge-to-main.js b/.github/workflows/merge-to-main.js index efbc9e55bc..286ddaff19 100644 --- a/.github/workflows/merge-to-main.js +++ b/.github/workflows/merge-to-main.js @@ -9,6 +9,7 @@ const { const PR_TITLE = '[Release] Stage to Main'; const STAGE = 'stage'; const PROD = 'main'; +const MIN_SOT_APPROVALS = process.env.MIN_SOT_APPROVALS ? Number(process.env.MIN_SOT_APPROVALS) : 4; let github, owner, repo; @@ -40,7 +41,7 @@ const main = async (params) => { const stageToMainPR = await getStageToMainPR(); const signOffs = stageToMainPR?.labels.filter((l) => l.includes('SOT')); console.log(`${signOffs.length} SOT labels on PR ${stageToMainPR.number}`); - if (signOffs.length >= 4) { + if (signOffs.length >= MIN_SOT_APPROVALS) { console.log('Stage to Main PR has all required labels. Merging...'); await github.rest.pulls.merge({ owner, diff --git a/.github/workflows/merge-to-main.yaml b/.github/workflows/merge-to-main.yaml index ada833d19f..9800b0435a 100644 --- a/.github/workflows/merge-to-main.yaml +++ b/.github/workflows/merge-to-main.yaml @@ -9,6 +9,7 @@ on: env: MILO_RELEASE_SLACK_WH: ${{ secrets.MILO_RELEASE_SLACK_WH }} + MIN_SOT_APPROVALS: ${{ secrets.MIN_SOT_APPROVALS }} jobs: merge-to-main: diff --git a/.github/workflows/merge-to-stage.js b/.github/workflows/merge-to-stage.js index 7c85415da1..c48c478933 100644 --- a/.github/workflows/merge-to-stage.js +++ b/.github/workflows/merge-to-stage.js @@ -231,7 +231,7 @@ const main = async (params) => { github = params.github; owner = params.context.repo.owner; repo = params.context.repo.repo; - if (isWithinRCP(process.env.STAGE_RCP_OFFSET_DAYS || 2)) return console.log('Stopped, within RCP period.'); + if (isWithinRCP({ offset: process.env.STAGE_RCP_OFFSET_DAYS || 2, excludeShortRCP: true })) return console.log('Stopped, within RCP period.'); try { const stageToMainPR = await getStageToMainPR(); diff --git a/.github/workflows/rcp-notifier.js b/.github/workflows/rcp-notifier.js index ad5bdd2cde..11793238a6 100644 --- a/.github/workflows/rcp-notifier.js +++ b/.github/workflows/rcp-notifier.js @@ -2,10 +2,13 @@ const { slackNotification, getLocalConfigs, RCPDates, + isShortRCP, } = require('./helpers.js'); -const isWithin24Hours = (targetDate) => - Math.abs(new Date() - targetDate) <= 24 * 60 * 60 * 1000; +const isWithin24Hours = (targetDate) => { + const now = new Date(); + return now < targetDate && new Date(now.getTime() + 24 * 60 * 60 * 1000) > targetDate; +}; const calculateDateOffset = (date, offset) => { const newDate = new Date(date); @@ -19,17 +22,18 @@ const main = async () => { for (const rcp of RCPDates) { const start = new Date(rcp.start); const end = new Date(rcp.end); + const isShort = isShortRCP(start, end); const tenDaysBefore = calculateDateOffset(start, 10); const fourDaysBefore = calculateDateOffset(start, 4); const stageOffset = Number(process.env.STAGE_RCP_OFFSET_DAYS) || 2; const slackText = (days) => `Reminder RCP starts in ${days} days: from ${start.toUTCString()} to ${end.toUTCString()}. Merges to stage will be disabled beginning ${calculateDateOffset(start, stageOffset).toUTCString()}.`; - if (isWithin24Hours(tenDaysBefore)) { + if (isWithin24Hours(tenDaysBefore) && !isShort) { console.log('Is within 24 hours of 10 days before RCP'); await slackNotification(slackText(10), process.env.MILO_DEV_HOOK); } - if (isWithin24Hours(fourDaysBefore)) { + if (isWithin24Hours(fourDaysBefore) && !isShort) { console.log('Is within 24 hours of 4 days before RCP'); await slackNotification(slackText(4), process.env.MILO_DEV_HOOK); } From 7483f29e5a54a55219bc9c7efe519038c2788289 Mon Sep 17 00:00:00 2001 From: Nicolas Peltier <1032754+npeltier@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:09:50 +0100 Subject: [PATCH 5/8] MWPW-156157 use OST v1.19.1 (#3290) will use www.adobe.com cached calls of WCS --- libs/blocks/ost/ost.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/blocks/ost/ost.js b/libs/blocks/ost/ost.js index 9e115ab2ee..c397a4172a 100644 --- a/libs/blocks/ost/ost.js +++ b/libs/blocks/ost/ost.js @@ -8,7 +8,7 @@ const IMS_COMMERCE_CLIENT_ID = 'aos_milo_commerce'; const IMS_SCOPE = 'AdobeID,openid'; const IMS_ENV = 'prod'; const IMS_PROD_URL = 'https://auth.services.adobe.com/imslib/imslib.min.js'; -const OST_VERSION = '1.18.4'; +const OST_VERSION = '1.19.1'; const OST_BASE = `https://www.stage.adobe.com/special/tacocat/ost/lib/${OST_VERSION}`; const OST_SCRIPT_URL = `${OST_BASE}/index.js`; const OST_STYLE_URL = `${OST_BASE}/index.css`; From 57d66cf3446564dc57be8c9b61b3f0de89f35ee5 Mon Sep 17 00:00:00 2001 From: Santoshkumar Nateekar Date: Mon, 9 Dec 2024 04:11:41 -0800 Subject: [PATCH 6/8] [MWPW-163723] [NALA] Update Nala CircleCI Job to Manual Trigger (#3317) updating the job to manual trigger Co-authored-by: Santoshkumar Sharanappa Nateekar --- .github/workflows/run-nala-circleci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-nala-circleci.yml b/.github/workflows/run-nala-circleci.yml index a2a7e963bf..d7b115959d 100644 --- a/.github/workflows/run-nala-circleci.yml +++ b/.github/workflows/run-nala-circleci.yml @@ -1,9 +1,7 @@ name: Nala Tests on CircleCI on: - push: - branches: - - stage + workflow_dispatch: jobs: trigger-circleci: @@ -15,4 +13,4 @@ jobs: curl -X POST 'https://circle.ci.adobe.com/api/v2/project/gh/wcms/nala/pipeline' \ -H 'Circle-Token: ${{ secrets.CCI_TOKEN }}' \ -H 'content-type: application/json' \ - -d "{\"branch\":\"main\"}" \ No newline at end of file + -d "{\"branch\":\"main\"}" From 988468198cdcbad58064f8303abfb14d02f7ed6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sonja=20Popovi=C4=87?= <32739655+SonjaPopovic@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:14:45 +0100 Subject: [PATCH 7/8] MWPW-154147: add spectrum switch component (#3264) * MWPW-154147-spectrum switch * MWPW-154147-spectrum switch * MWPW-154147-spectrum switch test * MWPW-154147-spectrum switch test --------- Co-authored-by: Sonja Popovic --- .../spectrum-web-components/dist/checkbox.js | 18 ++++----- .../spectrum-web-components/dist/switch.js | 12 ++++++ .../spectrum-web-components/package.json | 1 + .../spectrum-web-components/src/checkbox.js | 1 + .../spectrum-web-components/src/switch.js | 3 ++ .../spectrum-web-components/switch.test.html | 39 +++++++++++++++++++ 6 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 libs/features/spectrum-web-components/dist/switch.js create mode 100644 libs/features/spectrum-web-components/src/switch.js create mode 100644 test/features/spectrum-web-components/switch.test.html diff --git a/libs/features/spectrum-web-components/dist/checkbox.js b/libs/features/spectrum-web-components/dist/checkbox.js index aa3bf04a86..7bc9bcc957 100644 --- a/libs/features/spectrum-web-components/dist/checkbox.js +++ b/libs/features/spectrum-web-components/dist/checkbox.js @@ -1,18 +1,18 @@ /* eslint-disable */ /* Generated by Milo */ -import{html as r,SizedMixin as C,SpectrumElement as p}from"./base.js";import{property as l}from"./base.js";import{html as x}from"./base.js";import{property as b,query as f}from"./base.js";import{ifDefined as g}from"./base.js";var v=Object.defineProperty,k=Object.getOwnPropertyDescriptor,d=(a,o,i,c)=>{for(var e=c>1?void 0:c?k(o,i):o,h=a.length-1,s;h>=0;h--)(s=a[h])&&(e=(c?s(o,i,e):s(e))||e);return c&&e&&v(o,i,e),e};function u(a){class o extends a{constructor(){super(...arguments),this.checked=!1,this.readonly=!1}handleChange(){if(this.readonly){this.inputElement.checked=this.checked;return}this.checked=this.inputElement.checked;let c=new CustomEvent("change",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(c)||(this.checked=!this.inputElement.checked,this.inputElement.checked=this.checked)}render(){return x` +import{html as r,SizedMixin as E,SpectrumElement as p}from"./base.js";import{property as l}from"./base.js";import{html as f}from"./base.js";import{property as u,query as g}from"./base.js";import{ifDefined as z}from"./base.js";var k=Object.defineProperty,x=Object.getOwnPropertyDescriptor,d=(a,o,i,c)=>{for(var e=c>1?void 0:c?x(o,i):o,h=a.length-1,s;h>=0;h--)(s=a[h])&&(e=(c?s(o,i,e):s(e))||e);return c&&e&&k(o,i,e),e};function b(a){class o extends a{constructor(){super(...arguments),this.checked=!1,this.readonly=!1}handleChange(){if(this.readonly){this.inputElement.checked=this.checked;return}this.checked=this.inputElement.checked;let c=new CustomEvent("change",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(c)||(this.checked=!this.inputElement.checked,this.inputElement.checked=this.checked)}render(){return f` - `}}return d([b({type:Boolean,reflect:!0})],o.prototype,"checked",2),d([b({type:String,reflect:!0})],o.prototype,"name",2),d([b({type:Boolean,reflect:!0})],o.prototype,"readonly",2),d([f("#input")],o.prototype,"inputElement",2),o}import{css as z}from"./base.js";var y=z` + `}}return d([u({type:Boolean,reflect:!0})],o.prototype,"checked",2),d([u({type:String,reflect:!0})],o.prototype,"name",2),d([u({type:Boolean,reflect:!0})],o.prototype,"readonly",2),d([g("#input")],o.prototype,"inputElement",2),o}import{css as y}from"./base.js";var w=y` :host{--spectrum-checkbox-content-color-default:var(--spectrum-neutral-content-color-default);--spectrum-checkbox-content-color-hover:var(--spectrum-neutral-content-color-hover);--spectrum-checkbox-content-color-down:var(--spectrum-neutral-content-color-down);--spectrum-checkbox-content-color-focus:var(--spectrum-neutral-content-color-key-focus);--spectrum-checkbox-focus-indicator-color:var(--spectrum-focus-indicator-color);--spectrum-checkbox-content-color-disabled:var(--spectrum-disabled-content-color);--spectrum-checkbox-control-color-disabled:var(--spectrum-disabled-content-color);--spectrum-checkbox-checkmark-color:var(--spectrum-gray-75);--spectrum-checkbox-invalid-color-default:var(--spectrum-negative-color-900);--spectrum-checkbox-invalid-color-hover:var(--spectrum-negative-color-1000);--spectrum-checkbox-invalid-color-down:var(--spectrum-negative-color-1100);--spectrum-checkbox-invalid-color-focus:var(--spectrum-negative-color-1000);--spectrum-checkbox-emphasized-color-default:var(--spectrum-accent-color-900);--spectrum-checkbox-emphasized-color-hover:var(--spectrum-accent-color-1000);--spectrum-checkbox-emphasized-color-down:var(--spectrum-accent-color-1100);--spectrum-checkbox-emphasized-color-focus:var(--spectrum-accent-color-1000);--spectrum-checkbox-control-selected-color-default:var(--spectrum-neutral-background-color-selected-default);--spectrum-checkbox-control-selected-color-hover:var(--spectrum-neutral-background-color-selected-hover);--spectrum-checkbox-control-selected-color-down:var(--spectrum-neutral-background-color-selected-down);--spectrum-checkbox-control-selected-color-focus:var(--spectrum-neutral-background-color-selected-key-focus);--spectrum-checkbox-font-size:var(--spectrum-font-size-100);--spectrum-checkbox-line-height:var(--spectrum-line-height-100);--spectrum-checkbox-line-height-cjk:var(--spectrum-cjk-line-height-100);--spectrum-checkbox-height:var(--spectrum-component-height-100);--spectrum-checkbox-control-size:var(--spectrum-checkbox-control-size-medium);--spectrum-checkbox-control-corner-radius:var(--spectrum-corner-radius-75);--spectrum-checkbox-focus-indicator-gap:var(--spectrum-focus-indicator-gap);--spectrum-checkbox-focus-indicator-thickness:var(--spectrum-focus-indicator-thickness);--spectrum-checkbox-border-width:var(--spectrum-border-width-200);--spectrum-checkbox-selected-border-width:calc(var(--spectrum-checkbox-control-size)/2);--spectrum-checkbox-top-to-text:var(--spectrum-component-top-to-text-100);--spectrum-checkbox-text-to-control:var(--spectrum-text-to-control-100);--spectrum-checkbox-animation-duration:var(--spectrum-animation-duration-100)}:host([size=s]){--spectrum-checkbox-font-size:var(--spectrum-font-size-75);--spectrum-checkbox-height:var(--spectrum-component-height-75);--spectrum-checkbox-control-size:var(--spectrum-checkbox-control-size-small);--spectrum-checkbox-top-to-text:var(--spectrum-component-top-to-text-75);--spectrum-checkbox-text-to-control:var(--spectrum-text-to-control-75)}:host{--spectrum-checkbox-font-size:var(--spectrum-font-size-100);--spectrum-checkbox-height:var(--spectrum-component-height-100);--spectrum-checkbox-control-size:var(--spectrum-checkbox-control-size-medium);--spectrum-checkbox-top-to-text:var(--spectrum-component-top-to-text-100);--spectrum-checkbox-text-to-control:var(--spectrum-text-to-control-100)}:host([size=l]){--spectrum-checkbox-font-size:var(--spectrum-font-size-200);--spectrum-checkbox-height:var(--spectrum-component-height-200);--spectrum-checkbox-control-size:var(--spectrum-checkbox-control-size-large);--spectrum-checkbox-top-to-text:var(--spectrum-component-top-to-text-200);--spectrum-checkbox-text-to-control:var(--spectrum-text-to-control-200)}:host([size=xl]){--spectrum-checkbox-font-size:var(--spectrum-font-size-300);--spectrum-checkbox-height:var(--spectrum-component-height-300);--spectrum-checkbox-control-size:var(--spectrum-checkbox-control-size-extra-large);--spectrum-checkbox-top-to-text:var(--spectrum-component-top-to-text-300);--spectrum-checkbox-text-to-control:var(--spectrum-text-to-control-300)}:host{color:var(--highcontrast-checkbox-content-color-default,var(--mod-checkbox-content-color-default,var(--spectrum-checkbox-content-color-default)));min-block-size:var(--mod-checkbox-height,var(--spectrum-checkbox-height));max-inline-size:100%;vertical-align:top;align-items:flex-start;display:inline-flex;position:relative}:host(:is(:active,[active])) #box:before{border-color:var(--highcontrast-checkbox-highlight-color-down,var(--mod-checkbox-control-color-down,var(--spectrum-checkbox-control-color-down)))}:host(:is(:active,[active])) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-down,var(--mod-checkbox-control-selected-color-down,var(--spectrum-checkbox-control-selected-color-down)))}:host(:is(:active,[active])) #label{color:var(--highcontrast-checkbox-content-color-down,var(--mod-checkbox-content-color-down,var(--spectrum-checkbox-content-color-down)))}:host([invalid][invalid]) #box:before,:host([invalid][invalid]) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-invalid-color-default,var(--spectrum-checkbox-invalid-color-default)))}:host([invalid][invalid]) #input:focus-visible+#box:before,:host([invalid][invalid][indeterminate]) #input:focus-visible+#box:before{border-color:var(--highcontrast-checkbox-color-hover,var(--mod-checkbox-invalid-color-hover,var(--spectrum-checkbox-invalid-color-hover)))}:host([readonly]){border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-control-selected-color-default,var(--spectrum-checkbox-control-selected-color-default)))}:host([readonly]:is(:active,[active])) #box:before{border-color:var(--highcontrast-checkbox-selected-color-default,var(--mod-checkbox-control-selected-color-default,var(--spectrum-checkbox-control-selected-color-default)))}:host([readonly]) #input:checked:disabled+#box:before,:host([readonly]) #input:disabled+#box:before{border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-control-selected-color-default,var(--spectrum-checkbox-control-selected-color-default)));background-color:var(--highcontrast-checkbox-background-color-default,var(--mod-checkbox-checkmark-color,var(--spectrum-checkbox-checkmark-color)))}:host([readonly]) #input:checked:disabled~#label,:host([readonly]) #input:disabled~#label{forced-color-adjust:none;color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-content-color-default,var(--spectrum-checkbox-content-color-default)))}:host([indeterminate]) #box:before,:host([indeterminate]) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-default,var(--mod-checkbox-control-selected-color-default,var(--spectrum-checkbox-control-selected-color-default)));border-width:var(--mod-checkbox-selected-border-width,var(--spectrum-checkbox-selected-border-width))}:host([indeterminate]) #box #checkmark,:host([indeterminate]) #input:checked+#box #checkmark{display:none}:host([indeterminate]) #box #partialCheckmark,:host([indeterminate]) #input:checked+#box #partialCheckmark{opacity:1;display:block;transform:scale(1)}:host([indeterminate]) #input:focus-visible+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-focus,var(--mod-checkbox-control-selected-color-focus,var(--spectrum-checkbox-control-selected-color-focus)))}:host([invalid][invalid][indeterminate]) #box:before,:host([invalid][invalid][indeterminate]) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-invalid-color-default,var(--spectrum-checkbox-invalid-color-default)));border-width:var(--mod-checkbox-selected-border-width,var(--spectrum-checkbox-selected-border-width))}:host([emphasized]) #input:checked+#box:before,:host([emphasized][indeterminate]) #box:before,:host([emphasized][indeterminate]) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-default,var(--mod-checkbox-emphasized-color-default,var(--spectrum-checkbox-emphasized-color-default)))}:host([emphasized]) #input:focus-visible:checked+#box:before,:host([emphasized][indeterminate]) #input:focus-visible+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-focus,var(--mod-checkbox-emphasized-color-focus,var(--spectrum-checkbox-emphasized-color-focus)))}:host([emphasized][invalid][invalid]) #input:focus-visible:checked+#box:before{border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-invalid-color-focus,var(--spectrum-checkbox-invalid-color-focus)))}@media (hover:hover){:host(:hover) #box:before{border-color:var(--highcontrast-checkbox-highlight-color-hover,var(--mod-checkbox-control-color-hover,var(--spectrum-checkbox-control-color-hover)))}:host(:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-hover,var(--mod-checkbox-control-selected-color-hover,var(--spectrum-checkbox-control-selected-color-hover)))}:host(:hover) #label{color:var(--highcontrast-checkbox-content-color-hover,var(--mod-checkbox-content-color-hover,var(--spectrum-checkbox-content-color-hover)))}:host([invalid][invalid]:hover) #box:before,:host([invalid][invalid]:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-hover,var(--mod-checkbox-invalid-color-hover,var(--spectrum-checkbox-invalid-color-hover)))}:host([readonly]:hover) #box:before{border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-control-selected-color-default,var(--spectrum-checkbox-control-selected-color-default)))}:host([indeterminate]:hover) #box:before,:host([indeterminate]:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-hover,var(--mod-checkbox-control-selected-color-hover,var(--spectrum-checkbox-control-selected-color-hover)))}:host([invalid][invalid][indeterminate]:hover) #box:before,:host([invalid][invalid][indeterminate]:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-invalid-color-hover,var(--spectrum-checkbox-invalid-color-hover)))}:host([invalid][invalid][indeterminate]:hover) #label{color:var(--highcontrast-checkbox-content-color-hover,var(--mod-checkbox-content-color-hover,var(--spectrum-checkbox-content-color-hover)))}:host([emphasized][indeterminate]:hover) #box:before,:host([emphasized][indeterminate]:hover) #input:checked+#box:before,:host([emphasized]:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-hover,var(--mod-checkbox-emphasized-color-hover,var(--spectrum-checkbox-emphasized-color-hover)))}:host([emphasized][invalid][invalid][indeterminate]:hover) #box:before,:host([emphasized][invalid][invalid][indeterminate]:hover) #input:checked+#box:before,:host([emphasized][invalid][invalid]:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-hover,var(--mod-checkbox-invalid-color-hover,var(--spectrum-checkbox-invalid-color-hover)))}:host([emphasized][indeterminate]:hover) #box:before,:host([emphasized][indeterminate]:hover) #input:checked+#box:before,:host([emphasized]:hover) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-hover,var(--mod-checkbox-emphasized-color-hover,var(--spectrum-checkbox-emphasized-color-hover)))}}:host([emphasized][indeterminate]:is(:active,[active])) #box:before,:host([emphasized][indeterminate]:is(:active,[active])) #input:checked+#box:before,:host([emphasized]:is(:active,[active])) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-default,var(--mod-checkbox-emphasized-color-down,var(--spectrum-checkbox-emphasized-color-down)))}:host([emphasized][invalid][invalid]:is(:active,[active])) #box:before,:host([emphasized][invalid][invalid]:is(:active,[active])) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-default,var(--mod-checkbox-control-invalid-color-down,var(--spectrum-checkbox-invalid-color-down)))}:host([emphasized]:focus-visible) #box:before,:host([emphasized]:focus-visible) #input:checked+#box:before{border-color:var(--highcontrast-checkbox-color-focus,var(--mod-checkbox-control-color-focus,var(--spectrum-checkbox-control-color-focus)))}#label{text-align:start;font-size:var(--mod-checkbox-font-size,var(--spectrum-checkbox-font-size));transition:color var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-in-out;line-height:var(--mod-checkbox-line-height,var(--spectrum-checkbox-line-height));margin-block-start:var(--mod-checkbox-top-to-text,var(--spectrum-checkbox-top-to-text));margin-inline-start:var(--mod-checkbox-text-to-control,var(--spectrum-checkbox-text-to-control))}#label:lang(ja),#label:lang(ko),#label:lang(zh){line-height:var(--mod-checkbox-line-height-cjk,var(--spectrum-checkbox-line-height-cjk))}#input{color:var(--mod-checkbox-control-color-default,var(--spectrum-checkbox-control-color-default));box-sizing:border-box;inline-size:100%;block-size:100%;opacity:.0001;z-index:1;cursor:pointer;margin:0;padding:0;font-family:inherit;font-size:100%;line-height:1.15;position:absolute;overflow:visible}#input:disabled{cursor:default}#input:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-default,var(--mod-checkbox-control-selected-color-default,var(--spectrum-checkbox-control-selected-color-default)));background-color:var(--mod-checkbox-checkmark-color,var(--spectrum-checkbox-checkmark-color));border-width:var(--mod-checkbox-selected-border-width,var(--spectrum-checkbox-selected-border-width))}#input:checked+#box #checkmark{opacity:1;transform:scale(1)}#input:focus-visible+#box:before{border-color:var(--highcontrast-checkbox-color-focus,var(--mod-checkbox-control-color-focus,var(--spectrum-checkbox-control-color-focus)))}#input:focus-visible+#box:after{forced-color-adjust:none;box-shadow:0 0 0 var(--mod-checkbox-focus-indicator-thinkness,var(--spectrum-checkbox-focus-indicator-thickness))var(--highcontrast-checkbox-focus-indicator-color,var(--mod-checkbox-focus-indicator-color,var(--spectrum-checkbox-focus-indicator-color)));margin:calc(var(--mod-checkbox-focus-indicator-gap,var(--spectrum-checkbox-focus-indicator-gap))*-1)}#input:focus-visible+#label{color:var(--highcontrast-checkbox-content-color-focus,var(--mod-checkbox-content-color-focus,var(--spectrum-checkbox-content-color-focus)))}#input:focus-visible:checked+#box:before{border-color:var(--highcontrast-checkbox-highlight-color-focus,var(--mod-checkbox-control-selected-color-focus,var(--spectrum-checkbox-control-selected-color-focus)))}#box{--spectrum-checkbox-spacing:calc(var(--mod-checkbox-height,var(--spectrum-checkbox-height)) - var(--mod-checkbox-control-size,var(--spectrum-checkbox-control-size)));margin:calc(var(--mod-checkbox-spacing,var(--spectrum-checkbox-spacing))/2)0;flex-grow:0;flex-shrink:0;justify-content:center;align-items:center;display:flex;position:relative}#box,#box:before{box-sizing:border-box;inline-size:var(--mod-checkbox-control-size,var(--spectrum-checkbox-control-size));block-size:var(--mod-checkbox-control-size,var(--spectrum-checkbox-control-size))}#box:before{forced-color-adjust:none;border-color:var(--highcontrast-checkbox-color-default,var(--mod-checkbox-control-color-default,var(--spectrum-checkbox-control-color-default)));z-index:0;content:"";border-radius:var(--mod-checkbox-control-corner-radius,var(--spectrum-checkbox-control-corner-radius));border-width:var(--mod-checkbox-border-width,var(--spectrum-checkbox-border-width));transition:border var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-in-out,box-shadow var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-in-out;border-style:solid;display:block;position:absolute}#box:after{border-radius:calc(var(--mod-checkbox-control-corner-radius,var(--spectrum-checkbox-control-corner-radius)) + var(--mod-checkbox-focus-indicator-gap,var(--spectrum-checkbox-focus-indicator-gap)));content:"";margin:var(--mod-checkbox-focus-indicator-gap,var(--spectrum-checkbox-focus-indicator-gap));transition:box-shadow var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-out,margin var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-out;display:block;position:absolute;inset-block:0;inset-inline:0;transform:translate(0)}#checkmark,#partialCheckmark{color:var(--highcontrast-checkbox-background-color-default,var(--mod-checkbox-checkmark-color,var(--spectrum-checkbox-checkmark-color)));opacity:0;transition:opacity var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-in-out,transform var(--mod-checkbox-animation-duration,var(--spectrum-checkbox-animation-duration))ease-in-out;transform:scale(0)}#partialCheckmark{display:none}#input:checked:disabled+#box:before,#input:disabled+#box:before{border-color:var(--highcontrast-checkbox-disabled-color-default,var(--mod-checkbox-control-color-disabled,var(--spectrum-checkbox-control-color-disabled)));background-color:var(--highcontrast-checkbox-background-color-default,var(--mod-checkbox-checkmark-color,var(--spectrum-checkbox-checkmark-color)))}#input:checked:disabled~#label,#input:disabled~#label{forced-color-adjust:none;color:var(--highcontrast-checkbox-disabled-color-default,var(--mod-checkbox-content-color-disabled,var(--spectrum-checkbox-content-color-disabled)))}@media (forced-colors:active){#input:focus-visible+#box{forced-color-adjust:none;outline-color:var(--highcontrast-checkbox-focus-indicator-color,var(--mod-checkbox-focus-indicator-color,var(--spectrum-checkbox-focus-indicator-color)));outline-offset:var(--highcontrast-checkbox-focus-indicator-gap,var(--mod-checkbox-focus-indicator-gap,var(--spectrum-checkbox-focus-indicator-gap)));outline-style:auto;outline-width:var(--mod-focus-indicator-thickness,var(--spectrum-focus-indicator-thickness))}#input:focus-visible+#box:after{box-shadow:0 0 0 0 var(--highcontrast-checkbox-focus-indicator-color,var(--mod-checkbox-focus-indicator-color,var(--spectrum-checkbox-focus-indicator-color)))}:host{--highcontrast-checkbox-content-color-default:CanvasText;--highcontrast-checkbox-content-color-hover:CanvasText;--highcontrast-checkbox-content-color-down:CanvasText;--highcontrast-checkbox-content-color-focus:CanvasText;--highcontrast-checkbox-background-color-default:Canvas;--highcontrast-checkbox-color-default:ButtonText;--highcontrast-checkbox-color-hover:ButtonText;--highcontrast-checkbox-color-focus:Highlight;--highcontrast-checkbox-highlight-color-default:Highlight;--highcontrast-checkbox-highlight-color-hover:Highlight;--highcontrast-checkbox-highlight-color-down:Highlight;--highcontrast-checkbox-highlight-color-focus:Highlight;--highcontrast-checkbox-disabled-color-default:GrayText;--highcontrast-checkbox-focus-indicator-color:CanvasText}}:host{--spectrum-checkbox-control-color-default:var(--system-spectrum-checkbox-control-color-default);--spectrum-checkbox-control-color-hover:var(--system-spectrum-checkbox-control-color-hover);--spectrum-checkbox-control-color-down:var(--system-spectrum-checkbox-control-color-down);--spectrum-checkbox-control-color-focus:var(--system-spectrum-checkbox-control-color-focus)}:host{vertical-align:top;display:inline-flex}:host(:focus){outline:none}:host([disabled]){pointer-events:none}:host(:empty) label{display:none} -`,m=y;import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import E from"./icons/checkmark.js";import j from"./icons/dash.js";var w=Object.defineProperty,I=Object.getOwnPropertyDescriptor,n=(a,o,i,c)=>{for(var e=c>1?void 0:c?I(o,i):o,h=a.length-1,s;h>=0;h--)(s=a[h])&&(e=(c?s(o,i,e):s(e))||e);return c&&e&&w(o,i,e),e},B={s:()=>r` +`,m=w;import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import"./icons-ui.js";import j from"./icons/checkmark.js";import D from"./icons/dash.js";var I=Object.defineProperty,C=Object.getOwnPropertyDescriptor,n=(a,o,i,c)=>{for(var e=c>1?void 0:c?C(o,i):o,h=a.length-1,s;h>=0;h--)(s=a[h])&&(e=(c?s(o,i,e):s(e))||e);return c&&e&&I(o,i,e),e},O={s:()=>r` - `},D={s:()=>r` + `},T={s:()=>r` - `},t=class extends C(u(p),{noDefaultSize:!0}){constructor(){super(...arguments),this.disabled=!1,this.indeterminate=!1,this.invalid=!1,this.emphasized=!1,this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.hasAttribute("autofocus")&&this.updateComplete.then(()=>{this.focus()})}static get styles(){return[m,E,j]}click(){var o;this.disabled||(o=this.inputElement)==null||o.click()}handleChange(){this.indeterminate=!1,super.handleChange()}render(){return r` + `},t=class extends E(b(p),{noDefaultSize:!0}){constructor(){super(...arguments),this.disabled=!1,this.indeterminate=!1,this.invalid=!1,this.emphasized=!1,this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.hasAttribute("autofocus")&&this.updateComplete.then(()=>{this.focus()})}static get styles(){return[m,j,D]}click(){var o;this.disabled||(o=this.inputElement)==null||o.click()}handleChange(){this.indeterminate=!1,super.handleChange()}render(){return r` ${super.render()} - ${this.checked?B[this.size]():r``} - ${this.indeterminate?D[this.size]():r``} + ${this.checked?O[this.size]():r``} + ${this.indeterminate?T[this.size]():r``} - `}updated(o){super.updated(o),o.has("disabled")&&(typeof o.get("disabled")<"u"||this.disabled)&&(this.disabled?(this.inputElement.tabIndex=this.tabIndex,this.tabIndex=-1):(this.tabIndex=this.inputElement.tabIndex,this.inputElement.removeAttribute("tabindex")),this.inputElement.disabled=this.disabled),o.has("indeterminate")&&(this.inputElement.indeterminate=this.indeterminate),o.has("invalid")&&(this.invalid?this.inputElement.setAttribute("aria-invalid","true"):this.inputElement.removeAttribute("aria-invalid"))}};t.shadowRootOptions={...p.shadowRootOptions,delegatesFocus:!0},n([l({type:Boolean,reflect:!0})],t.prototype,"disabled",2),n([l({type:Boolean,reflect:!0})],t.prototype,"indeterminate",2),n([l({type:Boolean,reflect:!0})],t.prototype,"invalid",2),n([l({type:Boolean,reflect:!0})],t.prototype,"emphasized",2),n([l({reflect:!0,type:Number,attribute:"tabindex"})],t.prototype,"tabIndex",2);import{defineElement as O}from"./base.js";O("sp-checkbox",t); + `}updated(o){super.updated(o),o.has("disabled")&&(typeof o.get("disabled")<"u"||this.disabled)&&(this.disabled?(this.inputElement.tabIndex=this.tabIndex,this.tabIndex=-1):(this.tabIndex=this.inputElement.tabIndex,this.inputElement.removeAttribute("tabindex")),this.inputElement.disabled=this.disabled),o.has("indeterminate")&&(this.inputElement.indeterminate=this.indeterminate),o.has("invalid")&&(this.invalid?this.inputElement.setAttribute("aria-invalid","true"):this.inputElement.removeAttribute("aria-invalid"))}};t.shadowRootOptions={...p.shadowRootOptions,delegatesFocus:!0},n([l({type:Boolean,reflect:!0})],t.prototype,"disabled",2),n([l({type:Boolean,reflect:!0})],t.prototype,"indeterminate",2),n([l({type:Boolean,reflect:!0})],t.prototype,"invalid",2),n([l({type:Boolean,reflect:!0})],t.prototype,"emphasized",2),n([l({reflect:!0,type:Number,attribute:"tabindex"})],t.prototype,"tabIndex",2);import{defineElement as U}from"./base.js";U("sp-checkbox",t);import{Focusable as B}from"./shared.js";var v=class extends b(B){get focusElement(){return this.inputElement}};export{v as CheckboxBase}; diff --git a/libs/features/spectrum-web-components/dist/switch.js b/libs/features/spectrum-web-components/dist/switch.js new file mode 100644 index 0000000000..a9191914b7 --- /dev/null +++ b/libs/features/spectrum-web-components/dist/switch.js @@ -0,0 +1,12 @@ +/* eslint-disable */ +/* Generated by Milo */ + +import{html as v,SizedMixin as g}from"./base.js";import{property as f}from"./base.js";import{CheckboxBase as k}from"./checkbox.js";import{css as d}from"./base.js";var n=d` + :host{--spectrum-switch-label-color-default:var(--spectrum-neutral-content-color-default);--spectrum-switch-label-color-hover:var(--spectrum-neutral-content-color-hover);--spectrum-switch-label-color-down:var(--spectrum-neutral-content-color-down);--spectrum-switch-label-color-focus:var(--spectrum-neutral-content-color-key-focus);--spectrum-switch-label-color-disabled:var(--spectrum-disabled-content-color);--spectrum-switch-background-color:var(--spectrum-gray-300);--spectrum-switch-background-color-disabled:var(--spectrum-gray-300);--spectrum-switch-background-color-selected-disabled:var(--spectrum-disabled-content-color);--spectrum-switch-background-color-selected-default:var(--spectrum-neutral-background-color-selected-default);--spectrum-switch-background-color-selected-hover:var(--spectrum-neutral-background-color-selected-hover);--spectrum-switch-background-color-selected-down:var(--spectrum-neutral-background-color-selected-down);--spectrum-switch-background-color-selected-focus:var(--spectrum-neutral-background-color-selected-key-focus);--spectrum-switch-focus-indicator-thickness:var(--mod-focus-indicator-thickness,var(--spectrum-focus-indicator-thickness));--spectrum-switch-focus-indicator-color:var(--spectrum-focus-indicator-color);--spectrum-switch-handle-background-color:var(--spectrum-gray-75);--spectrum-switch-handle-border-color-disabled:var(--spectrum-disabled-content-color)}:host([disabled]){--spectrum-switch-label-color-default:var(--spectrum-disabled-content-color)}:host([emphasized]){--spectrum-switch-background-color-selected-default:var(--spectrum-accent-color-900);--spectrum-switch-background-color-selected-hover:var(--spectrum-accent-color-1000);--spectrum-switch-background-color-selected-down:var(--spectrum-accent-color-1100);--spectrum-switch-background-color-selected-focus:var(--spectrum-accent-color-1000);--spectrum-switch-handle-border-color-selected-default:var(--spectrum-accent-color-900);--spectrum-switch-handle-border-color-selected-hover:var(--spectrum-accent-color-1000);--spectrum-switch-handle-border-color-selected-down:var(--spectrum-accent-color-1100);--spectrum-switch-handle-border-color-selected-focus:var(--spectrum-accent-color-1000)}:host([size=s]){--spectrum-switch-min-height:var(--spectrum-component-height-75);--spectrum-switch-control-width:var(--spectrum-switch-control-width-small);--spectrum-switch-control-height:var(--spectrum-switch-control-height-small);--spectrum-switch-control-label-spacing:var(--spectrum-text-to-control-75);--spectrum-switch-spacing-top-to-control:var(--spectrum-switch-top-to-control-small);--spectrum-switch-spacing-top-to-label:var(--spectrum-component-top-to-text-75);--spectrum-switch-font-size:var(--spectrum-font-size-75)}:host{--spectrum-switch-min-height:var(--spectrum-component-height-100);--spectrum-switch-control-width:var(--spectrum-switch-control-width-medium);--spectrum-switch-control-height:var(--spectrum-switch-control-height-medium);--spectrum-switch-control-label-spacing:var(--spectrum-text-to-control-100);--spectrum-switch-spacing-top-to-control:var(--spectrum-switch-top-to-control-medium);--spectrum-switch-spacing-top-to-label:var(--spectrum-component-top-to-text-100);--spectrum-switch-font-size:var(--spectrum-font-size-100)}:host([size=l]){--spectrum-switch-min-height:var(--spectrum-component-height-200);--spectrum-switch-control-width:var(--spectrum-switch-control-width-large);--spectrum-switch-control-height:var(--spectrum-switch-control-height-large);--spectrum-switch-control-label-spacing:var(--spectrum-text-to-control-200);--spectrum-switch-spacing-top-to-control:var(--spectrum-switch-top-to-control-large);--spectrum-switch-spacing-top-to-label:var(--spectrum-component-top-to-text-200);--spectrum-switch-font-size:var(--spectrum-font-size-200)}:host([size=xl]){--spectrum-switch-min-height:var(--spectrum-component-height-300);--spectrum-switch-control-width:var(--spectrum-switch-control-width-extra-large);--spectrum-switch-control-height:var(--spectrum-switch-control-height-extra-large);--spectrum-switch-control-label-spacing:var(--spectrum-text-to-control-300);--spectrum-switch-spacing-top-to-control:var(--spectrum-switch-top-to-control-extra-large);--spectrum-switch-spacing-top-to-label:var(--spectrum-component-top-to-text-300);--spectrum-switch-font-size:var(--spectrum-font-size-300)}:host{min-block-size:var(--mod-switch-height,var(--spectrum-switch-min-height));max-inline-size:100%;vertical-align:top;align-items:flex-start;display:inline-flex;position:relative}#input{box-sizing:border-box;inline-size:100%;block-size:100%;opacity:0;z-index:1;cursor:pointer;margin:0;padding:0;position:absolute;inset-block-start:0;inset-inline-start:0}:host([checked]) #input+#switch:before{transform:translateX(calc(var(--mod-switch-control-width,var(--spectrum-switch-control-width)) - 100%))}:host([checked]) #input+#switch:dir(rtl):before,:host([dir=rtl][checked]) #input+#switch:before{transform:translateX(calc(( var(--mod-switch-control-width,var(--spectrum-switch-control-width)) - 100% )*-1))}:host([disabled]) #input,:host([disabled]) #input{cursor:default}#input:focus-visible+#switch:after{margin:calc(var(--mod-focus-indicator-gap,var(--spectrum-focus-indicator-gap))*-1)}#label{color:var(--highcontrast-switch-label-color-default,var(--mod-switch-label-color-default,var(--spectrum-switch-label-color-default)));margin-inline:var(--mod-switch-control-label-spacing,var(--spectrum-switch-control-label-spacing));font-size:var(--mod-switch-font-size,var(--spectrum-switch-font-size));line-height:var(--mod-line-height-100,var(--spectrum-line-height-100));transition:color var(--mod-animation-duration-200,var(--spectrum-animation-duration-200))ease-in-out;margin-block-start:var(--mod-switch-spacing-top-to-label,var(--spectrum-switch-spacing-top-to-label));margin-block-end:0}#switch{box-sizing:border-box;inline-size:var(--mod-switch-control-width,var(--spectrum-switch-control-width));margin-block:calc(var(--mod-switch-height,var(--spectrum-switch-min-height)) - var(--mod-switch-control-height,var(--spectrum-switch-control-height)) - var(--mod-switch-spacing-top-to-control,var(--spectrum-switch-spacing-top-to-control)));vertical-align:middle;transition:background var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,border var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out;block-size:var(--mod-switch-control-height,var(--spectrum-switch-control-height));border-radius:calc(var(--mod-switch-control-height,var(--spectrum-switch-control-height))/2);flex-grow:0;flex-shrink:0;margin-inline:0;display:inline-block;position:relative;inset-inline:0}#switch:before{box-sizing:border-box;transition:background var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,border var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,transform var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,box-shadow var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out;inline-size:var(--mod-switch-control-height,var(--spectrum-switch-control-height));block-size:var(--mod-switch-control-height,var(--spectrum-switch-control-height));border-width:var(--mod-border-width-200,var(--spectrum-border-width-200));border-radius:calc(var(--mod-switch-control-height,var(--spectrum-switch-control-height))/2);border-style:solid}#switch:after,#switch:before{content:"";display:block;position:absolute;inset-block-start:0;inset-inline-start:0}#switch:after{border-radius:calc(var(--mod-switch-control-height,var(--spectrum-switch-control-height))/2 + var(--mod-focus-indicator-gap,var(--spectrum-focus-indicator-gap))*2);transition:opacity var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-out,margin var(--spectrum-animation-duration-100,var(--spectrum-animation-duration-100))ease-out;margin:0;inset-block-end:0;inset-inline-end:0}#switch{background-color:var(--highcontrast-switch-background-color,var(--mod-switch-background-color,var(--spectrum-switch-background-color)))}#switch:before{background-color:var(--highcontrast-switch-handle-background-color,var(--mod-switch-handle-background-color,var(--spectrum-switch-handle-background-color)));border-color:var(--highcontrast-switch-handle-border-color-default,var(--mod-switch-handle-border-color-default,var(--spectrum-switch-handle-border-color-default)))}:host(:active) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-down,var(--mod-switch-handle-border-color-down,var(--spectrum-switch-handle-border-color-down)))}:host(:active) #input~#label{color:var(--highcontrast-switch-label-color-down,var(--mod-switch-label-color-down,var(--spectrum-switch-label-color-down)))}:host(:active[checked]) #input:enabled+#switch{background-color:var(--highcontrast-switch-background-color-selected-down,var(--mod-switch-background-color-selected-down,var(--spectrum-switch-background-color-selected-down)))}:host(:active[checked]) #input:enabled+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-selected-down,var(--mod-switch-handle-border-color-selected-down,var(--spectrum-switch-handle-border-color-selected-down)))}#input:focus-visible+#switch:after{box-shadow:0 0 0 var(--mod-switch-focus-indicator-thickness,var(--spectrum-switch-focus-indicator-thickness))var(--highcontrast-switch-focus-indicator-color,var(--mod-switch-focus-indicator-color,var(--spectrum-switch-focus-indicator-color)))}#input:focus-visible+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-focus,var(--mod-switch-handle-border-color-focus,var(--spectrum-switch-handle-border-color-focus)))}:host([checked]) #input:focus-visible+#switch{background-color:var(--highcontrast-switch-background-color-selected-focus,var(--mod-switch-background-color-selected-focus,var(--spectrum-switch-background-color-selected-focus)))}:host([checked]) #input:focus-visible+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-selected-focus,var(--mod-switch-handle-border-color-selected-focus,var(--spectrum-switch-handle-border-color-selected-focus)))}#input:focus-visible~#label{color:var(--highcontrast-switch-label-color-focus,var(--mod-switch-label-color-focus,var(--spectrum-switch-label-color-focus)))}@media (hover:hover){:host(:hover) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-hover,var(--mod-switch-handle-border-color-hover,var(--spectrum-switch-handle-border-color-hover)));box-shadow:none}:host(:hover) #input~#label{color:var(--highcontrast-switch-label-color-hover,var(--mod-switch-label-color-hover,var(--spectrum-switch-label-color-hover)))}:host([checked]:hover) #input:enabled+#switch{background-color:var(--highcontrast-switch-background-color-selected-hover,var(--mod-switch-background-color-selected-hover,var(--spectrum-switch-background-color-selected-hover)))}:host([checked]:hover) #input:enabled+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-selected-hover,var(--mod-switch-handle-border-color-selected-hover,var(--spectrum-switch-handle-border-color-selected-hover)))}:host([disabled]:hover) #input+#switch,:host([disabled]:hover) #input+#switch{background-color:var(--highcontrast-switch-background-color-disabled,var(--mod-switch-background-color-disabled,var(--spectrum-switch-background-color-disabled)))}:host([disabled]:hover) #input+#switch:before,:host([disabled]:hover) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-disabled,var(--mod-switch-handle-border-color-disabled,var(--spectrum-switch-handle-border-color-disabled)))}:host([disabled]:hover) #input~#label,:host([disabled]:hover) #input~#label{color:var(--highcontrast-switch-label-color-disabled,var(--mod-switch-label-color-disabled,var(--spectrum-switch-label-color-disabled)))}:host([disabled][checked]:hover) #input+#switch,:host([disabled][checked]:hover) #input+#switch{background-color:var(--highcontrast-switch-background-color-selected-disabled,var(--mod-switch-background-color-selected-disabled,var(--spectrum-switch-background-color-selected-disabled)))}:host([disabled][checked]:hover) #input+#switch:before,:host([disabled][checked]:hover) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-disabled,var(--mod-switch-handle-border-color-disabled,var(--spectrum-switch-handle-border-color-disabled)))}:host([disabled][checked]:hover) #input~#label,:host([disabled][checked]:hover) #input~#label{color:var(--highcontrast-switch-label-color-disabled,var(--mod-switch-label-color-disabled,var(--spectrum-switch-label-color-disabled)))}:host(:hover) #input:focus-visible+#switch:after{box-shadow:0 0 0 var(--mod-switch-focus-indicator-thickness,var(--spectrum-switch-focus-indicator-thickness))var(--highcontrast-switch-focus-indicator-color,var(--mod-switch-focus-indicator-color,var(--spectrum-switch-focus-indicator-color)))}:host(:hover) #input:focus-visible+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-focus,var(--mod-switch-handle-border-color-focus,var(--spectrum-switch-handle-border-color-focus)))}:host([checked]:hover) #input:focus-visible+#switch{background-color:var(--highcontrast-switch-background-color-selected-focus,var(--mod-switch-background-color-selected-focus,var(--spectrum-switch-background-color-selected-focus)))}:host([checked]:hover) #input:focus-visible+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-selected-focus,var(--mod-switch-handle-border-color-selected-focus,var(--spectrum-switch-handle-border-color-selected-focus)))}:host(:hover) #input:focus-visible~#label{color:var(--highcontrast-switch-label-color-focus,var(--mod-switch-label-color-focus,var(--spectrum-switch-label-color-focus)))}}:host([checked]) #input+#switch{background-color:var(--highcontrast-switch-background-color-selected-default,var(--mod-switch-background-color-selected-default,var(--spectrum-switch-background-color-selected-default)))}:host([checked]) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-selected-default,var(--mod-switch-handle-border-color-selected-default,var(--spectrum-switch-handle-border-color-selected-default)))}:host([disabled]) #input+#switch,:host([disabled]) #input+#switch{background-color:var(--highcontrast-switch-background-color-disabled,var(--mod-switch-background-color-disabled,var(--spectrum-switch-background-color-disabled)))}:host([disabled]) #input+#switch:before,:host([disabled]) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-disabled,var(--mod-switch-handle-border-color-disabled,var(--spectrum-switch-handle-border-color-disabled)))}:host([disabled][checked]) #input+#switch,:host([disabled][checked]) #input+#switch{background-color:var(--highcontrast-switch-background-color-selected-disabled,var(--mod-switch-background-color-selected-disabled,var(--spectrum-switch-background-color-selected-disabled)))}:host([disabled][checked]) #input+#switch:before,:host([disabled][checked]) #input+#switch:before{border-color:var(--highcontrast-switch-handle-border-color-disabled,var(--mod-switch-handle-border-color-disabled,var(--spectrum-switch-handle-border-color-disabled)))}:host([disabled]) #input~#label,:host([disabled]) #input~#label{color:var(--highcontrast-switch-label-color-disabled,var(--mod-switch-label-color-disabled,var(--spectrum-switch-label-color-disabled)))}@media (forced-colors:active){:host{forced-color-adjust:none;--highcontrast-switch-label-color-default:ButtonText;--highcontrast-switch-label-color-hover:ButtonText;--highcontrast-switch-label-color-down:ButtonText;--highcontrast-switch-label-color-focus:ButtonText;--highcontrast-switch-label-color-disabled:GrayText;--highcontrast-switch-handle-background-color:ButtonFace;--highcontrast-switch-handle-border-color-default:ButtonText;--highcontrast-switch-handle-border-color-hover:Highlight;--highcontrast-switch-handle-border-color-down:Highlight;--highcontrast-switch-handle-border-color-focus:Highlight;--highcontrast-switch-handle-border-color-disabled:Highlight;--highcontrast-switch-handle-border-color-selected-default:Highlight;--highcontrast-switch-handle-border-color-selected-hover:Highlight;--highcontrast-switch-handle-border-color-selected-down:Highlight;--highcontrast-switch-handle-border-color-selected-focus:Highlight;--highcontrast-switch-background-color:ButtonFace;--highcontrast-switch-background-color-selected-default:Highlight;--highcontrast-switch-background-color-selected-hover:Highlight;--highcontrast-switch-background-color-selected-down:Highlight;--highcontrast-switch-background-color-selected-focus:Highlight;--highcontrast-switch-background-color-selected-disabled:Highlight;--highcontrast-switch-focus-indicator-color:ButtonText}#input:not(:checked)+#switch{box-shadow:inset 0 0 0 1px ButtonText}@media (hover:hover){:host(:hover) #input:not(:checked)+#switch{box-shadow:inset 0 0 0 1px Highlight}:host([disabled][checked]:hover) #input+#switch,:host([disabled][checked]:hover) #input+#switch{box-shadow:inset 0 0 0 1px GrayText;background-color:GrayText}:host([disabled][checked]:hover) #input+#switch:before,:host([disabled][checked]:hover) #input+#switch:before{border-color:GrayText;background-color:ButtonFace}}:host([disabled]) #input:not(:checked)+#switch,:host([disabled]) #input:not(:checked)+#switch{box-shadow:inset 0 0 0 1px GrayText;background-color:ButtonFace}:host([disabled]) #input:not(:checked)+#switch:before,:host([disabled]) #input:not(:checked)+#switch:before{border-color:GrayText;background-color:ButtonFace}:host([disabled][checked]) #input+#switch,:host([disabled][checked]) #input+#switch{box-shadow:inset 0 0 0 1px GrayText;background-color:GrayText}:host([disabled][checked]) #input+#switch:before,:host([disabled][checked]) #input+#switch:before{border-color:GrayText;background-color:ButtonFace}:host([disabled]) #input~#label,:host([disabled]) #input~#label{color:GrayText}}:host{--spectrum-switch-handle-border-color-default:var(--system-spectrum-switch-handle-border-color-default);--spectrum-switch-handle-border-color-hover:var(--system-spectrum-switch-handle-border-color-hover);--spectrum-switch-handle-border-color-down:var(--system-spectrum-switch-handle-border-color-down);--spectrum-switch-handle-border-color-focus:var(--system-spectrum-switch-handle-border-color-focus);--spectrum-switch-handle-border-color-selected-default:var(--system-spectrum-switch-handle-border-color-selected-default);--spectrum-switch-handle-border-color-selected-hover:var(--system-spectrum-switch-handle-border-color-selected-hover);--spectrum-switch-handle-border-color-selected-down:var(--system-spectrum-switch-handle-border-color-selected-down);--spectrum-switch-handle-border-color-selected-focus:var(--system-spectrum-switch-handle-border-color-selected-focus)}:host([disabled]){pointer-events:none} +`,h=n;import{css as u}from"./base.js";var b=u` + #switch:before{transition:background var(--spectrum-global-animation-duration-100,.13s)ease-in-out,border var(--spectrum-global-animation-duration-100,.13s)ease-in-out,box-shadow var(--spectrum-global-animation-duration-100,.13s)ease-in-out} +`,l=b;var p=Object.defineProperty,w=Object.getOwnPropertyDescriptor,m=(c,o,s,e)=>{for(var t=e>1?void 0:e?w(o,s):o,i=c.length-1,a;i>=0;i--)(a=c[i])&&(t=(e?a(o,s,t):a(t))||t);return e&&t&&p(o,s,t),t},r=class extends g(k){constructor(){super(...arguments),this.emphasized=!1}static get styles(){return window.hasOwnProperty("ShadyDOM")?[h,l]:[h]}render(){return v` + ${super.render()} + + + `}firstUpdated(o){super.firstUpdated(o),this.inputElement.setAttribute("role","switch")}updated(o){o.has("checked")&&this.inputElement.setAttribute("aria-checked",this.checked?"true":"false")}};m([f({type:Boolean,reflect:!0})],r.prototype,"emphasized",2);import{defineElement as x}from"./base.js";x("sp-switch",r); diff --git a/libs/features/spectrum-web-components/package.json b/libs/features/spectrum-web-components/package.json index d8e48d0b67..e3fc8dcf9a 100644 --- a/libs/features/spectrum-web-components/package.json +++ b/libs/features/spectrum-web-components/package.json @@ -38,6 +38,7 @@ "@spectrum-web-components/search": "^0.47.2", "@spectrum-web-components/shared": "^0.47.2", "@spectrum-web-components/sidenav": "^0.47.2", + "@spectrum-web-components/switch": "^0.47.2", "@spectrum-web-components/tabs": "^0.47.2", "@spectrum-web-components/textfield": "^0.47.2", "@spectrum-web-components/theme": "^0.47.2", diff --git a/libs/features/spectrum-web-components/src/checkbox.js b/libs/features/spectrum-web-components/src/checkbox.js index e9b091ad04..1fd0f86513 100644 --- a/libs/features/spectrum-web-components/src/checkbox.js +++ b/libs/features/spectrum-web-components/src/checkbox.js @@ -1 +1,2 @@ import '@spectrum-web-components/checkbox/sp-checkbox.js'; +export * from '@spectrum-web-components/checkbox/src/CheckboxBase.js'; diff --git a/libs/features/spectrum-web-components/src/switch.js b/libs/features/spectrum-web-components/src/switch.js new file mode 100644 index 0000000000..80a6e2f13a --- /dev/null +++ b/libs/features/spectrum-web-components/src/switch.js @@ -0,0 +1,3 @@ +/* eslint-disable no-unused-vars */ +/* eslint-disable import/no-unresolved */ +import '@spectrum-web-components/switch/sp-switch.js'; diff --git a/test/features/spectrum-web-components/switch.test.html b/test/features/spectrum-web-components/switch.test.html new file mode 100644 index 0000000000..bd077b123a --- /dev/null +++ b/test/features/spectrum-web-components/switch.test.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + From 39eafc824fd4d1500bedaa8a65debec23b14f8e5 Mon Sep 17 00:00:00 2001 From: Santoshkumar Nateekar Date: Mon, 9 Dec 2024 09:48:07 -0800 Subject: [PATCH 8/8] [NALA][Table-Tooltip] Update tooltip locator (#3335) update tooltip locator Co-authored-by: Santoshkumar Sharanappa Nateekar --- nala/blocks/table/table.page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nala/blocks/table/table.page.js b/nala/blocks/table/table.page.js index eaa03d9f28..93e3854408 100644 --- a/nala/blocks/table/table.page.js +++ b/nala/blocks/table/table.page.js @@ -63,7 +63,7 @@ export default class Table { // verify tooltip information if (tooltip) { const headerColumnTooltip = await headerColumn.locator('.milo-tooltip'); - await expect(await headerColumnTooltip.locator('.icon-milo-info')).toBeVisible(); + await expect(await headerColumnTooltip.locator('.icon-milo')).toBeVisible(); await expect(await headerColumnTooltip).toHaveAttribute('data-tooltip', tooltip.tooltipText); await headerColumnTooltip.hover(); } @@ -94,7 +94,7 @@ export default class Table { } if (column.tooltip) { const tooltip = await sectionRowColumn.locator('.milo-tooltip'); - await expect(await tooltip.locator('.icon-milo-info')).toBeVisible(); + await expect(await tooltip.locator('.icon-milo')).toBeVisible(); await expect(await tooltip).toHaveAttribute('data-tooltip', column.tooltipText); await tooltip.hover(); }