Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions blocks/edit/da-assets/da-assets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNx, nxJS } from '../../../scripts/utils.js';
import { getNx } from '../../../scripts/utils.js';
import getPathDetails from '../../shared/pathDetails.js';
import { getRepositoryConfig, getResponsiveImageConfig } from './helpers/config.js';
import {
Expand Down Expand Up @@ -177,9 +177,17 @@ export function buildHandleSelection(
}

export async function openAssets() {
const { loadStyle } = await import(`${getNx()}${nxJS}`);
const { loadIms, handleSignIn } = await import(`${getNx()}/utils/ims.js`);
const loadScript = (await import(`${getNx()}/utils/script.js`)).default;
const nx = getNx();
const isNx2 = nx.endsWith('/nx2');
const { loadStyle } = await import(`${nx}/utils/utils.js`);
// TODO: remove the ternary and the nx v1 branch once nxver=2 is
// rolled out on the CDN. Kept for backward compat during the
// transition: nx v1 exposes loadScript at utils/script.js; nx2
// re-exports it from utils/utils.js.
const loadScript = isNx2
? (await import(`${nx}/utils/utils.js`)).loadScript
: (await import(`${nx}/utils/script.js`)).default;
const { loadIms, handleSignIn } = await import(`${nx}/utils/ims.js`);

const details = await loadIms();
if (details.anonymous) handleSignIn();
Expand All @@ -195,7 +203,10 @@ export async function openAssets() {
return;
}

await loadStyle(import.meta.url.replace('.js', '.css'));
const assetSheet = await loadStyle(import.meta.url);
if (assetSheet && !document.adoptedStyleSheets.includes(assetSheet)) {
document.adoptedStyleSheets = [...document.adoptedStyleSheets, assetSheet];
}
await loadScript(ASSET_SELECTOR_URL);

dialog = document.createElement('dialog');
Expand Down
2 changes: 1 addition & 1 deletion blocks/edit/da-content/da-content.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

position: relative;
flex: 0 1 auto;
width: var(--grid-container-width);
width: var(--se-grid-container-width, var(--grid-container-width));
}

da-editor {
Expand Down
8 changes: 4 additions & 4 deletions blocks/edit/da-editor/da-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

.da-version-title {
margin: 0;
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
font-size: 18px;
font-weight: 700;
color: #000;
Expand All @@ -52,14 +52,14 @@
}

.da-version-action-area button {
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
display: inline-block;
font-style: normal;
cursor: pointer;
padding: 5px 14px;
line-height: 18px;
font-size: 15px;
border-radius: var(--s2-radius-300);
border-radius: var(--s2-corner-radius-800, var(--s2-radius-300));
outline-offset: 0;
transition: outline-offset .2s;
text-decoration: none;
Expand Down Expand Up @@ -814,7 +814,7 @@ da-library.hide {
left: -1px;
font-size: 13px;
background-color: rgb(250 129 0);
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
border-radius: 2px;
font-style: normal;
font-weight: normal;
Expand Down
2 changes: 1 addition & 1 deletion blocks/edit/da-library/da-library.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

input, button {
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
font-weight: 400;
}

Expand Down
2 changes: 1 addition & 1 deletion blocks/edit/da-library/da-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from './helpers/helpers.js';

const sheet = await getSheet('/blocks/edit/da-library/da-library.css');
const buttons = await getSheet(`${getNx()}/styles/buttons.css`);
const buttons = await getSheet(`${getNx().replace(/\/nx2$/, '/nx')}/styles/buttons.css`);

const ICONS = [
'/blocks/edit/img/S2_Icon_ExperienceAdd_20_N.svg',
Expand Down
9 changes: 6 additions & 3 deletions blocks/edit/da-not-found/da-not-found.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import '../../shared/da-dialog/da-dialog.js';
import { getNx, getNx2Api, nxJS } from '../../../scripts/utils.js';
import { getNx, getNx2Api } from '../../../scripts/utils.js';

const { loadStyle } = await import(`${getNx()}${nxJS}`);
await loadStyle('/blocks/edit/da-not-found/da-not-found.css');
const { loadStyle } = await import(`${getNx()}/utils/utils.js`);
const sheet = await loadStyle('/blocks/edit/da-not-found/da-not-found.css');
if (sheet && !document.adoptedStyleSheets.includes(sheet)) {
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
}

async function folderHasContents(folderPath) {
try {
Expand Down
2 changes: 1 addition & 1 deletion blocks/edit/da-palette/da-palette.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ input {
}

button {
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
display: block;
border: 2px solid #1373e6;
background: #1373e6;
Expand Down
4 changes: 2 additions & 2 deletions blocks/edit/da-title/da-title.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ h1 {
}

button {
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
}

da-prepare {
Expand Down Expand Up @@ -52,7 +52,7 @@ da-dialog {
}

.da-title-inner {
max-width: var(--grid-container-width);
max-width: var(--se-grid-container-width, var(--grid-container-width));
margin: 0 auto;
display: block;
justify-content: space-between;
Expand Down
4 changes: 2 additions & 2 deletions blocks/edit/da-versions/da-versions.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

.da-versions-close-btn {
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
line-height: 32px;
font-weight: 700;
font-size: 20px;
Expand Down Expand Up @@ -173,7 +173,7 @@
.da-version-new-input {
border: none;
border-bottom: 2px solid #C8C8C8;
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
font-size: 18px;
font-weight: 700;
padding: 6px 0;
Expand Down
4 changes: 4 additions & 0 deletions blocks/edit/edit.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* TODO: remove once dark-mode styling is complete. */
.light-scheme, .dark-scheme {
color-scheme: light;
}
6 changes: 5 additions & 1 deletion blocks/edit/edit.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import getPathDetails from '../shared/pathDetails.js';
import { contentLogin, livePreviewLogin } from '../shared/utils.js';
import { getNx2Api } from '../../scripts/utils.js';
import { getNx, getNx2Api } from '../../scripts/utils.js';

import './da-title/da-title.js';
import './da-content/da-content.js';

const { loadStyle } = await import(`${getNx()}/utils/utils.js`);
const styles = await loadStyle(import.meta.url);
document.adoptedStyleSheets.push(styles);

const EMPTY_DOC = '<body><header></header><main><div></div></main><footer></footer></body>';
const DOMPARSER = new DOMParser();

Expand Down
9 changes: 6 additions & 3 deletions blocks/edit/prose/plugins/focalPointDialog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import '../../../shared/da-dialog/da-dialog.js';
import { getNx, nxJS } from '../../../../scripts/utils.js';
import { getNx } from '../../../../scripts/utils.js';

const { loadStyle } = await import(`${getNx()}${nxJS}`);
await loadStyle('/blocks/edit/prose/plugins/focalPointDialog.css');
const { loadStyle } = await import(`${getNx()}/utils/utils.js`);
const focalSheet = await loadStyle('/blocks/edit/prose/plugins/focalPointDialog.css');
if (focalSheet && !document.adoptedStyleSheets.includes(focalSheet)) {
document.adoptedStyleSheets = [...document.adoptedStyleSheets, focalSheet];
}

let currentDialog = null;
let faceApiLoaded = false;
Expand Down
2 changes: 1 addition & 1 deletion blocks/sheet/da-sheet-preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
box-shadow: rgb(181 181 181) 0 0 20px 0;
border-radius: 12px;
height: 500px;
padding: var(--spacing-200);
padding: var(--s2-spacing-200, var(--spacing-200));
overflow: scroll;
box-sizing: border-box;
}
Expand Down
6 changes: 3 additions & 3 deletions blocks/sheet/da-sheet-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { LitElement, html, nothing } from 'da-lit';
import { getNx } from '../../scripts/utils.js';
import getPathDetails from '../shared/pathDetails.js';

const { default: getStyle } = await import(`${getNx()}/utils/styles.js`);
const { loadStyle } = await import(`${getNx()}/utils/utils.js`);

const style = await getStyle('/blocks/sheet/da-sheet-preview.css');
const style = await loadStyle('/blocks/sheet/da-sheet-preview.css');

class DaSheetPreview extends LitElement {
static properties = {
Expand Down Expand Up @@ -46,7 +46,7 @@ class DaSheetPreview extends LitElement {
}

renderValue(value) {
if (!(value.startsWith('/') || value.startsWith('http'))) return value;
if (typeof value !== 'string' || !(value.startsWith('/') || value.startsWith('http'))) return value;
const links = value.split(',').map((val) => val.replaceAll(' ', ''));
return links.map((link) => html`<a href="${this.getUrl(link)}" target="_blank">${link}</a> `);
}
Expand Down
8 changes: 4 additions & 4 deletions blocks/sheet/da-sheet-tabs.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:host {
display: flex;
gap: var(--spacing-200);
margin-bottom: var(--spacing-200);
gap: var(--s2-spacing-200, var(--spacing-200));
margin-bottom: var(--s2-spacing-200, var(--spacing-200));
flex-wrap: wrap;
}

Expand All @@ -14,7 +14,7 @@ ul {
padding: 0;
list-style: none;
display: flex;
gap: var(--spacing-200);
gap: var(--s2-spacing-200, var(--spacing-200));
flex-wrap: wrap;
}

Expand All @@ -38,7 +38,7 @@ input {

button,
input[type="text"] {
font-family: var(--body-font-family);
font-family: var(--s2-font-family, var(--body-font-family));
}

li.active {
Expand Down
8 changes: 4 additions & 4 deletions blocks/sheet/da-sheet-tabs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { LitElement, html, nothing } from 'da-lit';
import { getNx } from '../../scripts/utils.js';
import inlinesvg from '../shared/inlinesvg.js';
import { handleSave } from './utils/utils.js';

const { default: getStyle } = await import(`${getNx()}/utils/styles.js`);
const { default: getSvg } = await import(`${getNx()}/utils/svg.js`);
const { loadStyle } = await import(`${getNx()}/utils/utils.js`);

const style = await getStyle(import.meta.url);
const style = await loadStyle(import.meta.url);

const SHEET_TEMPLATE = { minDimensions: [20, 20], sheetName: 'data' };
const ICONS = [
Expand All @@ -31,7 +31,7 @@ class DaSheetTabs extends LitElement {
connectedCallback() {
super.connectedCallback();
this.shadowRoot.adoptedStyleSheets = [style];
getSvg({ parent: this.shadowRoot, paths: ICONS });
inlinesvg({ parent: this.shadowRoot, paths: ICONS });
this._names = this.getNames();
this.showSheet(0);
this.getPermissions();
Expand Down
2 changes: 1 addition & 1 deletion blocks/sheet/da-version-review.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ button {
padding: 5px 14px;
line-height: 18px;
font-size: 15px;
border-radius: var(--s2-radius-300);
border-radius: var(--s2-corner-radius-800, var(--s2-radius-300));
outline-offset: 0;
transition: outline-offset .2s;
text-decoration: none;
Expand Down
4 changes: 2 additions & 2 deletions blocks/sheet/da-version-review.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { LitElement, html } from 'da-lit';
import { getNx } from '../../scripts/utils.js';

const { default: getStyle } = await import(`${getNx()}/utils/styles.js`);
const { loadStyle } = await import(`${getNx()}/utils/utils.js`);

const style = await getStyle('/blocks/sheet/da-version-review.css');
const style = await loadStyle('/blocks/sheet/da-version-review.css');

class DaVersionReview extends LitElement {
static properties = { data: { type: Object } };
Expand Down
8 changes: 7 additions & 1 deletion blocks/sheet/sheet.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* stylelint-disable property-no-vendor-prefix */

/* TODO: remove once dark-mode styling is complete. */
.light-scheme, .dark-scheme {
color-scheme: light;
}

body {
background: rgb(250 250 250);
}
Expand All @@ -14,7 +20,7 @@ body {
display: flex;
justify-content: center;
max-width: 83.4%;
margin: 0 auto var(--spacing-600) auto;
margin: 0 auto var(--s2-spacing-600, var(--spacing-600)) auto;
}

da-versions,
Expand Down
7 changes: 5 additions & 2 deletions blocks/sheet/sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import { getData } from './utils/index.js';
import { staleCheck, showDaDialog, restoreVersion } from './utils/utils.js';
import { convertSheets } from '../edit/utils/helpers.js';

const { default: getStyle } = await import(`${getNx()}/utils/styles.js`);
const { loadStyle } = await import(`${getNx()}/utils/utils.js`);

const style = await getStyle('/blocks/sheet/da-sheet-panes.css');
const blockStyle = await loadStyle(import.meta.url);
document.adoptedStyleSheets = [...document.adoptedStyleSheets, blockStyle];

const style = await loadStyle('/blocks/sheet/da-sheet-panes.css');

class DaSheetPanes extends LitElement {
static properties = {
Expand Down
22 changes: 18 additions & 4 deletions blocks/sheet/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import { getNx, getNx2Api, nxJS } from '../../../scripts/utils.js';
import { getNx, getNx2Api } from '../../../scripts/utils.js';
import { handleSave, staleCheck } from './utils.js';
import '../da-sheet-tabs.js';

const { loadStyle } = await import(`${getNx()}${nxJS}`);
const loadScript = (await import(`${getNx()}/utils/script.js`)).default;
const nx = getNx();
const isNx2 = nx.endsWith('/nx2');
const { loadStyle } = await import(`${nx}/utils/utils.js`);
// TODO: remove the ternary and the nx v1 branch once nxver=2 is rolled
// out on the CDN. Kept for backward compat during the transition:
// nx v1 exposes loadScript at utils/script.js; nx2 re-exports it from
// utils/utils.js.
const loadScript = isNx2
? (await import(`${nx}/utils/utils.js`)).loadScript
: (await import(`${nx}/utils/script.js`)).default;

async function adoptStyle(href) {
const sheet = await loadStyle(href);
if (!sheet || document.adoptedStyleSheets.includes(sheet)) return;
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
}

const SHEET_TEMPLATE = { minDimensions: [20, 20], sheetName: 'data' };

Expand Down Expand Up @@ -151,7 +165,7 @@ export async function getData(input) {
export default async function init(el, data) {
const suppliedData = data || await getData(el.details);

await loadStyle('/deps/jspreadsheet-ce/dist/jspreadsheet.css');
await adoptStyle('/deps/jspreadsheet-ce/dist/jspreadsheet.css');
await loadScript('/deps/jspreadsheet-ce/dist/index.js');
await loadScript('/deps/jsuites/dist/jsuites.js');

Expand Down
1 change: 0 additions & 1 deletion test/fixtures/nx/utils/styles.js

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/nx/utils/svg.js

This file was deleted.

2 changes: 2 additions & 0 deletions test/fixtures/nx/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const loadStyle = async () => {
return sheet;
};

export const loadScript = async () => {};

export const DA_ADMIN = 'https://admin.da.live';

let _hashState = {};
Expand Down
Loading