mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-22 11:56:21 +03:00
feat: save text of note
This commit is contained in:
parent
b6b7de4773
commit
dfd29afdc5
5 changed files with 49 additions and 36 deletions
|
@ -4,6 +4,12 @@ import Menu from "./components/menu";
|
||||||
import CreateNote from "./pages/create";
|
import CreateNote from "./pages/create";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
Storage.prototype.setObj = function (key, obj) {
|
||||||
|
return this.setItem(key, JSON.stringify(obj));
|
||||||
|
};
|
||||||
|
Storage.prototype.getObj = function (key) {
|
||||||
|
return JSON.parse(this.getItem(key));
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-4 lg:grid-cols-5 gap-10 text-black dark:text-white">
|
<div className="grid grid-cols-4 lg:grid-cols-5 gap-10 text-black dark:text-white">
|
||||||
<Menu />
|
<Menu />
|
||||||
|
|
|
@ -14,12 +14,14 @@ function Button(props) {
|
||||||
|
|
||||||
function ButtonWithAction(props) {
|
function ButtonWithAction(props) {
|
||||||
return (
|
return (
|
||||||
<div
|
<Link to="#">
|
||||||
onClick={props.onClick}
|
<div
|
||||||
className={`transition-transform w-48 ease-[cubic-bezier(.69,.58,.32,1.69)] hover:scale-105 p-2 pl-6 text-lg bg-zinc-100 hover:bg-zinc-300 dark:bg-zinc-600 dark:hover:bg-zinc-800 rounded-2xl ${props.className}`}
|
onClick={props.onClick}
|
||||||
>
|
className={`transition-transform w-48 ease-[cubic-bezier(.69,.58,.32,1.69)] hover:scale-105 p-2 pl-6 text-lg bg-zinc-100 hover:bg-zinc-300 dark:bg-zinc-600 dark:hover:bg-zinc-800 rounded-2xl ${props.className}`}
|
||||||
{props.children}
|
>
|
||||||
</div>
|
{props.children}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ function CheckBox(props) {
|
||||||
return (
|
return (
|
||||||
<div className={`form-check m-5 ${props.className}`}>
|
<div className={`form-check m-5 ${props.className}`}>
|
||||||
<input
|
<input
|
||||||
className="form-check-input appearance-none h-3 w-6 checked:bg-blue-600 checked:border-blue-600 pr-3 border border-gray-300 rounded-lg mr-1 checked:shadow-lg checked:shadow-blue-600 transition ease-out"
|
className="form-check-input appearance-none h-3 w-6 duration-500 checked:bg-blue-600 checked:border-blue-600 pr-3 border border-gray-300 rounded-lg mr-1 checked:shadow-lg checked:shadow-blue-600 transition ease-out"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id={props.id}
|
id={props.id}
|
||||||
defaultChecked={props.checked}
|
defaultChecked={props.checked}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
MagnifyingGlassCircleIcon,
|
MagnifyingGlassCircleIcon,
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
ExclamationCircleIcon,
|
ExclamationCircleIcon,
|
||||||
|
Cog6ToothIcon,
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
|
|
||||||
function Menu() {
|
function Menu() {
|
||||||
|
@ -33,6 +34,13 @@ function Menu() {
|
||||||
Подробнее
|
Подробнее
|
||||||
</IconWithButton>
|
</IconWithButton>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button href="/options">
|
||||||
|
<IconWithButton
|
||||||
|
icon={<Cog6ToothIcon className="transform translate-z-0 h-7 w-7" />}
|
||||||
|
>
|
||||||
|
Настройки
|
||||||
|
</IconWithButton>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,10 @@ import ReactMarkdown from "react-markdown";
|
||||||
function CreateNote() {
|
function CreateNote() {
|
||||||
const [preview, setPreview] = useState(false);
|
const [preview, setPreview] = useState(false);
|
||||||
const [publicState, setPublicState] = useState(true);
|
const [publicState, setPublicState] = useState(true);
|
||||||
const [text, setText] = useState("");
|
const [text, setText] = useState(localStorage.getItem("NoteText"));
|
||||||
|
const [name, setName] = useState(localStorage.getItem("NoteName"));
|
||||||
|
|
||||||
|
let inputStyle = `form-control block px-3 py-1.5 text-base font-normal text-gray-700 dark:text-white bg-white dark:bg-zinc-900 bg-clip-padding border border-solid border-gray-300 rounded-lg transition ease-in-out focus:border-blue-600 focus:outline-none`;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||||
|
@ -23,44 +25,39 @@ function CreateNote() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{preview && (
|
<input
|
||||||
<div className="w-full md">
|
type="text"
|
||||||
<ReactMarkdown>{text}</ReactMarkdown>
|
className={`mb-2 md:w-1/6 w-full ${inputStyle}`}
|
||||||
</div>
|
placeholder="Название заметки..."
|
||||||
)}
|
value={localStorage.getItem("NoteName")}
|
||||||
|
onChange={(e) => {
|
||||||
|
localStorage.setItem("NoteName", e.target.value);
|
||||||
|
setName(e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
className={`
|
className={`
|
||||||
form-control
|
${inputStyle}
|
||||||
block
|
|
||||||
w-full
|
w-full
|
||||||
px-3
|
|
||||||
py-1.5
|
|
||||||
text-base
|
|
||||||
font-normal
|
|
||||||
text-gray-700
|
|
||||||
dark:text-white
|
|
||||||
bg-white
|
|
||||||
dark:bg-zinc-900
|
|
||||||
bg-clip-padding
|
|
||||||
border
|
|
||||||
border-solid
|
|
||||||
border-gray-300
|
|
||||||
rounded-lg
|
|
||||||
transition
|
|
||||||
ease-in-out
|
|
||||||
m-0
|
|
||||||
focus:border-blue-600
|
|
||||||
focus:outline-none
|
|
||||||
${preview ? "hidden" : ""}
|
${preview ? "hidden" : ""}
|
||||||
`}
|
`}
|
||||||
rows="10"
|
rows="10"
|
||||||
placeholder="Ваша заметка начинается здесь. Можно использовать markdown..."
|
placeholder="Ваша заметка начинается здесь. Можно использовать markdown..."
|
||||||
maxLength={5000}
|
maxLength={5000}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
localStorage.setItem("NoteText", e.target.value);
|
||||||
setText(e.target.value);
|
setText(e.target.value);
|
||||||
}}
|
}}
|
||||||
></textarea>
|
>
|
||||||
|
{localStorage.getItem("NoteText")}
|
||||||
|
</textarea>
|
||||||
|
|
||||||
|
{preview && (
|
||||||
|
<div className="w-full md">
|
||||||
|
<ReactMarkdown>{text}</ReactMarkdown>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 justify-items-center w-full">
|
<div className="grid grid-cols-1 lg:grid-cols-2 justify-items-center w-full">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
className="justify-self-center lg:justify-self-start"
|
className="justify-self-center lg:justify-self-start"
|
||||||
|
@ -69,7 +66,7 @@ function CreateNote() {
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPublicState(!publicState);
|
setPublicState(!publicState);
|
||||||
}}
|
}}
|
||||||
checked
|
checked={localStorage.getItem("private")}
|
||||||
/>
|
/>
|
||||||
<div className="justify-self-center lg:justify-self-end">
|
<div className="justify-self-center lg:justify-self-end">
|
||||||
<ButtonWithAction className="m-5" onClick={""}>
|
<ButtonWithAction className="m-5" onClick={""}>
|
||||||
|
|
Loading…
Add table
Reference in a new issue