dees-wcctools/ts_web/elements/wcc-frame.ts

116 lines
3.7 KiB
TypeScript
Raw Normal View History

2023-08-07 16:20:17 +00:00
import { DeesElement, property, html, customElement, type TemplateResult, css, cssManager } from '@design.estate/dees-element';
2020-05-11 00:36:58 +00:00
2023-08-07 16:20:17 +00:00
import * as domtools from '@design.estate/dees-domtools';
2020-05-11 00:36:58 +00:00
2022-04-14 14:56:04 +00:00
declare global {
interface HTMLElementTagNameMap {
'wcc-frame': WccFrame;
}
}
2020-05-11 00:36:58 +00:00
@customElement('wcc-frame')
2020-12-09 18:32:11 +00:00
export class WccFrame extends DeesElement {
2020-05-11 00:36:58 +00:00
@property()
public viewport: string;
2022-04-14 14:56:04 +00:00
public static styles = [
css`
:host {
border: 10px solid #ffaeaf;
position: absolute;
background: ${cssManager.bdTheme('#333', '#000')};
left: 200px;
right: 0px;
top: 0px;
bottom: 100px;
overflow-y: auto;
overflow-x: auto;
}
.viewport {
container-type: inline-size;
container-name: wccToolsViewport;
position: relative;
min-height: 100%;
}
`,
]
2020-05-11 00:36:58 +00:00
public render(): TemplateResult {
return html`
<style>
:host {
${(() => {
switch (this.viewport) {
case 'desktop':
return `
padding: 0px 0px;
`;
case 'tablet':
return `
2020-06-01 13:18:51 +00:00
padding: 0px ${
(document.body.clientWidth - 200 - domtools.breakpoints.tablet) / 2
}px;
2020-05-11 00:36:58 +00:00
`;
case 'phablet':
return `
2020-06-01 13:18:51 +00:00
padding: 0px ${
(document.body.clientWidth - 200 - domtools.breakpoints.phablet) / 2
}px;
2020-05-11 00:36:58 +00:00
`;
case 'phone':
return `
2020-06-01 13:18:51 +00:00
padding: 0px ${
(document.body.clientWidth - 200 - domtools.breakpoints.phone) / 2
}px;
2020-05-11 00:36:58 +00:00
`;
}
2022-04-14 14:56:04 +00:00
})()}
2020-05-11 00:36:58 +00:00
}
2022-04-14 14:56:04 +00:00
2020-05-11 00:36:58 +00:00
.viewport {
${this.viewport !== 'desktop'
2022-04-14 14:56:04 +00:00
? html` border-right: 1px dotted #444; border-left: 1px dotted #444; `
: html``
}
2020-05-11 00:36:58 +00:00
background:
2022-04-14 14:56:04 +00:00
${
this.goBright ? `
2020-12-09 18:32:11 +00:00
radial-gradient(#CCCCCC 3px, transparent 4px),
radial-gradient(#CCCCCC 3px, transparent 4px),
linear-gradient(#eeeeee 4px, transparent 0),
linear-gradient(45deg, transparent 74px, transparent 75px, #CCCCCC 75px, #CCCCCC 76px, transparent 77px, transparent 109px),
linear-gradient(-45deg, transparent 75px, transparent 76px, #CCCCCC 76px, #CCCCCC 77px, transparent 78px, transparent 109px),
#eeeeee;
background-size: 109px 109px, 109px 109px,100% 6px, 109px 109px, 109px 109px;
background-position: 54px 55px, 0px 0px, 0px 0px, 0px 0px, 0px 0px;
` : `
radial-gradient(#444444 3px, transparent 4px),
radial-gradient(#444444 3px, transparent 4px),
linear-gradient(#222222 4px, transparent 0),
linear-gradient(45deg, transparent 74px, transparent 75px, #444444 75px, #444444 76px, transparent 77px, transparent 109px),
linear-gradient(-45deg, transparent 75px, transparent 76px, #444444 76px, #444444 77px, transparent 78px, transparent 109px),
#222222;
background-size: 109px 109px, 109px 109px,100% 6px, 109px 109px, 109px 109px;
background-position: 54px 55px, 0px 0px, 0px 0px, 0px 0px, 0px 0px;
2022-04-14 14:56:04 +00:00
`
}
2020-05-11 00:36:58 +00:00
}
</style>
<div class="viewport">
2022-04-14 14:56:04 +00:00
2020-05-11 00:36:58 +00:00
</div>
`;
}
2021-04-01 19:09:57 +00:00
public async getDisplayedInstance() {
await this.updateComplete;
const slottedContent = this.children;
console.log(slottedContent);
}
2022-04-14 14:56:04 +00:00
public async getViewportElement(): Promise<HTMLElement> {
return this.shadowRoot.querySelector('.viewport') as HTMLElement;
}
2020-05-11 00:36:58 +00:00
}