Skip to content

Commit ca8cde3

Browse files
bors[bot]tcr
andcommitted
Merge #249
249: Fixes header to top of page, and stops sidebar from influencing page height r=tcr a=tcr Co-authored-by: Tim Ryan <id@timryan.org>
2 parents 2ecd6a1 + 3dbb37f commit ca8cde3

File tree

8 files changed

+146
-110
lines changed

8 files changed

+146
-110
lines changed

edit-frontend/src/app/app.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class EditorFrame extends React.Component {
398398
});
399399
e.preventDefault();
400400
}}
401-
>{CONFIG.title}</a>
401+
><span className="hamburger"></span> {CONFIG.title}</a>
402402
<NativeButtons
403403
editor={this}
404404
buttons={this.state.buttons}
@@ -417,16 +417,17 @@ export class EditorFrame extends React.Component {
417417
<div id="edit-sidebar" className={this.state.sidebarExpanded ? 'expanded' : ''}>
418418
<div id="edit-sidebar-inner">
419419
<div id="edit-sidebar-inner-inner">
420-
<div id="recently-viewed">
421-
<p><span id="edit-sidebar-new"><button onClick={_ => {
422-
window.location.href = '/?from='; // TODO this is a hack
423-
}}>New</button></span>Recently Viewed</p>
424-
<div id="recently-viewed-list">{
425-
recentlyViewed().map((doc) => (
426-
<div><a href={doc.path} title={'/' + doc.path}>{doc.path}</a></div>
427-
))
428-
}</div>
429-
<div id="edit-sidebar-inner-inner"></div>
420+
<div id="edit-sidebar-scrollable">
421+
<div id="recently-viewed">
422+
<p><span id="edit-sidebar-new"><button onClick={_ => {
423+
window.location.href = '/?from='; // TODO this is a hack
424+
}}>New</button></span>Recently Viewed</p>
425+
<div id="recently-viewed-list">{
426+
recentlyViewed().map((doc) => (
427+
<div key={doc.path}><a href={doc.path} title={'/' + doc.path}>{doc.path}</a></div>
428+
))
429+
}</div>
430+
</div>
430431
</div>
431432
<div id="edit-sidebar-footer">
432433
Read more at <a href="http://docs.edit.io">docs.edit.io</a>.<br />Or contribute to <a href="http://github.com/tcr/edit-text">edit-text on Github</a>.
@@ -750,7 +751,7 @@ class EditText extends React.Component {
750751
.connect()
751752
.then(() => {
752753
console.log('Loading static editor.');
753-
this.props.client.clientBindings.command(JSON.stringify({
754+
this.props.client.clientBindings!.command(JSON.stringify({
754755
ClientCommand: {
755756
Init: ["$local", convertMarkdownToDoc(this.props.markdown), 100],
756757
}

edit-frontend/src/editor/wasm.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class WasmController implements ControllerImpl {
5959
onError: (err: any) => void | null;
6060

6161
// TODO refactor wasmClient, remove Module
62-
clientBindings: WasmClientModule;
62+
clientBindings: WasmClientModule | null;
6363

6464
sendCommand(command: ControllerCommand) {
6565
if (CONFIG.console_command_log) {
@@ -69,9 +69,13 @@ export class WasmController implements ControllerImpl {
6969
}
7070

7171
try {
72-
this.clientBindings.command(JSON.stringify({
73-
ControllerCommand: command,
74-
}));
72+
if (!this.clientBindings) {
73+
console.error('Tried to send message to controller before WebAssembly initialized.');
74+
} else {
75+
this.clientBindings.command(JSON.stringify({
76+
ControllerCommand: command,
77+
}));
78+
}
7579
} catch (e) {
7680
this.onError ? this.onError(e) : null;
7781
throw e;

edit-frontend/styles/edit-text.scss

-7
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,3 @@ span.Link:hover::before {
253253
padding: 2px 5px;
254254
color: white;
255255
}
256-
257-
// Debugging
258-
259-
// Spans should never be successive.
260-
span + span {
261-
outline: thin solid #32a1ce;
262-
}

edit-frontend/styles/edit.scss

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import 'modal';
44
@import 'debug';
55
@import 'layout';
6+
@import 'sidebar';
67
@import 'multi';
78
.edit-text { @import "edit-text"; }
89

edit-frontend/styles/layout.scss

+16-82
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,26 @@ body {
2121
height: 100%;
2222

2323
#edit-layout {
24-
flex: 1;
2524
display: flex;
2625
flex-direction: row;
26+
overflow: auto;
27+
flex-grow: 1;
2728

2829
#edit-sidebar {
2930
width: 0;
3031
display: flex;
3132
overflow: visible;
3233
flex-direction: column;
34+
align-self: stretch;
3335

3436
// When expanded, expand #edit-sidebar-inner.
35-
&.expanded {
36-
#edit-sidebar-inner {
37-
width: 300px;
38-
}
37+
#edit-sidebar-inner {
38+
width: 0;
39+
border-right: none;
40+
}
41+
&.expanded #edit-sidebar-inner {
42+
width: 300px;
43+
border-right: 1px #999 solid;
3944
}
4045

4146
#edit-sidebar-inner {
@@ -44,92 +49,21 @@ body {
4449
overflow: hidden;
4550
background: #eee;
4651
z-index: 1000;
47-
border-right: 1px #999 solid;
52+
4853
display: flex;
49-
flex: 1;
5054
flex-direction: column;
55+
height: 100%;
5156

52-
width: 0;
53-
57+
// To fix all contents at 300px even when animating the drawer
58+
// opening, this inner item re-fixes the width at 300px.
5459
#edit-sidebar-inner-inner {
55-
box-sizing: border-box;
5660
width: 300px;
5761
display: flex;
5862
flex: 1;
5963
flex-direction: column;
64+
overflow: auto;
6065

61-
#recently-viewed {
62-
padding: 1px 20px;
63-
flex: 1;
64-
overflow: auto;
65-
}
66-
67-
#edit-sidebar-footer {
68-
flex: 0;
69-
margin: 0 15px;
70-
}
71-
}
72-
}
73-
74-
#edit-sidebar-footer {
75-
border-top: 1px solid #ccc;
76-
padding: 9px 10px 17px;
77-
text-align: center;
78-
font-size: 0.9em;
79-
opacity: 0.6;
80-
}
81-
82-
#recently-viewed {
83-
p {
84-
font-size: 1.2em;
85-
margin: 1.3em 0 0.5em;
86-
font-weight: 500;
87-
color: #444;
88-
}
89-
90-
#edit-sidebar-new {
91-
float: right;
92-
margin-top: -4px;
93-
94-
button {
95-
border: 1px solid #aaa;
96-
background: #fff;
97-
font-size: 12px;
98-
padding: 5px 10px;
99-
text-transform: uppercase;
100-
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
101-
cursor: pointer;
102-
}
103-
}
104-
105-
#recently-viewed-list:empty::after {
106-
content: 'No documents to display.';
107-
}
108-
109-
#recently-viewed-list > * {
110-
a { text-decoration: none; }
111-
&:hover a { text-decoration: underline; }
112-
113-
a {
114-
display: block;
115-
text-overflow: ellipsis;
116-
white-space: nowrap;
117-
overflow: hidden;
118-
119-
padding: 0.5em 0 0.25em 0.4em;
120-
121-
font-size: 18px;
122-
&:not(:hover) {
123-
color: #000000;
124-
}
125-
}
126-
127-
a::before {
128-
content: '\01F4CB';
129-
margin-right: 13px;
130-
filter: grayscale(60%) contrast(130%);
131-
opacity: 0.8;
132-
}
66+
// Scrollable contents inside here.
13367
}
13468
}
13569
}

edit-frontend/styles/sidebar.scss

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Sidebar styling. Also see layout.scss
2+
3+
#edit-sidebar {
4+
#edit-sidebar-footer {
5+
flex: 0;
6+
margin: 0 15px;
7+
border-top: 1px solid #ccc;
8+
padding: 9px 10px 17px;
9+
text-align: center;
10+
font-size: 0.9em;
11+
opacity: 0.6;
12+
}
13+
14+
#edit-sidebar-scrollable {
15+
overflow: auto;
16+
flex-grow: 1;
17+
18+
#recently-viewed {
19+
padding: 1px 20px;
20+
margin-bottom: 20px;
21+
22+
p {
23+
font-size: 1.2em;
24+
margin: 1.3em 0 0.5em;
25+
font-weight: 500;
26+
color: #444;
27+
}
28+
29+
#edit-sidebar-new {
30+
float: right;
31+
margin-top: -4px;
32+
33+
button {
34+
border: 1px solid #aaa;
35+
background: #fff;
36+
font-size: 12px;
37+
color: #333;
38+
font-weight: bold;
39+
padding: 5px 10px;
40+
text-transform: uppercase;
41+
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
42+
cursor: pointer;
43+
}
44+
}
45+
46+
#recently-viewed-list:empty::after {
47+
content: 'No documents to display.';
48+
}
49+
50+
#recently-viewed-list > * {
51+
a { text-decoration: none; }
52+
&:hover a { text-decoration: underline; }
53+
54+
a {
55+
display: block;
56+
text-overflow: ellipsis;
57+
white-space: nowrap;
58+
overflow: hidden;
59+
60+
padding: 0.5em 0 0.25em 0.4em;
61+
62+
font-size: 17px;
63+
&:not(:hover) {
64+
color: #000000;
65+
}
66+
}
67+
68+
a::before {
69+
content: '\01F4CB';
70+
margin-right: 13px;
71+
filter: grayscale(60%) contrast(130%);
72+
opacity: 0.8;
73+
}
74+
}
75+
}
76+
}
77+
}

