mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 11:44:40 +00:00
fix custom shortcut logos
This commit is contained in:
@@ -2,12 +2,7 @@ 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";
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
|
import { CustomShortcut } from "../types/AppProps";
|
||||||
interface Shortcut {
|
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
enabled?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Shortcuts() {
|
export default function Shortcuts() {
|
||||||
const { settingsState, setSettingsState } = useSettingsContext();
|
const { settingsState, setSettingsState } = useSettingsContext();
|
||||||
@@ -35,7 +30,7 @@ export default function Shortcuts() {
|
|||||||
|
|
||||||
const addNewCustomShortcut = (): void => {
|
const addNewCustomShortcut = (): void => {
|
||||||
if (isValidTitle(newTitle) && isValidURL(newURL)) {
|
if (isValidTitle(newTitle) && isValidURL(newURL)) {
|
||||||
const newShortcut: Shortcut = { name: newTitle.trim(), url: newURL.trim() };
|
const newShortcut: CustomShortcut = { name: newTitle.trim(), url: newURL.trim(), icon: newTitle[0] };
|
||||||
const updatedCustomShortcuts = [...settingsState.customshortcuts, newShortcut];
|
const updatedCustomShortcuts = [...settingsState.customshortcuts, newShortcut];
|
||||||
setSettingsState({ ...settingsState, customshortcuts: updatedCustomShortcuts });
|
setSettingsState({ ...settingsState, customshortcuts: updatedCustomShortcuts });
|
||||||
setNewTitle("");
|
setNewTitle("");
|
||||||
@@ -118,8 +113,8 @@ export default function Shortcuts() {
|
|||||||
|
|
||||||
{/* Shortcuts Section */}
|
{/* Shortcuts Section */}
|
||||||
{settingsState.shortcuts ? (
|
{settingsState.shortcuts ? (
|
||||||
settingsState.shortcuts.map((shortcut) => shortcut.name && (
|
settingsState.shortcuts.map((shortcut, index) => shortcut.name && (
|
||||||
<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={index}>
|
||||||
{shortcut.name}
|
{shortcut.name}
|
||||||
<Switch state={shortcut.enabled} onChange={(isOn) => switchChange(shortcut.name, isOn)} />
|
<Switch state={shortcut.enabled} onChange={(isOn) => switchChange(shortcut.name, isOn)} />
|
||||||
</div>
|
</div>
|
||||||
@@ -131,21 +126,11 @@ export default function Shortcuts() {
|
|||||||
{/* Custom Shortcuts Section */}
|
{/* Custom Shortcuts Section */}
|
||||||
{settingsState.customshortcuts ? (
|
{settingsState.customshortcuts ? (
|
||||||
settingsState.customshortcuts.map((shortcut, index) => (
|
settingsState.customshortcuts.map((shortcut, index) => (
|
||||||
<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={index}>
|
||||||
{shortcut.name}
|
{shortcut.name}
|
||||||
<button onClick={() => deleteCustomShortcut(index)}>
|
<button onClick={() => deleteCustomShortcut(index)}>
|
||||||
<svg
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-6 h-6">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||||
className="w-4 h-4 text-red-500"
|
|
||||||
viewBox="0 0 20 20"
|
|
||||||
fill="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fillRule="evenodd"
|
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
d="M15.707 4.293a1 1 0 010 1.414L11.414 10l4.293 4.293a1 1 0 11-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 11-1.414-1.414L8.586 10 4.293 5.707a1 1 0 111.414-1.414L10 8.586l4.293-4.293a1 1 0 011.414 0z"
|
|
||||||
clipRule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ interface Shortcut {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomShortcut {
|
export interface CustomShortcut {
|
||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
icon: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MainConfig {
|
export interface MainConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user