working on some text logic playing with ideas

This commit is contained in:
Triston Armstrong 2024-10-07 00:28:54 -04:00
parent 95924ba49f
commit 5b0b8c2224
2 changed files with 9 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import images from "../signals/images"
import { CardSelector } from "./cardSelector/CardSelector" import { CardSelector } from "./cardSelector/CardSelector"
import { isTheme } from "../utils/isTheme" import { isTheme } from "../utils/isTheme"
import { TextItem } from "./TextItem" import { TextItem } from "./TextItem"
import texts from "../signals/texts"
export default function InfiniteCanvas() { export default function InfiniteCanvas() {
const containerRef = useRef<HTMLDivElement>(null) const containerRef = useRef<HTMLDivElement>(null)
@ -29,6 +30,7 @@ export default function InfiniteCanvas() {
window.addEventListener("resize", updateDimensions) window.addEventListener("resize", updateDimensions)
notes.loadLocalStorage() notes.loadLocalStorage()
images.loadLocalStorage() images.loadLocalStorage()
texts.loadLocalStorage()
return () => { return () => {
window.removeEventListener("resize", updateDimensions) window.removeEventListener("resize", updateDimensions)

View File

@ -3,6 +3,7 @@ import { TextSignal, focusedItem } from "../signals"
import { useDebounce } from "../utils/useDebounce" import { useDebounce } from "../utils/useDebounce"
import texts, { TextCardType } from "../signals/texts" import texts, { TextCardType } from "../signals/texts"
import { LayerEnum } from "../utils/enums" import { LayerEnum } from "../utils/enums"
import { isTheme } from "../utils/isTheme"
namespace TextItem { namespace TextItem {
export interface TextCardProps { export interface TextCardProps {
@ -87,20 +88,19 @@ export function TextItem({ key: itemKey, data: item }: TextItem.TextCardProps) {
return ( return (
<div <div
onmousedown={() => focusedItem.value = itemKey} onmousedown={_handleMouseDown}
className="select-none transition flex flex-col justify-stretch shadow-lg rounded border border-[#3c3c3c] absolute border-dashed" className="select-none transition flex flex-col justify-stretch rounded border border-[#3c3c3c] absolute border-dashed"
style={{ style={{
zIndex: `${focusedItem.value == itemKey ? LayerEnum.CARD_ELEVATED : LayerEnum.CARD}`, zIndex: `${focusedItem.value == itemKey ? LayerEnum.CARD_ELEVATED : LayerEnum.CARD}`,
width: `${item.dimensions.w}px`, width: `${item.dimensions.w}px`,
height: `${item.dimensions.h}px`, height: `${item.dimensions.h + 100}px`,
top: `${item.position.y}px`, top: `${item.position.y}px`,
left: `${item.position.x}px`, left: `${item.position.x}px`,
}} }}
> >
<svg viewBox="0 0 56 18"> <div className={'relative w-full h-full'}>
<text x="0" y="15" fill={'white'}>{item.contents}</text> <p className={'w-full h-full'}>{item.contents}</p>
</svg> </div>
</div > </div >
) )