Mike0021 commited on
Commit
f72992d
·
verified ·
1 Parent(s): 9b1cdbc

Pi Web fork: file viewer code at 12px on an 18px line

Browse files
Files changed (1) hide show
  1. piweb/hf-design.patch +35 -7
piweb/hf-design.patch CHANGED
@@ -9387,7 +9387,7 @@ index b46d21a..8a8b640 100644
9387
 
9388
  export function FolderIcon({ size = 14, open = false }: IconProps & { open?: boolean }) {
9389
  diff --git a/components/FileViewer.tsx b/components/FileViewer.tsx
9390
- index 9426211..5f0943f 100644
9391
  --- a/components/FileViewer.tsx
9392
  +++ b/components/FileViewer.tsx
9393
  @@ -6,6 +6,7 @@ import SyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-light";
@@ -9407,7 +9407,26 @@ index 9426211..5f0943f 100644
9407
 
9408
  export type { FileViewerState } from "@/lib/file-viewer-state";
9409
 
9410
- @@ -81,12 +84,14 @@ const FILE_CODE_STYLE: CSSProperties = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9411
  // dark theme's shorthand is dropped, as CodeBlock does: a theme switch then never
9412
  // makes React remove one beside the other (it warned, and the view lost its
9413
  // background).
@@ -9424,7 +9443,16 @@ index 9426211..5f0943f 100644
9424
  delete fileViewerDarkTheme['pre[class*="language-"]'].background;
9425
 
9426
  const FILE_LINE_NUMBER_STYLE: CSSProperties = {
9427
- @@ -119,10 +124,7 @@ interface SelectedLineRange {
 
 
 
 
 
 
 
 
 
9428
 
9429
  function MentionIcon() {
9430
  return (
@@ -9436,7 +9464,7 @@ index 9426211..5f0943f 100644
9436
  );
9437
  }
9438
 
9439
- @@ -252,11 +254,7 @@ function DownloadLink({ filePath, sourceSessionId }: { filePath: string; sourceS
9440
  aria-label={t("i18n.downloadFile")}
9441
  className="file-viewer-icon-button"
9442
  >
@@ -9449,7 +9477,7 @@ index 9426211..5f0943f 100644
9449
  </a>
9450
  );
9451
  }
9452
- @@ -1442,7 +1440,7 @@ function TextFileViewer({
9453
  <SyntaxHighlighter
9454
  className={wrapLines ? "file-source-view is-wrapped" : "file-source-view"}
9455
  language={language === "text" || !prismReady ? "plaintext" : language}
@@ -9458,7 +9486,7 @@ index 9426211..5f0943f 100644
9458
  showLineNumbers
9459
  lineNumberStyle={{
9460
  ...FILE_LINE_NUMBER_STYLE,
9461
- @@ -1708,12 +1706,7 @@ function TextFileViewer({
9462
  color: wrapLines ? "var(--text)" : "var(--text-muted)",
9463
  }}
9464
  >
@@ -9472,7 +9500,7 @@ index 9426211..5f0943f 100644
9472
  </button>
9473
  </>
9474
  )}
9475
- @@ -1733,7 +1726,7 @@ function TextFileViewer({
9476
  gap: 10,
9477
  padding: "5px 8px",
9478
  border: "1px solid var(--border)",
 
9387
 
9388
  export function FolderIcon({ size = 14, open = false }: IconProps & { open?: boolean }) {
9389
  diff --git a/components/FileViewer.tsx b/components/FileViewer.tsx
9390
+ index 9426211..ce8ff16 100644
9391
  --- a/components/FileViewer.tsx
9392
  +++ b/components/FileViewer.tsx
9393
  @@ -6,6 +6,7 @@ import SyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-light";
 
9407
 
9408
  export type { FileViewerState } from "@/lib/file-viewer-state";
9409
 
9410
+ @@ -69,11 +72,16 @@ const DISPLAY_MODE_LABELS: Record<DisplayMode, string> = {
9411
+ diff: "Diff",
9412
+ };
9413
+
9414
+ +// Code in the file viewer (source, diff, large files): 12px on an 18px line, compact
9415
+ +// and still easy to read; the line numbers keep the same 18px rhythm.
9416
+ +const FILE_CODE_FONT_SIZE = 12;
9417
+ +const FILE_CODE_LINE_HEIGHT = "18px";
9418
+ +
9419
+ const FILE_CODE_STYLE: CSSProperties = {
9420
+ fontFamily: "var(--font-mono)",
9421
+ fontWeight: "var(--font-mono-weight)",
9422
+ - fontSize: 13,
9423
+ - lineHeight: 1.6,
9424
+ + fontSize: FILE_CODE_FONT_SIZE,
9425
+ + lineHeight: FILE_CODE_LINE_HEIGHT,
9426
+ };
9427
+
9428
+ // Prism's light theme colors <pre> with backgroundColor, its dark theme with
9429
+ @@ -81,12 +89,14 @@ const FILE_CODE_STYLE: CSSProperties = {
9430
  // dark theme's shorthand is dropped, as CodeBlock does: a theme switch then never
9431
  // makes React remove one beside the other (it warned, and the view lost its
9432
  // background).
 
9443
  delete fileViewerDarkTheme['pre[class*="language-"]'].background;
9444
 
9445
  const FILE_LINE_NUMBER_STYLE: CSSProperties = {
9446
+ @@ -102,7 +112,7 @@ const FILE_LINE_NUMBER_STYLE: CSSProperties = {
9447
+ fontSize: 11,
9448
+ fontStyle: "normal",
9449
+ fontVariantNumeric: "tabular-nums",
9450
+ - lineHeight: "20.8px",
9451
+ + lineHeight: FILE_CODE_LINE_HEIGHT,
9452
+ userSelect: "none",
9453
+ flexShrink: 0,
9454
+ verticalAlign: "top",
9455
+ @@ -119,10 +129,7 @@ interface SelectedLineRange {
9456
 
9457
  function MentionIcon() {
9458
  return (
 
9464
  );
9465
  }
9466
 
9467
+ @@ -252,11 +259,7 @@ function DownloadLink({ filePath, sourceSessionId }: { filePath: string; sourceS
9468
  aria-label={t("i18n.downloadFile")}
9469
  className="file-viewer-icon-button"
9470
  >
 
9477
  </a>
9478
  );
9479
  }
9480
+ @@ -1442,7 +1445,7 @@ function TextFileViewer({
9481
  <SyntaxHighlighter
9482
  className={wrapLines ? "file-source-view is-wrapped" : "file-source-view"}
9483
  language={language === "text" || !prismReady ? "plaintext" : language}
 
9486
  showLineNumbers
9487
  lineNumberStyle={{
9488
  ...FILE_LINE_NUMBER_STYLE,
9489
+ @@ -1708,12 +1711,7 @@ function TextFileViewer({
9490
  color: wrapLines ? "var(--text)" : "var(--text-muted)",
9491
  }}
9492
  >
 
9500
  </button>
9501
  </>
9502
  )}
9503
+ @@ -1733,7 +1731,7 @@ function TextFileViewer({
9504
  gap: 10,
9505
  padding: "5px 8px",
9506
  border: "1px solid var(--border)",