Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: make custom snackbar

thecodrr7226e8720e24
diff --git a/apps/web/package.json b/apps/web/package.json
index 35c6fe3e8..025801edc 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -17,9 +17,7 @@
"react-quill": "^1.3.3",
"react-scripts": "3.2.0",
"react-simple-dropdown": "^3.2.3",
- "react-virtualized-auto-sizer": "^1.0.2",
"react-virtuoso": "^0.12.3",
- "react-window": "^1.8.5",
"rebass": "^4.0.7",
"timeago-react": "^3.0.0"
},
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index 95e48d390..990ea51dc 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -66,6 +66,7 @@ function App() {
/>
<Editor />
</Flex>
+ <Box id="snackbarContainer" />
</Flex>
</ThemeProvider>
);
diff --git a/apps/web/src/components/snackbar/index.js b/apps/web/src/components/snackbar/index.js
new file mode 100644
index 000000000..84caaf543
--- /dev/null
+++ b/apps/web/src/components/snackbar/index.js
@@ -0,0 +1,51 @@
+import React from "react";
+import ReactDOM from "react-dom";
+import { Flex, Text } from "rebass";
+import { ThemeProvider } from "emotion-theming";
+import theme from "../../theme";
+
+export function showSnack(message, icon = undefined) {
+ const root = document.getElementById("snackbarContainer");
+ if (root) {
+ ReactDOM.render(<Snackbar message={message} Icon={icon} />, root);
+ setTimeout(() => {
+ const snackbar = document.getElementById("snackbar");
+ if (!snackbar) return;
+ setTimeout(() => ReactDOM.unmountComponentAtNode(root), 1000);
+ snackbar.animate(
+ {
+ opacity: [1, 0],
+ transform: ["translateY(0px)", "translateY(500px)"]
+ },
+ 1000
+ );
+ }, 2000);
+ }
+}
+
+const Snackbar = props => (
+ <ThemeProvider theme={theme}>
+ <Flex
+ id="snackbar"
+ sx={{
+ position: "absolute",
+ bottom: 10,
+ left: "50%",
+ textAlign: "center",
+ color: "fontSecondary",
+ fontFamily: "body",
+ fontWeight: "body",
+ borderRadius: "default",
+ animation: "1s ease-out fadeUp"
+ }}
+ alignItems="center"
+ flexDirection="row"
+ bg="accent"
+ py={2}
+ px={2}
+ >
+ {props.Icon && <props.Icon size={18} />}
+ <Text mx={1}>{props.message}</Text>
+ </Flex>
+ </ThemeProvider>
+);
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index 45053215a..1eabf2495 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -4,4 +4,18 @@ body,
#root {
margin: 0;
height: 100%;
+ overflow: hidden;
+}
+@keyframes fadeUp {
+ 0% {
+ transform: translateY(500px);
+ opacity: 0;
+ }
+ 80% {
+ transform: translateY(0px);
+ opacity: 0.7;
+ }
+ 100% {
+ opacity: 1;
+ }
}
diff --git a/apps/web/src/views/Home.js b/apps/web/src/views/Home.js
index eaa287c86..2ab18f2f9 100644
--- a/apps/web/src/views/Home.js
+++ b/apps/web/src/views/Home.js
@@ -12,6 +12,7 @@ import "react-simple-dropdown/styles/Dropdown.css";
import { db, ev } from "../common";
import { Virtuoso as List } from "react-virtuoso";
import AutoSizer from "react-virtualized-auto-sizer";
+import { showSnack } from "../components/snackbar";
const menuItems = [
{ title: "Favorite", icon: Icon.Heart },
@@ -21,6 +22,7 @@ const menuItems = [
let notesMenu = undefined;
function sendNewNoteEvent() {
+ showSnack("Let's start writing!", Icon.Edit2);
ev.emit("onNewNote");
}
@@ -113,12 +115,17 @@ function Home() {
</Text>
</Flex>
<List
- style={{ width: "100%", flex: "1 1 auto" }}
+ style={{ width: "100%", flex: "1 1 auto", height: "auto" }}
totalCount={notes.length}
item={index => {
const note = notes[index];
return (
- <Box bg="navbg" px={3} py={3} sx={{ borderRadius: "default" }}>
+ <Box
+ bg="navbg"
+ px={3}
+ py={3}
+ sx={{ borderRadius: "default", marginBottom: 2 }}
+ >
<Flex flexDirection="row" justifyContent="space-between">
<Text fontFamily="body" fontSize="title" fontWeight="bold">
{note.title}
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index 789885fb1..e11b2461b 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8760,6 +8760,11 @@ [email protected]:
optionalDependencies:
fsevents "2.0.7"
+react-simple-animate@^3.3.5:
+ version "3.3.5"
+ resolved "https://registry.yarnpkg.com/react-simple-animate/-/react-simple-animate-3.3.5.tgz#df9e90879872edd6eadc29cfaf438ba04b6e6915"
+ integrity sha512-3tlJ1cazBsEBIJH9GKxrdm9xtsVp9mtVAOK4SgOZVPJKJIKokfgZA+FvqBBTmqQMDfutxI4ogLivBzhAG8/5kA==
+
react-simple-dropdown@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/react-simple-dropdown/-/react-simple-dropdown-3.2.3.tgz#c9737bcb7a54c7de267a1afeeec04de588a3fa7b"