-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding demo server with API file upload
- Loading branch information
Showing
13 changed files
with
422 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { html, css, LitElement } from 'lit-element'; | ||
import { AnypointMenuMixin } from '@anypoint-web-components/anypoint-menu-mixin/anypoint-menu-mixin.js'; | ||
|
||
class ApiFileSelector extends AnypointMenuMixin(LitElement) { | ||
static get styles() { | ||
return css`:host { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background: #fff; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
justify-content: center; | ||
} | ||
h1 { | ||
font-size: 112px; | ||
font-weight: 300; | ||
letter-spacing: -.044em; | ||
line-height: 120px; | ||
box-sizing: border-box; | ||
margin: 0; | ||
} | ||
section[role="main"] { | ||
height: 60%; | ||
margin-top: 40px; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
justify-content: center; | ||
transition: box-shadow 0.23s cubic-bezier(0.4, 0, 0.2, 1); | ||
width: 80%; | ||
border: 1px #e5e5e5 solid; | ||
} | ||
@media (max-width: 1200px) { | ||
h1 { | ||
font-size: 54px; | ||
text-align: center; | ||
margin: 0 24px; | ||
line-height: 64px; | ||
} | ||
`; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
}; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this._selectHandler = this._selectHandler.bind(this); | ||
} | ||
|
||
connectedCallback() { | ||
/* istanbul ignore else */ | ||
if (super.connectedCallback) { | ||
super.connectedCallback(); | ||
} | ||
this.addEventListener('select', this._selectHandler); | ||
} | ||
|
||
disconnectedCallback() { | ||
/* istanbul ignore else */ | ||
if (super.disconnectedCallback) { | ||
super.disconnectedCallback(); | ||
} | ||
this.removeEventListener('select', this._selectHandler); | ||
} | ||
|
||
_selectHandler(e) { | ||
const value = e.detail.item.textContent; | ||
this.dispatchEvent(new CustomEvent('candidate-selected', { | ||
detail: value | ||
})); | ||
} | ||
|
||
render() { | ||
return html` | ||
<h1>Select API main file</h1> | ||
<p class="intro">We have found multiple API files.</p> | ||
<section role="main"> | ||
<p class="drop-welcome">Choose the main API file</p> | ||
<slot></slot> | ||
</section> | ||
`; | ||
} | ||
} | ||
window.customElements.define('api-file-selector', ApiFileSelector); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { html, css, LitElement } from 'lit-element'; | ||
import { AnypointMenuMixin } from '@anypoint-web-components/anypoint-menu-mixin/anypoint-menu-mixin.js'; | ||
import '@anypoint-web-components/anypoint-button/anypoint-icon-button.js'; | ||
import '@anypoint-web-components/anypoint-button/anypoint-button.js'; | ||
import '@polymer/iron-icon/iron-icon.js'; | ||
|
||
class ApiSelector extends AnypointMenuMixin(LitElement) { | ||
static get styles() { | ||
return css`:host { | ||
width: 340px; | ||
display: block; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
background-color: #fff; | ||
transform: translateX(100%); | ||
transform-origin: top right; | ||
transition: transform 0.3s cubic-bezier(0.74, 0.03, 0.3, 0.97); | ||
position: fixed; | ||
box-shadow: var(--anypoiont-dropdown-shaddow); | ||
} | ||
:host([opened]) { | ||
transform: translateX(0); | ||
} | ||
.header { | ||
display: flex; | ||
align-items: center; | ||
margin: 0 12px; | ||
} | ||
.title { | ||
flex: 1; | ||
font-size: 1.1rem; | ||
font-weight: 500; | ||
} | ||
.upload { | ||
width: 100%; | ||
} | ||
`; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
opened: { type: Boolean, reflect: true } | ||
}; | ||
} | ||
|
||
get opened() { | ||
return this._opened; | ||
} | ||
|
||
set opened(value) { | ||
const old = this._opened; | ||
if (old === value) { | ||
return; | ||
} | ||
this._opened = value; | ||
this.requestUpdate('opened', value); | ||
this.dispatchEvent(new CustomEvent('opened-changed', { | ||
detail: { | ||
value | ||
} | ||
})); | ||
} | ||
|
||
close() { | ||
this.opened = false; | ||
} | ||
|
||
opeen() { | ||
this.opened = true; | ||
} | ||
|
||
_uploadHandler() { | ||
this.dispatchEvent(new CustomEvent('upload')); | ||
this.opened = false; | ||
} | ||
|
||
render() { | ||
return html` | ||
<div class="header"> | ||
<div class="title">Select API</div> | ||
<anypoint-icon-button | ||
aria-label="Activate to close the API menu" | ||
@click="${this.close}"> | ||
<iron-icon icon="arc:close"></iron-icon> | ||
</anypoint-icon-button> | ||
</div> | ||
<anypoint-button @click="${this._uploadHandler}" class="upload"> | ||
<iron-icon icon="arc:add-circle-outline"></iron-icon> | ||
Upload an API | ||
</anypoint-button> | ||
<section> | ||
<slot></slot> | ||
</section> | ||
`; | ||
} | ||
} | ||
window.customElements.define('api-selector', ApiSelector); |
Oops, something went wrong.