From 43a6a9f88c14b89686d95189692d4e8df9ba4bf1 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 15 May 2023 16:34:17 +0300 Subject: [PATCH] changed popup to expanding section --- src/components/InputElements.tsx | 28 ++++++++----------- src/css/pages/Admin.css | 12 +++++++- src/pages/admin/Flags.tsx | 47 ++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/components/InputElements.tsx b/src/components/InputElements.tsx index 643b36e..5eca867 100644 --- a/src/components/InputElements.tsx +++ b/src/components/InputElements.tsx @@ -47,25 +47,21 @@ export type InputElementProperties = { } export const ToggleSwitch = ({ value, onChange, inputRef, children }: InputElementProperties) => { - return

- -

; + return ; }; export const VerticalToggleSwitch = ({ value, onChange, inputRef, children }: InputElementProperties) => { - return

- -

; + return ; }; type ManualInputProperties = { diff --git a/src/css/pages/Admin.css b/src/css/pages/Admin.css index 7320e6d..e5cec4a 100644 --- a/src/css/pages/Admin.css +++ b/src/css/pages/Admin.css @@ -14,11 +14,16 @@ } .flag { - background-color: var(--bg-color); + /* background-color: var(--bg-color); */ +} + +details .flag { + margin-left: 1.7rem; } .tile { width: calc(25% - 8px); + background-color: var(--bg-color); } .flag.list-element { @@ -29,6 +34,11 @@ .list.category { user-select: none; + background-color: var(--color-darkGrey); + padding: 1rem; + margin: 0.5rem; + border-radius: 1rem; + border: 2px solid var(--bg-color); } .list.category > * { diff --git a/src/pages/admin/Flags.tsx b/src/pages/admin/Flags.tsx index 6f9ab59..3ac87d9 100644 --- a/src/pages/admin/Flags.tsx +++ b/src/pages/admin/Flags.tsx @@ -3,8 +3,6 @@ import { Flag as APIFlag } from "../../@types/ApiStructures"; import { OrganisedFlags, capitalise, get, organiseFlags } from "../../util/Util"; import { ClickToEdit, Dropdown, InputElementType, NumberInput, StringInput, ToggleSwitch } from "../../components/InputElements"; import { PageButtons } from "../../components/PageControls"; -import { Popup } from "../../components/PageElements"; -import ClickDetector from "../../util/ClickDetector"; const Flag = ({ flag: incoming }: { flag: APIFlag }) => { @@ -28,9 +26,11 @@ const Flag = ({ flag: incoming }: { flag: APIFlag }) => { else if (flag.type === 'number') Input = setUnsaved(true)} inputRef={valueRef} value={flag.value as number} type='float' />; else if (flag.type === 'boolean') Input = setUnsaved(true)} inputRef={valueRef} value={flag.value as boolean} />; - return
+ return
{unsaved && Unsaved changes} -

updateFlag({...flag, name: val})} value={flag.name} />

+

+ updateFlag({ ...flag, name: val })} value={flag.name} /> +

{unsaved && }

ID: {flag.id}

@@ -55,26 +55,34 @@ const Flag = ({ flag: incoming }: { flag: APIFlag }) => { }; const FlagTile = ({ flag }: { flag: APIFlag }) => { - return
+ return
; }; -const FlagListElement = ({ flag, onClick }: { flag: APIFlag, onClick?: React.ReactEventHandler }) => { - return
- {flag.name} [{flag.type}] ({flag.id}) -
; +const FlagListElement = ({ flag }: { flag: APIFlag, onClick?: React.ReactEventHandler }) => { + // return
+ // {flag.name} [{flag.type}] ({flag.id}) + //
; + return
+ + {flag.name} [{flag.type}] ({flag.id}) + + + + +
; }; -const ListCategory = ({ flags, name, setFlag }: { flags: OrganisedFlags, name: string, setFlag: (flag: APIFlag) => void }) => { +const ListCategory = ({ flags, name, setFlag }: { flags: OrganisedFlags, name: string, setFlag?: (flag: APIFlag) => void }) => { const categories = Object.keys(flags); const elements: JSX.Element[] = []; for (const category of categories) { const element = flags[category]; if (element.id) - elements.push( setFlag(element as APIFlag)} key={element.id as string} flag={element as APIFlag} />); + elements.push( setFlag && setFlag(element as APIFlag)} key={element.id as string} flag={element as APIFlag} />); else elements.push(); } @@ -97,16 +105,21 @@ const ListView = ({ flags }: { flags: APIFlag[] }) => { const organised = organiseFlags(flags); const [currentFlag, setCurrentFlag] = useState(null); + const selectFlag = (flag: APIFlag) => { + console.log(flag); + setCurrentFlag(flag); + }; - return setCurrentFlag(null)}> + // return setCurrentFlag(null)}> - - - + // + // + // - setCurrentFlag(flag)} name={'root'} flags={organised} /> + // selectFlag(flag)} name={'root'} flags={organised} /> - ; + // ; + return selectFlag(flag)} name={'root'} flags={organised} />; }; const TileView = ({ flags, children }: { flags: APIFlag[], children: React.ReactNode }) => {