Starting InlineEdit component
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
$primary_color: #242a33;
|
$primary_color: #242a33;
|
||||||
$second_color: #1A1B1E;
|
$secondary_color: #1A1B1E;
|
||||||
$third_color:#25262b;
|
$third_color:#25262b;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import React from 'react';
|
|||||||
|
|
||||||
import style from "./index.module.scss";
|
import style from "./index.module.scss";
|
||||||
|
|
||||||
|
|
||||||
function FooterPage() {
|
function FooterPage() {
|
||||||
return <Footer id="footer" height={70} className={style.footer}>
|
return <Footer id="footer" height={70} className={style.footer}>
|
||||||
Made by Pwnzer0tt1
|
Made by Pwnzer0tt1
|
||||||
|
|||||||
20
frontend/src/components/InlineEdit/index.module.scss
Executable file
20
frontend/src/components/InlineEdit/index.module.scss
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
@use "../../vars" as *;
|
||||||
|
@use "../../index.scss" as *;
|
||||||
|
|
||||||
|
.click_to_edit {
|
||||||
|
background-color: #1B1B1B;
|
||||||
|
border: 0;
|
||||||
|
padding: 5px 8px;
|
||||||
|
min-width: 10px;
|
||||||
|
user-select: none;
|
||||||
|
border-radius: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.click_to_edit:hover {
|
||||||
|
cursor: text;
|
||||||
|
background-color: #1B1B1B;
|
||||||
|
}
|
||||||
|
|
||||||
|
.click_to_edit:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
24
frontend/src/components/InlineEdit/index.tsx
Executable file
24
frontend/src/components/InlineEdit/index.tsx
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import style from "./index.module.scss";
|
||||||
|
|
||||||
|
const InlineEdit = ({ value, setValue, ...others }:{ value:string, setValue: (s:string)=>void}) => {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
role="textbox"
|
||||||
|
contentEditable
|
||||||
|
className={style.click_to_edit}
|
||||||
|
aria-label="Field name"
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter" || event.key === "Escape") {
|
||||||
|
event.target.blur();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onBlur={(event) => {
|
||||||
|
setValue((event.target as HTMLSpanElement).textContent ?? "");
|
||||||
|
}}
|
||||||
|
{...others}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default InlineEdit;
|
||||||
Reference in New Issue
Block a user