Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor-container): some UI related issues #357

Merged
merged 4 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 2 additions & 8 deletions __snapshots__/bay-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<div
id="ceContainer"
slot="container"
>
<div id="ceContainer">
<conducting-equipment-editor>
</conducting-equipment-editor>
<conducting-equipment-editor>
Expand Down Expand Up @@ -99,10 +96,7 @@
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<div
id="ceContainer"
slot="container"
>
<div id="ceContainer">
<conducting-equipment-editor readonly="">
</conducting-equipment-editor>
<conducting-equipment-editor readonly="">
Expand Down
14 changes: 4 additions & 10 deletions __snapshots__/substation-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<voltage-level-editor slot="container">
<voltage-level-editor>
</voltage-level-editor>
<voltage-level-editor slot="container">
<voltage-level-editor>
</voltage-level-editor>
</editor-container>

Expand Down Expand Up @@ -88,15 +88,9 @@
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<voltage-level-editor
readonly=""
slot="container"
>
<voltage-level-editor readonly="">
</voltage-level-editor>
<voltage-level-editor
readonly=""
slot="container"
>
<voltage-level-editor readonly="">
</voltage-level-editor>
</editor-container>

Expand Down
10 changes: 2 additions & 8 deletions __snapshots__/voltage-level-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<div
id="bayContainer"
slot="container"
>
<div id="bayContainer">
<bay-editor>
</bay-editor>
<bay-editor>
Expand Down Expand Up @@ -95,10 +92,7 @@
<mwc-icon-button icon="delete">
</mwc-icon-button>
</abbr>
<div
id="bayContainer"
slot="container"
>
<div id="bayContainer">
<bay-editor readonly="">
</bay-editor>
<bay-editor readonly="">
Expand Down
6 changes: 3 additions & 3 deletions __snapshots__/zeroline-pane.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</abbr>
</nav>
</h1>
<section tabindex="0">
<section>
<substation-editor>
</substation-editor>
<substation-editor>
Expand Down Expand Up @@ -79,7 +79,7 @@
</abbr>
</nav>
</h1>
<section tabindex="0">
<section>
<substation-editor readonly="">
</substation-editor>
<substation-editor readonly="">
Expand Down Expand Up @@ -123,7 +123,7 @@
</abbr>
</nav>
</h1>
<section tabindex="0">
<section>
<substation-editor>
</substation-editor>
<substation-editor>
Expand Down
39 changes: 20 additions & 19 deletions src/editor-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export class EditorContainer extends LitElement {

async firstUpdated(): Promise<void> {
await super.updateComplete;

if (this.addMenu) this.addMenu.anchor = this.headerContainer;

const parentEditorContainer =
<EditorContainer>(
(<ShadowRoot>this.parentNode).host?.closest('editor-container')
Expand All @@ -89,6 +91,8 @@ export class EditorContainer extends LitElement {
);

this.contrasted = !parentEditorContainer.contrasted;

this.tabIndex = 0;
}

private renderAddButtons(): TemplateResult[] {
Expand Down Expand Up @@ -122,6 +126,7 @@ export class EditorContainer extends LitElement {
id="menu"
corner="TOP_RIGHT"
menuCorner="END"
.anchor=${this.headerContainer}
@selected=${(e: Event) => {
const tagName = (<ListItem>(<Menu>e.target).selected).value;
this.openCreateWizard(tagName);
Expand Down Expand Up @@ -178,15 +183,14 @@ export class EditorContainer extends LitElement {
contrasted: this.contrasted,
nomargin: this.nomargin,
})}"
tabindex="0"
>
${this.renderHeader()}
<slot name="container"></slot>
<slot></slot>
</section>`;
}

static styles = css`
:host(.moving) section {
:host(.moving) .container {
opacity: 0.3;
}

Expand All @@ -195,7 +199,7 @@ export class EditorContainer extends LitElement {
transition: all 200ms linear;
outline-style: solid;
margin: 8px 12px 16px;
padding: 0.02px; /*Dirty hack to force outline around content with margin*/
overflow: hidden;
outline-width: 0px;
outline-color: var(--mdc-theme-primary);
opacity: 1;
Expand All @@ -215,34 +219,31 @@ export class EditorContainer extends LitElement {

.nomargin {
margin: 0px;
overflow: visible;
}

.container:focus {
box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14),
0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2);
:host {
outline: none;
}

.container:focus-within {
:host(:focus-within) .container {
box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14),
0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2);
outline-width: 2px;
transition: all 250ms linear;
}

.container:focus-within h1,
.container:focus-within h2,
.container:focus-within h3 {
:host(:focus-within) h1,
:host(:focus-within) h2,
:host(:focus-within) h3 {
color: var(--mdc-theme-surface);
transition: background-color 200ms linear;
}

.container:focus-within h1,
.container:focus-within h2,
.container:focus-within h3 {
background-color: var(--mdc-theme-primary);
}

.container.secondary:focus-within h1,
.container.secondary:focus-within h2,
.container.secondary:focus-within h3 {
:host(:focus-within) .container.secondary h1,
:host(:focus-within) .container.secondary h2,
:host(:focus-within) .container.secondary h3 {
background-color: var(--mdc-theme-secondary);
}

Expand Down
2 changes: 1 addition & 1 deletion src/zeroline-pane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class ZerolinePane extends LitElement {
</h1>
${this.renderIedContainer()}
${this.doc?.querySelector(':root > Substation')
? html`<section tabindex="0">
? html`<section>
${Array.from(this.doc.querySelectorAll('Substation') ?? [])
.filter(isPublic)
.map(
Expand Down
4 changes: 2 additions & 2 deletions src/zeroline/bay-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class BayEditor extends LitElement {
renderIedContainer(): TemplateResult {
const ieds = this.getAttachedIeds?.(this.element) ?? [];
return ieds?.length
? html`<div slot="container" id="iedcontainer">
? html`<div id="iedcontainer">
${ieds.map(ied => html`<ied-editor .element=${ied}></ied-editor>`)}
</div>`
: html``;
Expand Down Expand Up @@ -99,7 +99,7 @@ export class BayEditor extends LitElement {
></mwc-icon-button>
</abbr>
${this.renderIedContainer()}
<div slot="container" id="ceContainer">
<div id="ceContainer">
${Array.from(
getChildElementsByTagName(this.element, 'ConductingEquipment')
).map(
Expand Down
3 changes: 1 addition & 2 deletions src/zeroline/substation-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class SubstationEditor extends LitElement {
renderIedContainer(): TemplateResult {
const ieds = this.getAttachedIeds?.(this.element) ?? [];
return ieds?.length
? html`<div id="iedcontainer" slot="container">
? html`<div id="iedcontainer">
${ieds.map(ied => html`<ied-editor .element=${ied}></ied-editor>`)}
</div>`
: html``;
Expand Down Expand Up @@ -110,7 +110,6 @@ export class SubstationEditor extends LitElement {
).map(
voltageLevel =>
html`<voltage-level-editor
slot="container"
.element=${voltageLevel}
.getAttachedIeds=${this.getAttachedIeds}
?readonly=${this.readonly}
Expand Down
4 changes: 2 additions & 2 deletions src/zeroline/voltage-level-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class VoltageLevelEditor extends LitElement {
renderIedContainer(): TemplateResult {
const ieds = this.getAttachedIeds?.(this.element) ?? [];
return ieds?.length
? html`<div id="iedcontainer" slot="container">
? html`<div id="iedcontainer">
${ieds.map(ied => html`<ied-editor .element=${ied}></ied-editor>`)}
</div>`
: html``;
Expand Down Expand Up @@ -121,7 +121,7 @@ export class VoltageLevelEditor extends LitElement {
></mwc-icon-button>
</abbr>
${this.renderIedContainer()}
<div id="bayContainer" slot="container">
<div id="bayContainer">
${Array.from(this.element?.querySelectorAll(selectors.Bay) ?? []).map(
bay => html`<bay-editor
.element=${bay}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/editor-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('editor-container', () => {
);
beforeEach(async () => {
parent = await fixture(
`<editor-container header="parent header"><bay-editor .element=${bay} slot="container"></bay-editor></editor-container>`
`<editor-container header="parent header"><bay-editor .element=${bay}></bay-editor></editor-container>`
);

element = parent
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('editor-container', () => {

it('negated the set contrasted property of the parent', async () => {
parent = await fixture(
`<editor-container contrasted header="parent header"><bay-editor .element=${bay} slot="container"></bay-editor></editor-container>`
`<editor-container contrasted header="parent header"><bay-editor .element=${bay}></bay-editor></editor-container>`
);

element = parent
Expand All @@ -230,7 +230,7 @@ describe('editor-container', () => {

it('makes sure maximum level is 6', async () => {
parent = await fixture(
`<editor-container level="6" header="parent header"><bay-editor .element=${bay} slot="container"></bay-editor></editor-container>`
`<editor-container level="6" header="parent header"><bay-editor .element=${bay}></bay-editor></editor-container>`
);

element = parent
Expand Down