Skip to content
Merged
61 changes: 35 additions & 26 deletions packages/diffs/src/editor/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const editorCSS: string = /* CSS */ `
50% { opacity: 0; }
100% { opacity: 1; }
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but I would love to get this file moved into a normal css file so we can run it through our various linters and stuff. I think it would also be nice to figure out a way to figure out how to make it a re-usable stylesheet like we do here:

https://github.com/pierrecomputer/pierre/blob/main/packages/diffs/src/components/web-components.ts

:host, /* for jump anchor */
:host, /* for scroll anchor */
[data-code], /* for editor overlay */
[data-content] /* for wrap line */
[data-content] /* for wrap line measurement */
{
position: relative;
}
Expand All @@ -18,13 +18,16 @@ export const editorCSS: string = /* CSS */ `
caret-color: var(--diffs-bg-caret);
outline: none;
}
@media (min-width: 480px) {
[data-content] {
caret-color: transparent;
}
[data-quick-edit] {
caret-color: currentColor;
}
[data-column-number] {
color: var(--diffs-editor-line-number-fg);
}
[data-column-number]:is([data-selected-line]),
[data-gutter-buffer]:is([data-selected-line]) {
background-color: var(--diffs-editor-line-number-active-bg);
color: var(--diffs-editor-line-number-active-fg);
}
[data-column-number]:is([data-active]) {
color: var(--diffs-editor-line-number-active-fg);
}
[data-line] {
cursor: text;
Expand All @@ -38,32 +41,25 @@ export const editorCSS: string = /* CSS */ `
[data-line-annotation]:is([data-selected-line]) {
background-color: var(--diffs-editor-line-highlight-bg);
}
[data-column-number] {
color: var(--diffs-editor-line-number-fg);
}
[data-column-number]:is([data-selected-line]),
[data-gutter-buffer]:is([data-selected-line]) {
background-color: var(--diffs-editor-line-number-active-bg);
color: var(--diffs-editor-line-number-active-fg);
}
[data-column-number]:is([data-active]) {
color: var(--diffs-editor-line-number-active-fg);
}
[data-line]:is([data-line-type='change-deletion']) {
background-color: var(--diffs-line-bg);
-webkit-user-select: none;
user-select: none;
}
[data-caret], [data-selection-range] {

[data-editor-overlay] {
display: contents;
}
[data-caret], [data-selection-range], [data-match-range] {
position: absolute;
top: 0;
left: 0;
height: 1lh;
line-height: var(--diffs-line-height);
pointer-events: none;
}
[data-caret] {
width: 2px;
height: 1lh;
background-color: var(--diffs-bg-caret-override, var(--diffs-editor-cursor-fg,
light-dark(
color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg)),
Expand All @@ -75,7 +71,6 @@ export const editorCSS: string = /* CSS */ `
visibility: hidden;
}
[data-selection-range] {
height: 1lh;
z-index: -10;
background-color: var(--diffs-editor-selection-bg);
}
Expand All @@ -84,6 +79,17 @@ export const editorCSS: string = /* CSS */ `
height: 100%;
background-color: var(--diffs-bg);
}
[data-match-range] {
background-color: var(--diffs-editor-find-match-bg,
var(--diffs-editor-selection-bg)
);
z-index: -10;
}
[data-match-range]:not([data-focus]) {
background-color: var(--diffs-editor-find-match-highlight-bg,
light-dark(#FF963288, #FF963266)
);
}
[data-rtl] {
border-top-left-radius: 3px;
}
Expand All @@ -96,10 +102,13 @@ export const editorCSS: string = /* CSS */ `
[data-rbr] {
border-bottom-right-radius: 3px;
}
[data-editor-overlay] {
display: contents;
}
@media (min-width: 480px) {
[data-content] {
caret-color: transparent;
}
[data-quick-edit] {
caret-color: currentColor;
}
[data-content]:focus ~ [data-editor-overlay] [data-caret] {
visibility: visible;
}
Expand Down
Loading
Loading