mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
add custom shortcut menu
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Switch from "../components/Switch";
|
import Switch from "../components/Switch";
|
||||||
import { useSettingsContext } from "../SettingsContext";
|
import { useSettingsContext } from "../SettingsContext";
|
||||||
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
|
|
||||||
interface Shortcut {
|
interface Shortcut {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -39,6 +40,8 @@ export default function Shortcuts() {
|
|||||||
setSettingsState({ ...settingsState, customshortcuts: updatedCustomShortcuts });
|
setSettingsState({ ...settingsState, customshortcuts: updatedCustomShortcuts });
|
||||||
setNewTitle("");
|
setNewTitle("");
|
||||||
setNewURL("");
|
setNewURL("");
|
||||||
|
|
||||||
|
setFormVisible(false);
|
||||||
} else {
|
} else {
|
||||||
// Replace with a more user-friendly way to display errors
|
// Replace with a more user-friendly way to display errors
|
||||||
console.error("Please enter a valid title and URL.");
|
console.error("Please enter a valid title and URL.");
|
||||||
@@ -50,26 +53,71 @@ export default function Shortcuts() {
|
|||||||
setSettingsState({ ...settingsState, customshortcuts: updatedCustomShortcuts });
|
setSettingsState({ ...settingsState, customshortcuts: updatedCustomShortcuts });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [isFormVisible, setFormVisible] = useState(false);
|
||||||
|
|
||||||
|
const toggleForm = () => {
|
||||||
|
setFormVisible(!isFormVisible);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col divide-y divide-zinc-100">
|
<div className="flex flex-col divide-y divide-zinc-100">
|
||||||
{/* Form Section */}
|
|
||||||
<div className="flex items-center justify-between px-4 py-3">
|
<AnimatePresence>
|
||||||
<input
|
{isFormVisible ? (
|
||||||
type="text"
|
<motion.div
|
||||||
placeholder="Title"
|
initial={{ opacity: 0, height: 0 }}
|
||||||
value={newTitle}
|
animate={{ opacity: 1, height: "auto" }}
|
||||||
onChange={(e) => setNewTitle(e.target.value)}
|
exit={{ opacity: 0, height: 0 }}
|
||||||
/>
|
transition={{ type: "spring", damping: 20 }}
|
||||||
<input
|
>
|
||||||
type="text"
|
<div className="flex flex-col items-center mb-4">
|
||||||
placeholder="URL"
|
<motion.input
|
||||||
value={newURL}
|
initial={{ opacity: 0, y: -10 }}
|
||||||
onChange={(e) => setNewURL(e.target.value)}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
/>
|
transition={{ delay: 0.2 }}
|
||||||
<button onClick={addNewCustomShortcut}>Add</button>
|
className="w-full p-2 rounded-md bg-zinc-100 dark:bg-zinc-700 focus:outline-none"
|
||||||
</div>
|
type="text"
|
||||||
{/* Shortcuts Section */}
|
placeholder="Shortcut Name"
|
||||||
{settingsState.shortcuts ? (
|
value={newTitle}
|
||||||
|
onChange={(e) => setNewTitle(e.target.value)}
|
||||||
|
/>
|
||||||
|
<motion.input
|
||||||
|
initial={{ opacity: 0, y: -10 }}
|
||||||
|
animate={{ opacity: 1, y: 0 }}
|
||||||
|
transition={{ delay: 0.3 }}
|
||||||
|
className="w-full p-2 my-2 rounded-md bg-zinc-100 dark:bg-zinc-700 focus:outline-none"
|
||||||
|
type="text"
|
||||||
|
placeholder="URL eg. https://google.com"
|
||||||
|
value={newURL}
|
||||||
|
onChange={(e) => setNewURL(e.target.value)}
|
||||||
|
/>
|
||||||
|
<motion.button
|
||||||
|
initial={{ opacity: 0 }}
|
||||||
|
animate={{ opacity: 1 }}
|
||||||
|
transition={{ delay: 0.4 }}
|
||||||
|
className="w-full px-4 py-2 text-white bg-blue-500 rounded-md"
|
||||||
|
onClick={ addNewCustomShortcut }
|
||||||
|
>
|
||||||
|
Add
|
||||||
|
</motion.button>
|
||||||
|
</div>
|
||||||
|
</motion.div>
|
||||||
|
) : (
|
||||||
|
<motion.button
|
||||||
|
initial={{ backgroundColor: "rgba(29, 161, 242, 1)", height: "auto" }}
|
||||||
|
animate={{ backgroundColor: "rgba(29, 161, 242, 1)", height: "auto" }}
|
||||||
|
exit={{ backgroundColor: "rgba(29, 161, 242, 1)", height: "auto" }}
|
||||||
|
transition={{ type: 'tween', ease: "easeOut" }}
|
||||||
|
className="px-4 py-2 mb-4 text-white bg-blue-500 rounded"
|
||||||
|
onClick={toggleForm}
|
||||||
|
>
|
||||||
|
Add Custom Shortcut
|
||||||
|
</motion.button>
|
||||||
|
)}
|
||||||
|
</AnimatePresence>
|
||||||
|
|
||||||
|
{/* Shortcuts Section */}
|
||||||
|
{settingsState.shortcuts ? (
|
||||||
settingsState.shortcuts.map((shortcut) => (
|
settingsState.shortcuts.map((shortcut) => (
|
||||||
<div className="flex items-center justify-between px-4 py-3" key={shortcut.name}>
|
<div className="flex items-center justify-between px-4 py-3" key={shortcut.name}>
|
||||||
{shortcut.name}
|
{shortcut.name}
|
||||||
|
|||||||
Reference in New Issue
Block a user