Skip to content
This repository was archived by the owner on Jul 12, 2021. It is now read-only.

Commit 6a021bb

Browse files
authored
Add option to hide titles (#86)
1 parent 95873b1 commit 6a021bb

File tree

19 files changed

+213
-77
lines changed

19 files changed

+213
-77
lines changed

src/main/i18n/translations/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const translationsDe: Partial<Translations> = {
8080
auto: "Automatisch",
8181
"diary-entries": "Tagebucheinträge",
8282
"first-day-of-week": "Erster Wochentag",
83+
"hide-titles": "Titel ausblenden",
8384
no: "Nein",
8485
ok: "OK",
8586
"reset-diary": "Tagebuch zurücksetzen",

src/main/i18n/translations/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const translationsEn: Translations = {
8080
auto: "Auto",
8181
"diary-entries": "Diary entries",
8282
"first-day-of-week": "First day of the week",
83+
"hide-titles": "Hide titles",
8384
no: "No",
8485
ok: "OK",
8586
"reset-diary": "Reset diary",

src/renderer/assets/styles/components/_editor.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ $editor-padding-large: 2 * $spacing-abs-large;
1111
}
1212

1313
.editor-scrollable {
14-
display: grid;
14+
display: flex;
1515
flex: 1;
16-
grid-template-rows: auto auto 1fr;
16+
flex-direction: column;
1717
overflow-y: auto;
1818

1919
@media (max-width: $screen-desktop) {
@@ -30,6 +30,11 @@ $editor-padding-large: 2 * $spacing-abs-large;
3030
font-size: 150%;
3131
}
3232

33+
// Fill editor height
34+
.editor-text-wrapper {
35+
flex: 1;
36+
}
37+
3338
.editor-toolbar {
3439
@include background-color("background-toolbar");
3540
@include box-shadow(0 -1.5px 1px 0, "shadow-inner");

src/renderer/assets/styles/elements/_form.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ legend {
77
font-weight: $font-weight-bold;
88
}
99

10-
.fieldset-content {
10+
.form-group {
1111
display: flex;
1212
flex-wrap: wrap;
1313
align-items: center;
1414
margin-right: -$spacing-abs-small;
1515
margin-bottom: -$spacing-abs-small;
1616
}
1717

18-
.fieldset-content > * {
18+
.form-group > * {
1919
margin-right: $spacing-abs-small;
2020
margin-bottom: $spacing-abs-small;
2121
}

src/renderer/components/elements/editor/editor/Editor.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const listPlugin = createListPlugin();
3131
const plugins = [listPlugin];
3232

3333
export interface StateProps {
34+
hideTitles: boolean;
3435
dateSelected: Moment;
3536
entries: Entries;
3637
}
@@ -163,6 +164,7 @@ export default class Editor extends PureComponent<Props, State> {
163164

164165
render = (): ReactNode => {
165166
const { dateSelected, textEditorState, titleEditorState } = this.state;
167+
const { hideTitles } = this.props;
166168

167169
// Detect active inline/block styles
168170
const blockType = RichUtils.getCurrentBlockType(textEditorState);
@@ -174,17 +176,19 @@ export default class Editor extends PureComponent<Props, State> {
174176
<form className="editor">
175177
<div className="editor-scrollable">
176178
<p className="text-faded">{weekdayDate}</p>
177-
<div className="editor-title-wrapper">
178-
<PluginEditor
179-
editorState={titleEditorState}
180-
handleKeyCommand={this.handleTitleKeyCommand}
181-
keyBindingFn={Editor.titleKeyBindingFn}
182-
onBlur={this.saveEntry}
183-
onChange={this.onTitleChange}
184-
placeholder={translations["add-a-title"]}
185-
spellCheck
186-
/>
187-
</div>
179+
{!hideTitles && (
180+
<div className="editor-title-wrapper">
181+
<PluginEditor
182+
editorState={titleEditorState}
183+
handleKeyCommand={this.handleTitleKeyCommand}
184+
keyBindingFn={Editor.titleKeyBindingFn}
185+
onBlur={this.saveEntry}
186+
onChange={this.onTitleChange}
187+
placeholder={translations["add-a-title"]}
188+
spellCheck
189+
/>
190+
</div>
191+
)}
188192
<div className="editor-text-wrapper">
189193
<PluginEditor
190194
editorState={textEditorState}

src/renderer/components/elements/editor/editor/EditorContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IndexDate } from "../../../../types";
66
import Editor, { DispatchProps, StateProps } from "./Editor";
77

88
const mapStateToProps = (state: RootState): StateProps => ({
9+
hideTitles: state.app.hideTitles,
910
dateSelected: state.diary.dateSelected,
1011
entries: state.file.entries,
1112
});

src/renderer/components/overlays/pref-overlay/PrefOverlay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React, { ReactElement } from "react";
22

33
import { translations } from "../../../utils/i18n";
44
import OverlayContainer from "../overlay-hoc/OverlayContainer";
5+
import EntriesPref from "./entries-pref/EntriesPref";
56
import FileDirPrefContainer from "./file-dir-pref/FileDirPrefContainer";
67
import FirstDayOfWeekPrefContainer from "./first-day-of-week-pref/FirstDayOfWeekPrefContainer";
7-
import FutureEntriesPrefContainer from "./future-entries-pref/FutureEntriesPrefContainer";
88
import PasswordPrefContainer from "./password-pref/PasswordPrefContainer";
99
import ThemePrefContainer from "./theme-pref/ThemePrefContainer";
1010

@@ -28,7 +28,7 @@ export default function PrefOverlay(props: Props): ReactElement {
2828
<form className="preferences-form">
2929
<ThemePrefContainer />
3030
{!isLocked && <FirstDayOfWeekPrefContainer />}
31-
{!isLocked && <FutureEntriesPrefContainer />}
31+
{!isLocked && <EntriesPref />}
3232
<FileDirPrefContainer />
3333
{!isLocked && <PasswordPrefContainer />}
3434
</form>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { ReactElement } from "react";
2+
3+
import { translations } from "../../../../utils/i18n";
4+
import FutureEntriesPrefContainer from "./future-entries-pref/FutureEntriesPrefContainer";
5+
import HideTitlesPrefContainer from "./hide-titles-pref/HideTitlesPrefContainer";
6+
7+
/**
8+
* Preference fieldset for options related to diary entries
9+
*/
10+
export default function EntriesPref(): ReactElement {
11+
return (
12+
<fieldset className="fieldset-entries">
13+
<legend>{translations["diary-entries"]}</legend>
14+
<div className="fieldset-content">
15+
<HideTitlesPrefContainer />
16+
<br />
17+
<FutureEntriesPrefContainer />
18+
</div>
19+
</fieldset>
20+
);
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ReactElement } from "react";
22

3-
import { translations } from "../../../../utils/i18n";
3+
import { translations } from "../../../../../utils/i18n";
44

55
export interface StateProps {
66
allowFutureEntries: boolean;
@@ -21,20 +21,15 @@ export default function FutureEntriesPref(props: Props): ReactElement {
2121
const toggleAllowFutureEntries = (): void => updateFutureEntriesPref(!allowFutureEntries);
2222

2323
return (
24-
<fieldset className="fieldset-future-entries">
25-
<legend>{translations["diary-entries"]}</legend>
26-
<div className="fieldset-content">
27-
<label htmlFor="checkbox-future-entries">
28-
<input
29-
type="checkbox"
30-
name="checkbox-future-entries"
31-
id="checkbox-future-entries"
32-
checked={allowFutureEntries}
33-
onChange={toggleAllowFutureEntries}
34-
/>
35-
{translations["allow-future-entries"]}
36-
</label>
37-
</div>
38-
</fieldset>
24+
<label htmlFor="checkbox-future-entries">
25+
<input
26+
type="checkbox"
27+
name="checkbox-future-entries"
28+
id="checkbox-future-entries"
29+
checked={allowFutureEntries}
30+
onChange={toggleAllowFutureEntries}
31+
/>
32+
{translations["allow-future-entries"]}
33+
</label>
3934
);
4035
}

src/renderer/components/overlays/pref-overlay/future-entries-pref/FutureEntriesPrefContainer.tsx renamed to src/renderer/components/overlays/pref-overlay/entries-pref/future-entries-pref/FutureEntriesPrefContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { connect } from "react-redux";
22

3-
import { updateFutureEntriesPref } from "../../../../store/app/actionCreators";
4-
import { RootState, ThunkDispatchT } from "../../../../store/store";
3+
import { updateFutureEntriesPref } from "../../../../../store/app/actionCreators";
4+
import { RootState, ThunkDispatchT } from "../../../../../store/store";
55
import FutureEntriesPref, { DispatchProps, StateProps } from "./FutureEntriesPref";
66

77
const mapStateToProps = (state: RootState): StateProps => ({

0 commit comments

Comments
 (0)