mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { ShadowlessElement } from '@blocksuite/block-std';
|
||||
import { css, html } from 'lit';
|
||||
import { customElement } from 'lit/decorators.js';
|
||||
|
||||
@customElement('left-side-panel')
|
||||
export class LeftSidePanel extends ShadowlessElement {
|
||||
static override styles = css`
|
||||
left-side-panel {
|
||||
padding-top: 50px;
|
||||
width: 300px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
|
||||
currentContent: HTMLElement | null = null;
|
||||
|
||||
hideContent() {
|
||||
if (this.currentContent) {
|
||||
this.style.display = 'none';
|
||||
this.currentContent.remove();
|
||||
this.currentContent = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override render(): unknown {
|
||||
return html``;
|
||||
}
|
||||
|
||||
showContent(ele: HTMLElement) {
|
||||
if (this.currentContent) {
|
||||
this.currentContent.remove();
|
||||
}
|
||||
this.style.display = 'block';
|
||||
this.currentContent = ele;
|
||||
this.append(ele);
|
||||
}
|
||||
|
||||
toggle(ele: HTMLElement) {
|
||||
if (this.currentContent !== ele) {
|
||||
this.showContent(ele);
|
||||
} else {
|
||||
this.hideContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'left-side-panel': LeftSidePanel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user