A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: implement favorite/pinned ui
thecodrre3ea6c653f94
diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.jsindex 0571f1e3a..05ec989c5 100644--- a/apps/web/src/components/list-item/index.js+++ b/apps/web/src/components/list-item/index.js@@ -16,16 +16,48 @@ const ListItem = props => (alignItems="center"justifyContent="space-between"py={1}+ bg={props.pinned ? "#1790F310" : "background"}sx={{+ position: "relative",borderRadius: "default",marginBottom: 2,+ marginTop: props.pinned ? 4 : 0,borderBottom: "1px solid",borderBottomColor: "navbg",cursor: "default",...ButtonPressedStyle}}>- <Box>+ {props.pinned && (+ <Flex+ bg="primary"+ sx={{+ borderRadius: 35,+ width: 35,+ height: 35,+ position: "absolute",+ top: -15,+ left: 0+ }}+ alignItems="center"+ justifyContent="center"+ >+ <Box+ bg="white"+ sx={{+ borderRadius: 5,+ width: 3,+ height: 3,+ boxShadow: "1px 1px 4px 0px #000000bd" //TODO+ }}+ />+ </Flex>+ )}+ <Box+ sx={{+ paddingTop: props.pinned ? 4 : 0+ }}+ ><Flex flexDirection="row" justifyContent="space-between"><Text fontFamily="heading" fontSize="title" fontWeight="bold">{props.title}diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex 2c9595c3d..dabb75d33 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -1,4 +1,5 @@import React from "react";+import { Flex } from "rebass";import * as Icon from "react-feather";import TimeAgo from "timeago-react";import { db, ev } from "../../common";@@ -7,23 +8,38 @@ import ListItem from "../list-item";import { navigate, routes } from "../../navigation";const dropdownRefs = [];-const menuItems = [+const menuItems = note => [{- title: "Move",- onClick: note => {+ title: note.notebook.notebook ? "Move" : "Add to notebook",+ onClick: () => {navigate(routes.notebooks.key, undefined, {intent: "moveNote",data: note});}},- { title: "Pin" },- { title: "Favorite" },+ {+ title: note.pinned ? "Unpin" : "Pin",+ onClick: async () =>+ db.pinItem("note", note.dateCreated).then(() => {+ showSnack("Note pinned!", Icon.Check);+ ev.emit("refreshNotes");+ })+ },+ {+ title: note.favorite ? "Unfavorite" : "Favorite",+ onClick: async () =>+ db.favoriteItem("note", note.dateCreated).then(() => {+ showSnack("Note favorited!", Icon.Check);+ ev.emit("refreshNotes");+ })+ },+ { title: note.locked ? "Remove lock" : "Lock" }, //TODO{ title: "Share" },{title: "Delete",color: "red",- onClick: note => {+ onClick: () => {ev.emit("onClearNote", note.dateCreated);db.deleteNotes([note]).then(//TODO implement undo@@ -48,9 +64,16 @@ const Note = ({ item, index }) => {body={note.headline}index={index}onClick={sendOpenNoteEvent.bind(this, note)}- info={<TimeAgo datetime={note.dateCreated} />}+ info={+ <Flex flexDirection="row" justifyContent="center" alignItems="center">+ <TimeAgo datetime={note.dateCreated} />+ {note.locked && <Icon.Lock size={16} style={{ marginLeft: 5 }} />}+ {note.favorite && <Icon.Star size={16} style={{ marginLeft: 5 }} />}+ </Flex>+ }+ pinned={note.pinned}menuData={note}- menuItems={menuItems}+ menuItems={menuItems(note)}dropdownRefs={dropdownRefs}/>);diff --git a/apps/web/src/theme.js b/apps/web/src/theme.jsindex 645426af3..5762fa7e7 100644--- a/apps/web/src/theme.js+++ b/apps/web/src/theme.js@@ -39,7 +39,7 @@ const shadowsLight = {export default {breakpoints: ["480px", "834px", "1200px"],colors: colorsLight,- space: [0, 5, 10, 12],+ space: [0, 5, 10, 12, 15],fontSizes: {heading: 36,input: 16,diff --git a/apps/web/src/views/Home.js b/apps/web/src/views/Home.jsindex 7b4bb88ba..ff0cbd91d 100644--- a/apps/web/src/views/Home.js+++ b/apps/web/src/views/Home.js@@ -13,10 +13,12 @@ function Home() {groupCounts: [],groups: []});+ const [pinnedItems, setPinnedItems] = useState([]);useEffect(() => {function onRefreshNotes() {setNotes(db.groupNotes(undefined, true));}+ setPinnedItems(db.getPinned());onRefreshNotes();ev.addListener("refreshNotes", onRefreshNotes);return () => {@@ -25,9 +27,12 @@ function Home() {}, []);return (<Flex flexDirection="column" flex="1 1 auto">- {notes.items.length > 0 ? (+ {notes.items.length > 0 || pinnedItems.length > 0 ? (<Flex flexDirection="column" flex="1 1 auto"><Search placeholder="Search" />+ {pinnedItems.map((item, index) => (+ <Note index={index * notes.items.length} item={item} />+ ))}<Liststyle={{width: "100%",diff --git a/apps/web/yarn.lock b/apps/web/yarn.lockindex 321669f26..485ccf73b 100644--- a/apps/web/yarn.lock+++ b/apps/web/yarn.lock@@ -6991,7 +6991,7 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:"notes-core@https://github.com/thecodrr/notes-core.git":version "0.2.0"- resolved "https://github.com/thecodrr/notes-core.git#265c12f66aa05fc2353e97e01279fe226fcd9b06"+ resolved "https://github.com/thecodrr/notes-core.git#efbb64e63681c544cd00497f3242bb07f4cf7685"dependencies:fuzzysearch "^1.0.3"transfun "^1.0.2"