mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 17:39:55 +08:00
a5641ae608
Closes: [BS-1475](https://linear.app/affine-design/issue/BS-1475/颜色主题更新) [BS-1803](https://linear.app/affine-design/issue/BS-1803/fill-color色板影响的yuan素) [BS-1804](https://linear.app/affine-design/issue/BS-1804/border-color色板影响的yuan素) [BS-1815](https://linear.app/affine-design/issue/BS-1815/连线文字配色略瞎) ### What's Changed * refactor `EdgelessLineWidthPanel` component, the previous width is fixed and cannot be used in the new design * refactor `EdgelessColorPanel` and `EdgelessColorButton` components, make them simple and reusable * delete redundant `EdgelessOneRowColorPanel` component * unity and update color palette, if the previously set color is not in the latest color palette, the custom color button will be selected
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
import { PALETTES, type StrokeStyle } from '@blocksuite/affine-model';
|
|
import { WithDisposable } from '@blocksuite/global/utils';
|
|
import { css, html, LitElement } from 'lit';
|
|
import { property } from 'lit/decorators.js';
|
|
|
|
import type { ColorEvent } from './color-panel.js';
|
|
import { type LineStyleEvent, LineStylesPanel } from './line-styles-panel.js';
|
|
|
|
export class StrokeStylePanel extends WithDisposable(LitElement) {
|
|
static override styles = css`
|
|
:host {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.line-styles {
|
|
display: flex;
|
|
flex-direction: row;
|
|
gap: 8px;
|
|
align-items: center;
|
|
}
|
|
`;
|
|
|
|
override render() {
|
|
return html`
|
|
<div class="line-styles">
|
|
${LineStylesPanel({
|
|
selectedLineSize: this.strokeWidth,
|
|
selectedLineStyle: this.strokeStyle,
|
|
onClick: e => this.setStrokeStyle(e),
|
|
})}
|
|
</div>
|
|
<editor-toolbar-separator
|
|
data-orientation="horizontal"
|
|
></editor-toolbar-separator>
|
|
<edgeless-color-panel
|
|
role="listbox"
|
|
aria-label="Border colors"
|
|
.palettes=${PALETTES}
|
|
.value=${this.strokeColor}
|
|
.hollowCircle=${this.hollowCircle}
|
|
@select=${(e: ColorEvent) => this.setStrokeColor(e)}
|
|
>
|
|
</edgeless-color-panel>
|
|
`;
|
|
}
|
|
|
|
@property({ attribute: false })
|
|
accessor hollowCircle: boolean | undefined = undefined;
|
|
|
|
@property({ attribute: false })
|
|
accessor setStrokeColor!: (e: ColorEvent) => void;
|
|
|
|
@property({ attribute: false })
|
|
accessor setStrokeStyle!: (e: LineStyleEvent) => void;
|
|
|
|
@property({ attribute: false })
|
|
accessor strokeColor!: string;
|
|
|
|
@property({ attribute: false })
|
|
accessor strokeStyle!: StrokeStyle;
|
|
|
|
@property({ attribute: false })
|
|
accessor strokeWidth!: number;
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'stroke-style-panel': StrokeStylePanel;
|
|
}
|
|
}
|