Skip to content

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

feat: improve dialog usability and appearance

thecodrrcc974a27aacb
diff --git a/apps/web/src/components/dialogs/add-notebook-dialog.js b/apps/web/src/components/dialogs/add-notebook-dialog.js
index 8c18999b2..804e95bfe 100644
--- a/apps/web/src/components/dialogs/add-notebook-dialog.js
+++ b/apps/web/src/components/dialogs/add-notebook-dialog.js
@@ -1,12 +1,12 @@
import React from "react";
-import { Flex, Box, Button as RebassButton, Text } from "rebass";
-import { Input } from "@rebass/forms";
+import { Flex, Text } from "rebass";
import * as Icon from "../icons";
import Dialog, { showDialog } from "./dialog";
import { store } from "../../stores/notebook-store";
import { qclone } from "qclone";
import { showToast } from "../../utils/toast";
import { db } from "../../common";
+import Field from "../field";
class AddNotebookDialog extends React.Component {
title = "";
@@ -119,66 +119,49 @@ class AddNotebookDialog extends React.Component {
negativeButton={{ text: "Cancel", onClick: props.onClose }}
>
<Flex flexDirection="column" sx={{ overflowY: "auto" }}>
- <Input
- data-test-id="dialog-nb-name"
- autoFocus
- onChange={(e) => (this.title = e.target.value)}
- placeholder="Enter name"
- defaultValue={this.title}
+ <Field autoFocus required label="Title" name="title" id="title" />
+ <Field
+ label="Description"
+ name="description"
+ id="description"
+ helpText="Optional"
+ sx={{ mt: 1 }}
/>
- <Input
- data-test-id="dialog-nb-description"
- mt={2}
- onChange={(e) => (this.description = e.target.value)}
- placeholder="Enter description (optional)"
- defaultValue={this.description}
- />
- <Flex flexDirection="row" mt={2}>
- <Input
- data-test-id={"dialog-nb-topic"}
- ref={(ref) => (this._topicInputRef = ref)}
- placeholder="Add a topic"
- onChange={(e) => {
- if (!this.state.isEditting) return;
- const topics = this.state.topics.slice();
- topics[this.state.editIndex].title = e.target.value;
- this.setState({
- topics,
- });
- }}
- onKeyUp={(e) => {
- if (e.nativeEvent.key === "Enter") {
- if (this.state.isEditting) {
- this.doneEditingTopic();
- } else {
- this.addTopic(e.target.value);
- }
- }
- }}
- />
- <RebassButton
- variant="tertiary"
- sx={{ marginLeft: 1 }}
- px={2}
- py={1}
- onClick={() => {
+ <Field
+ inputRef={(ref) => (this._topicInputRef = ref)}
+ label="Topics"
+ name="topic"
+ id="topic"
+ action={{
+ onClick: () => {
if (this.state.isEditting) {
this.doneEditingTopic();
} else {
this.addTopic(this._topicInputRef.value);
}
- }}
- data-test-id="dialog-nb-topic-action"
- >
- <Box height={20}>
- {this.state.isEditting ? (
- <Icon.Checkmark size={22} />
- ) : (
- <Icon.Plus size={22} />
- )}
- </Box>
- </RebassButton>
- </Flex>
+ },
+ icon: this.state.isEditting ? Icon.Checkmark : Icon.Plus,
+ }}
+ onChange={(e) => {
+ if (!this.state.isEditting) return;
+ const topics = this.state.topics.slice();
+ topics[this.state.editIndex].title = e.target.value;
+ this.setState({
+ topics,
+ });
+ }}
+ onKeyUp={(e) => {
+ if (e.nativeEvent.key === "Enter") {
+ if (this.state.isEditting) {
+ this.doneEditingTopic();
+ } else {
+ this.addTopic(e.target.value);
+ }
+ }
+ }}
+ helpText="Press enter to add a topic (optional)"
+ sx={{ mt: 1 }}
+ />
{this.state.topics.map((topic, index) => (
<TopicItem
key={topic.id || topic.title || index}
diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.js
index 4e2367fba..07797c67c 100644
--- a/apps/web/src/components/dialogs/confirm.js
+++ b/apps/web/src/components/dialogs/confirm.js
@@ -17,8 +17,8 @@ function Confirm(props) {
}}
negativeButton={{ text: props.noText, onClick: props.onNo }}
>
- <Box my={2}>
- <Text as="span" variant="body" fontSize={18}>
+ <Box>
+ <Text as="span" variant="body">
{props.message}
</Text>
</Box>
@@ -50,15 +50,12 @@ export function showDeleteConfirmation(type, multi = false) {
if (multi) noun += "s";
let lowerCaseNoun = noun.toLowerCase();
- let [firstPronoun, secondPronoun] = multi
- ? ["these", "they"]
- : ["this", "it"];
+ let secondPronoun = multi ? "they" : "it";
return confirm(Icon.Trash, {
- title: `Delete ${noun}`,
- subtitle: `Are you sure you want to delete ${firstPronoun} ${lowerCaseNoun}?`,
+ title: `Delete ${noun}?`,
message: (
- <Text as="span">
+ <Text as="span" fontSize="body">
The {lowerCaseNoun} will be{" "}
<Text as="span" color="primary">
kept in your Trash for 7 days
diff --git a/apps/web/src/components/dialogs/dialog.js b/apps/web/src/components/dialogs/dialog.js
index 12ba5465a..df5a9161b 100644
--- a/apps/web/src/components/dialogs/dialog.js
+++ b/apps/web/src/components/dialogs/dialog.js
@@ -73,25 +73,18 @@ function Dialog(props) {
/>
)}
<Flex
- variant="columnCenter"
+ flexDirection="column"
pb={2}
- mb={3}
- sx={{ borderBottom: "1px solid", borderColor: "border" }}
+ //sx={{ borderBottom: "1px solid", borderColor: "border" }}
>
{/* {props.icon && (
<props.icon size={props.iconSize || 38} color="primary" />
)} */}
- <Text
- variant="heading"
- textAlign="center"
- color="text"
- mx={1}
- mt={props.icon && 1}
- >
+ <Text variant="heading" textAlign="left" color="text">
{props.title}
</Text>
{props.description && (
- <Text variant="body" textAlign="center" color="gray" mx={1} mt={1}>
+ <Text variant="body" textAlign="left" color="gray" mt={1}>
{props.description}
</Text>
)}
diff --git a/apps/web/src/components/dialogs/exportdialog.js b/apps/web/src/components/dialogs/exportdialog.js
index a98247e7b..380655410 100644
--- a/apps/web/src/components/dialogs/exportdialog.js
+++ b/apps/web/src/components/dialogs/exportdialog.js
@@ -5,6 +5,26 @@ import download from "../../utils/download";
import * as Icon from "../icons";
import Dialog, { showDialog } from "./dialog";
+const formats = [
+ {
+ type: "md",
+ title: "Markdown",
+ icon: Icon.Markdown,
+ subtitle: "Can be opened in any plain-text or markdown editor.",
+ },
+ {
+ type: "html",
+ title: "HTML",
+ icon: Icon.HTML,
+ subtitle: "Can be opened in any browser.",
+ },
+ {
+ type: "txt",
+ title: "Text",
+ icon: Icon.Text,
+ subtitle: "Can be opened in any plain-text editor.",
+ },
+];
function ExportDialog(props) {
return (
<Dialog
@@ -12,32 +32,40 @@ function ExportDialog(props) {
title={props.title}
icon={props.icon}
description="You can export your note to Markdown, HTML, or Text."
- buttonsAlignment="center"
onClose={props.onClose}
+ scrollable
negativeButton={{
onClick: props.onClose,
text: "Cancel",
}}
>
- <Flex justifyContent="center" alignItems="center">
- <Button mr={2} onClick={() => props.exportNote("html")}>
- <Flex variant="rowCenter">
- <Icon.HTML color="static" />
- <Text ml={1}>HTML</Text>
- </Flex>
- </Button>
- <Button mr={2} onClick={() => props.exportNote("md")}>
- <Flex variant="rowCenter">
- <Icon.Markdown color="static" />
- <Text ml={1}>Markdown</Text>
- </Flex>
- </Button>
- <Button mr={2} onClick={() => props.exportNote("txt")}>
- <Flex variant="rowCenter">
- <Icon.Text color="static" />
- <Text ml={1}>Text</Text>
- </Flex>
- </Button>
+ <Flex flexDirection="column">
+ {formats.map((format) => (
+ <Button
+ variant="tertiary"
+ sx={{ display: "flex" }}
+ mb={1}
+ onClick={() => props.exportNote(format.type)}
+ >
+ <format.icon
+ color="primary"
+ sx={{ p: 1, bg: "shade", borderRadius: "default" }}
+ />
+ <Flex flexDirection="column" alignItems="flex-start" ml={2}>
+ <Text variant="title" textAlign="left">
+ {format.title}
+ </Text>
+ <Text
+ variant="subtitle"
+ textAlign="left"
+ fontWeight="normal"
+ color="gray"
+ >
+ {format.subtitle}
+ </Text>
+ </Flex>
+ </Button>
+ ))}
</Flex>
</Dialog>
);
diff --git a/apps/web/src/components/dialogs/logindialog.js b/apps/web/src/components/dialogs/logindialog.js
index 436c8763c..ddfb1ca5f 100644
--- a/apps/web/src/components/dialogs/logindialog.js
+++ b/apps/web/src/components/dialogs/logindialog.js
@@ -17,7 +17,21 @@ function LoginDialog(props) {
<Dialog
isOpen={true}
title={"Sign in to Your Account"}
- description={"Signing in allows you to sync your notes across devices."}
+ description={
+ <Flex alignItems="center">
+ <Text as="span" fontSize="body" color="gray">
+ Don't have an account?{" "}
+ <Button
+ variant="anchor"
+ sx={{ textAlign: "left" }}
+ fontSize="body"
+ onClick={showSignUpDialog}
+ >
+ Create an account here.
+ </Button>
+ </Text>
+ </Flex>
+ }
icon={Icon.Login}
onClose={onClose}
scrollable
@@ -30,28 +44,7 @@ function LoginDialog(props) {
text: "Sign in",
loading: isLoggingIn,
disabled: isLoggingIn,
- // onClick: () => {
- // console.log(document.getElementById("loginForm"));
- // }, //submit(setError, form, login, onClose),
}}
- buttonsAlignment="center"
- footer={
- <>
- <Text fontSize="title" textAlign="center" color="gray" mt={3}>
- Don't have an account?
- </Text>
- <Button
- mt={3}
- variant="anchor"
- justifySelf="center"
- alignSelf="center"
- fontSize="body"
- onClick={showSignUpDialog}
- >
- Sign up here
- </Button>
- </>
- }
>
<Flex
id="loginForm"
@@ -69,7 +62,7 @@ function LoginDialog(props) {
.then(onClose)
.catch((e) => setError(e.message));
}}
- variant="columnFill"
+ flexDirection="column"
>
<Field
autoFocus
diff --git a/apps/web/src/components/dialogs/move-note-dialog.js b/apps/web/src/components/dialogs/move-note-dialog.js
index 40b89943e..18c690a41 100644
--- a/apps/web/src/components/dialogs/move-note-dialog.js
+++ b/apps/web/src/components/dialogs/move-note-dialog.js
@@ -1,11 +1,11 @@
import React from "react";
-import { Flex, Box, Text, Button } from "rebass";
+import { Flex, Box, Text } from "rebass";
import * as Icon from "../icons";
import { db } from "../../common";
import Dialog, { showDialog } from "./dialog";
import { showNotesMovedToast } from "../../common/toasts";
import { showToast } from "../../utils/toast";
-import { Input } from "@rebass/forms";
+import Field from "../field";
class MoveDialog extends React.Component {
history = [];
@@ -36,7 +36,6 @@ class MoveDialog extends React.Component {
title={"Add Note to Notebook"}
description={"Organize your notes by adding them to notebooks."}
icon={Icon.Move}
- buttonsAlignment="center"
onClose={props.onClose}
negativeButton={{
text: "Cancel",
@@ -44,31 +43,27 @@ class MoveDialog extends React.Component {
}}
>
<Flex flexDirection="column" sx={{ overflowY: "hidden" }}>
- <Text variant="title">Notebooks</Text>
- <Flex flexDirection="row" my={2}>
- <Input
- ref={(ref) => (this.inputRef = ref)}
- data-test-id="mnd-new-notebook-title"
- placeholder={"Enter new notebook title"}
- onKeyUp={async (e) => {
- if (e.key === "Enter") await this.addNotebook(e.target);
- }}
- />
- <Button
- variant="tertiary"
- p={1}
- px={2}
- ml={2}
- onClick={async () => {
+ <Field
+ inputRef={(ref) => (this.inputRef = ref)}
+ data-test-id="mnd-new-notebook-title"
+ label="Notebooks"
+ id="notebook-title"
+ name="notebook-title"
+ helpText="Press enter to add a new notebook"
+ action={{
+ onClick: async () => {
await this.addNotebook(this.inputRef);
- }}
- data-test-id="mnd-new-notebook-add"
- >
- <Icon.Plus size={22} />
- </Button>
- </Flex>
+ },
+ icon: Icon.Plus,
+ }}
+ onKeyUp={async (e) => {
+ if (e.key === "Enter") await this.addNotebook(e.target);
+ }}
+ />
<Box
+ mt={1}
sx={{
+ borderRadius: "default",
borderWidth: 1,
borderStyle: "solid",
borderColor: "border",
diff --git a/apps/web/src/components/dialogs/signupdialog.js b/apps/web/src/components/dialogs/signupdialog.js
index 914a2a066..ee853439d 100644
--- a/apps/web/src/components/dialogs/signupdialog.js
+++ b/apps/web/src/components/dialogs/signupdialog.js
@@ -1,5 +1,5 @@
import React, { useState } from "react";
-import { Text, Box, Button } from "rebass";
+import { Text, Box, Button, Flex } from "rebass";
import * as Icon from "../icons";
import Dialog, { showDialog } from "./dialog";
import { useStore } from "../../stores/user-store";
@@ -17,12 +17,20 @@ function SignUpDialog(props) {
<Dialog
isOpen={true}
title={"Create a new Account"}
- description={"Sign up for a 14-day free trial (no credit card)."}
+ description={
+ <Flex alignItems="center">
+ <Text fontSize="body" textAlign="center" color="gray" mr="3px">
+ Already have an account?
+ </Text>
+ <Button variant="anchor" fontSize="body" onClick={showLogInDialog}>
+ Sign in here.
+ </Button>
+ </Flex>
+ }
icon={Icon.Signup}
onClose={onClose}
scrollable
negativeButton={{ text: "Cancel", onClick: onClose }}
- buttonsAlignment="center"
positiveButton={{
props: {
form: "signupForm",
@@ -32,21 +40,6 @@ function SignUpDialog(props) {
loading: isSigningIn,
disabled: isSigningIn,
}}
- footer={
- <>
- <Text fontSize="title" textAlign="center" color="gray" mt={3}>
- Already have an account?
- </Text>
- <Button
- variant="anchor"
- mt={2}
- fontSize="body"
- onClick={showLogInDialog}
- >
- Sign in here.
- </Button>
- </>
- }
>
<Box
id="signupForm"
diff --git a/apps/web/src/components/field/index.js b/apps/web/src/components/field/index.js
index 91436afef..705761089 100644
--- a/apps/web/src/components/field/index.js
+++ b/apps/web/src/components/field/index.js
@@ -13,6 +13,11 @@ function Field(props) {
required,
autoFocus,
autoComplete,
+ helpText,
+ action,
+ onKeyUp,
+ onChange,
+ inputRef,
} = props;
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
@@ -28,17 +33,22 @@ function Field(props) {
>
{label}
</Label>
- {/* <Label htmlFor={id} sx={{ fontSize: "body", color: "gray" }} mb={1}>
- Hello I am secondary
- </Label> */}
+ {helpText && (
+ <Label htmlFor={id} sx={{ fontSize: "subBody", color: "gray" }}>
+ {helpText}
+ </Label>
+ )}
<Flex mt={1} sx={{ position: "relative" }}>
<Input
+ ref={inputRef}
autoFocus={autoFocus}
required={required}
name={name}
id={id}
autoComplete={autoComplete}
type={type || "text"}
+ onChange={onChange}
+ onKeyUp={onKeyUp}
/>
{type === "password" && (
<Flex
@@ -65,6 +75,23 @@ function Field(props) {
)}
</Flex>
)}
+ {action && (
+ <Flex
+ onClick={action.onClick}
+ variant="rowCenter"
+ sx={{
+ position: "absolute",
+ right: 0,
+ top: 0,
+ bottom: 0,
+ px: 1,
+ borderRadius: "default",
+ ":hover": { bg: "border" },
+ }}
+ >
+ <action.icon />
+ </Flex>
+ )}
</Flex>
</Flex>
);
diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.js
index dc335356f..e36cdb376 100644
--- a/apps/web/src/components/list-item/index.js
+++ b/apps/web/src/components/list-item/index.js
@@ -1,5 +1,5 @@
import React, { useEffect, useCallback } from "react";
-import { Flex, Box, Text } from "rebass";
+import { Flex, Text } from "rebass";
import * as Icon from "../icons";
import {
store as selectionStore,
@@ -22,9 +22,10 @@ function selectMenuItem(isSelected, toggleSelection) {
}
const ItemSelector = ({ isSelected, toggleSelection }) => {
- return (
- <Box
- width={24}
+ return isSelected ? (
+ <Icon.Check
+ color="primary"
+ size={16}
sx={{
marginLeft: 0,
marginRight: 1,
@@ -32,9 +33,9 @@ const ItemSelector = ({ isSelected, toggleSelection }) => {
cursor: "pointer",
}}
onClick={() => toggleSelection()}
- >
- {isSelected ? <Icon.Check color="primary" /> : <Icon.CircleEmpty />}
- </Box>
+ />
+ ) : (
+ <Icon.CircleEmpty />
);
};