fix(core): copy more button group style (#10240)
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
flip,
|
flip,
|
||||||
offset,
|
offset,
|
||||||
type Placement,
|
type Placement,
|
||||||
|
shift,
|
||||||
} from '@floating-ui/dom';
|
} from '@floating-ui/dom';
|
||||||
import type { CSSResult } from 'lit';
|
import type { CSSResult } from 'lit';
|
||||||
import { css, html, LitElement, unsafeCSS } from 'lit';
|
import { css, html, LitElement, unsafeCSS } from 'lit';
|
||||||
@@ -68,6 +69,11 @@ const triangleMap = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The padding for the autoShift and autoFlip middleware
|
||||||
|
// It's used to prevent the tooltip from overflowing the screen
|
||||||
|
const AUTO_SHIFT_PADDING = 12;
|
||||||
|
const AUTO_FLIP_PADDING = 12;
|
||||||
|
|
||||||
// Ported from https://floating-ui.com/docs/tutorial#arrow-middleware
|
// Ported from https://floating-ui.com/docs/tutorial#arrow-middleware
|
||||||
const updateArrowStyles = ({
|
const updateArrowStyles = ({
|
||||||
placement,
|
placement,
|
||||||
@@ -166,7 +172,8 @@ export class Tooltip extends LitElement {
|
|||||||
referenceElement: this.parentElement!,
|
referenceElement: this.parentElement!,
|
||||||
placement: this.placement,
|
placement: this.placement,
|
||||||
middleware: [
|
middleware: [
|
||||||
this.autoFlip && flip({ padding: 12 }),
|
this.autoFlip && flip({ padding: AUTO_FLIP_PADDING }),
|
||||||
|
this.autoShift && shift({ padding: AUTO_SHIFT_PADDING }),
|
||||||
offset((this.arrow ? TRIANGLE_HEIGHT : 0) + this.offset),
|
offset((this.arrow ? TRIANGLE_HEIGHT : 0) + this.offset),
|
||||||
arrow({
|
arrow({
|
||||||
element: portalRoot.shadowRoot!.querySelector('.arrow')!,
|
element: portalRoot.shadowRoot!.querySelector('.arrow')!,
|
||||||
@@ -248,6 +255,17 @@ export class Tooltip extends LitElement {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor autoFlip = true;
|
accessor autoFlip = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shifts the floating element to keep it in view.
|
||||||
|
* this prevents the floating element from
|
||||||
|
* overflowing along its axis of alignment,
|
||||||
|
* thereby preserving the side it’s placed on.
|
||||||
|
*
|
||||||
|
* See https://floating-ui.com/docs/shift
|
||||||
|
*/
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor autoShift = false;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor hoverOptions: Partial<HoverOptions> = {};
|
accessor hoverOptions: Partial<HoverOptions> = {};
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ export class ChatCopyMore extends WithDisposable(LitElement) {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 2px;
|
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
color: ${unsafeCSSVarV2('icon/primary')};
|
color: ${unsafeCSSVarV2('icon/primary')};
|
||||||
@@ -195,7 +194,7 @@ export class ChatCopyMore extends WithDisposable(LitElement) {
|
|||||||
data-testid="action-retry-button"
|
data-testid="action-retry-button"
|
||||||
>
|
>
|
||||||
${ResetIcon({ width: '20px', height: '20px' })}
|
${ResetIcon({ width: '20px', height: '20px' })}
|
||||||
<affine-tooltip>Retry</affine-tooltip>
|
<affine-tooltip .autoShift=${true}>Retry</affine-tooltip>
|
||||||
</div>`
|
</div>`
|
||||||
: nothing}
|
: nothing}
|
||||||
${isLast
|
${isLast
|
||||||
|
|||||||
Reference in New Issue
Block a user