blocksuite icon indicating copy to clipboard operation
blocksuite copied to clipboard

Support pseudo-element ::part to customize built-in weight styles

Open nawbc opened this issue 1 year ago • 1 comments

Discussed in https://github.com/toeverything/blocksuite/discussions/6053

Originally posted by nawbc January 21, 2024 In some cases, developers need to simply customize the editor styles. The ::part(), exportparts (html global attributes) can be used to simply implement shadow dom element custom styles that u want to expose. and it doesn't affect the overall design.

Why not CSS var attributes? Because it's a heavy workload and not flexible.

Browser Compatibility

https://developer.mozilla.org/en-US/docs/Web/CSS/::part#browser_compatibility

.e.g slash-menu-popover.ts source code.

...
<div class="slash-menu" style="${slashMenuStyles}" part="slash-menu">
  ${this._categoryTemplate()}
  <div class="slash-item-container">${btnItems}</div>
</div>
...

custom.html


<style>
  affine-slash-menu::part(slash-menu) {
    border: 1px solid;
    border-radius: 2px;
  }
</style>

image

I can PR for this feature.

nawbc avatar Jan 22 '24 06:01 nawbc

LGTM, would be great to also apply this convention to different widgets!

doodlewind avatar Jan 22 '24 09:01 doodlewind