Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all \u003cpre\u003e\u003ccode\u003e blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks"); } } catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); } })(); (function(){ try { var __m = "github.com"; var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length \u003e 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions components/EditorHints/EditorHints.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
import React, { Fragment, useState } from "react";

const EditorHints = () => {
const [visible, setVisible] = useState<boolean>(true);

return (
<Fragment>
{visible && (
<div className="bg-gray-700 flex flex-col items-center w-screen fixed left-0 bottom-0">
<div className="w-full text-neutral-400 flex justify-end px-8 py-4">
<button
onClick={() => {
setVisible(false);
}}
>
X
</button>
</div>

<div className="max-w-3xl text-neutral-400 pb-8 pt-4 px-24">
<h3 className="">How to use the editor</h3>
<p className="text-sm my-2">
Your post remains private until you β€œpublish” the article.
</p>
<p className="text-sm my-2">
You can edit and format the main content of your article using
Markdown. If you have never used Markdown, you can check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
</div>
)}
</Fragment>
);
};

export default EditorHints;
17 changes: 17 additions & 0 deletions components/Layout/LayoutEditor.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import type { NextPage } from "next";
import Nav from "../Nav/Nav";

type Props = {
children: JSX.Element;
};

const LayoutEditor: NextPage<Props> = ({ children }) => {
return (
<>
<Nav />
{children}
</>
);
};

export default LayoutEditor;
15 changes: 15 additions & 0 deletions icons/icon-eye-shut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions icons/icon-eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 70 additions & 108 deletions pages/alpha/create/[[...postIdArr]].tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,9 @@ import { ChevronUpIcon } from "@heroicons/react/solid";

import type { SavePostInput } from "../../../schema/post";
import { ConfirmPostSchema } from "../../../schema/post";
import Layout from "../../../components/Layout/Layout";
import LayoutEditor from "../../../components/Layout/LayoutEditor";
import { PromptDialog } from "../../../components/PromptService/PromptService";
import EditorHints from "../../../components/EditorHints/EditorHints";

import { trpc } from "../../../utils/trpc";
import { useDebounce } from "../../../hooks/useDebounce";
Expand All@@ -24,6 +25,9 @@ import { useMarkdownShortcuts } from "../../../markdoc/editor/shortcuts/shortcut
import { markdocComponents } from "../../../markdoc/components";
import { config } from "../../../markdoc/config";

import IconEye from "../../../icons/icon-eye.svg";
import IconEyeShut from "../../../icons/icon-eye-shut.svg";

