[fix] grid, other insets (#2858)

Fix the grid and other insets, a few CSS cleanups.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Turn on the grid.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Fixes a bug with the grid not appearing.
This commit is contained in:
Steve Ruiz 2024-02-18 23:01:00 +00:00 committed by GitHub
parent 7e673b5e37
commit 3e41c3acd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 25 deletions

View file

@ -90,6 +90,8 @@
/* own properties */ /* own properties */
position: relative; position: relative;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
overflow: clip; overflow: clip;
} }
@ -215,6 +217,8 @@ input,
.tl-canvas { .tl-canvas {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
color: var(--color-text); color: var(--color-text);
z-index: var(--layer-canvas); z-index: var(--layer-canvas);
cursor: var(--tl-cursor); cursor: var(--tl-cursor);
@ -230,7 +234,12 @@ input,
} }
.tl-overlays { .tl-overlays {
position: relative; position: absolute;
inset: 0px;
height: 100%;
width: 100%;
contain: strict;
pointer-events: none;
z-index: var(--layer-overlays); z-index: var(--layer-overlays);
} }
@ -250,26 +259,14 @@ input,
pointer-events: none; pointer-events: none;
} }
.tl-positioned {
position: absolute;
top: 0px;
left: 0px;
transform-origin: top left;
}
.tl-fixed-layer {
position: absolute;
inset: 0px;
contain: strict;
pointer-events: none;
}
/* ------------------- Background ------------------- */ /* ------------------- Background ------------------- */
.tl-background { .tl-background {
position: absolute; position: absolute;
background-color: var(--color-background); background-color: var(--color-background);
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
z-index: var(--layer-background); z-index: var(--layer-background);
} }
@ -278,6 +275,8 @@ input,
.tl-grid { .tl-grid {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
width: 100%;
height: 100%;
touch-action: none; touch-action: none;
pointer-events: none; pointer-events: none;
z-index: var(--layer-grid); z-index: var(--layer-grid);
@ -340,6 +339,8 @@ input,
.tl-svg-container { .tl-svg-container {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
pointer-events: none; pointer-events: none;
stroke-linecap: round; stroke-linecap: round;
stroke-linejoin: round; stroke-linejoin: round;
@ -350,6 +351,8 @@ input,
.tl-html-container { .tl-html-container {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
pointer-events: none; pointer-events: none;
stroke-linecap: round; stroke-linecap: round;
stroke-linejoin: round; stroke-linejoin: round;
@ -781,6 +784,8 @@ input,
.tl-text-content { .tl-text-content {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
min-width: 1px; min-width: 1px;
min-height: 1px; min-height: 1px;
overflow: visible; overflow: visible;
@ -982,6 +987,8 @@ input,
line-height: inherit; line-height: inherit;
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
z-index: 10; z-index: 10;
} }
@ -1024,6 +1031,8 @@ input,
.tl-text-label__inner > .tl-text-input { .tl-text-label__inner > .tl-text-input {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
padding: 16px; padding: 16px;
z-index: 4; z-index: 4;
} }
@ -1199,6 +1208,8 @@ input,
position: absolute; position: absolute;
z-index: 1; z-index: 1;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
background-color: var(--color-background); background-color: var(--color-background);
opacity: 0.28; opacity: 0.28;
} }
@ -1289,13 +1300,13 @@ input,
.tl-frame-name-input { .tl-frame-name-input {
position: absolute; position: absolute;
top: 0px;
left: 0px;
border: none; border: none;
background: none; background: none;
outline: none; outline: none;
padding: var(--space-3) var(--space-3); padding: var(--space-3) var(--space-3);
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
font-size: inherit; font-size: inherit;
font-family: inherit; font-family: inherit;
font-weight: inherit; font-weight: inherit;
@ -1371,6 +1382,8 @@ input,
.tl-error-boundary__overlay { .tl-error-boundary__overlay {
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
z-index: 500; z-index: 500;
background-color: var(--color-overlay); background-color: var(--color-overlay);
} }
@ -1385,6 +1398,8 @@ input,
pointer-events: none; pointer-events: none;
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
z-index: -1; z-index: -1;
} }
/* some browsers seem to have some weird interactions between stacking contexts /* some browsers seem to have some weird interactions between stacking contexts
@ -1395,6 +1410,8 @@ it from receiving any pointer events or affecting the cursor. */
display: block; display: block;
position: absolute; position: absolute;
inset: 0px; inset: 0px;
height: 100%;
width: 100%;
z-index: 600; z-index: 600;
pointer-events: all; pointer-events: all;
} }

View file

@ -97,8 +97,6 @@ export function Canvas({ className }: { className?: string }) {
data-testid="canvas" data-testid="canvas"
{...events} {...events}
> >
{Background && <Background />}
<GridWrapper />
<svg className="tl-svg-context"> <svg className="tl-svg-context">
<defs> <defs>
{shapeSvgDefs} {shapeSvgDefs}
@ -109,12 +107,15 @@ export function Canvas({ className }: { className?: string }) {
{SvgDefs && <SvgDefs />} {SvgDefs && <SvgDefs />}
</defs> </defs>
</svg> </svg>
{Background && <Background />}
<GridWrapper />
<div ref={rHtmlLayer} className="tl-html-layer tl-shapes" draggable={false}> <div ref={rHtmlLayer} className="tl-html-layer tl-shapes" draggable={false}>
<OnTheCanvasWrapper /> <OnTheCanvasWrapper />
<SelectionBackgroundWrapper /> <SelectionBackgroundWrapper />
{hideShapes ? null : debugSvg ? <ShapesWithSVGs /> : <ShapesToDisplay />} {hideShapes ? null : debugSvg ? <ShapesWithSVGs /> : <ShapesToDisplay />}
</div> </div>
<div className="tl-fixed-layer tl-overlays"> <div className="tl-overlays">
<div ref={rHtmlLayer2} className="tl-html-layer"> <div ref={rHtmlLayer2} className="tl-html-layer">
{debugGeometry ? <GeometryDebuggingView /> : null} {debugGeometry ? <GeometryDebuggingView /> : null}
<HandlesWrapper /> <HandlesWrapper />

View file

@ -185,14 +185,11 @@ export const TldrawSelectionForeground: TLSelectionForegroundComponent = track(
textHandleHeight * zoom >= 4 textHandleHeight * zoom >= 4
return ( return (
<svg <svg className="tl-overlays__item tl-selection__fg" data-testid="selection-foreground">
className="tl-overlays__item tl-selection__fg tl-svg-context"
data-testid="selection-foreground"
>
<g ref={rSvg}> <g ref={rSvg}>
{shouldDisplayBox && ( {shouldDisplayBox && (
<rect <rect
className={classNames('tl-selection__fg__outline')} className="tl-selection__fg__outline"
width={toDomPrecision(width)} width={toDomPrecision(width)}
height={toDomPrecision(height)} height={toDomPrecision(height)}
/> />