appstore/dist/components/titlebar.js

83 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2023-12-19 18:53:48 +08:00
/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2023/12/19 16:53:27
*/
import { html, css, Component } from 'wkit'
class Titlebar extends Component {
static styles = css`
:host {
display: flex;
width: 100%;
height: 48px;
}
.titlebar {
display: flex;
align-items: center;
width: 100%;
height: 48px;
padding: 0 16px;
border-radius: 8px 8px 0 0;
2023-12-20 19:06:35 +08:00
background: var(--titlebar-background, transparent);
2023-12-19 18:53:48 +08:00
color: var(--color-dark-1);
}
.btns {
display: flex;
align-items: center;
gap: 6px;
i {
display: block;
width: 12px;
height: 12px;
border-radius: 50%;
2023-12-20 19:06:35 +08:00
background: var(--color-grey-1);
cursor: default;
2023-12-19 18:53:48 +08:00
2023-12-20 19:06:35 +08:00
&:nth-child(1) {
background: var(--color-red-1);
cursor: pointer;
2023-12-19 18:53:48 +08:00
}
}
}
2023-12-20 19:06:35 +08:00
:host([minimize]) .btns {
i:nth-child(2) {
background: var(--color-orange-1);
cursor: pointer;
}
}
:host([maximize]) .btns {
i:nth-child(3) {
background: var(--color-green-1);
cursor: pointer;
}
}
2023-12-19 18:53:48 +08:00
`
#handleClick(ev) {
if (ev.currentTarget === ev.target) {
return
}
let { act } = ev.target.dataset
this.$emit(act)
}
render() {
return html`
<div class="titlebar">
<section class="btns" @click=${this.#handleClick}>
<i data-act="close"></i><i data-act="minimize"></i
><i data-act="maximize"></i>
</section>
</div>
`
}
}
Titlebar.reg('titlebar')