From ab616c5fc78b518dbcd41f9546484d290c7fc47b Mon Sep 17 00:00:00 2001
From: Lim Chee Aun
Date: Wed, 1 Mar 2023 17:48:52 +0800
Subject: [PATCH] Slight redesign of Shortcuts form
Yeah, still no Edit
---
src/components/shortcuts-settings.css | 27 +--
src/components/shortcuts-settings.jsx | 256 +++++++++++++++-----------
2 files changed, 154 insertions(+), 129 deletions(-)
diff --git a/src/components/shortcuts-settings.css b/src/components/shortcuts-settings.css
index 5d795cfb..0758f967 100644
--- a/src/components/shortcuts-settings.css
+++ b/src/components/shortcuts-settings.css
@@ -40,39 +40,20 @@
cursor: pointer;
}
-#shortcuts-settings-container form {
- display: flex;
- gap: 8px;
- flex-wrap: wrap;
- align-items: center;
- padding: 16px;
- background-color: var(--bg-faded-color);
- border-radius: 16px;
+#shortcut-settings-form form > * {
}
-#shortcuts-settings-container form header {
- display: flex;
- align-items: center;
- justify-content: space-between;
-}
-
-#shortcuts-settings-container form > * {
- flex-basis: max(320px, 100%);
- margin: 0;
- padding: 0;
-}
-
-#shortcuts-settings-container form label {
+#shortcut-settings-form label {
display: flex;
flex-direction: row;
gap: 8px;
align-items: center;
}
-#shortcuts-settings-container form label > span:first-child {
+#shortcut-settings-form label > span:first-child {
flex-basis: 5em;
text-align: right;
}
-#shortcuts-settings-container form :is(input[type='text'], select) {
+#shortcut-settings-form :is(input[type='text'], select) {
flex-grow: 1;
flex-basis: 70%;
flex-shrink: 1;
diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx
index 0c20725e..ecf39c3d 100644
--- a/src/components/shortcuts-settings.jsx
+++ b/src/components/shortcuts-settings.jsx
@@ -9,6 +9,7 @@ import states from '../utils/states';
import AsyncText from './AsyncText';
import Icon from './icon';
+import Modal from './modal';
const SHORTCUTS_LIMIT = 9;
@@ -161,6 +162,7 @@ function ShortcutsSettings() {
const [lists, setLists] = useState([]);
const [followedHashtags, setFollowedHashtags] = useState([]);
+ const [showForm, setShowForm] = useState(false);
useEffect(() => {
(async () => {
@@ -308,116 +310,158 @@ function ShortcutsSettings() {
No shortcuts yet. Add one from the form below.
)}
-
- = SHORTCUTS_LIMIT}
- lists={lists}
- followedHashtags={followedHashtags}
- onSubmit={(data) => {
- console.log('onSubmit', data);
- states.shortcuts.push(data);
+
+ >
+
+ {shortcuts.length >= SHORTCUTS_LIMIT &&
+ `Max ${SHORTCUTS_LIMIT} shortcuts`}
+
+
+
+
+ {showForm && (
+ {
+ if (e.target === e.currentTarget) {
+ setShowForm(false);
+ }
+ }}
+ >
+ = SHORTCUTS_LIMIT}
+ lists={lists}
+ followedHashtags={followedHashtags}
+ onSubmit={(data) => {
+ console.log('onSubmit', data);
+ states.shortcuts.push(data);
+ }}
+ onClose={() => setShowForm(false)}
+ />
+
+ )}
+
+ );
+}
+
+function ShortcutForm({
+ type,
+ lists,
+ followedHashtags,
+ onSubmit,
+ disabled,
+ onClose = () => {},
+}) {
+ const [currentType, setCurrentType] = useState(type);
+ return (
+
);
}
export default ShortcutsSettings;
-function ShortcutForm({ type, lists, followedHashtags, onSubmit, disabled }) {
- const [currentType, setCurrentType] = useState(type);
- return (
- <>
-
- >
- );
-}