Experiment useAutoAnimate
This commit is contained in:
parent
cafadd0980
commit
8d694ecf1b
11
package-lock.json
generated
11
package-lock.json
generated
|
@ -9,6 +9,7 @@
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@formatjs/intl-localematcher": "~0.4.2",
|
"@formatjs/intl-localematcher": "~0.4.2",
|
||||||
|
"@formkit/auto-animate": "~0.8.0",
|
||||||
"@github/text-expander-element": "~2.5.0",
|
"@github/text-expander-element": "~2.5.0",
|
||||||
"@iconify-icons/mingcute": "~1.2.8",
|
"@iconify-icons/mingcute": "~1.2.8",
|
||||||
"@justinribeiro/lite-youtube": "~1.5.0",
|
"@justinribeiro/lite-youtube": "~1.5.0",
|
||||||
|
@ -3043,6 +3044,11 @@
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@formkit/auto-animate": {
|
||||||
|
"version": "0.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@formkit/auto-animate/-/auto-animate-0.8.0.tgz",
|
||||||
|
"integrity": "sha512-G8f7489ka0mWyi+1IEZT+xgIwcpWtRMmE2x+IrVoQ+KM1cP6VDj/TbujZjwxdb0P8w8b16/qBfViRmydbYHwMw=="
|
||||||
|
},
|
||||||
"node_modules/@github/combobox-nav": {
|
"node_modules/@github/combobox-nav": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@github/combobox-nav/-/combobox-nav-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@github/combobox-nav/-/combobox-nav-2.1.5.tgz",
|
||||||
|
@ -9558,6 +9564,11 @@
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@formkit/auto-animate": {
|
||||||
|
"version": "0.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@formkit/auto-animate/-/auto-animate-0.8.0.tgz",
|
||||||
|
"integrity": "sha512-G8f7489ka0mWyi+1IEZT+xgIwcpWtRMmE2x+IrVoQ+KM1cP6VDj/TbujZjwxdb0P8w8b16/qBfViRmydbYHwMw=="
|
||||||
|
},
|
||||||
"@github/combobox-nav": {
|
"@github/combobox-nav": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@github/combobox-nav/-/combobox-nav-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@github/combobox-nav/-/combobox-nav-2.1.5.tgz",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@formatjs/intl-localematcher": "~0.4.2",
|
"@formatjs/intl-localematcher": "~0.4.2",
|
||||||
|
"@formkit/auto-animate": "~0.8.0",
|
||||||
"@github/text-expander-element": "~2.5.0",
|
"@github/text-expander-element": "~2.5.0",
|
||||||
"@iconify-icons/mingcute": "~1.2.8",
|
"@iconify-icons/mingcute": "~1.2.8",
|
||||||
"@justinribeiro/lite-youtube": "~1.5.0",
|
"@justinribeiro/lite-youtube": "~1.5.0",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import './shortcuts-settings.css';
|
import './shortcuts-settings.css';
|
||||||
|
|
||||||
|
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||||
import {
|
import {
|
||||||
compressToEncodedURIComponent,
|
compressToEncodedURIComponent,
|
||||||
decompressFromEncodedURIComponent,
|
decompressFromEncodedURIComponent,
|
||||||
|
@ -201,6 +202,8 @@ function ShortcutsSettings({ onClose }) {
|
||||||
const [showForm, setShowForm] = useState(false);
|
const [showForm, setShowForm] = useState(false);
|
||||||
const [showImportExport, setShowImportExport] = useState(false);
|
const [showImportExport, setShowImportExport] = useState(false);
|
||||||
|
|
||||||
|
const [shortcutsListParent] = useAutoAnimate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -316,9 +319,10 @@ function ShortcutsSettings({ onClose }) {
|
||||||
</details>
|
</details>
|
||||||
</p> */}
|
</p> */}
|
||||||
{shortcuts.length > 0 ? (
|
{shortcuts.length > 0 ? (
|
||||||
<ol class="shortcuts-list">
|
<ol class="shortcuts-list" ref={shortcutsListParent}>
|
||||||
{shortcuts.filter(Boolean).map((shortcut, i) => {
|
{shortcuts.filter(Boolean).map((shortcut, i) => {
|
||||||
const key = i + Object.values(shortcut);
|
// const key = i + Object.values(shortcut);
|
||||||
|
const key = Object.values(shortcut).join('-');
|
||||||
const { type } = shortcut;
|
const { type } = shortcut;
|
||||||
if (!SHORTCUTS_META[type]) return null;
|
if (!SHORTCUTS_META[type]) return null;
|
||||||
let { icon, title, subtitle } = SHORTCUTS_META[type];
|
let { icon, title, subtitle } = SHORTCUTS_META[type];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import './accounts.css';
|
import './accounts.css';
|
||||||
|
|
||||||
|
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||||
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||||
import { useReducer, useState } from 'preact/hooks';
|
|
||||||
import { useReducer } from 'preact/hooks';
|
import { useReducer } from 'preact/hooks';
|
||||||
|
|
||||||
import Avatar from '../components/avatar';
|
import Avatar from '../components/avatar';
|
||||||
|
@ -21,6 +21,7 @@ function Accounts({ onClose }) {
|
||||||
const moreThanOneAccount = accounts.length > 1;
|
const moreThanOneAccount = accounts.length > 1;
|
||||||
|
|
||||||
const [_, reload] = useReducer((x) => x + 1, 0);
|
const [_, reload] = useReducer((x) => x + 1, 0);
|
||||||
|
const [accountsListParent] = useAutoAnimate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="accounts-container" class="sheet" tabIndex="-1">
|
<div id="accounts-container" class="sheet" tabIndex="-1">
|
||||||
|
@ -34,7 +35,7 @@ function Accounts({ onClose }) {
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<section>
|
<section>
|
||||||
<ul class="accounts-list">
|
<ul class="accounts-list" ref={accountsListParent}>
|
||||||
{accounts.map((account, i) => {
|
{accounts.map((account, i) => {
|
||||||
const isCurrent = account.info.id === currentAccount;
|
const isCurrent = account.info.id === currentAccount;
|
||||||
const isDefault = i === 0; // first account is always default
|
const isDefault = i === 0; // first account is always default
|
||||||
|
|
Loading…
Reference in a new issue