-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Notes): Add an in-between menu for note creation
- Loading branch information
Showing
4 changed files
with
196 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
<script setup lang="ts"> | ||
import { onDeactivated, ref } from "vue"; | ||
import type { ApiNote } from "../../../apiTypes"; | ||
import { uuidv4 } from "../../../core/utils"; | ||
import { coreStore } from "../../../store/core"; | ||
import { noteSystem } from "../../systems/notes"; | ||
import { noteState } from "../../systems/notes/state"; | ||
import { NoteManagerMode } from "../../systems/notes/types"; | ||
import { locationSettingsState } from "../../systems/settings/location/state"; | ||
const emit = defineEmits<(e: "mode", mode: NoteManagerMode) => void>(); | ||
const title = ref(""); | ||
const isLocal = ref(true); | ||
onDeactivated(() => { | ||
title.value = ""; | ||
isLocal.value = true; | ||
}); | ||
async function createNote(): Promise<void> { | ||
const uuid = uuidv4(); | ||
const note: ApiNote = { | ||
uuid, | ||
creator: coreStore.state.username, | ||
title: title.value || "New note...", | ||
text: "", | ||
showOnHover: false, | ||
showIconOnShape: false, | ||
isRoomNote: isLocal.value, | ||
location: isLocal.value ? locationSettingsState.reactive.activeLocation : null, | ||
tags: [], | ||
access: [], | ||
shapes: [], | ||
}; | ||
await noteSystem.newNote(note, true); | ||
if (noteState.raw.shapeFilter) noteSystem.attachShape(uuid, noteState.raw.shapeFilter, true); | ||
noteState.mutableReactive.currentNote = note.uuid; | ||
emit("mode", NoteManagerMode.Edit); | ||
} | ||
</script> | ||
|
||
<template> | ||
<header> | ||
<span id="return" title="Back to list" @click="$emit('mode', NoteManagerMode.List)">↩</span> | ||
Create a new note | ||
</header> | ||
<div id="create-note"> | ||
<label for="new-note-title">Title:</label> | ||
<input id="new-note-title" v-model="title" type="text" placeholder="New note..." autofocus /> | ||
<label for="new-note-type">Type:</label> | ||
<div @click="isLocal = true"> | ||
<input type="radio" name="new-note-type" value="local" :checked="isLocal" /> | ||
<div> | ||
<div>Local note</div> | ||
<div> | ||
A note that is relevant to the current campaign only. This is the most common kind of type and | ||
should be used for most cases. | ||
</div> | ||
</div> | ||
</div> | ||
<div @click="isLocal = false"> | ||
<input type="radio" name="new-note-type" value="global" :checked="!isLocal" /> | ||
<div> | ||
<div>Global note</div> | ||
<div> | ||
A note that will be visible in all campaigns. This is a special type that can be used to note down | ||
information on common things like monster stats thare are used in multiple campaigns. | ||
</div> | ||
</div> | ||
</div> | ||
<button @click="createNote">Create note</button> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
header { | ||
display: flex; | ||
font-size: 1.75em; | ||
align-items: center; | ||
#return { | ||
margin-right: 1rem; | ||
&:hover { | ||
cursor: pointer; | ||
font-weight: bold; | ||
} | ||
} | ||
#title { | ||
flex-grow: 1; | ||
margin-right: 1rem; | ||
border: none; | ||
border-bottom: solid 1px black; | ||
font-weight: bold; | ||
font-size: inherit; | ||
padding: 0.5rem; | ||
&.edit:hover { | ||
cursor: text; | ||
} | ||
} | ||
} | ||
#create-note { | ||
display: grid; | ||
grid-template-columns: auto 1fr; | ||
align-items: center; | ||
column-gap: 1rem; | ||
row-gap: 1rem; | ||
margin-top: 1rem; | ||
> label { | ||
font-weight: bold; | ||
} | ||
> input { | ||
border-radius: 1rem; | ||
padding: 0.5rem 1rem; | ||
border-style: solid; | ||
} | ||
> div { | ||
grid-column: 1/-1; | ||
display: flex; | ||
padding: 1rem; | ||
border: solid 1px black; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
&:first-of-type { | ||
border-top-left-radius: 1rem; | ||
border-top-right-radius: 1rem; | ||
margin-bottom: -1rem; // offset row-gap | ||
border-bottom: none; | ||
} | ||
&:last-of-type { | ||
border-bottom-left-radius: 1rem; | ||
border-bottom-right-radius: 1rem; | ||
} | ||
> div { | ||
display: flex; | ||
flex-direction: column; | ||
margin-left: 1rem; | ||
> div:first-of-type { | ||
font-weight: bold; | ||
} | ||
} | ||
} | ||
button { | ||
background-color: lightblue; | ||
border: solid 2px lightblue; | ||
border-width: 1px; | ||
border-radius: 1rem; | ||
padding: 0.5rem 0.75rem; | ||
grid-column: 1/-1; | ||
width: 10rem; | ||
&:hover { | ||
cursor: pointer; | ||
background-color: rgba(173, 216, 230, 0.5); | ||
} | ||
} | ||
} | ||
</style> |
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