const Create: NextPage = () => {
const router = useRouter();
const { postIdArr } = router.query;
Expand DownExpand Up@@ -72,7 +76,6 @@ const Create: NextPage = () => {
return toast.error("Something went wrong auto-saving");
},
onSuccess() {
toast.success("Saved");
setSavedTime(
new Date().toLocaleString(undefined, {
dateStyle: "medium",
Expand DownExpand Up@@ -259,15 +262,15 @@ const Create: NextPage = () => {
};

return (
<Layout>
<Fragment>
<LayoutEditor>
<div className="bg-smoke">
<PromptDialog
shouldConfirmLeave={unsavedChanges}
updateParent={handleOpenDialog}
/>
<form onSubmit={handleSubmit(onSubmit)}>
<Transition.Root show={open} as={Fragment}>
<div className="fixed left-0 bottom-0 top-0 z-50 w-full h-screen bg-black">
<div className="fixed left-0 bottom-0 top-0 w-full h-screen bg-smoke">
<button
type="button"
className="absolute right-8 top-8 underline cursor-pointer z-50"
Expand DownExpand Up@@ -337,7 +340,7 @@ const Create: NextPage = () => {
</button>
</div>
))}
<p className="mt-2 text-sm text-neutral-400">
<p className="mt-2 text-sm text-gray-400">
Tag with up to 5 topics. This makes it easier for
readers to find and know what your story is about.
</p>
Expand DownExpand Up@@ -409,6 +412,7 @@ const Create: NextPage = () => {
</button>
</div>
</div>
sadfasdf
</div>
</div>
</div>
Expand DownExpand Up@@ -438,44 +442,66 @@ const Create: NextPage = () => {
<div className="absolute bg-black top-0 bottom-0 left-0 right-0 opacity-25 z-60" />
</div>
)}
<div className="bg-black">
<div className="editor-actions bg-black sticky z-20 top-0 flex justify-end items-center py-4 lg:py-6 px-4 sm:px-6 g:px-4">
<p className="mr-4">
{saveStatus === "loading" && (
<span className="text-gray-400 text-xs lg:text-sm">
Saving...
</span>
)}
{saveStatus === "error" && savedTime && (
<span className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</span>
)}
{saveStatus === "success" && savedTime && (
<span
className="text-gray-400 text-xs lg:text-sm"
title={savedTime.toString()}
>
{`Saved`}
</span>
)}
</p>

<button
type="button"
title="Preview"
className="py-2 px-3 mr-4 inline-flex justify-center focus:outline-none"
onClick={() => setViewPreview((current) => !current)}
>
{viewPreview ? (
<IconEyeShut
className="h-6 w-6 fill-slate-400"
aria-hidden="true"
/>
) : (
<IconEye
className="h-6 w-6 fill-slate-700"
aria-hidden="true"
/>
)}
</button>

<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 py-2 px-3 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
<div className="bg-smoke relative">
<div className="flex-grow w-full max-w-7xl mx-auto xl:px-8 lg:flex text-black">
{/* Left sidebar & main wrapper */}
<div className="flex-1 min-w-0 xl:flex">
<div className="xl:flex-shrink-0 xl:w-64 ">
<div className="h-full pl-4 pr-6 py-6 sm:pl-6 xl:pl-0 lg:px-4">
{/* Start left column area */}
<div className="h-full relative">
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h1 className="text-3xl tracking-tight font-extrabold text-white">
{viewPreview ? "Previewing" : "Editing"} your post
</h1>
<p className="mt-1 text-neutral-400">
The body of your content can be edited using markdown.
Your post remains private until you
&#8220;publish&#8221; the article.
</p>
<div className="flex">
<button
type="button"
className="bg-white border border-neutral-300 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-neutral-700 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300 mt-4"
onClick={() =>
setViewPreview((current) => !current)
}
>
{viewPreview ? "Back to editing" : "View preview"}
</button>
</div>
</div>
</div>
{/* End left column area */}
</div>
</div>
<div className="lg:min-w-0 lg:flex-1">
<div className="h-full py-0 lg:py-6 px-4 sm:px-6 lg:px-4 ">
{/* Start main area*/}
<div className="relative h-full">
<div className="bg-black text-white border-2 border-white shadow-xl">
<div className="text-white border-white shadow-xl">
{viewPreview ? (
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<h2 className="pt-4 sm:my-5 text-3xl font-bold leading-tight">
Expand All@@ -498,10 +524,10 @@ const Create: NextPage = () => {
</article>
</section>
) : (
<div className="py-6 px-4 sm:p-6 lg:pb-8">
<section className="mx-auto pb-4 max-w-xl py-6 px-4 sm:p-6 lg:pb-8">
<input
autoFocus
className="border-none text-2xl leading-5 outline-none bg-black focus:bg-black"
className="bg-smoke border-none text-2xl leading-5 outline-none focus:ring-0"
placeholder="Article title"
type="text"
aria-label="Post Content"
Expand All@@ -510,89 +536,25 @@ const Create: NextPage = () => {

<CustomTextareaAutosize
placeholder="Enter your content here πŸ’–"
className="border-none text-lg outline-none shadow-none mb-8 bg-black focus:bg-black"
className="bg-smoke border-none focus:ring-0 text-lg outline-none shadow-none mb-8"
minRows={25}
{...register("body")}
inputRef={textareaRef}
/>

<div className="flex justify-between items-center">
<>
{saveStatus === "loading" && (
<p>Auto-saving...</p>
)}
{saveStatus === "error" && savedTime && (
<p className="text-red-600 text-xs lg:text-sm">
{`Error saving, last saved: ${savedTime.toString()}`}
</p>
)}
{saveStatus === "success" && savedTime && (
<p className="text-neutral-400 text-xs lg:text-sm">
{`Saved: ${savedTime.toString()}`}
</p>
)}
</>
<div />

<div className="flex">
<button
type="button"
disabled={isDisabled}
className="disabled:opacity-50 ml-5 bg-gradient-to-r from-orange-400 to-pink-600 shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:from-orange-300 hover:to-pink-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-300"
onClick={() => setOpen(true)}
>
{!data?.published && "Publish"}
{data?.published && "Save Changes"}
</button>
</div>
</div>
</div>
</section>
)}
</div>
</div>
{/* End main area */}
</div>
</div>
</div>
<div className="pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 xl:pr-0">
<div className="h-full sm:pl-6 xl:pl-4 py-6 lg:w-80 pl-4">
{/* Start right column area */}
<div className="bg-black text-neutral-800 border-2 border-white shadow-xl p-6">
<h3 className="text-xl tracking-tight font-semibold text-white">
How to use the editor
</h3>
<p className="mt-1 text-neutral-400">
You can edit and format the main content of your article
using Markdown. If you have never used Markdown, you can
check out{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
this
</a>{" "}
free guide on{" "}
<a
href="https://www.markdownguide.org/"
target="_blank"
rel="noopener noreferrer"
className="fancy-link"
>
markdownguide
</a>
.
</p>
</div>
{/* End right column area */}
</div>
</div>
</div>
</div>
</form>
</Fragment>
</Layout>
<EditorHints />
</div>
</LayoutEditor>
);
};

Expand Down