Skip to content

Commit 10c11c2

Browse files
style
1 parent 6efb753 commit 10c11c2

File tree

12 files changed

+61
-36
lines changed

12 files changed

+61
-36
lines changed

packages/react/src/components/DiffContent.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { DiffLineType, NewLineSymbol, type DiffFile, type DiffLine, type SyntaxLine } from "@git-diff-view/core";
2-
import { memoFunc, addContentHighlightBGName, delContentHighlightBGName, diffFontSizeName } from "@git-diff-view/utils";
2+
import {
3+
memoFunc,
4+
addContentHighlightBGName,
5+
delContentHighlightBGName,
6+
diffFontSizeName,
7+
getSymbol,
8+
} from "@git-diff-view/utils";
39
import * as React from "react";
410

511
import { DiffNoNewLine } from "./DiffNoNewLine";
@@ -32,19 +38,6 @@ export const getStyleObjectFromString = memoFunc((str: string) => {
3238
return style;
3339
});
3440

35-
export const getSymbol = (symbol: NewLineSymbol) => {
36-
switch (symbol) {
37-
case NewLineSymbol.LF:
38-
return "␊";
39-
case NewLineSymbol.CR:
40-
return "␍";
41-
case NewLineSymbol.CRLF:
42-
return "␍␊";
43-
default:
44-
return "";
45-
}
46-
};
47-
4841
const DiffString = ({
4942
rawLine,
5043
diffLine,

packages/react/src/components/DiffContent_v2.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import {
66
type diffChanges,
77
type SyntaxLine,
88
} from "@git-diff-view/core";
9-
import { addContentHighlightBGName, delContentHighlightBGName, diffFontSizeName } from "@git-diff-view/utils";
9+
import {
10+
addContentHighlightBGName,
11+
delContentHighlightBGName,
12+
diffFontSizeName,
13+
getSymbol,
14+
} from "@git-diff-view/utils";
1015
import * as React from "react";
1116

12-
import { getStyleObjectFromString, getSymbol } from "./DiffContent";
17+
import { getStyleObjectFromString } from "./DiffContent";
1318
import { DiffNoNewLine } from "./DiffNoNewLine";
1419

1520
const RenderRange = ({

packages/react/src/components/DiffSplitHunkLineWrap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ const DiffSplitHunkLineGitLab = ({
274274
)}
275275
</td>
276276
<td
277-
className="diff-line-hunk-content pr-[10px] align-middle"
277+
className="diff-line-hunk-content relative pr-[10px] align-middle"
278278
style={{ backgroundColor: `var(${hunkContentBGName})` }}
279279
>
280280
<div

packages/react/src/components/DiffSplitViewNormal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
22
import { getSplitContentLines, type DiffFile } from "@git-diff-view/core";
3-
import { removeAllSelection, syncScroll, diffFontSizeName, borderColorName, diffAsideWidthName } from "@git-diff-view/utils";
3+
import {
4+
removeAllSelection,
5+
syncScroll,
6+
diffFontSizeName,
7+
borderColorName,
8+
diffAsideWidthName,
9+
} from "@git-diff-view/utils";
410
import { Fragment, memo, useEffect, useRef } from "react";
511
import * as React from "react";
612
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";

packages/react/src/components/v2/DiffSplitHunkLineWrap_v2.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const DiffSplitHunkLineGitLab = ({
206206
</div>
207207
<div className="diff-split-line w-[1px] flex-shrink-0" style={{ backgroundColor: `var(${borderColorName})` }} />
208208
<div
209-
className="diff-line-hunk-action flex w-[1%] min-w-[40px] select-none flex-col items-center justify-center p-[1px]"
209+
className="diff-line-hunk-action flex relative w-[1%] min-w-[40px] select-none flex-col items-center justify-center p-[1px]"
210210
style={{
211211
backgroundColor: `var(${hunkLineNumberBGName})`,
212212
color: `var(${plainLineNumberColorName})`,
@@ -268,7 +268,7 @@ const DiffSplitHunkLineGitLab = ({
268268
)}
269269
</div>
270270
<div
271-
className="diff-line-hunk-content flex w-full items-center px-[10px]"
271+
className="diff-line-hunk-content flex relative w-full items-center px-[10px]"
272272
style={{ backgroundColor: `var(${hunkContentBGName})`, color: `var(${hunkContentColorName})` }}
273273
>
274274
{currentHunk.splitInfo?.plainText || currentHunk.text}

packages/utils/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,14 @@ export declare const syncScroll: (left: HTMLElement, right: HTMLElement) => () =
3434
export declare const diffFontSizeName = "--diff-font-size--";
3535
export declare const diffAsideWidthName = "--diff-aside-width--";
3636
export declare const memoFunc: <T extends Function>(func: T) => T;
37+
declare enum NewLineSymbol {
38+
CRLF = 1,
39+
CR = 2,
40+
LF = 3,
41+
NEWLINE = 4,
42+
NORMAL = 5,
43+
NULL = 6
44+
}
45+
export declare const getSymbol: (symbol: NewLineSymbol) => "" | "\u240A" | "\u240D" | "\u240D\u240A";
3746

3847
export {};

packages/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
]
4141
},
4242
"dependencies": {
43+
"@git-diff-view/core": "^0.0.23"
4344
}
4445
}

packages/utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from "./color";
33
export * from "./dom";
44
export * from "./size";
55
export * from "./utils";
6+
export * from "./symbol";

packages/utils/src/symbol.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NewLineSymbol } from "@git-diff-view/core";
2+
3+
export const getSymbol = (symbol: NewLineSymbol) => {
4+
switch (symbol) {
5+
case NewLineSymbol.LF:
6+
return "␊";
7+
case NewLineSymbol.CR:
8+
return "␍";
9+
case NewLineSymbol.CRLF:
10+
return "␍␊";
11+
default:
12+
return "";
13+
}
14+
};

packages/vue/src/components/DiffContent.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
import { DiffLineType, NewLineSymbol, type DiffFile, type DiffLine, type SyntaxLine } from "@git-diff-view/core";
2-
import { addContentHighlightBGName, delContentHighlightBGName, diffFontSizeName } from "@git-diff-view/utils";
2+
import {
3+
addContentHighlightBGName,
4+
delContentHighlightBGName,
5+
diffFontSizeName,
6+
getSymbol,
7+
} from "@git-diff-view/utils";
38

49
import { DiffNoNewLine } from "./DiffNoNewLine";
510

6-
const getSymbol = (symbol: NewLineSymbol) => {
7-
switch (symbol) {
8-
case NewLineSymbol.LF:
9-
return "␊";
10-
case NewLineSymbol.CR:
11-
return "␍";
12-
case NewLineSymbol.CRLF:
13-
return "␍␊";
14-
default:
15-
return "";
16-
}
17-
};
18-
1911
const DiffString = ({
2012
rawLine,
2113
diffLine,

0 commit comments

Comments
 (0)