From f018def803552f99aee45ec904157c2c107179cd Mon Sep 17 00:00:00 2001 From: Nikhil Mehta Date: Wed, 29 Jun 2022 09:39:16 +0530 Subject: [PATCH 1/5] feat(kbd shortcut): added submit keyboard shortcut for index page --- helpers/driverjsTutorials.ts | 17 ++++++++++++++++- helpers/isSkipSubmitKbdShortcutTutorial.ts | 16 ++++++++++++++++ pages/index.vue | 10 ++++++++++ plugins/cookie-injector.client.ts | 3 +++ styles/global.scss | 9 +++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 helpers/isSkipSubmitKbdShortcutTutorial.ts diff --git a/helpers/driverjsTutorials.ts b/helpers/driverjsTutorials.ts index 2853850..40f4539 100644 --- a/helpers/driverjsTutorials.ts +++ b/helpers/driverjsTutorials.ts @@ -30,6 +30,17 @@ const labelsTutorial: Tutorial[] = [ }, ] +const submitShortcutTutorial: Tutorial[] = [ + { + element: '#submitButton', + popover: { + title: 'New keyboard shortcut', + description: + 'Now you can press Cmd + Enter/Ctrl + Enter to go to compare screen.', + }, + }, +] + const actionBarTutorial: Tutorial[] = [ { element: '#toggleScrollInSyncSection', @@ -60,7 +71,7 @@ const backButtonTutorial: Tutorial[] = [ popover: { title: 'Go back to edit screen', description: - 'Now your data persists between the page navigation. Only if you have clicked on "Compare" button', + 'Now your data persists between the page navigation.
PS: Works only if you have clicked on "Compare" button', }, }, ] @@ -81,6 +92,10 @@ const tutorialsMetadata: TutorialsMetadata = { tutorial: labelsTutorial, cookieName: 'isSkipTutorial', }, + { + tutorial: submitShortcutTutorial, + cookieName: 'isSkipSubmitKbdShortcutTutorial', + }, ], } diff --git a/helpers/isSkipSubmitKbdShortcutTutorial.ts b/helpers/isSkipSubmitKbdShortcutTutorial.ts new file mode 100644 index 0000000..30200dc --- /dev/null +++ b/helpers/isSkipSubmitKbdShortcutTutorial.ts @@ -0,0 +1,16 @@ +export default function () { + const cookies = document.cookie.split(';') + const cookieMap: { + isSkipSubmitKbdShortcutTutorial?: string + } = { + isSkipSubmitKbdShortcutTutorial: 'false', + } + cookies.forEach((element) => { + const [name, val] = element.split('=') + const trimmedName = name.trim() + if (trimmedName === 'isSkipSubmitKbdShortcutTutorial') { + cookieMap[trimmedName] = val + } + }) + return cookieMap.isSkipSubmitKbdShortcutTutorial === 'true' +} diff --git a/pages/index.vue b/pages/index.vue index 21f063e..e076459 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -60,6 +60,7 @@ @@ -85,6 +86,15 @@ export default Vue.extend({ }, mounted() { showTutorials(this.$cookies, this.$route.path, this.$cookies.isDarkMode) + document.addEventListener('keydown', (event) => { + const { metaKey, ctrlKey, key } = event + if ((metaKey || ctrlKey) && key === 'Enter') { + const button: HTMLButtonElement = document.getElementById( + 'submitButton' + ) as HTMLButtonElement + button.click() + } + }) }, methods: { checkForm(e: Event) { diff --git a/plugins/cookie-injector.client.ts b/plugins/cookie-injector.client.ts index dcf63c0..a484fc9 100644 --- a/plugins/cookie-injector.client.ts +++ b/plugins/cookie-injector.client.ts @@ -3,12 +3,14 @@ import isDarkModeCookie from '~/helpers/isDarkModeCookie' import isSkipTutorialCookie from '~/helpers/isSkipTutorialCookie' import isSkipScrollInSyncTutorial from '~/helpers/isSkipScrollInSyncTutorial' import isSkipBackButtonPersistsDataTutorial from '~/helpers/isSkipBackButtonPersistsDataTutorial' +import isSkipSubmitKbdShortcutTutorial from '~/helpers/isSkipSubmitKbdShortcutTutorial' interface Cookies { isDarkMode: boolean isSkipTutorial: boolean isSkipScrollInSyncTutorial: boolean isSkipBackButtonPersistsDataTutorial: boolean + isSkipSubmitKbdShortcutTutorial: boolean } declare module 'vue/types/vue' { interface Vue { @@ -41,6 +43,7 @@ const cookieInjectorPlugin: Plugin = (_context, inject) => { isSkipScrollInSyncTutorial: isSkipScrollInSyncTutorial(), isSkipBackButtonPersistsDataTutorial: isSkipBackButtonPersistsDataTutorial(), + isSkipSubmitKbdShortcutTutorial: isSkipSubmitKbdShortcutTutorial(), }) } diff --git a/styles/global.scss b/styles/global.scss index be59082..3b63469 100644 --- a/styles/global.scss +++ b/styles/global.scss @@ -43,6 +43,15 @@ main { margin-top: 2rem; } +kbd { + @apply bg-gray-100 dark:bg-gray-800 border bottom-1 dark:border-gray-600 border-gray-300 shadow rounded-sm text-gray-700 dark:text-gray-50 inline-block; + font-size: 0.85em; + font-weight: 700; + line-height: 1; + padding: 2px 4px; + white-space: nowrap; +} + /* custom scrollbar */ ::-webkit-scrollbar { width: 10px; From 41752aa7e0cbb9939de526b7b709c037d8c8ac06 Mon Sep 17 00:00:00 2001 From: Nikhil Mehta Date: Wed, 29 Jun 2022 10:11:35 +0530 Subject: [PATCH 2/5] feat(theme): theme changes between page transition --- components/navbar.vue | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/navbar.vue b/components/navbar.vue index 4e1dfe8..c75fbcf 100644 --- a/components/navbar.vue +++ b/components/navbar.vue @@ -156,7 +156,8 @@ - diff --git a/components/buttons/copyLink.vue b/components/buttons/copyLink.vue index ee92ac7..eaf8db3 100644 --- a/components/buttons/copyLink.vue +++ b/components/buttons/copyLink.vue @@ -47,8 +47,9 @@ - diff --git a/components/buttons/nextDiff.vue b/components/buttons/nextDiff.vue index de48c7d..17118b7 100644 --- a/components/buttons/nextDiff.vue +++ b/components/buttons/nextDiff.vue @@ -25,14 +25,15 @@ - diff --git a/components/buttons/prevDiff.vue b/components/buttons/prevDiff.vue index f6b1c09..e96ab6e 100644 --- a/components/buttons/prevDiff.vue +++ b/components/buttons/prevDiff.vue @@ -26,12 +26,13 @@ diff --git a/components/buttons/skipToNav.vue b/components/buttons/skipToNav.vue index d22e3f7..c208d4e 100644 --- a/components/buttons/skipToNav.vue +++ b/components/buttons/skipToNav.vue @@ -6,14 +6,15 @@ Skip to main content -