-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathautogrow.css
More file actions
77 lines (67 loc) · 4.24 KB
/
autogrow.css
File metadata and controls
77 lines (67 loc) · 4.24 KB
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
/**
* Make code-input elements resize automatically and fit their content live using CSS
* classes, optionally between a minimum and maximum size specified using CSS variables.
*
* Files: autogrow.css
*/
/* Inspired greatly by https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas/
and the fact code-input.js already implements the article's main structure. */
code-input.code-input_autogrow_height {
--code-input_autogrow_min-height: 0px;
--code-input_autogrow_max-height: calc(infinity * 1px);
/* See FindAndReplace/GoToLine dialog visibility */
--code-input_autogrow_internal-min-height: 0px;
--code-input_autogrow_true-min-height: max(var(--code-input_autogrow_min-height), var(--code-input_autogrow_internal-min-height));
height: max-content;
max-height: var(--code-input_autogrow_max-height);
}
code-input.code-input_autogrow_height textarea {
height: calc(var(--code-input_autogrow_true-min-height) - var(--padding-top, 16px) - var(--padding-bottom, 16px))!important; /* So minimum height possible while containing highlighted code */
min-height: max(var(--code-input_synced-height), calc(100% - var(--padding-top, 16px) - var(--padding-bottom, 16px)));
}
code-input.code-input_autogrow_height > pre,
code-input.code-input_autogrow_height > pre code {
min-height: calc(var(--code-input_autogrow_true-min-height) - var(--padding-top, 16px) - var(--padding-bottom, 16px));
}
code-input.code-input_autogrow_width {
--code-input_autogrow_min-width: 100px;
--code-input_autogrow_max-width: 100%;
/* See FindAndReplace/GoToLine dialog visibility */
--code-input_autogrow_internal-min-width: 0px;
--code-input_autogrow_true-min-width: max(var(--code-input_autogrow_min-width), var(--code-input_autogrow_internal-min-width));
width: max-content; /* Using unset rather than max-content makes always 100% width. */
max-width: var(--code-input_autogrow_max-width);
}
code-input.code-input_autogrow_width textarea {
width: calc(var(--code-input_autogrow_true-min-width) - var(--padding-left, 16px) - var(--padding-right, 16px))!important; /* So minimum width possible while containing highlighted code */
min-width: max(var(--code-input_synced-width), calc(100% - var(--padding-left, 16px) - var(--padding-right, 16px)));
}
code-input.code-input_autogrow_width pre code,
code-input.code-input_autogrow_width pre {
min-width: calc(var(--code-input_autogrow_true-min-width) - var(--padding-left, 16px) - var(--padding-right, 16px));
}
/* FindAndReplace / GoToLine dialog visibility */
code-input.code-input_autogrow_width:has(.code-input_go-to-line_dialog:not(.code-input_go-to-line_hidden-dialog)) {
--code-input_autogrow_internal-min-width: 300px;
}
code-input.code-input_autogrow_height:has(.code-input_go-to-line_dialog:not(.code-input_go-to-line_hidden-dialog)) {
--code-input_autogrow_internal-min-height: 150px;
}
code-input.code-input_autogrow_width:has(.code-input_find-and-replace_dialog:not(.code-input_find-and-replace_hidden-dialog)) {
--code-input_autogrow_internal-min-width: 500px;
}
code-input.code-input_autogrow_height:has(.code-input_find-and-replace_dialog:not(.code-input_find-and-replace_hidden-dialog)) {
--code-input_autogrow_internal-min-height: 170px;
}
/* Autogrow doesn't work with fallback textarea (since its functioning depends on
synchronisation to pre code element). Stick to the minimum size. */
/* At least one line high, leave space for no-JS instructions */
code-input.code-input_autogrow_height:has(textarea[data-code-input-fallback]) {
--code-input_autogrow_internal-min-height: calc(4em + var(--padding-top, 16px) + var(--padding-bottom, 16px)); /* For browsers that don't support 1lh */
--code-input_autogrow_internal-min-height: calc(1lh + 2em + var(--padding-top, 16px) + var(--padding-bottom, 16px)); /* So minimum height possible while containing highlighted code */
height: var(--code-input_autogrow_true-min-height);
}
code-input textarea[data-code-input-fallback] {
height: calc(var(--code-input_autogrow_true-min-height) - var(--padding-top, 16px) - var(--padding-bottom, 16px) - 2em)!important; /* So minimum height possible while containing highlighted code */
min-height: calc(100% - var(--padding-top, 16px) - var(--padding-bottom, 16px) - 2em);
}