frontend: perform primary action in most modals by pressing enter

This commit is contained in:
hippoz 2022-05-06 03:19:52 +03:00
parent 96975c149b
commit c8604515d6
No known key found for this signature in database
GPG key ID: 7C52899193467641
5 changed files with 35 additions and 5 deletions

View file

@ -40,6 +40,12 @@ import { maybeFly } from "../../animations";
overlayStore.open("login", {}); overlayStore.open("login", {});
} }
}; };
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await create();
};
</script> </script>
<style> <style>
@ -52,7 +58,7 @@ import { maybeFly } from "../../animations";
} }
</style> </style>
<div class="modal-backdrop modal-backdrop-opaque"> <div class="modal-backdrop modal-backdrop-opaque" on:keydown="{ onKeydown }">
<div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation on:outroend="{ outroEnd }"> <div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation on:outroend="{ outroEnd }">
<div class="modal-header"> <div class="modal-header">
<span class="h4">Create an Account</span> <span class="h4">Create an Account</span>

View file

@ -22,6 +22,12 @@ import { maybeFade, maybeFly } from "../../animations";
} }
close(); close();
}; };
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await create();
};
</script> </script>
<style> <style>
@ -30,7 +36,7 @@ import { maybeFade, maybeFly } from "../../animations";
} }
</style> </style>
<div class="modal-backdrop" transition:maybeFade="{{ duration: 300, easing: quintInOut }}" on:click="{ close }"> <div class="modal-backdrop" transition:maybeFade="{{ duration: 300, easing: quintInOut }}" on:click="{ close }" on:keydown="{ onKeydown }">
<div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation> <div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation>
<div class="modal-header"> <div class="modal-header">
<span class="h4">Create Channel</span> <span class="h4">Create Channel</span>

View file

@ -34,6 +34,12 @@
} }
close(); close();
}; };
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await save();
};
</script> </script>
<style> <style>
@ -46,7 +52,7 @@
} }
</style> </style>
<div class="modal-backdrop" transition:maybeFade="{{ duration: 300, easing: quintInOut }}" on:click="{ close }"> <div class="modal-backdrop" transition:maybeFade="{{ duration: 300, easing: quintInOut }}" on:click="{ close }" on:keydown="{ onKeydown }">
<div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation> <div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation>
<div class="modal-header"> <div class="modal-header">
<span class="h4">Edit Channel</span> <span class="h4">Edit Channel</span>

View file

@ -34,6 +34,12 @@ import { maybeFade, maybeFly } from "../../animations";
} }
close(); close();
}; };
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await save();
};
</script> </script>
<style> <style>
@ -46,7 +52,7 @@ import { maybeFade, maybeFly } from "../../animations";
} }
</style> </style>
<div class="modal-backdrop" transition:maybeFade="{{ duration: 300, easing: quintInOut }}" on:click="{ close }"> <div class="modal-backdrop" transition:maybeFade="{{ duration: 300, easing: quintInOut }}" on:click="{ close }" on:keydown="{ onKeydown }">
<div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation> <div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation>
<div class="modal-header"> <div class="modal-header">
<span class="h4">Edit Message</span> <span class="h4">Edit Message</span>

View file

@ -44,6 +44,12 @@ import { maybeFly } from "../../animations";
overlayStore.open("createAccount", {}); overlayStore.open("createAccount", {});
} }
}; };
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await login();
};
</script> </script>
<style> <style>
@ -56,7 +62,7 @@ import { maybeFly } from "../../animations";
} }
</style> </style>
<div class="modal-backdrop modal-backdrop-opaque"> <div class="modal-backdrop modal-backdrop-opaque" on:keydown="{ onKeydown }">
<div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation on:outroend="{ outroEnd }"> <div class="modal" transition:maybeFly="{{ duration: 300, easing: quintInOut, y: 10 }}" on:click|stopPropagation on:outroend="{ outroEnd }">
<div class="modal-header"> <div class="modal-header">
<span class="h4">Welcome back!</span> <span class="h4">Welcome back!</span>