Skip to content

Commit c3125ad

Browse files
Multiple fixes (#211)
* Fix horizontal scroll * Attempt 2 * Fix merge issue * Do not display right column if it's empty * Fix editor width on empty page * A fix * Consider padding when calculating main column margin left * Mobile layout fix * Fix main column width in edit mode * Edit mode content width fix * Add comments Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
1 parent caea202 commit c3125ad

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/frontend/js/modules/writing.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export default class Writing {
8282
this.nodes.parentIdSelector = moduleEl.querySelector('[name="parent"]');
8383
this.nodes.putAboveIdSelector = moduleEl.querySelector('[name="above"]');
8484
this.nodes.uriInput = moduleEl.querySelector('[name="uri-input"]');
85+
86+
/**
87+
* Set minimum margin left for main column to prevent editor controls from overlapping sidebar
88+
*/
89+
document.documentElement.style.setProperty('--main-col-min-margin-left', '50px');
8590
};
8691

8792
/**

src/frontend/styles/components/writing.pcss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@
9191
.tc-cell {
9292
padding: 6px 8px;
9393
}
94+
95+
@media (--desktop) {
96+
.ce-block__content,
97+
.ce-toolbar__content {
98+
max-width: var(--layout-width-main-col);
99+
}
100+
}
94101
}
95102

96103
.codex-editor__redactor .ce-block:first-of-type .ce-header {

src/frontend/styles/layout.pcss

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
:root {
2+
/**
3+
* Allows to dynamically set main column minimun margin left.
4+
* Is used for adding extra space for editor controls in page edit mode (otherwise controls overlap sidebar)
5+
*/
6+
--main-col-min-margin-left: 0px;
7+
}
8+
19
.docs {
210
min-height: calc(100vh - var(--layout-height-header));
311

@@ -18,6 +26,8 @@
1826
&-inner {
1927
max-width: var(--layout-width-main-col);
2028
margin: 0 auto;
29+
min-width: 0;
30+
width: 100%;
2131

2232
@media (--desktop) {
2333
margin-left: 0;
@@ -28,15 +38,19 @@
2838

2939
&__content {
3040
--max-space-between-cols: 160px;
31-
41+
box-sizing: border-box;
3242
display: flex;
3343
justify-content: space-between;
34-
max-width: calc(var(--layout-width-main-col) + var(--max-space-between-cols) + var(--layout-sidebar-width));
35-
margin-left: max(0px, calc(50vw - var(--layout-sidebar-width) - var(--layout-width-main-col) / 2));
36-
margin-right: auto;
44+
padding: 20px var(--layout-padding-horizontal);
3745

38-
@media (--mobile) {
39-
padding: 20px var(--layout-padding-horizontal);
46+
@media (--desktop) {
47+
max-width: min(
48+
calc(var(--layout-width-main-col) + var(--max-space-between-cols) + var(--layout-sidebar-width)),
49+
calc(100vw - var(--layout-sidebar-width))
50+
);
51+
margin-left: max(var(--main-col-min-margin-left), calc(50vw - var(--layout-sidebar-width) - var(--layout-width-main-col) / 2) - var(--layout-padding-horizontal));
52+
margin-right: auto;
53+
padding: 0;
4054
}
4155
}
4256

@@ -55,6 +69,10 @@
5569
@media (--desktop) {
5670
display: block;
5771
}
72+
73+
&:empty {
74+
display: none;
75+
}
5876
}
5977

6078
&-sidebar {

0 commit comments

Comments
 (0)