Compare commits
2 Commits
bae0551895
...
1c6103142f
Author | SHA1 | Date | |
---|---|---|---|
|
1c6103142f | ||
|
328127c55e |
12
reminder-dashboard/package-lock.json
generated
12
reminder-dashboard/package-lock.json
generated
@ -13,6 +13,7 @@
|
|||||||
"react-colorful": "^5.6.1",
|
"react-colorful": "^5.6.1",
|
||||||
"react-query": "^3.39.3",
|
"react-query": "^3.39.3",
|
||||||
"tributejs": "^5.1.3",
|
"tributejs": "^5.1.3",
|
||||||
|
"use-debounce": "^10.0.0",
|
||||||
"wouter": "^3.0"
|
"wouter": "^3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -5206,6 +5207,17 @@
|
|||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/use-debounce": {
|
||||||
|
"version": "10.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/use-debounce/-/use-debounce-10.0.0.tgz",
|
||||||
|
"integrity": "sha512-XRjvlvCB46bah9IBXVnq/ACP2lxqXyZj0D9hj4K5OzNroMDpTEBg8Anuh1/UfRTRs7pLhQ+RiNxxwZu9+MVl1A==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/use-sync-external-store": {
|
"node_modules/use-sync-external-store": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"react-colorful": "^5.6.1",
|
"react-colorful": "^5.6.1",
|
||||||
"react-query": "^3.39.3",
|
"react-query": "^3.39.3",
|
||||||
"tributejs": "^5.1.3",
|
"tributejs": "^5.1.3",
|
||||||
|
"use-debounce": "^10.0.0",
|
||||||
"wouter": "^3.0"
|
"wouter": "^3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { JSX } from "preact";
|
import {JSX} from "preact";
|
||||||
import { createPortal } from "preact/compat";
|
import {createPortal} from "preact/compat";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
setModalOpen: (open: boolean) => never;
|
setModalOpen: (open: boolean) => never;
|
||||||
@ -9,7 +9,7 @@ type Props = {
|
|||||||
children: string | JSX.Element | JSX.Element[] | (() => JSX.Element);
|
children: string | JSX.Element | JSX.Element[] | (() => JSX.Element);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Modal = ({ setModalOpen, title, onSubmit, onSubmitText, children }: Props) => {
|
export const Modal = ({setModalOpen, title, onSubmit, onSubmitText, children}: Props) => {
|
||||||
const body = document.querySelector("body");
|
const body = document.querySelector("body");
|
||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
@ -34,7 +34,7 @@ export const Modal = ({ setModalOpen, title, onSubmit, onSubmitText, children }:
|
|||||||
<section class="modal-card-body">{children}</section>
|
<section class="modal-card-body">{children}</section>
|
||||||
{onSubmit && (
|
{onSubmit && (
|
||||||
<footer class="modal-card-foot">
|
<footer class="modal-card-foot">
|
||||||
<button class="button is-success" onInput={onSubmit}>
|
<button class="button is-success" onClick={onSubmit}>
|
||||||
{onSubmitText || "Save"}
|
{onSubmitText || "Save"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
@ -16,7 +16,7 @@ export const Author = ({ name, icon, setReminder }: Props) => {
|
|||||||
class="is-rounded embed_author_url"
|
class="is-rounded embed_author_url"
|
||||||
url={icon}
|
url={icon}
|
||||||
alt="Image for embed author"
|
alt="Image for embed author"
|
||||||
setImage={(url) => {
|
setImage={(url: string) => {
|
||||||
setReminder((reminder) => ({
|
setReminder((reminder) => ({
|
||||||
...reminder,
|
...reminder,
|
||||||
embed_author_url: url,
|
embed_author_url: url,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
import { HexColorPicker } from "react-colorful";
|
import { HexColorPicker } from "react-colorful";
|
||||||
import { Modal } from "../../Modal";
|
import { Modal } from "../../Modal";
|
||||||
import { Reminder } from "../../../api";
|
import { Reminder } from "../../../api";
|
||||||
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
color: string;
|
color: string;
|
||||||
@ -38,16 +39,20 @@ export const Color = ({ color, setReminder }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ColorModal = ({ setModalOpen, color, setReminder }) => {
|
const ColorModal = ({ setModalOpen, color, setReminder }) => {
|
||||||
|
const setDebounced = useDebouncedCallback((color) => {
|
||||||
|
setReminder((reminder: Reminder) => ({
|
||||||
|
...reminder,
|
||||||
|
embed_color: colorToInt(color),
|
||||||
|
}));
|
||||||
|
}, 100);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal setModalOpen={setModalOpen} title={"Select Color"}>
|
<Modal setModalOpen={setModalOpen} title={"Select Color"}>
|
||||||
<div class="colorpicker-container">
|
<div class="colorpicker-container">
|
||||||
<HexColorPicker
|
<HexColorPicker
|
||||||
color={color}
|
color={color}
|
||||||
onInput={(color) => {
|
onChange={(color: string) => {
|
||||||
setReminder((reminder) => ({
|
setDebounced(color);
|
||||||
...reminder,
|
|
||||||
embed_color: colorToInt(color),
|
|
||||||
}));
|
|
||||||
}}
|
}}
|
||||||
></HexColorPicker>
|
></HexColorPicker>
|
||||||
</div>
|
</div>
|
||||||
@ -57,10 +62,7 @@ const ColorModal = ({ setModalOpen, color, setReminder }) => {
|
|||||||
id="colorInput"
|
id="colorInput"
|
||||||
value={color}
|
value={color}
|
||||||
onInput={(ev) => {
|
onInput={(ev) => {
|
||||||
setReminder((reminder) => ({
|
setDebounced(ev.currentTarget.value);
|
||||||
...reminder,
|
|
||||||
embed_color: colorToInt(ev.currentTarget.value),
|
|
||||||
}));
|
|
||||||
}}
|
}}
|
||||||
></input>
|
></input>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -65,7 +65,12 @@ export const Embed = () => {
|
|||||||
class="embed_thumbnail_url"
|
class="embed_thumbnail_url"
|
||||||
url={reminder.embed_thumbnail_url}
|
url={reminder.embed_thumbnail_url}
|
||||||
alt="Square thumbnail embedded image"
|
alt="Square thumbnail embedded image"
|
||||||
setImage={() => {}}
|
setImage={(url: string) =>
|
||||||
|
setReminder((reminder: Reminder) => ({
|
||||||
|
...reminder,
|
||||||
|
embed_thumbnail_url: url || null,
|
||||||
|
}))
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@ -76,7 +81,12 @@ export const Embed = () => {
|
|||||||
class="embed_image_url"
|
class="embed_image_url"
|
||||||
url={reminder.embed_image_url}
|
url={reminder.embed_image_url}
|
||||||
alt="Large embedded image"
|
alt="Large embedded image"
|
||||||
setImage={() => {}}
|
setImage={(url: string) =>
|
||||||
|
setReminder((reminder: Reminder) => ({
|
||||||
|
...reminder,
|
||||||
|
embed_image_url: url || null,
|
||||||
|
}))
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ const ImagePickerModal = ({ setModalOpen, setImage }) => {
|
|||||||
title={"Enter Image URL"}
|
title={"Enter Image URL"}
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
setImage(value);
|
setImage(value);
|
||||||
|
setModalOpen(false);
|
||||||
}}
|
}}
|
||||||
onSubmitText={"Save"}
|
onSubmitText={"Save"}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user