Skip to content

Commit bd55b79

Browse files
authored
Merge pull request freeCodeCamp#1640 from freeCodeCamp/text-justify-hyphenate
Settings: justified layout and hyphenation
2 parents c2f420a + 03d2817 commit bd55b79

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

assets/javascripts/app/settings.coffee

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ class app.Settings
2424
'news'
2525
]
2626

27-
LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars']
27+
LAYOUTS: [
28+
'_max-width'
29+
'_sidebar-hidden'
30+
'_native-scrollbars'
31+
'_text-justify-hyphenate'
32+
]
2833

2934
@defaults:
3035
count: 0
@@ -153,7 +158,8 @@ class app.Settings
153158

154159
toggleLayout: (layout, enable) ->
155160
classList = document.body.classList
156-
classList.toggle(layout, enable) unless app.router?.isSettings
161+
# sidebar is always shown for settings; its state is updated in app.views.Settings
162+
classList.toggle(layout, enable) unless layout is '_sidebar-hidden' and app.router?.isSettings
157163
classList.toggle('_overlay-scrollbars', $.overlayScrollbarsEnabled())
158164
return
159165

assets/javascripts/templates/pages/settings_tmpl.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ app.templates.settingsPage = (settings) -> """
2727
<label class="_settings-label _setting-max-width">
2828
<input type="checkbox" form="settings" name="layout" value="_max-width"#{if settings['_max-width'] then ' checked' else ''}>Enable fixed-width layout
2929
</label>
30+
<label class="_settings-label _setting-text-justify-hyphenate">
31+
<input type="checkbox" form="settings" name="layout" value="_text-justify-hyphenate"#{if settings['_text-justify-hyphenate'] then ' checked' else ''}>Enable justified layout and automatic hyphenation
32+
</label>
3033
<label class="_settings-label _hide-on-mobile">
3134
<input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
3235
<small>Tip: drag the edge of the sidebar to resize it.</small>

assets/stylesheets/components/_content.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
margin-top: var(--headerHeight);
3434
}
3535

36+
._text-justify-hyphenate & {
37+
text-align: justify;
38+
hyphens: auto;
39+
}
40+
3641
._overlay-scrollbars & { padding-left: .625rem; }
3742
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { margin-left: 0; }
3843
@supports (-ms-overflow-style: none) { margin-left: 0; }

0 commit comments

Comments
 (0)