Skip to content

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

feat: add skeleton loading animations

thecodrr9ddb7d266331
diff --git a/apps/web/package.json b/apps/web/package.json
index 1fbb631d2..9c8d15ef5 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -49,6 +49,7 @@
"react-dom": "^17.0.1",
"react-dropzone": "^11.4.2",
"react-hot-toast": "^2.2.0",
+ "react-loading-skeleton": "^3.1.0",
"react-modal": "^3.12.1",
"react-qrcode-logo": "^2.2.1",
"react-scripts": "^4.0.3",
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index 18e316296..aa003857d 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -1,19 +1,19 @@
import React, { useState, Suspense, useMemo, useRef, useEffect } from "react";
import { Box, Flex } from "rebass";
import ThemeProvider from "./components/theme-provider";
-import StatusBarPlaceholder from "./components/statusbar/index.lite";
import useMobile from "./utils/use-mobile";
import useTablet from "./utils/use-tablet";
import { LazyMotion, domAnimation } from "framer-motion";
import useDatabase from "./hooks/use-database";
-import Loader from "./components/loader";
import { Allotment } from "allotment";
import "allotment/dist/style.css";
import Config from "./utils/config";
-import EditorLoading from "./components/editor/loading";
-import NavigationMenuPlaceholder from "./components/navigationmenu/index.lite";
import { useStore } from "./stores/app-store";
import { Toaster } from "react-hot-toast";
+import { ViewLoader } from "./components/loaders/view-loader";
+import { NavigationLoader } from "./components/loaders/navigation-loader";
+import { StatusBarLoader } from "./components/loaders/status-bar-loader";
+import { EditorLoader } from "./components/loaders/editor-loader";
const GlobalMenuWrapper = React.lazy(() =>
import("./components/global-menu-wrapper")
@@ -133,7 +133,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
},
isTablet: isTablet || isNarrow,
}}
- fallback={<NavigationMenuPlaceholder />}
+ fallback={<NavigationLoader />}
/>
</Flex>
</Allotment.Pane>
@@ -147,12 +147,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
<SuspenseLoader
condition={isAppLoaded}
component={CachedRouter}
- fallback={
- <Loader
- title="Did you know?"
- text="All your notes are encrypted on your device."
- />
- }
+ fallback={<ViewLoader />}
/>
</Flex>
</Allotment.Pane>
@@ -166,12 +161,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
flexDirection="column"
>
<SuspenseLoader
- fallback={
- <Loader
- title="Fun fact"
- text="Notesnook was released in January 2021 by a team of only 3 people."
- />
- }
+ fallback={<EditorLoader />}
component={HashRouter}
condition={isAppLoaded}
/>
@@ -179,8 +169,9 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
</Allotment.Pane>
</Allotment>
</Flex>
+
<SuspenseLoader
- fallback={<StatusBarPlaceholder />}
+ fallback={<StatusBarLoader />}
component={StatusBar}
condition={isAppLoaded}
/>
@@ -217,7 +208,7 @@ function MobileAppContents({ isAppLoaded }) {
props={{
toggleNavigationContainer: () => {},
}}
- fallback={<NavigationMenuPlaceholder />}
+ fallback={<NavigationLoader />}
/>
</Flex>
<Flex
@@ -234,12 +225,7 @@ function MobileAppContents({ isAppLoaded }) {
<SuspenseLoader
condition={isAppLoaded}
component={CachedRouter}
- fallback={
- <Loader
- title="Did you know?"
- text="All your notes are encrypted on your device."
- />
- }
+ fallback={<ViewLoader />}
/>
<Box
id="overlay"
@@ -267,7 +253,7 @@ function MobileAppContents({ isAppLoaded }) {
flexDirection="column"
>
<SuspenseLoader
- fallback={<EditorLoading />}
+ fallback={<EditorLoader />}
component={HashRouter}
condition={isAppLoaded}
/>
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 0e499297a..95dd8e3d9 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -12,6 +12,7 @@ import { CustomScrollbarsVirtualList } from "../scroll-container";
import ReminderBar from "../reminder-bar";
import Announcements from "../announcements";
import useAnnouncements from "../../utils/use-announcements";
+import { ListLoader } from "../loaders/list-loader";
function ListContainer(props) {
const { type, groupType, items, context, refresh, header } = props;
@@ -39,10 +40,16 @@ function ListContainer(props) {
<Flex variant="columnFill">
{!props.items.length && props.placeholder ? (
<>
- {header || <ReminderBar />}
- <Flex variant="columnCenterFill">
- {props.isLoading ? <Icon.Loading rotate /> : <props.placeholder />}
- </Flex>
+ {props.isLoading ? (
+ <ListLoader />
+ ) : (
+ <>
+ {header || <ReminderBar />}
+ <Flex variant="columnCenterFill">
+ <props.placeholder />
+ </Flex>
+ </>
+ )}
</>
) : (
<>
diff --git a/apps/web/src/components/loaders/editor-loader.tsx b/apps/web/src/components/loaders/editor-loader.tsx
new file mode 100644
index 000000000..9ab51d88e
--- /dev/null
+++ b/apps/web/src/components/loaders/editor-loader.tsx
@@ -0,0 +1,20 @@
+import { memo } from "react";
+import Skeleton from "react-loading-skeleton";
+import { Box, Flex } from "rebass";
+import "react-loading-skeleton/dist/skeleton.css";
+
+export const EditorLoader = memo(function EditorLoader() {
+ return (
+ <Flex sx={{ flexDirection: "column", p: 2 }}>
+ <Flex sx={{ alignItems: "end", justifyContent: "end" }}>
+ <Skeleton width={45} height={30} style={{ marginRight: 5 }} />
+ <Skeleton width={45} height={30} />
+ </Flex>
+ <Skeleton height={39} style={{ marginTop: 20 }} />
+ <Box sx={{ mt: 4, mx: "5%" }}>
+ <Skeleton height={56} width={300} />
+ <Skeleton height={22} style={{ marginTop: 15 }} count={3} />
+ </Box>
+ </Flex>
+ );
+});
diff --git a/apps/web/src/components/loaders/list-loader.tsx b/apps/web/src/components/loaders/list-loader.tsx
new file mode 100644
index 000000000..9efbad33f
--- /dev/null
+++ b/apps/web/src/components/loaders/list-loader.tsx
@@ -0,0 +1,50 @@
+import { memo } from "react";
+import Skeleton from "react-loading-skeleton";
+import { Box, Flex } from "rebass";
+import "react-loading-skeleton/dist/skeleton.css";
+import { getRandomArbitrary } from "../../utils/random";
+
+const Lines = [1, 2, 3, 4].map(() => getRandomArbitrary(40, 90));
+export const ListLoader = memo(function ListLoader() {
+ return (
+ <>
+ <Flex alignItems="center" justifyContent={"center"} p={1}>
+ <Skeleton width={40} height={40} circle />
+ <Box sx={{ flex: 1, ml: 1, mt: 2 }}>
+ <Skeleton height={12} />
+ <Skeleton height={8} />
+ </Box>
+ </Flex>
+ {Lines.map((width) => (
+ <Box sx={{ py: 2, px: 1 }}>
+ <Skeleton
+ height={16}
+ baseColor="var(--border)"
+ width={`${width}%`}
+ style={{ marginBottom: 5 }}
+ />
+ <Skeleton height={12} count={2} baseColor="var(--hover)" />
+ <Flex>
+ <Skeleton height={10} inline width={50} baseColor="var(--hover)" />
+ <Skeleton
+ height={10}
+ inline
+ width={10}
+ baseColor="var(--shade)"
+ circle
+ style={{ marginLeft: 5 }}
+ />
+ <Skeleton
+ height={10}
+ inline
+ width={10}
+ baseColor="var(--hover)"
+ circle
+ style={{ marginLeft: 5 }}
+ />
+ </Flex>
+ </Box>
+ ))}
+ </>
+ );
+});
diff --git a/apps/web/src/components/loaders/navigation-loader.tsx b/apps/web/src/components/loaders/navigation-loader.tsx
new file mode 100644
index 000000000..df978f35e
--- /dev/null
+++ b/apps/web/src/components/loaders/navigation-loader.tsx
@@ -0,0 +1,49 @@
+import { memo } from "react";
+import Skeleton from "react-loading-skeleton";
+import { Box, Flex } from "rebass";
+import "react-loading-skeleton/dist/skeleton.css";
+
+export const NavigationLoader = memo(function NavigationLoader() {
+ return (
+ <Flex
+ id="navigationmenu"
+ flexDirection="column"
+ flex={1}
+ sx={{
+ zIndex: 1,
+ position: "relative",
+ }}
+ bg={"bgSecondary"}
+ >
+ {[0, 1, 2, 3, 4, 5].map(() => (
+ <Flex
+ px={2}
+ py={"9px"}
+ mx={1}
+ mt={"3px"}
+ sx={{
+ position: "relative",
+ ":first-of-type": { mt: 1 },
+ ":last-of-type": { mb: 1 },
+ }}
+ >
+ <Skeleton
+ height={20}
+ width={20}
+ inline
+ circle
+ baseColor="var(--border)"
+ />
+ <Box sx={{ flex: 1, ml: 1 }}>
+ <Skeleton
+ height={18}
+ inline
+ baseColor="var(--border)"
+ borderRadius={5}
+ />
+ </Box>
+ </Flex>
+ ))}
+ </Flex>
+ );
+});
diff --git a/apps/web/src/components/loaders/status-bar-loader.tsx b/apps/web/src/components/loaders/status-bar-loader.tsx
new file mode 100644
index 000000000..b36b0ca39
--- /dev/null
+++ b/apps/web/src/components/loaders/status-bar-loader.tsx
@@ -0,0 +1,24 @@
+import { memo } from "react";
+import Skeleton from "react-loading-skeleton";
+import { Box } from "rebass";
+import "react-loading-skeleton/dist/skeleton.css";
+
+export const StatusBarLoader = memo(function StatusBarLoader() {
+ return (
+ <Box
+ bg="bgSecondary"
+ display={["none", "flex"]}
+ sx={{ borderTop: "1px solid", borderTopColor: "border" }}
+ justifyContent="space-between"
+ px={2}
+ height={27}
+ >
+ <Skeleton
+ width={80}
+ height={16}
+ baseColor="var(--border)"
+ borderRadius={5}
+ />
+ </Box>
+ );
+});
diff --git a/apps/web/src/components/loaders/view-loader.tsx b/apps/web/src/components/loaders/view-loader.tsx
new file mode 100644
index 000000000..7afab5e0d
--- /dev/null
+++ b/apps/web/src/components/loaders/view-loader.tsx
@@ -0,0 +1,20 @@
+import { memo } from "react";
+import Skeleton from "react-loading-skeleton";
+import { Box, Flex } from "rebass";
+import "react-loading-skeleton/dist/skeleton.css";
+import { ListLoader } from "./list-loader";
+
+export const ViewLoader = memo(function ViewLoader() {
+ return (
+ <Box sx={{ m: 1 }}>
+ <Flex sx={{ justifyContent: "space-between" }}>
+ <Skeleton height={35} width={100} borderRadius={5} />
+ <Flex>
+ <Skeleton height={35} width={35} circle style={{ marginRight: 5 }} />
+ <Skeleton height={35} width={35} circle />
+ </Flex>
+ </Flex>
+ <ListLoader />
+ </Box>
+ );
+});
diff --git a/apps/web/src/components/navigation-menu/index.lite.js b/apps/web/src/components/navigation-menu/index.lite.js
deleted file mode 100644
index 4c4e353ab..000000000
--- a/apps/web/src/components/navigation-menu/index.lite.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Flex } from "rebass";
-import Loader from "../loader";
-
-function NavigationMenu() {
- return (
- <Flex
- id="navigationmenu"
- flexDirection="column"
- justifyContent="space-between"
- flex={1}
- sx={{
- borderRight: "1px solid",
- borderRightColor: "border",
- zIndex: 1,
- height: "auto",
- position: "relative",
- }}
- bg={"bgSecondary"}
- >
- <Loader />
- </Flex>
- );
-}
-export default NavigationMenu;
diff --git a/apps/web/src/components/status-bar/index.lite.js b/apps/web/src/components/status-bar/index.lite.js
deleted file mode 100644
index f642329d5..000000000
--- a/apps/web/src/components/status-bar/index.lite.js
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Box, Button, Text } from "rebass";
-import { Loading } from "../icons";
-
-function StatusBar() {
- return (
- <Box
- bg="bgSecondary"
- display={["none", "flex"]}
- sx={{ borderTop: "1px solid", borderTopColor: "border" }}
- justifyContent="space-between"
- px={2}
- >
- <Button
- variant="statusitem"
- display="flex"
- sx={{ alignItems: "center", justifyContent: "center" }}
- >
- <Loading size={12} />
- <Text variant="subBody" color="bgSecondaryText" ml={1}>
- Loading
- </Text>
- </Button>
- </Box>
- );
-}
-
-export default StatusBar;
diff --git a/apps/web/src/navigation/hash-routes.js b/apps/web/src/navigation/hash-routes.js
index ec627c7e3..8d02d5c28 100644
--- a/apps/web/src/navigation/hash-routes.js
+++ b/apps/web/src/navigation/hash-routes.js
@@ -27,6 +27,7 @@ import { hashNavigate } from ".";
import { Suspense } from "react";
import EditorLoading from "../components/editor/loading";
import EditorPlaceholder from "../components/editor/-placeholder";
+import { EditorLoader } from "../components/loaders/editor-loader";
const Editor = React.lazy(() => import("../components/editor"));
const hashroutes = {
@@ -62,7 +63,7 @@ const hashroutes = {
"/notes/create/:nonce": ({ nonce }) => {
closeOpenedDialog();
return (
- <Suspense fallback={<EditorLoading />}>
+ <Suspense fallback={<EditorLoader />}>
<Editor noteId={0} nonce={nonce} />
</Suspense>
);
@@ -71,7 +72,7 @@ const hashroutes = {
closeOpenedDialog();
return (
- <Suspense fallback={<EditorLoading />}>
+ <Suspense fallback={<EditorLoader />}>
<Editor noteId={noteId} />
</Suspense>
);