Skip to content

Commit 0db35db

Browse files
committed
Option for a minimal header
1 parent 5825b6d commit 0db35db

File tree

6 files changed

+61
-27
lines changed

6 files changed

+61
-27
lines changed

editor/src/components/header/MainHeader.tsx

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const capitalize = (str: string): string => {
2222

2323
export const MainHeader: React.FC = () => {
2424
const [_edit, setEdit] = useHashParamBoolean("edit");
25+
const [minimalHeader] = useHashParamBoolean("minimalheader");
2526
const [isLargerThan400] = useMediaQuery("(min-width: 400px)");
2627

2728
// only show the edit button if the command points to a script in the inputs
@@ -90,30 +91,32 @@ export const MainHeader: React.FC = () => {
9091
>
9192
Markdown
9293
</Button>
93-
<HStack
94-
borderLeft={"1px"}
95-
right={0}
96-
px={4}
97-
bg={"gray.100"}
98-
justifyContent={"space-around"}
99-
h={"headerHeight"}
100-
w={"16rem"}
101-
>
102-
{icon(
103-
Gear,
104-
"settings",
105-
() => setShownPanel(shownPanel === "settings" ? null : "settings"),
106-
true
107-
)}
108-
{icon(
109-
QuestionMark,
110-
"docs",
111-
() => setShownPanel(shownPanel === "docs" ? null : "docs"),
112-
true
113-
)}
114-
<ButtonCopyExternalLink />
115-
{icon(X, "close", () => setEdit(false))}
116-
</HStack>
94+
{!minimalHeader && (
95+
<HStack
96+
borderLeft={"1px"}
97+
right={0}
98+
px={4}
99+
bg={"gray.100"}
100+
justifyContent={"space-around"}
101+
h={"headerHeight"}
102+
w={"16rem"}
103+
>
104+
{icon(
105+
Gear,
106+
"settings",
107+
() => setShownPanel(shownPanel === "settings" ? null : "settings"),
108+
true
109+
)}
110+
{icon(
111+
QuestionMark,
112+
"docs",
113+
() => setShownPanel(shownPanel === "docs" ? null : "docs"),
114+
true
115+
)}
116+
<ButtonCopyExternalLink />
117+
{icon(X, "close", () => setEdit(false))}
118+
</HStack>
119+
)}
117120
</HStack>
118121
);
119122
};

editor/src/components/sections/PanelCode.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const LocalEditor: React.FC<{
3636
hidemenuififrame: true,
3737
mode: "markdown",
3838
theme: themeOptions?.theme || "vs-light",
39+
hideLineNumbers: true,
3940
});
4041
return `https://editor.mtfm.io/#?hm=disabled&options=${options}`;
4142
};

editor/src/components/sections/settings/EdiDisplayMode.tsx renamed to editor/src/components/sections/settings/EditDisplayMode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const validationSchema = yup.object({
3333

3434
interface FormType extends yup.InferType<typeof validationSchema> {}
3535

36-
export const EdiDisplayMode: React.FC = () => {
36+
export const EditDisplayMode: React.FC = () => {
3737
const [options, setOptions] = useOptions();
3838

3939
const onSubmit = useCallback(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useCallback } from "react";
2+
3+
import { Checkbox, Text, VStack } from "@chakra-ui/react";
4+
import { useHashParamBoolean } from "@metapages/hash-query/react-hooks";
5+
6+
export const EditMinimalHeader: React.FC = () => {
7+
const [minimalHeader, setMinimalHeader] =
8+
useHashParamBoolean("minimalheader");
9+
10+
const handleChange = useCallback(() => {
11+
// console.log("minimalheader", values.minimalheader);
12+
setMinimalHeader(!minimalHeader);
13+
}, [minimalHeader, setMinimalHeader]);
14+
15+
return (
16+
<VStack align="flex-start" w="100%" minW={"100%"} p={6}>
17+
<Text fontWeight={700}>Minimal Header</Text>
18+
<Checkbox
19+
id="minimalheader"
20+
name="minimalheader"
21+
isChecked={minimalHeader}
22+
onChange={handleChange}
23+
></Checkbox>
24+
</VStack>
25+
);
26+
};

editor/src/components/sections/settings/SectionOptions.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { EditBgColor } from "./EditBgColor";
66
import { EditButtonSettings } from "./EditButtonSettings";
77
import { EditColorScheme } from "./EditColorScheme";
88
import { EditEditorWidth } from "./EditEditorWidth";
9-
import { EdiDisplayMode } from "./EdiDisplayMode";
9+
import { EditDisplayMode } from "./EditDisplayMode";
10+
import { EditMinimalHeader } from "./EditMinimalHeader";
1011

1112
export const SectionOptions: React.FC = () => {
1213
return (
@@ -19,13 +20,15 @@ export const SectionOptions: React.FC = () => {
1920
>
2021
<EditButtonSettings />
2122
<Divider />
22-
<EdiDisplayMode />
23+
<EditDisplayMode />
2324
<Divider />
2425
<EditColorScheme />
2526
<Divider />
2627
<EditBgColor />
2728
<Divider />
2829
<EditEditorWidth />
30+
<Divider />
31+
<EditMinimalHeader />
2932
</VStack>
3033
);
3134
};

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ publish: _ensure_deployctl
4646
cp -r editor/dist deploy/editor
4747
cp -r worker/server.ts deploy/
4848
cp -r worker/index.html deploy/
49+
cp -r worker/public deploy/
4950
cd deploy
5051
deployctl deploy --project=metaframe-mdv2 --prod server.ts
5152

0 commit comments

Comments
 (0)