edit-frontend/styles/toolbar.scss

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1-
21
#toolbar {
2+
$left-width: 46px;
3+
34
display: flex;
45
flex-direction: row;
56
background: #ddd;
6-
border-bottom: 2px solid #aaa;
7-
padding: 5px 20px 8px;
7+
border-bottom: 1px solid #aaa;
8+
padding: 5px 20px 8px $left-width;
89
cursor: auto;
910
min-height: 44px;
1011
flex-wrap: wrap;
12+
position: relative;
13+
14+
.hamburger:before {
15+
content: "";
16+
font-size: 30px;
17+
line-height: 40px;
18+
vertical-align: center;
19+
position: absolute;
20+
top: 0;
21+
left: 0;
22+
bottom: 0;
23+
width: $left-width;
24+
text-align: center;
25+
opacity: 0.5;
26+
}
1127

1228
#logo {
1329
content: "edit-text";
14-
margin: 3px 20px 0 0;
30+
margin: 3px 22px 0 0;
1531
font-family: Helvetica, Arial, sans-serif;
1632
color: #444;
1733
font-size: 20px;
@@ -49,6 +65,11 @@
4965
&:hover {
5066
color: #888;
5167
text-shadow: 1px 1px 1px #fff;
68+
69+
&::after {
70+
opacity: 0.7;
71+
}
72+
5273
}
5374
}
5475

edit-frontend/templates/client.hbs

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<div id="content">
3131
<div id="root-layout">
3232
<div id="toolbar">
33-
<a href="/" id="logo" class="{{release_mode}}">{{title}}</a>
33+
<a href="/" id="logo" class="{{release_mode}}"><span class="hamburger"></span> {{title}}</a>
3434
<div id="native-buttons"></div>
3535
<div id="local-buttons"></div>
3636
</div>
@@ -50,3 +50,8 @@
5050
this.CONFIG = {};
5151
</script>
5252
<script src="/$/edit.js"></script>
53+
<script>
54+
if (!window.DEBUG) {
55+
console.error('Could not determine if JavaScript bundle ran.');
56+
}
57+
</script>

0 commit comments

Comments
 (0)