summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src/components/diffview.module.css
blob: b3f61ac02438dadb270eaaf704b3744fdef8102a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.diff {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--sl-color-divider);
  background-color: var(--sl-color-bg-surface);
  border-radius: 0.25rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.beforeColumn,
.afterColumn {
  display: flex;
  flex-direction: column;
  overflow-x: visible;
  min-width: 0;
  align-items: stretch;
}

.beforeColumn {
  border-right: 1px solid var(--sl-color-divider);
}

.diff > .row:first-child [data-section="cell"]:first-child {
  padding-top: 0.5rem;
}

.diff > .row:last-child [data-section="cell"]:last-child {
  padding-bottom: 0.5rem;
}

[data-section="cell"] {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;

  width: 100%;
  padding: 0.1875rem 0.5rem 0.1875rem 2.2ch;
  margin: 0;

  &[data-display-mobile="true"] {
    display: none;
  }

  pre {
    --shiki-dark-bg: var(--sl-color-bg-surface) !important;
    background-color: var(--sl-color-bg-surface) !important;

    white-space: pre-wrap;
    word-break: break-word;

    code > span:empty::before {
      content: "\00a0";
      white-space: pre;
      display: inline-block;
      width: 0;
    }
  }
}

[data-diff-type="removed"] {
  background-color: var(--sl-color-red-low);

  pre {
    --shiki-dark-bg: var(--sl-color-red-low) !important;
    background-color: var(--sl-color-red-low) !important;
  }

  &::before {
    content: "-";
    position: absolute;
    left: 0.5ch;
    user-select: none;
    color: var(--sl-color-red-high);
  }
}

[data-diff-type="added"] {
  background-color: var(--sl-color-green-low);

  pre {
    --shiki-dark-bg: var(--sl-color-green-low) !important;
    background-color: var(--sl-color-green-low) !important;
  }

  &::before {
    content: "+";
    position: absolute;
    left: 0.6ch;
    user-select: none;
    color: var(--sl-color-green-high);
  }
}

@media (max-width: 40rem) {
  .row {
    grid-template-columns: 1fr;
  }

  .afterColumn {
    display: none;
  }

  .beforeColumn {
    border-right: none;
  }

  [data-section="cell"] {
    &[data-display-mobile="true"] {
      display: flex;
    }

    &[data-display-mobile="false"] {
      display: none;
    }
  }
}