Compare commits

..

1 Commits

Author SHA1 Message Date
Triston Armstrong
86d4f94f56 (feat): make text appear on screen and minimap 2024-10-06 12:42:36 -04:00
8 changed files with 37 additions and 31 deletions

View File

@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="light dark" />
<title>KlectrTemplate</title>
</head>

View File

@ -4,7 +4,6 @@ import { useDebounce } from "../utils/useDebounce"
import { LayerEnum } from "../utils/enums"
import images, { ImageCardType } from "../signals/images"
import { updateLocalStorage } from "../utils/localStorage"
import { isTheme } from "../utils/isTheme"
namespace ImageCard {
export interface ImageCardProps {
@ -91,7 +90,7 @@ export function ImageCard({ key: itemKey, data: item }: ImageCard.ImageCardProps
return (
<div
onmousedown={_handleMouseDown}
className="select-none transition flex flex-col justify-stretch shadow-md rounded border border-[#1c1c1c] absolute"
className="select-none transition flex flex-col justify-stretch shadow-lg rounded border border-[#3c3c3c] absolute"
style={{
zIndex: `${focusedItem.value == itemKey ? LayerEnum.CARD_ELEVATED : LayerEnum.CARD}`,
top: `${item.position.y}px`,
@ -105,7 +104,7 @@ export function ImageCard({ key: itemKey, data: item }: ImageCard.ImageCardProps
backgroundPosition: 'center'
}}
>
<button className="flex justify-center items-center hover:bg-blue-500 rounded w-5 h-5 dark:text-[#777] dark:hover:text-white text-white text-md absolute right-0 top-0" onclick={(_e: Event) => {
<button className="flex justify-center items-center hover:bg-blue-500 w-5 h-5 text-white text-md absolute right-0 top-0" onclick={(_e: Event) => {
ImagesSignal.default.removeImage(item.id)
ImagesSignal.default.images.notify()
debounceLSUpdate()
@ -129,7 +128,7 @@ function ExpandIcon({ cb }: {
height="24"
viewBox="0 0 24 24"
fill="none"
stroke={isTheme('dark') ? "#777" : "#999"}
stroke="#333"
stroke-width="1"
stroke-linecap="round"
stroke-linejoin="round"

View File

@ -6,7 +6,6 @@ import { MiniMap } from "./MiniMap"
import { ImageCard } from "./ImageCard"
import images from "../signals/images"
import { CardSelector } from "./cardSelector/CardSelector"
import { isTheme } from "../utils/isTheme"
import { TextItem } from "./TextItem"
export default function InfiniteCanvas() {
@ -44,13 +43,13 @@ export default function InfiniteCanvas() {
className="h-screen w-full absolute top-0 left-0"
>
<div
className="dark:bg-black absolute top-0 left-0"
className="absolute top-0 left-0"
ref={containerRef}
style={{
width: `${canvasDimentsion.value.width}px`,
height: `${canvasDimentsion.value.width}px`,
backgroundSize: "30px 30px",
backgroundImage: `radial-gradient(circle, rgba(${isTheme('dark') ? '255, 255, 255, 0.2' : '0, 0, 0, 0.2'}) 1px, transparent 1px)`,
backgroundImage: "radial-gradient(circle, rgba(255, 255, 255, 0.2) 1px, transparent 1px)",
}}>
{Object.keys(NotesSigal.default.notes.value).map((itemKey: string) => {
const item = NotesSigal.default.notes.value[itemKey]

View File

@ -35,14 +35,15 @@ export function MiniMap() {
return (
<div
className="dark:bg-[#ffffff11] bg-[#0001] fixed rounded"
ref={el} style={{
width: `${width}px`,
height: `${height}px`,
translate: `${xPos}px ${yPos}px`,
zIndex: `${LayerEnum.MINIMAP}`,
}}>
<div ref={el} style={{
position: 'fixed',
backgroundColor: '#ffffff11',
width: `${width}px`,
height: `${height}px`,
translate: `${xPos}px ${yPos}px`,
zIndex: `${LayerEnum.MINIMAP}`,
borderRadius: '4px'
}}>
{Object.keys(images.images.value).map((imageKey: ImageCardType['id']) => {
const image = images.images.value[imageKey]
@ -57,13 +58,16 @@ export function MiniMap() {
}
return (
<div ref={el} className={"absolute dark:bg-green-500 bg-green-300 dark:hover:bg-blue-500 hover:bg-blue-300 cursor-pointer border dark:border-[#222] border-green-500 rounded"}
<div ref={el} className={"bg-green-500 hover:bg-blue-500 cursor-pointer"}
onclick={_handleItemClick}
style={{
position: 'absolute',
width: `${image.dimensions.w / _MAP_SCALE_FACTOR}px`,
height: `${image.dimensions.h / _MAP_SCALE_FACTOR}px`,
top: `${(image.position.y / _MAP_SCALE_FACTOR)}px`,
left: `${(image.position.x / _MAP_SCALE_FACTOR)}px`,
border: '1px solid #222',
borderRadius: '2px',
zIndex: `${LayerEnum.MINIMAP + 1}`
}}
></div>
@ -83,13 +87,16 @@ export function MiniMap() {
}
return (
<div className={"absolute dark:bg-gray-500 bg-gray-300 hover:bg-blue-500 cursor-pointer border dark:border-[#222] border-gray-500 rounded"}
<div className={"bg-gray-500 hover:bg-blue-500 cursor-pointer"}
onclick={_handleItemClick}
style={{
position: 'absolute',
width: `${note.dimensions.w / _MAP_SCALE_FACTOR}px`,
height: `${note.dimensions.h / _MAP_SCALE_FACTOR}px`,
top: `${(note.position.y / _MAP_SCALE_FACTOR)}px`,
left: `${(note.position.x / _MAP_SCALE_FACTOR)}px`,
border: '1px solid #222',
borderRadius: '2px',
zIndex: `${LayerEnum.MINIMAP + 1}`
}}
></div>
@ -126,13 +133,16 @@ export function MiniMap() {
})}
<div
className={'absolute bg-blue-200 bg-opacity-10 border dark:border-blue-800 border-blue-500 bg-blue-500 rounded'}
className={'bg-blue-200 bg-opacity-10'}
style={{
position: 'absolute',
width: `${viewportWidth / _MAP_SCALE_FACTOR}px`,
height: `${viewportHeight / _MAP_SCALE_FACTOR}px`,
top: `${scrollY.value / _MAP_SCALE_FACTOR}px`,
left: `${scrollX.value / _MAP_SCALE_FACTOR}px`,
zIndex: `${LayerEnum.MINIMAP * 1000}`,
border: '1px solid #777',
zIndex: `${LayerEnum.MINIMAP}`,
borderRadius: '2px'
}}></div>
</div >
)

View File

@ -3,7 +3,6 @@ import { NotesSigal, focusedItem } from "../signals"
import { useDebounce } from "../utils/useDebounce"
import notes, { NoteCardType } from "../signals/notes"
import { LayerEnum } from "../utils/enums"
import { isTheme } from "../utils/isTheme"
namespace NoteCard {
export interface NoteCardProps {
@ -89,30 +88,31 @@ export function NoteCard({ key: itemKey, data: item }: NoteCard.NoteCardProps) {
return (
<div
onmousedown={() => focusedItem.value = itemKey}
className="text-[#333] dark:bg-[#111] dark:border-[#1c1c1c] bg-[#eee] select-none transition flex flex-col justify-stretch shadow-md rounded border border-[#ddd] absolute"
className="select-none transition flex flex-col justify-stretch shadow-lg rounded border border-[#3c3c3c] absolute"
style={{
zIndex: `${focusedItem.value == itemKey ? LayerEnum.CARD_ELEVATED : LayerEnum.CARD}`,
width: `${item.dimensions.w}px`,
height: `${item.dimensions.h}px`,
top: `${item.position.y}px`,
left: `${item.position.x}px`,
backgroundColor: '#181818',
}}
>
<div className="flex-1 flex flex-col gap-1">
<div className="px-2 flex justify-between items-center cursor-move" onmousedown={_handleMouseDown}>
<div style={{
opacity: saved.value ? '0' : '100'
}} className={`rounded-full w-1 h-1 dark:bg-white bg-green-500`}></div>
<button className="text-md dark:text-[#777] text-black" onclick={(_e: Event) => {
}} className={`rounded-full w-1 h-1 bg-white`}></div>
<button className="text-md" onclick={(_e: Event) => {
NotesSigal.default.removeNote(item.id)
NotesSigal.default.notes.notify()
updateLocalStorage()
}}>x</button>
</div>
<hr className="border dark:border-[#1c1c1c] border-[#ddd]" />
<hr className="border border-[#3c3c3c]" />
<textarea
placeholder={"Todo: put some note here"}
className="flex resize-none px-2 w-full h-full bg-transparent resize-none focus:outline-none dark:text-gray-300"
className="flex resize-none px-2 w-full h-full bg-transparent resize-none focus:outline-none text-gray-300"
value={item.contents}
onkeypress={() => { saved.value = false }}
onchange={(e) => {
@ -142,7 +142,7 @@ function ExpandIcon({ cb }: {
height="24"
viewBox="0 0 24 24"
fill="none"
stroke={isTheme('dark') ? "#777" : "#999"}
stroke="#333"
stroke-width="1"
stroke-linecap="round"
stroke-linejoin="round"

View File

@ -10,7 +10,7 @@ export function CardSelector() {
return (
<div
ref={containerRef}
className="z-50 flex gap-1 border dark:border-[#3c3c3c] border-[#ddd] rounded-full fixed px-4 dark:bg-[#222] bg-[#eee] top-2 py-1 shadow-md"
className="z-50 flex gap-1 border border-[#9c9c9c] rounded-full fixed px-4 bg-[#181818] top-2 py-1 shadow-xl"
style={{
left: `${window.innerWidth / 2 - (containerRef.current?.getBoundingClientRect().width ?? 1) / 2}px`
}}>

View File

@ -23,9 +23,11 @@ html {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
color: white;
}
body {
margin: 0;
padding: 0;
background-color: #111;
}

View File

@ -1,3 +0,0 @@
export function isTheme(value: "light" | "dark") {
return window.matchMedia(`(prefers-color-scheme: ${value})`).matches
}