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

feat(open-scd): remove landing dialog around buttons #74

Merged
merged 5 commits into from
Dec 17, 2020
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
68 changes: 37 additions & 31 deletions src/open-scd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class OpenSCD extends Setting(
@query('#menu') menuUI!: Drawer;
@query('#file-input') fileUI!: HTMLInputElement;
@query('#saveas') saveUI!: Dialog;
@query('#landing-dialog') landingDialog!: Dialog;

/** Loads and parses an `XMLDocument` after [[`src`]] has changed. */
private loadDoc(src: string): Promise<string> {
Expand All @@ -108,7 +107,6 @@ export class OpenSCD extends Setting(
reject(get('openSCD.readAbort', { name: this.srcName }))
);
reader.addEventListener('load', () => {
if (reader.result) this.landingDialog.close();
this.doc = reader.result
? new DOMParser().parseFromString(
<string>reader.result,
Expand Down Expand Up @@ -200,7 +198,6 @@ export class OpenSCD extends Setting(
schema.release
);

this.landingDialog.close();
wizard.close();

return [];
Expand All @@ -212,8 +209,8 @@ export class OpenSCD extends Setting(
{
title: get('menu.new'),
primary: {
icon: 'save',
label: get('save'),
icon: 'add',
label: get('add'),
action: this.createNewProject(),
},
content: [
Expand All @@ -228,11 +225,11 @@ export class OpenSCD extends Setting(
<mwc-list activatable>
<mwc-radio-list-item
value="${JSON.stringify(versionSupport.edition1)}"
>Edition1 (Schema 1.7)</mwc-radio-list-item
>Edition 1 (Schema 1.7)</mwc-radio-list-item
>
<mwc-radio-list-item
value="${JSON.stringify(versionSupport.edition2)}"
>Edition 2(2007A)</mwc-radio-list-item
>Edition 2 (2007A)</mwc-radio-list-item
>
<mwc-radio-list-item
selected
Expand Down Expand Up @@ -431,31 +428,27 @@ export class OpenSCD extends Setting(
${translate('cancel')}
</mwc-button>
</mwc-dialog>

<mwc-dialog open id="landing-dialog" hideActions scrimClickAction="">
<div style="display:flex; flex-direction: row">

${
this.doc
? until(
this.plugins.editors[this.activeTab].getContent(),
html`<mwc-linear-progress indeterminate></mwc-linear-progress>`
)
: html`<div class="landing">
<mwc-icon-button
class="landing_page_icon"
class="landing_icon"
icon="create_new_folder"
@click=${() => this.openNewProjectWizard()}>
<div class="label">${translate('menu.new')}</div>
<div class="landing_label">${translate('menu.new')}</div>
</mwc-icon-button>
<mwc-icon-button
class="landing_page_icon"
class="landing_icon"
icon="folder_open"
@click=${() => this.fileUI.click()}>
<div class="label">${translate('menu.open')}</div>
<div class="landing_label">${translate('menu.open')}</div>
</mwc-button>
</div>
</mwc-dialog>

${
this.doc
? until(
this.plugins.editors[this.activeTab].getContent(),
html`<mwc-linear-progress indeterminate></mwc-linear-progress>`
)
: ``
</div>`
}

<input id="file-input" type="file" accept=".scd,.ssd" @change="${
Expand Down Expand Up @@ -510,21 +503,34 @@ export class OpenSCD extends Setting(
font-weight: 300;
}

.landing_page_icon {
width: 150px;
height: 160px;
.landing {
display: flex;
flex-direction: row;
justify-content: center;
position: absolute;
top: calc(50vh - 80px);
left: calc(50vw - 180px);
}

.landing_icon {
margin: 10px;
border-style: solid;
border-radius: 10px;
width: 160px;
height: 150px;
text-align: center;
color: var(--mdc-theme-primary);
--mdc-icon-button-size: 100px;
--mdc-icon-size: 100px;
--mdc-button-horizontal-padding: 40px;
--mdc-theme-primary: var(--mdc-theme-secondary);
}

.label {
width: 140px;
.landing_label {
width: 160px;
height: 50px;
margin-top: 100px;
margin-left: -20px;
margin-left: -30px;
font-family: 'Roboto', sans-serif;
}
`;
}
3 changes: 3 additions & 0 deletions src/wizard-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class WizardDialog extends LitElement {
dialogAction="prev"
icon="navigate_before"
label=${this.wizard?.[index - 1].title}
outlined
></mwc-button>`
: html``}
${page.secondary
Expand All @@ -136,6 +137,7 @@ export class WizardDialog extends LitElement {
slot="secondaryAction"
dialogAction="close"
label="${translate('cancel')}"
outlined
style="--mdc-theme-primary: var(--mdc-theme-error)"
></mwc-button>`}
${page.primary
Expand All @@ -153,6 +155,7 @@ export class WizardDialog extends LitElement {
dialogAction="next"
icon="navigate_next"
label=${this.wizard?.[index + 1].title}
outlined
trailingicon
></mwc-button>`
: html``}
Expand Down
9 changes: 4 additions & 5 deletions test/integration/open-scd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,22 @@ describe('open-scd', () => {
`);
});

it('loads with open landing page', () => {
expect(element.landingDialog).to.have.property('open');
expect(element.landingDialog).to.have.property('scrimClickAction');
it('looks like its snapshot', () => {
expect(element).shadowDom.to.equalSnapshot();
});

it('open new project wizard on new project icon click', async () => {
expect(element.wizardUI).to.not.exist;
(<HTMLElement>(
element.landingDialog.querySelector('mwc-icon-button:nth-child(1)')
element.shadowRoot!.querySelector('div > mwc-icon-button:nth-child(1)')
)).click();
await element.updateComplete;
expect(element.wizardUI).to.exist;
});

it('creates empty SCL new project wizard primary icon button click', async () => {
(<HTMLElement>(
element.landingDialog.querySelector('mwc-icon-button:nth-child(1)')
element.shadowRoot!.querySelector('div > mwc-icon-button:nth-child(1)')
)).click();
await element.updateComplete;
(<HTMLElement>(
Expand Down