-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathcode-blocks.module.scss
156 lines (136 loc) · 3.2 KB
/
code-blocks.module.scss
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
.code-block {
& ::selection {
background-color: rgba(106, 95, 193, 0.5);
}
pre {
background-color: var(--code-background);
border-radius: 0 0 0.25rem 0.25rem;
margin-top: 0;
margin-bottom: 0;
}
code[class*='language-'],
pre[class*='language-'] {
font-family: var(--font-family-monospace);
}
pre[class*='language-'] {
font-size: 0.85rem;
border: 0;
border-radius: 4px;
margin: 0 0 1rem;
}
/**
* Shift padding on code diffs, so the background highlight covers the whole line
*/
pre[class^='language-']:has(:global(.code-diff)) {
padding-right: 0;
& :global(.diff-deleted) :global(.token.operator:first-of-type),
& :global(.diff-inserted) :global(.token.operator:first-of-type) {
padding-right: 12px;
}
}
pre[class^='language-']:has(:global(.highlight-line)) {
padding-left: 0;
padding-right: 0;
& :global(.code-line) {
padding-left: 12px;
padding-right: 12px;
}
}
/**
* Line highlighting in code blocks
*
* 1. Make the element just wide enough to fit its content.
* 2. Always fill the visible space in .code-highlight.
*/
:global(.code-highlight) {
// 1
float: left;
// 2
min-width: 100%;
}
:global(.code-line) {
display: block;
float: left;
min-width: 100%;
box-sizing: border-box;
// Set placeholder for highlight accent border color to transparent
border-left: 4px solid rgba(0, 0, 0, 0);
svg {
display: inline;
}
> :global(.table) {
display: inline;
}
}
:global(.highlight-line) {
background-color: rgba(239, 239, 239, 0.06);
/* Set highlight bg color */
border-left: 4px solid var(--brandPink);
}
/* Diff highlighting, classes provided by rehype-prism-plus */
/* Set inserted line (+) color */
/* Move the margin left and adjust width so we can keep the parent padding */
:global(.diff-inserted),
:global(.inserted) {
background-color: rgba(16, 185, 129, 0.2);
margin-left: -12px;
width: calc(100% + 12px);
}
/* Diff highlighting, classes provided by rehype-prism-plus */
/* Set deleted line (-) color */
/* Move the margin left and adjust width so we can keep the parent padding */
:global(.diff-deleted),
:global(.deleted) {
background-color: rgba(239, 68, 68, 0.2);
margin-left: -12px;
width: calc(100% + 12px);
}
}
.code-actions {
display: grid;
height: 32px;
grid-template-columns: max-content max-content;
grid-gap: 1rem;
align-items: center;
position: absolute;
margin: 0 0.25rem;
right: 0;
top: -35px;
}
.filename {
font-size: 0.75rem;
color: var(--white);
font-weight: normal;
}
.class-name {
color: lightgrey;
}
.copy {
font-size: 0.85rem;
color: white;
border: none;
margin: 0;
padding: 4px;
background: none;
outline: none;
border-radius: 2px;
transition: background 150ms ease-in-out;
&:hover,
&:focus {
background: rgba(255, 255, 255, 0.25);
}
}
.copied {
position: absolute;
right: 4px;
top: 4px;
margin: 0;
padding: 0 6px;
border-radius: 2px;
font-size: 0.85rem;
background: rgba(255, 255, 255, 0.25);
border: none;
color: var(--white);
transition: opacity 150ms;
z-index: 10000;
}