dees-wcctools/test/elements/test-demoelement.ts

80 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-04-01 19:09:57 +00:00
import {
DeesElement,
customElement,
TemplateResult,
html,
property,
} from '@designestate/dees-element';
2020-11-26 02:28:17 +00:00
import * as domtools from '@designestate/dees-domtools';
2021-04-01 19:09:57 +00:00
enum ETestEnum {
'first' = 'first',
'second' = 'second',
'awesome' = 'awesome',
}
2020-11-26 02:28:17 +00:00
@customElement('test-demoelement')
2020-11-27 16:40:38 +00:00
export class TestDemoelement extends DeesElement {
2021-09-27 11:30:02 +00:00
public static demo = () => html`<test-demoelement>This is a slot text</test-demoelement>`;
2020-11-26 02:28:17 +00:00
2021-04-01 19:09:57 +00:00
@property({
type: Boolean,
})
public demoBoolean = false;
@property({
type: String,
})
public demoString = 'default demo string';
@property({
type: Number,
})
public demoNumber = 2;
@property({
type: ETestEnum,
})
public demoENum: ETestEnum = ETestEnum.first;
2020-11-26 02:28:17 +00:00
public render() {
return html`
<style>
2020-11-27 16:40:38 +00:00
.maincontainer, .themeindicator {
2020-11-26 02:28:17 +00:00
display: block;
padding: 10px;
border-radius: 10px;
2020-11-27 16:40:38 +00:00
margin-bottom: 20px;
2020-11-26 02:28:17 +00:00
}
2020-11-27 16:40:38 +00:00
.maincontainer {
color: #fff;
2020-11-26 02:28:17 +00:00
background: #000;
2020-11-27 16:40:38 +00:00
}
.themeindicator {
color: ${this.goBright ? '#000' : '#fff'};
background: ${this.goBright ? '#fff' : '#000'};
}
${domtools.breakpoints.cssForPhablet(`
.maincontainer, .themeindicator {
border-radius: 50px;
2020-11-26 02:28:17 +00:00
}
`)}
2021-04-01 19:09:57 +00:00
pre b {
color: green;
}
2020-11-26 02:50:50 +00:00
</style>
2020-11-27 16:40:38 +00:00
<div class="maincontainer"><slot>This is a demo element</slot></div>
<div class="themeindicator">
2021-04-01 19:09:57 +00:00
You have selected the ${this.goBright ? 'bright' : 'dark'} theme.
<pre>
2021-04-01 19:11:23 +00:00
demoBoolean is <b>${this.demoBoolean}</b>
2021-04-01 19:09:57 +00:00
demoString is <b>"${this.demoString}"</b>
2021-04-01 19:11:23 +00:00
demoNumber is <b>${this.demoNumber}</b>
2021-04-01 19:09:57 +00:00
demoEnum is <b>"${this.demoENum}"</b>
</pre>
2020-11-27 16:40:38 +00:00
</div>
2020-11-26 02:28:17 +00:00
`;
}
2020-11-26 02:50:50 +00:00
}