-
Notifications
You must be signed in to change notification settings - Fork 12
/
CodeChatEditor.css
176 lines (149 loc) · 5.33 KB
/
CodeChatEditor.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
/* Copyright (C) 2023 Bryan A. Jones.
This file is part of the CodeChat Editor.
The CodeChat Editor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
The CodeChat Editor is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
the CodeChat Editor. If not, see
[http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
# `CodeChatEditor.css` -- Styles for the CodeChat Editor
This style sheet is used by the HTML generated by
[CodeChatEditor.mts](../../src/CodeChatEditor.mts).
TODO: do a much better job of grouping common styles. Rename styles based on
whether they style a code or doc block.
## Import a theme
Eventually, this will be a user-configurable setting.
*/
@import url('themes/light.css');
/* ## Styles for the entire page layout
This is used only to store a reused variable value. See the
[CSS docs](https://drafts.csswg.org/css-variables/). */
:root {
--top-height: 6.7rem;
--body-padding: 0.2rem;
}
/* See [box sizing](https://css-tricks.com/box-sizing/) for the following
technique to use `border-box` sizing. */
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
/* For box model simplicity, switch the padding and margin. */
padding: var(--body-padding);
margin: 0px;
}
/* Provide space at the top of the screen for the filename and TinyMCE menu bar. */
#CodeChat-top {
height: var(--top-height);
}
/* The rest of the screen is the editor area. Omit this for printing, so the
text flows across multiple pages. */
@media not print {
#CodeChat-body {
height: calc(100vh - var(--top-height) - 2 * var(--body-padding));
overflow: auto;
}
}
/* ## Misc styling
Make the filename compact. */
#CodeChat-filename p {
margin: 0px;
white-space: nowrap;
}
/* ## Doc block styling */
.CodeChat-doc {
/* Use
[flexbox layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox)
to style doc blocks. The goal of this layout is:
\<max line number spaces> \<padding to match the ACE editor> \<doc block
indent> \<doc block contents>
where:
- `<div class="CodeChat-ACE-gutter-padding">` contains \<max line number
spaces>
- `<div class="CodeChat-ACE-padding">` contains \<padding to match the
ACE editor>
- `<div class="CodeChat-doc-indent">` contains \<doc block indent>
- `<div class="CodeChat-TinyMCE">` contains the \<doc block contents> */
display: flex;
padding: 0px 2px 0px 6px;
}
/* Preserve whitespace in the indent of a doc block. */
.CodeChat-doc-indent {
/* Make this \<doc block indent> not expand or shrink, but take exactly the
width required by the text (spaces) it contains. */
flex: 0 0 auto;
white-space: pre;
tab-size: 4;
}
/* Reset what CodeMirror messes up for doc blocks. */
.CodeChat-doc-contents {
font-family: auto;
line-height: initial;
white-space: normal;
flex-grow: 1;
}
/* Remove the editor's border when it's selected, since this hides the cursor
when the cursor is at the beginning of a line and isn't necessary (the entire
screen is an editor, not just that region.) Note that the `focus-visible`
attribute is only visible briefly, but this eliminated that visual flicker. */
.CodeChat-doc-contents.mce-edit-focus,
.CodeChat-doc-contents:focus-visible {
outline-width: 0px;
}
/* ## Combined code/doc block styling
<span id="remove-space">Remove space between a code block followed by a doc
block. Doc block elements typically have top margin and/or padding that
produce this undesired space; remove it on the first element in the doc
block, the first element of the first element in the doc block, etc.</span> */
.CodeChat-doc-contents > *:first-child,
.CodeChat-doc-contents > *:first-child > *:first-child,
.CodeChat-doc-contents > *:first-child > *:first-child > *:first-child,
.CodeChat-doc-contents
> *:first-child
> *:first-child
> *:first-child
> *:first-child,
.CodeChat-doc-contents
> *:first-child
> *:first-child
> *:first-child
> *:first-child
> *:first-child {
margin-top: 0px;
padding-top: 0px;
}
/* [Remove space](remove-space) between a doc block followed by a code block. */
.CodeChat-doc-contents > *:last-child,
.CodeChat-doc-contents > *:last-child > *:last-child,
.CodeChat-doc-contents > *:last-child > *:last-child > *:last-child,
.CodeChat-doc-contents
> *:last-child
> *:last-child
> *:last-child
> *:last-child,
.CodeChat-doc-contents
> *:last-child
> *:last-child
> *:last-child
> *:last-child
> *:last-child {
margin-bottom: 0px;
padding-bottom: 0px;
}
/* Provide nicer defaults for tables. */
.CodeChat-doc-contents table, .CodeChat-doc-contents th, .CodeChat-doc-contents td {
border-collapse: collapse;
padding-left: 4px;
padding-right: 4px;
border: 1px solid;
}