Skip to content

Commit

Permalink
add default memo
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathontoon committed Jan 9, 2020
1 parent 840d5f4 commit 12479a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/js/globals.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
export const MARGIN = 48;
export const GRID_SIZE = 10;

export const DEFAULT_MEMO = {
id: "9346dc6c-f982-48ce-9e21-f6a334b367b3",
text: `Manifest is an incredibly simple grid-based pinboard for note taking.\n\nCreate as many notes as you want, and they will snap to the grid set by your current window size. All notes can be be moved, resized and deleted.\n\nYour browser's local storage is also utilized to save notes between session.\n\nManifest is free and completely open-source. Licensed under the GNU General Public License v2.0.\n\nIf you find a bug or have a suggestion feel free to file an issue on Github.\n\nhttps://github.com/jonathontoon/manifest/issues`,
position: {
top: 50,
left: 50
},
size: {
width: 411,
height: 312
}
};
9 changes: 8 additions & 1 deletion src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GRID_SIZE, MARGIN } from "./globals";
import { GRID_SIZE, MARGIN, DEFAULT_MEMO } from "./globals";
import { snapToGrid, confirm, uuidv4, getLocalStorageItem, setLocalStorageItem } from "./utils";

import "../sass/index.scss";
Expand Down Expand Up @@ -376,6 +376,13 @@ function onLoad() {
const memos = getLocalStorageItem("manifest_memos");
if (!memos) {
setLocalStorageItem("manifest_memos", {});

const memo = createMemo(DEFAULT_MEMO.id, DEFAULT_MEMO.text, DEFAULT_MEMO.position, DEFAULT_MEMO.size);
board.appendChild(memo);

const memos = getLocalStorageItem("manifest_memos");
memos[DEFAULT_MEMO.id] = { text: DEFAULT_MEMO.text, position: DEFAULT_MEMO.position, size: DEFAULT_MEMO.size };
setLocalStorageItem("manifest_memos", memos);
} else {
Object.keys(memos).forEach(function (key) {
const memo = createMemo(key, memos[key].text, memos[key].position, memos[key].size);
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export function uuidv4() {
var r = Math.random() * 16 | 0; var v = c === "x" ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};
};

0 comments on commit 12479a0

Please sign in to comment.