From 6885227c304267842a36888bf93246e94d865462 Mon Sep 17 00:00:00 2001 From: Lumi Pakkanen Date: Sat, 15 Jun 2024 12:20:12 +0300 Subject: [PATCH] Fix auto-focus when async modal is opened ref #49 --- src/components/ExporterButtons.vue | 3 + src/components/ModalDialog.vue | 3 +- src/components/ModifyScale.vue | 63 ++++++++++-- src/components/NewScale.vue | 15 +++ src/components/modals/ShareUrl.vue | 95 ------------------- src/components/modals/export/KorgExport.vue | 3 +- .../modals/export/MtsSysexExport.vue | 3 +- src/components/modals/export/ReaperExport.vue | 3 +- .../generation/CombinationProductSet.vue | 6 +- .../modals/generation/ConcordanceShell.vue | 6 +- .../modals/generation/EnumerateChord.vue | 6 +- .../modals/generation/EqualTemperament.vue | 6 +- .../modals/generation/EulerGenus.vue | 6 +- .../modals/generation/GeneratorSequence.vue | 6 +- .../modals/generation/HarmonicSeries.vue | 6 +- .../modals/generation/HistoricalScale.vue | 6 +- .../modals/generation/LoadPreset.vue | 6 +- src/components/modals/generation/MosScale.vue | 5 + src/components/modals/generation/RankTwo.vue | 5 + .../modals/generation/SpanLattice.vue | 6 +- .../modals/generation/StackSteps.vue | 6 +- .../modals/generation/SubharmonicSeries.vue | 6 +- .../modals/generation/SummonOctaplex.vue | 6 +- .../modification/ApproximateByHarmonics.vue | 6 +- .../modification/ApproximateByRatios.vue | 6 +- .../ApproximateBySubharmonics.vue | 6 +- .../modification/CoalesceDuplicates.vue | 6 +- .../modals/modification/ConvertType.vue | 6 +- .../modals/modification/EnumerateScale.vue | 6 +- .../modals/modification/EqualizeScale.vue | 6 +- .../modals/modification/ExpandScale.vue | 6 +- .../modals/modification/MergeOffsets.vue | 6 +- .../modals/modification/RandomVariance.vue | 6 +- .../modals/modification/RepeatScale.vue | 6 +- .../modals/modification/RotateScale.vue | 6 +- .../modals/modification/StretchScale.vue | 6 +- .../modals/modification/TakeSubset.vue | 6 +- .../modals/modification/TemperScale.vue | 6 +- 38 files changed, 231 insertions(+), 135 deletions(-) delete mode 100644 src/components/modals/ShareUrl.vue diff --git a/src/components/ExporterButtons.vue b/src/components/ExporterButtons.vue index 0e0994c3..3ef33aea 100644 --- a/src/components/ExporterButtons.vue +++ b/src/components/ExporterButtons.vue @@ -120,6 +120,7 @@ function doExport(exporter: ExporterKey) { diff --git a/src/components/ModifyScale.vue b/src/components/ModifyScale.vue index feaba26d..61f7132d 100644 --- a/src/components/ModifyScale.vue +++ b/src/components/ModifyScale.vue @@ -185,46 +185,93 @@ defineExpose({ blur }) - + - + - - - - - - + + + + + + diff --git a/src/components/NewScale.vue b/src/components/NewScale.vue index 91dd3292..b69ed3e4 100644 --- a/src/components/NewScale.vue +++ b/src/components/NewScale.vue @@ -168,50 +168,59 @@ defineExpose({ blur }) /> + -import { nextTick, ref } from 'vue' -import Modal from '@/components/ModalDialog.vue' - -const props = defineProps<{ - scaleName: string - newline: string -}>() - -const emit = defineEmits(['confirm', 'cancel']) -defineExpose({ initialize }) - -// This ref is for display purposes only. -// The methods use location directly. -const url = ref(window.location.href) -const urlInput = ref(null) - -function initialize() { - url.value = window.location.href - nextTick(() => { - if (urlInput.value !== null) { - urlInput.value.select() - urlInput.value.setSelectionRange(0, 99999) - } - }) -} - -function copyToClipboard() { - window.navigator.clipboard.writeText(window.location.href) - emit('confirm') -} - -function email() { - const recipient = '' - const subject = encodeURIComponent(`Scale Workshop - ${props.scaleName}`) - const bodyLines = [ - 'Sending you this musical scale:', - props.scaleName, - '', - 'The link below has more info:', - '', - window.location.href - ] - const body = encodeURIComponent(bodyLines.join(props.newline)) - window.open(`mailto:${recipient}?subject=${subject}&body=${body}`) -} - -function tweet() { - const text = encodeURIComponent(props.scaleName + ' ♫ ' + window.location.href) - window.open(`https://twitter.com/intent/tweet?text=${text}`) -} - -function postOnFacebook() { - let link: string - // Sharing a local URL won't work because Facebook screens the URL it receives. - if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') { - link = encodeURIComponent('https://sevish.com/scaleworkshop/') - } else { - link = encodeURIComponent(window.location.href) - } - window.open(`https://www.facebook.com/sharer/sharer.php?u=${link}`) -} - - - diff --git a/src/components/modals/export/KorgExport.vue b/src/components/modals/export/KorgExport.vue index 627940c7..d07a0d0a 100644 --- a/src/components/modals/export/KorgExport.vue +++ b/src/components/modals/export/KorgExport.vue @@ -8,6 +8,7 @@ import type { Interval } from 'sonic-weave' import type { Scale } from '@/scale' const props = defineProps<{ + show: boolean newline: string midiOctaveOffset: number relativeIntervals: Interval[] @@ -59,7 +60,7 @@ async function doExport() {