-
Notifications
You must be signed in to change notification settings - Fork 0
/
callout-link.css
373 lines (316 loc) · 9.56 KB
/
callout-link.css
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/* https://docs.obsidian.md/Reference/CSS+variables/Editor/Callout */
/* https://docs.obsidian.md/Reference/CSS+variables/Foundations/Typography */
/* https://docs.obsidian.md/Reference/CSS+variables/Foundations/Spacing */
/*
Callout format:
> [!link] ignored ← title ignored, hlink produces horizontal link callout rather than vertical/card callout
> [Example Title w/ link](https://example.com/xxx) ← title, can be just text but also link
>
> ![[S8288469ecf534a62b5462ae9ef47bf5dK.webp]] ← cover image (should be in wikilink format)
>
> [example.com](https://example.com/xxx) ← link, can be also be an empty link: []()
>
> A very nice description ← description, can be skipped by using a not-printable character like <wbr>
*/
/*
Class overrides:
These can be used in the cssclasses prop of a note
- callout-link-image-contain will use object-fit: contain; for cover images
- callout-link-max-w-20 will set the max width for the default variant to 20rem
- callout-link-ratio-3-4 will set the cover image aspect ratio to 3/4.
When combined with callout-link-max-w-20 works well with tall and narrow cover images like movie posters
*/
/* @settings
name: Link Callouts
id: link-callout-settings
settings:
-
id: callout-link-max-width-default
title: Maximum Width (Default Variant)
description: Maximum width for link callout when the callout container is over 50rem, should be greater or equal to the minimum width
type: variable-text
default: 30rem
-
id: callout-link-min-width
title: Minimum Width
description: Minimum width for both link callout variations
type: variable-text
default: 20rem
-
id: callout-link-max-height-horizontal
title: Maximum Height (Horizontal variant)
description: Maximum height for link callout
type: variable-text
default: 8rem
-
id: callout-link-background
title: Background Color
type: variable-themed-color
format: rgb
opacity: true
default-dark: rgb(18 18 18)
default-light: rgba(0, 0, 0, 0.024)
-
id: callout-link-link-color
title: Link Color
type: variable-themed-color
format: rgb
opacity: true
default-dark: rgb(125 125 125)
default-light: rgb(104, 104, 104)
-
id: callout-link-link-hover-color
title: Link Color (on hover)
type: variable-themed-color
format: rgb
opacity: true
default-dark: rgb(145 145 145)
default-light: rgb(84, 84, 84)
-
id: callout-link-title-color
title: Title Color
type: variable-themed-color
format: rgb
opacity: true
default-dark: rgb(241 241 241)
default-light: rgb(35, 35, 35)
-
id: callout-link-desc-color
title: Description Color
type: variable-themed-color
format: rgb
opacity: true
default-dark: rgb(125 125 125)
default-light: rgb(104, 104, 104)
-
id: callout-link-cover-image-background
title: Cover Image Background Color
type: variable-themed-color
format: rgb
opacity: true
default-dark: rgb(0, 0, 0)
default-light: rgb(255, 255, 255)
*/
body {
--callout-link-padding: var(--size-4-4);
/* defaults in case style settings is not installed */
--callout-link-max-width-default: 30rem;
--callout-link-min-width: 20rem;
--callout-link-max-height-horizontal: 8rem;
}
body.theme-dark {
/* defaults in case style settings is not installed */
--callout-link-background: rgb(18 18 18);
--callout-link-link-color: rgb(125 125 125);
--callout-link-link-hover-color: rgb(145 145 145);
--callout-link-title-color: rgb(241 241 241);
--callout-link-desc-color: rgb(125 125 125);
--callout-link-cover-image-background: black;
}
body.theme-light {
/* defaults in case style settings is not installed */
--callout-link-background: rgba(0, 0, 0, 0.024);
--callout-link-link-color: rgb(104, 104, 104);
--callout-link-link-hover-color: rgb(84, 84, 84);
--callout-link-title-color: rgb(35, 35, 35);
--callout-link-desc-color: rgb(104, 104, 104);
--callout-link-cover-image-background: white;
}
.callout[data-callout="link"],
.callout[data-callout="hlink"] {
display: flex;
flex-direction: column;
width: 100%;
container-type: inline-size;
/* callout variable overrides */
--callout-padding: 0;
--callout-color: transparent;
--callout-blend-mode: normal;
--callout-content-padding: 0;
--callout-content-background: var(--callout-link-background);
}
.callout[data-callout="link"] {
--callout-link-aspect-ratio: 1.91;
}
.callout[data-callout="hlink"] {
--callout-link-aspect-ratio: 1;
}
.callout-link-ratio-3-4 .callout[data-callout="link"] {
--callout-link-aspect-ratio: 3 / 4;
}
.callout-link-max-w-20 .callout[data-callout="link"] {
--callout-link-max-width-default: 20rem;
}
@container (min-width: 40rem) {
.callout-link-max-w-20 .callout[data-callout="link"] .callout-content {
max-width: var(--callout-link-max-width-default);
}
}
:is(.callout[data-callout="link"], .callout[data-callout="hlink"])
.callout-title {
display: none;
}
:is(.callout[data-callout="link"], .callout[data-callout="hlink"])
.callout-content {
display: grid;
width: 100%;
min-width: var(--callout-link-min-width);
border-radius: var(--callout-radius);
}
.callout[data-callout="link"] .callout-content {
grid-template-columns: 100%;
grid-template-rows:
auto auto calc(var(--font-text-size) * var(--line-height-normal))
auto;
grid-template-areas:
"cover-image"
"link"
"title"
"desc";
}
@container (min-width: 50rem) {
.callout[data-callout="link"] .callout-content {
max-width: var(--callout-link-max-width-default);
}
}
:is(.callout[data-callout="link"], .callout[data-callout="hlink"])
.callout-content
p {
margin: 0;
padding: 0;
overflow-wrap: break-word;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
line-clamp: 1;
display: -webkit-box;
overflow: hidden;
/* cover image */
&:nth-child(2) {
grid-area: cover-image;
line-height: 0;
display: flex;
flex-direction: column;
width: 100%;
aspect-ratio: var(--callout-link-aspect-ratio);
background-color: var(--callout-link-cover-image-background);
}
&:nth-child(2) img {
border-radius: 0;
object-fit: cover;
aspect-ratio: var(--callout-link-aspect-ratio);
}
/* link */
&:nth-child(3) {
grid-area: link;
color: var(--callout-link-link-color);
--link-external-color: var(--callout-link-link-color);
--link-external-decoration: none;
--link-external-decoration-hover: none;
--link-external-color-hover: var(--callout-link-link-hover-color);
--link-color: var(--link-external-color);
--link-decoration: var(--link-external-decoration);
--link-decoration-hover: var(--link-external-decoration-hover);
--link-color-hover: var(--link-external-color-hover);
}
&:nth-child(3) a {
display: block;
background-image: none;
padding: 0 var(--callout-link-padding);
}
/* title */
&:nth-child(1) {
grid-area: title;
padding: 0 var(--callout-link-padding);
color: var(--callout-link-title-color);
--link-external-color: var(--callout-link-title-color);
--link-external-decoration: none;
--link-external-decoration-hover: none;
--link-external-color-hover: var(--callout-link-title-color);
--link-color: var(--link-external-color);
--link-decoration: var(--link-external-decoration);
--link-decoration-hover: var(--link-external-decoration-hover);
--link-color-hover: var(--link-external-color-hover);
}
&:nth-child(1) a {
display: block;
background-image: none;
}
/* description */
&:nth-child(4) {
grid-area: desc;
padding: 0 var(--callout-link-padding);
color: var(--callout-link-desc-color);
}
}
.callout[data-callout="link"] .callout-content p {
/* cover image */
&:nth-child(2) img {
width: 100%;
}
/* link */
&:nth-child(3) a {
margin-top: var(--callout-link-padding);
}
/* description */
&:nth-child(4) {
margin-bottom: var(--callout-link-padding);
}
}
.callout[data-callout="hlink"] .callout-content {
grid-template-columns:
calc(
var(--callout-link-max-height-horizontal) *
var(--callout-link-aspect-ratio)
)
auto;
grid-template-rows:
auto calc(var(--font-adaptive-normal) * var(--line-height-normal))
auto;
grid-template-areas:
"cover-image link"
"cover-image title"
"cover-image desc";
}
.callout[data-callout="hlink"] .callout-content p {
/* cover image */
&:nth-child(2) {
height: var(--callout-link-max-height-horizontal);
width: auto;
}
&:nth-child(2) img {
width: auto;
height: var(--callout-link-max-height-horizontal);
border-radius: 0;
}
/* link */
&:nth-child(3) {
align-self: end;
}
/* description */
&:nth-child(4) {
align-self: start;
}
}
.callout-link-image-contain
:is(.callout[data-callout="link"], .callout[data-callout="hlink"])
.callout-content
p:nth-child(2)
img {
object-fit: contain;
}
/* hack for minimal theme image zoom */
:is(
.callout[data-callout="link"]:active,
.callout[data-callout="hlink"]:active
):has(.image-embed:not(.canvas-node-content):active) {
container-type: normal;
}
:is(.callout[data-callout="link"]:active, .callout[data-callout="hlink"]:active)
p:nth-child(2)
img {
border-radius: var(--image-radius);
}
.callout[data-callout="hlink"]:active p:nth-child(2) img {
height: auto;
}