-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new toolbar and color options, under featureflag
- Loading branch information
1 parent
f3ed474
commit ff77fe3
Showing
8 changed files
with
184 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from "react"; | ||
import Icons from "../../svg/icons"; | ||
import { useAppSelector } from "../../store"; | ||
let timer: string | number | NodeJS.Timeout | undefined; | ||
const Tools = ({ changeStyle }: {changeStyle: (type:string, val?:string)=> void}) => { | ||
const selectedStyles = useAppSelector((store) => { | ||
const index = store.list.selected[0]; | ||
if (index) { | ||
return store.list.data[index[0]][index[1]].styles || {}; | ||
} | ||
return {}; | ||
}); | ||
const changeStyleWithDebounce = (type: string, val: string) => { | ||
clearTimeout(timer); | ||
timer = setTimeout(() => {changeStyle(type, val)}, 200) | ||
} | ||
return ( | ||
<div> | ||
<button onClick={() => changeStyle("B")}>B</button> | ||
<button onClick={() => changeStyle("U")}>U</button> | ||
<button onClick={() => changeStyle("I")}>I</button> | ||
{/* <button onClick={() => changeStyle("FONT", ((parseInt(selectedFontSize) || 12) - 1).toString())}>-</button> */} | ||
<span> | ||
<input | ||
className="font-size-input" | ||
type="number" | ||
placeholder="size" | ||
value={selectedStyles?.["fontSize"]?.split("px")?.[0] || ""} | ||
onChange={(e) => changeStyle("FONT", e.target.value)} | ||
onKeyDown={(e) => e.stopPropagation()} | ||
/> | ||
</span> | ||
{/* <button onClick={() => changeStyle("FONT", ((parseInt(selectedFontSize) || 12) + 1).toString())}>+</button> */} | ||
|
||
<button onClick={() => changeStyle("ALIGN-LEFT")}> | ||
<Icons type="align-left" /> | ||
</button> | ||
<button onClick={() => changeStyle("ALIGN-CENTER")}> | ||
<Icons type="align-center" /> | ||
</button> | ||
<button onClick={() => changeStyle("ALIGN-RIGHT")}> | ||
<Icons type="align-right" /> | ||
</button> | ||
<button onClick={() => changeStyle("ALIGN-JUSTIFY")}> | ||
<Icons type="align-justify" /> | ||
</button> | ||
<input | ||
type="color" | ||
value={selectedStyles?.["color"] || "#000000"} | ||
onChange={(e) => changeStyleWithDebounce("COLOR", e.target.value)} | ||
/> | ||
<input | ||
type="color" | ||
value={selectedStyles?.["background"] || "#000000"} | ||
onChange={(e) => changeStyleWithDebounce("BACKGROUND", e.target.value)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
export default Tools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const Icons = ({type}: {type: string}) => { | ||
switch (type) { | ||
case "align-left": | ||
return ( | ||
<svg width="12px" height="12px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<g id="SVGRepo_bgCarrier" stroke-width="0"></g> | ||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g> | ||
<g id="SVGRepo_iconCarrier"> | ||
<path | ||
d="M3 10H16M3 14H21M3 18H16M3 6H21" | ||
stroke="#000000" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
></path> | ||
</g> | ||
</svg> | ||
); | ||
case "align-right": | ||
return ( | ||
<svg width="12px" height="12px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<g id="SVGRepo_bgCarrier" stroke-width="0"></g> | ||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g> | ||
<g id="SVGRepo_iconCarrier"> | ||
<path | ||
d="M8 10H21M3 14H21M8 18H21M3 6H21" | ||
stroke="#000000" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
></path> | ||
</g> | ||
</svg> | ||
); | ||
case "align-center": | ||
return ( | ||
<svg width="12px" height="12px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<g id="SVGRepo_bgCarrier" stroke-width="0"></g> | ||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g> | ||
<g id="SVGRepo_iconCarrier"> | ||
<path | ||
d="M3 6H21M3 14H21M17 10H7M17 18H7" | ||
stroke="#000000" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
></path> | ||
</g> | ||
</svg> | ||
); | ||
case "align-justify": | ||
return ( | ||
<svg width="12px" height="12px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path | ||
d="M3 10H21M3 14H21M3 18H21M3 6H21" | ||
stroke="#000000" | ||
stroke-width="2" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
</svg> | ||
); | ||
} | ||
return <></> | ||
} | ||
export default Icons; |