appstore/dist/views/home.js

193 lines
4.2 KiB
JavaScript
Raw Normal View History

2023-12-20 19:06:35 +08:00
/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2023/12/19 16:53:27
*/
import { html, css, Component } from 'wkit'
import { watch } from 'wkitd'
import '../components/titlebar.js'
import '../components/slider.js'
class Home extends Component {
static animation = { type: 'scale', immediate: true }
static styles = [
css`
:host {
display: flex;
position: fixed;
left: calc(50vw - 512px);
top: calc(50vh - 380px);
z-index: 2;
width: 1024px;
height: 760px;
font-size: 14px;
color: var(--color-dark-1);
-webkit-user-select: none;
user-select: none;
}
.container {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
border-radius: 8px;
background: rgba(233, 233, 233, 0.9);
box-shadow: 0 0 12px rgba(0, 0, 0, 0.1);
--titlebar-background: linear-gradient(
90deg,
transparent 180px,
#fff 180px
);
}
li {
list-style: none;
}
`,
css`
.body {
flex: 1;
display: flex;
line-height: 1.5;
}
.sidebar {
flex-shrink: 0;
width: 180px;
height: 100%;
border-radius: 0 0 0 8px;
backdrop-filter: blur(5px);
}
.content {
flex: 1;
height: 100%;
padding: 0 32px 32px;
border-radius: 0 0 8px 0;
background: #fff;
}
`,
css`
.searchbar {
padding: 0 16px;
input {
width: 100%;
height: 30px;
padding: 0 16px;
line-height: 1;
border: 1px solid var(--color-grey-1);
border-radius: 16px;
background: rgba(255, 255, 255, 0.5);
font-size: 12px;
color: inherit;
outline: none;
transition: background 0.2s ease-in-out, border-color 0.2s ease-in-out;
&:focus {
background: rgba(255, 255, 255, 1);
border-color: transparent;
}
&::placeholder {
color: var(--color-grey-2);
}
}
}
.category {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 16px;
padding-left: 16px;
--wc-icon-size: 16px;
.item {
position: relative;
display: flex;
align-items: center;
height: 36px;
padding: 0 16px;
gap: 4px;
border-radius: 8px 0 0 8px;
transition: background 0.2s ease-in-out;
&:hover {
background: rgba(255, 255, 255, 0.5);
}
&.active {
background: rgba(255, 255, 255, 1);
&::before,
&::after {
position: absolute;
right: 0;
top: -12px;
width: 12px;
height: 12px;
background: url(/assets/img/round.webp);
content: '';
}
&::after {
top: unset;
bottom: -12px;
transform: rotate(-90deg);
}
}
}
}
`
]
#hide() {
this.$store.storeAppShow = false
}
mounted() {
// this.$store.storeAppShow = true
watch('$store.storeAppShow', v => {
this.$animate(!v)
})
}
render() {
return html`
<main class="container">
<wc-titlebar
minimize
maximize
@close=${this.#hide}
@minimize=${this.#hide}
></wc-titlebar>
<div class="body">
<aside class="sidebar">
<search class="searchbar">
<input placeholder="搜索应用" />
</search>
<menu class="category">
<li class="item active">
<wc-icon name="client"></wc-icon>
</li>
<li class="item"><wc-icon name="doc"></wc-icon></li>
<li class="item"><wc-icon name="setting"></wc-icon></li>
</menu>
</aside>
<div class="content">
<wc-slider></wc-slider>
</div>
</div>
</main>
`
}
}
Home.reg('home')