dees-appui-catalog/ts_web/elements/dees-appui-mainselector.ts

158 lines
3.9 KiB
TypeScript
Raw Normal View History

2023-10-06 09:05:58 +00:00
import * as plugins from '../plugins.js';
2022-05-02 11:43:55 +00:00
import * as interfaces from './interfaces/index.js';
2021-03-06 18:59:00 +00:00
import {
DeesElement,
2023-09-06 22:18:00 +00:00
type TemplateResult,
2021-03-06 18:59:00 +00:00
property,
customElement,
html,
2022-01-31 13:07:15 +00:00
css,
cssManager,
2023-09-06 16:43:33 +00:00
} from '@design.estate/dees-element';
2021-03-05 16:01:54 +00:00
2023-01-19 11:41:14 +00:00
/**
* the property selector menu
* mainly used to select assets within in an organization
*/
2023-12-08 17:26:19 +00:00
@customElement('dees-appui-mainselector')
export class DeesAppuiMainselector extends DeesElement {
public static demo = () => html`<dees-appui-mainselector></dees-appui-mainselector>`;
2021-03-05 16:01:54 +00:00
// INSTANCE
@property()
2021-03-06 18:59:00 +00:00
public selectionOptions: interfaces.ISelectionOption[] = [
2023-10-06 09:05:58 +00:00
{
key: 'Overview',
action: () => {},
},
2021-03-06 18:59:00 +00:00
{
key: 'option 1',
action: () => {},
},
{ key: 'option 2', action: () => {} },
{ key: 'option 3', action: () => {} },
{ key: 'option 4', action: () => {} },
2021-03-05 16:01:54 +00:00
];
2021-03-06 18:59:00 +00:00
@property()
public selectedOption: interfaces.ISelectionOption = null;
2022-01-31 13:07:15 +00:00
public static styles = [
cssManager.defaultStyles,
css`
:host {
2021-03-05 16:01:54 +00:00
color: #fff;
position: relative;
display: block;
width: 100%;
max-width: 300px;
height: 100%;
2023-09-06 16:43:33 +00:00
background: #000000;
border-right: 1px solid #222222;
2021-03-05 16:01:54 +00:00
}
.maincontainer {
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
}
.topbar {
position: absolute;
2023-09-06 16:43:33 +00:00
height: 32px;
2021-03-05 16:01:54 +00:00
width: 100%;
}
.topbar .heading {
2023-09-06 16:43:33 +00:00
padding-left: 16px;
padding-top: 8px;
line-height: 24px;
2023-10-06 09:05:58 +00:00
font-family: 'Roboto', 'Inter', sans-serif;
2023-01-10 12:11:02 +00:00
font-weight: 600;
2023-09-06 16:43:33 +00:00
font-size: 14px;
2021-03-05 16:01:54 +00:00
}
.selectionOptions {
position: absolute;
2023-09-06 16:43:33 +00:00
top: 32px;
padding-top: 8px;
2021-03-05 16:01:54 +00:00
left: 0px;
width: 100%;
2023-10-06 09:05:58 +00:00
font-family: 'Roboto', 'Inter', sans-serif;
2023-09-06 16:43:33 +00:00
font-size: 14px;
2021-03-05 16:01:54 +00:00
}
.selectionOptions .selectionOption {
2022-06-10 14:26:12 +00:00
margin-left: 16px;
margin-right: 16px;
padding-top: 8px;
padding-bottom: 8px;
2023-09-06 16:43:33 +00:00
border-top: 1px dotted #303030;
2021-03-06 18:59:00 +00:00
border-left: 0px solid rgba(0,0,0,0);
2021-03-05 16:01:54 +00:00
cursor: pointer;
2021-03-06 18:59:00 +00:00
transition: all 0.1s;
}
.selectionOptions .selectionOption:hover {
2022-06-10 14:26:12 +00:00
border-left: 2px solid #26A69A50;
2021-03-06 18:59:00 +00:00
padding-left: 8px;
}
2021-03-05 16:01:54 +00:00
.selectionOptions .selectionOption:first-child {
2023-09-06 16:43:33 +00:00
border-top: 1px solid rgba(0,0,0,0);
2021-03-05 16:01:54 +00:00
}
2023-09-06 16:43:33 +00:00
.selectionOptions .selectionOption.selectedOption {
border-left: 4px solid #26A69A;
padding-left: 10px;
2021-03-05 16:01:54 +00:00
}
2022-01-31 13:07:15 +00:00
`
];
public render(): TemplateResult {
return html`
<style>
2021-03-05 16:01:54 +00:00
</style>
<div class="maincontainer">
<div class="topbar">
<div class="heading">Properties</div>
</div>
<div class="selectionOptions">
2021-03-06 18:59:00 +00:00
${this.selectionOptions.map((selectionOptionArg) => {
2021-03-05 16:01:54 +00:00
return html`
2021-03-06 18:59:00 +00:00
<div
class="selectionOption ${this.selectedOption === selectionOptionArg
? 'selectedOption'
: null}"
@click="${() => {
this.selectOption(selectionOptionArg);
}}"
2023-10-06 09:05:58 +00:00
@contextmenu="${(eventArg: MouseEvent) => {
2023-10-31 11:17:56 +00:00
plugins.deesCatalog.DeesContextmenu.openContextMenuWithOptions(eventArg, [{
name: 'property settings',
action: async () => {},
iconName: 'gear',
}]);
2023-10-06 09:05:58 +00:00
}}"
2021-03-06 18:59:00 +00:00
>
2021-03-05 16:01:54 +00:00
${selectionOptionArg.key}
</div>
`;
})}
</div>
</div>
`;
}
2021-03-06 18:59:00 +00:00
private selectOption(optionArg: interfaces.ISelectionOption) {
this.selectedOption = optionArg;
this.selectedOption.action();
}
2021-03-08 01:01:56 +00:00
firstUpdated() {
this.selectOption(this.selectionOptions[0]);
}
2021-03-06 18:59:00 +00:00
}