Skip to content

Commit 310e6d6

Browse files
author
Zaydek Michels-Gualtieri
committed
House keeping for EditorApp
1 parent 9ae76bd commit 310e6d6

4 files changed

Lines changed: 23 additions & 27 deletions

File tree

src/EditorApp/EditorApp.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ const App = () => {
1919

2020
const [debouncedElements, setDebouncedElements] = React.useState(() => state.elements)
2121

22-
// Debounces elements by 50 milliseconds.
22+
// Debounces elements by one 60 FPS frame.
2323
React.useEffect(() => {
2424
if (!prefs.show || (prefs.show && prefs.desc === "releases")) {
2525
// No-op
2626
return
2727
}
2828
const id = setTimeout(() => {
2929
setDebouncedElements(state.elements)
30-
}, 50)
30+
}, 16.67)
3131
return () => {
3232
clearTimeout(id)
3333
}
@@ -46,30 +46,30 @@ const App = () => {
4646
}, [prefs.readOnlyMode])
4747

4848
React.useLayoutEffect(() => {
49-
if (state.show && state.desc === "markdown") {
49+
if (prefs.show && prefs.desc === "markdown") {
5050
prefsDispatch({
5151
type: "UPDATE_MARKDOWN",
5252
elements: debouncedElements,
5353
})
5454
}
5555
}, [
5656
debouncedElements,
57-
state.show,
58-
state.desc,
57+
prefs.show,
58+
prefs.desc,
5959
prefsDispatch,
6060
])
6161

6262
React.useLayoutEffect(() => {
63-
if (state.show && state.desc === "markup") {
63+
if (prefs.show && prefs.desc === "markup") {
6464
prefsDispatch({
6565
type: "UPDATE_MARKUP",
6666
elements: debouncedElements,
6767
})
6868
}
6969
}, [
7070
debouncedElements,
71-
state.show,
72-
state.desc,
71+
prefs.show,
72+
prefs.desc,
7373
prefsDispatch,
7474
])
7575

src/EditorApp/MemoFixedBottomWYSIWYGMenu/MemoFixedBottomWYSIWYGMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import WYSIWYGMenu from "./WYSIWYGMenu"
55

66
function areEqual(prev, next) {
77
const ok = (
8-
prev.prefs === next.prefs &&
8+
prev.readOnlyMode === next.readOnlyMode &&
99
JSONEqual(prev.rangeTypes, next.rangeTypes)
1010
)
1111
return ok

src/EditorApp/MemoFixedTopPreferences/MemoFixedTopPreferences.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import React from "react"
44
import Releases from "./Releases"
55
import tabSize from "lib/x/tabSize"
66
import Transition from "lib/x/Transition"
7-
8-
import {
9-
AbsoluteBottomLeftToolTip as TooltipL,
10-
AbsoluteBottomRightToolTip as TooltipR,
11-
} from "../Tooltips"
7+
import { AbsoluteBottomLeftToolTip as LeftTooltip } from "../Tooltips"
8+
import { AbsoluteBottomRightToolTip as RightTooltip } from "../Tooltips"
129

1310
const MemoFixedTopPreferences = React.memo(({ prefs }) => {
1411
const dispatch = React.useContext(PrefsDispatchContext)
@@ -38,11 +35,11 @@ const MemoFixedTopPreferences = React.memo(({ prefs }) => {
3835
}}
3936
>
4037
{(!prefs.show && tooltip === "lock") && (
41-
<TooltipL>
38+
<LeftTooltip>
4239
<p className="text-xs whitespace-pre text-gray-100">
4340
{!prefs.readOnlyMode ? "Enable Read-Only Mode" : "Disable Read-Only Mode"}
4441
</p>
45-
</TooltipL>
42+
</LeftTooltip>
4643
)}
4744
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
4845
{!prefs.readOnlyMode
@@ -71,14 +68,13 @@ const MemoFixedTopPreferences = React.memo(({ prefs }) => {
7168
}}
7269
>
7370
{(!prefs.show && tooltip === "releases") && (
74-
<TooltipR>
71+
<RightTooltip>
7572
<p className="text-xs whitespace-pre text-gray-100">
7673
View Releases
7774
</p>
78-
</TooltipR>
75+
</RightTooltip>
7976
)}
8077
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
81-
{/* <path d="M10 2a6 6 0 00-6 6v3.586l-.707.707A1 1 0 004 14h12a1 1 0 00.707-1.707L16 11.586V8a6 6 0 00-6-6zM10 18a3 3 0 01-3-3h6a3 3 0 01-3 3z" /> */}
8278
<path d="M18 3a1 1 0 00-1.447-.894L8.763 6H5a3 3 0 000 6h.28l1.771 5.316A1 1 0 008 18h1a1 1 0 001-1v-4.382l6.553 3.276A1 1 0 0018 15V3z" clipRule="evenodd" fillRule="evenodd" />
8379
</svg>
8480
</button>
@@ -97,11 +93,11 @@ const MemoFixedTopPreferences = React.memo(({ prefs }) => {
9793
}}
9894
>
9995
{(!prefs.show && tooltip === "markdown") && (
100-
<TooltipR>
96+
<RightTooltip>
10197
<p className="text-xs whitespace-pre text-gray-100">
102-
Show GitHub Flavored Markdown
98+
Render to GitHub Flavored Markdown
10399
</p>
104-
</TooltipR>
100+
</RightTooltip>
105101
)}
106102
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
107103
<path d="M2 5a2 2 0 012-2h12a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm3.293 1.293a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L7.586 10 5.293 7.707a1 1 0 010-1.414zM11 12a1 1 0 100 2h3a1 1 0 100-2h-3z" clipRule="evenodd" fillRule="evenodd" />
@@ -122,11 +118,11 @@ const MemoFixedTopPreferences = React.memo(({ prefs }) => {
122118
}}
123119
>
124120
{(!prefs.show && tooltip === "markup") && (
125-
<TooltipR>
121+
<RightTooltip>
126122
<p className="text-xs whitespace-pre text-gray-100">
127-
Show HyperText Markup Language
123+
Render to HTML
128124
</p>
129-
</TooltipR>
125+
</RightTooltip>
130126
)}
131127
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
132128
<path d="M12.316 3.051a1 1 0 01.633 1.265l-4 12a1 1 0 11-1.898-.632l4-12a1 1 0 011.265-.633zM5.707 6.293a1 1 0 010 1.414L3.414 10l2.293 2.293a1 1 0 11-1.414 1.414l-3-3a1 1 0 010-1.414l3-3a1 1 0 011.414 0zm8.586 0a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 11-1.414-1.414L16.586 10l-2.293-2.293a1 1 0 010-1.414z" clipRule="evenodd" fillRule="evenodd" />

src/EditorApp/usePreferences.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ function PreferencesReducer(state, action) {
7272
case "TOGGLE_MARKUP":
7373
actions(state).toggleMarkup()
7474
return
75-
case "UPDATE_Markdown":
75+
case "UPDATE_MARKDOWN":
7676
actions(state).updateMarkdown(action.elements)
7777
return
78-
case "UPDATE_Markup":
78+
case "UPDATE_MARKUP":
7979
actions(state).updateMarkup(action.elements)
8080
return
8181
case "HIDE_ALL":

0 commit comments

Comments
 (0)