mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-16 22:07:09 +08:00
Continue [BS-2240](https://linear.app/affine-design/issue/BS-2240/%E6%B8%85%E7%90%86%E9%87%8D%E5%A4%8D%E7%9A%84icon) This PR removes `icons/edgeless.ts` and refactor with `@blocksuite/icons` for reducing redundant icons
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import { ShapeStyle } from '@blocksuite/affine-model';
|
|
import { Slot } from '@blocksuite/global/utils';
|
|
import { css, html, LitElement } from 'lit';
|
|
import { property } from 'lit/decorators.js';
|
|
import { repeat } from 'lit/directives/repeat.js';
|
|
|
|
import type { ShapeTool } from '../../gfx-tool/shape-tool.js';
|
|
import { ShapeComponentConfig } from '../toolbar/shape/shape-menu-config.js';
|
|
|
|
export class EdgelessShapePanel extends LitElement {
|
|
static override styles = css`
|
|
:host {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
}
|
|
`;
|
|
|
|
slots = {
|
|
select: new Slot<ShapeTool['activatedOption']['shapeName']>(),
|
|
};
|
|
|
|
private _onSelect(value: ShapeTool['activatedOption']['shapeName']) {
|
|
this.selectedShape = value;
|
|
this.slots.select.emit(value);
|
|
}
|
|
|
|
override disconnectedCallback(): void {
|
|
this.slots.select.dispose();
|
|
super.disconnectedCallback();
|
|
}
|
|
|
|
override render() {
|
|
return repeat(
|
|
ShapeComponentConfig,
|
|
item => item.name,
|
|
({ name, generalIcon, scribbledIcon, tooltip, disabled }) =>
|
|
html`<edgeless-tool-icon-button
|
|
.disabled=${disabled}
|
|
.tooltip=${tooltip}
|
|
.active=${this.selectedShape === name}
|
|
.activeMode=${'background'}
|
|
.iconSize=${'20px'}
|
|
@click=${() => {
|
|
if (disabled) return;
|
|
this._onSelect(name);
|
|
}}
|
|
>
|
|
${this.shapeStyle === ShapeStyle.General
|
|
? generalIcon
|
|
: scribbledIcon}
|
|
</edgeless-tool-icon-button>`
|
|
);
|
|
}
|
|
|
|
@property({ attribute: false })
|
|
accessor selectedShape:
|
|
| ShapeTool['activatedOption']['shapeName']
|
|
| null
|
|
| undefined = undefined;
|
|
|
|
@property({ attribute: false })
|
|
accessor shapeStyle: ShapeStyle = ShapeStyle.Scribbled;
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'edgeless-shape-panel': EdgelessShapePanel;
|
|
}
|
|
}
|