Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 62 additions & 36 deletions src/components/GuitarTuner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,45 +106,50 @@ const hintPill = computed(() => (hint.value ? HINTS[hint.value] : undefined))
:complete="allTuned"
/>

<p v-if="allTuned" class="all-tuned" role="status">{{ t('tuner.allTuned') }}</p>
<template v-else>
<p class="info-row">
<span class="string-label">{{ t('tuner.string', { n: guitarStringNum }) }}</span>
<span class="info-sep" aria-hidden="true" />
<span class="frequency">{{
frequency !== null ? `${frequency.toFixed(1)} Hz` : '—'
}}</span>
</p>
<UiStatusPill
class="hint"
:tone="hintPill?.tone"
:icon="hintPill?.icon"
:hidden="!hintPill"
>
{{ hintPill ? t(hintPill.text) : '' }}
</UiStatusPill>
</template>
<!-- The reading gives way to the final message -->
<Transition name="ui-swap" mode="out-in">
<p v-if="allTuned" class="all-tuned" role="status">{{ t('tuner.allTuned') }}</p>
<div v-else class="readout">
<p class="info-row">
<span class="string-label">{{ t('tuner.string', { n: guitarStringNum }) }}</span>
<span class="info-sep" aria-hidden="true" />
<span class="frequency">{{
frequency !== null ? `${frequency.toFixed(1)} Hz` : '—'
}}</span>
</p>
<UiStatusPill
class="hint"
:tone="hintPill?.tone"
:icon="hintPill?.icon"
:hidden="!hintPill"
>
{{ hintPill ? t(hintPill.text) : '' }}
</UiStatusPill>
</div>
</Transition>
</section>

<!-- Meter + Start/Stop, near the thumb -->
<section v-if="!allTuned" class="controls">
<CentsMeter
:needle-percent="needlePercent"
:status="statusClass"
:clarity="signalClarity"
/>

<p v-if="error" class="error" role="alert">{{ error }}</p>

<UiButton
:variant="isListening ? 'glass' : 'primary'"
:loading="starting"
block
@click="toggle"
>
{{ starting ? t('tuner.starting') : isListening ? t('tuner.stop') : t('tuner.start') }}
</UiButton>
</section>
<Transition name="ui-fade">
<section v-if="!allTuned" class="controls">
<CentsMeter
:needle-percent="needlePercent"
:status="statusClass"
:clarity="signalClarity"
/>

<p v-if="error" class="error" role="alert">{{ error }}</p>

<UiButton
:variant="isListening ? 'glass' : 'primary'"
:loading="starting"
block
@click="toggle"
>
{{ starting ? t('tuner.starting') : isListening ? t('tuner.stop') : t('tuner.start') }}
</UiButton>
</section>
</Transition>
</UiSurface>
</div>

Expand Down Expand Up @@ -233,6 +238,13 @@ const hintPill = computed(() => (hint.value ? HINTS[hint.value] : undefined))
gap: var(--space-3);
}

.readout {
display: flex;
flex-direction: column;
align-items: center;
gap: inherit;
}

.controls {
grid-area: controls;
display: flex;
Expand Down Expand Up @@ -277,6 +289,20 @@ const hintPill = computed(() => (hint.value ? HINTS[hint.value] : undefined))
text-align: center;
}

/* The screen comes in piece by piece, top to bottom */
.tuner-card > * {
animation: ui-rise var(--duration-slow) var(--ease-out) both;
}
.tuner-card > :nth-child(2) {
animation-delay: 50ms;
}
.tuner-card > :nth-child(3) {
animation-delay: 100ms;
}
.tuner-card > :nth-child(4) {
animation-delay: 150ms;
}

/* All in tune: the ring and the message take the space of the controls */
.is-complete .tuner-card {
justify-content: flex-start;
Expand Down
68 changes: 51 additions & 17 deletions src/components/StringChips.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,28 @@ function isLocked(di: number): boolean {
const index = arrayIdx(di)
return props.isListening && props.lockedStringIndex === index && !props.tunedStrings.has(index)
}

// The locked outline is one cursor that slides from string to string
const cursorIndex = computed(() => displayStrings.value.findIndex((_, di) => isLocked(di)))
</script>

<template>
<!-- One glass track holds every chip: no glass on glass -->
<UiSurface class="strings-display" material="glass" radius="xl">
<UiSurface
class="strings-display"
material="glass"
radius="xl"
:style="{ '--count': displayStrings.length }"
>
<!-- The index sits on the cursor itself, so a cursor fading out stays where it was -->
<Transition name="ui-fade">
<span
v-if="cursorIndex >= 0"
class="chip-cursor"
:style="{ '--index': cursorIndex }"
aria-hidden="true"
/>
</Transition>
<button
v-for="(str, di) in displayStrings"
:key="di"
Expand All @@ -46,13 +63,15 @@ function isLocked(di: number): boolean {
<span class="chip-note">{{ formatNote(str.note, tuning.preferFlats) }}</span>
<span class="chip-octave">{{ str.octave }}</span>
<!-- Tuned is said with a check too, not by colour alone -->
<UiIcon
v-if="tunedStrings.has(arrayIdx(di))"
class="chip-check"
name="check"
:size="14"
:stroke-width="3.4"
/>
<Transition name="ui-pop">
<UiIcon
v-if="tunedStrings.has(arrayIdx(di))"
class="chip-check"
name="check"
:size="14"
:stroke-width="3.4"
/>
</Transition>
</button>
</UiSurface>
</template>
Expand All @@ -79,10 +98,30 @@ function isLocked(di: number): boolean {
color: var(--text-primary);
font-variant-numeric: tabular-nums;
transition:
background var(--duration-fast),
box-shadow var(--duration-fast),
transform var(--duration-fast) var(--ease-out),
opacity var(--duration-fast);
background-color var(--duration-slow) var(--ease-out),
transform var(--duration-base) var(--ease-spring),
opacity var(--duration-base);
}
.string-chip > span {
transition: color var(--duration-base) var(--ease-out);
}

/* The string being tuned: accent tint and outline, sliding from chip to chip. The chips share
the width equally, so its place follows from the index alone */
.chip-cursor {
position: absolute;
top: var(--space-1);
bottom: var(--space-1);
left: var(--space-1);
width: calc((100% - (var(--count) + 1) * var(--space-1)) / var(--count));
border-radius: var(--radius-lg);
background: var(--accent-tint);
box-shadow: inset 0 0 0 1.5px var(--accent);
transform: translateX(calc(var(--index) * (100% + var(--space-1))));
transition:
transform var(--duration-slow) var(--ease-spring),
opacity var(--duration-base);
pointer-events: none;
}

.chip-num,
Expand All @@ -105,11 +144,6 @@ function isLocked(di: number): boolean {
right: 3px;
}

/* The string being tuned: accent tint and outline */
.string-chip.locked {
background: var(--accent-tint);
box-shadow: inset 0 0 0 1.5px var(--accent);
}
.string-chip.locked .chip-num,
.string-chip.locked .chip-octave {
color: var(--accent);
Expand Down
61 changes: 45 additions & 16 deletions src/components/TunerRing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,36 @@ const head = computed(() => {
<svg class="ring-svg" viewBox="0 0 260 260" aria-hidden="true">
<circle class="ring-track" :cx="CENTER" :cy="CENTER" :r="RING_R" />
</svg>
<svg v-if="progress > 0" class="ring-svg ring-glow" viewBox="0 0 260 260" aria-hidden="true">
<circle
class="ring-progress"
:cx="CENTER"
:cy="CENTER"
:r="RING_R"
:stroke-dasharray="ringDash"
:transform="`rotate(-90 ${CENTER} ${CENTER})`"
<!-- When a string is confirmed the full arc fades away rather than vanishing -->
<Transition name="ui-fade">
<svg v-if="progress > 0" class="ring-svg ring-glow" viewBox="0 0 260 260" aria-hidden="true">
<circle
class="ring-progress"
:cx="CENTER"
:cy="CENTER"
:r="RING_R"
:stroke-dasharray="ringDash"
:transform="`rotate(-90 ${CENTER} ${CENTER})`"
/>
<circle class="ring-head" :cx="head.x" :cy="head.y" r="9" />
</svg>
</Transition>
<!-- The next string's note takes the place of the last one; at the end a check draws itself -->
<Transition name="ui-swap" mode="out-in">
<UiIcon
v-if="complete"
key="complete"
class="ring-check"
name="check"
size="51%"
:stroke-width="2.15"
draw
/>
<circle class="ring-head" :cx="head.x" :cy="head.y" r="9" />
</svg>
<UiIcon v-if="complete" class="ring-check" name="check" size="51%" :stroke-width="2.15" />
<div v-else class="note-display" :class="status">
<span class="note-name">{{ note }}</span>
<span class="note-octave">{{ octave }}</span>
</div>
<div v-else :key="note + octave" class="note-display" :class="status">
<span class="note-name">{{ note }}</span>
<span class="note-octave">{{ octave }}</span>
</div>
</Transition>
</div>
</template>

Expand Down Expand Up @@ -106,7 +120,11 @@ const head = computed(() => {
gap: 0.77cqi;
color: var(--note-idle);
line-height: 1;
transition: color var(--duration-fast);
/* Its own transition replaces ui-swap's, so it carries opacity and transform too */
transition:
color var(--duration-base) var(--ease-out),
opacity var(--duration-base) var(--ease-out),
transform var(--duration-slow) var(--ease-spring);
}
.note-display.in-tune {
color: var(--green);
Expand All @@ -127,8 +145,19 @@ const head = computed(() => {
}

.ring-check {
--ui-icon-draw-delay: 120ms;
position: relative;
color: var(--green);
filter: var(--glow-green);
}

/* Every string in tune: the ring gives a small happy bounce */
.ring-wrapper.complete {
animation: ring-celebrate 700ms var(--ease-spring);
}
@keyframes ring-celebrate {
40% {
transform: scale(1.05);
}
}
</style>
63 changes: 33 additions & 30 deletions src/components/TuningSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,37 +83,40 @@ function handleSelect(id: string) {
/>
</template>

<div class="tuning-list">
<p v-if="filtered.length === 0" class="no-results">
{{ t('selector.noResults') }}
</p>

<UiListRow
v-for="tuning in filtered"
:key="tuning.id"
class="tuning-card"
:title="tuning.name"
:selected="activeTuning.id === tuning.id"
@select="handleSelect(tuning.id)"
>
<template #meta>
<span class="card-strings">{{ tuning.strings }} {{ t('tuner.strSuffix') }}</span>
<span v-if="isCustom(tuning.id)" class="badge-custom">{{ t('selector.custom') }}</span>
</template>
<!-- Thinnest string first, as on the chips -->
<span v-for="(str, i) in [...tuning.tuning].reverse()" :key="i" class="string-note"
>{{ formatNote(str.note, tuning.preferFlats) }}{{ str.octave }}</span
<!-- Another instrument: its list fades in where the other one was -->
<Transition name="ui-fade" mode="out-in">
<div :key="activeCategory" class="tuning-list">
<p v-if="filtered.length === 0" class="no-results">
{{ t('selector.noResults') }}
</p>

<UiListRow
v-for="tuning in filtered"
:key="tuning.id"
class="tuning-card"
:title="tuning.name"
:selected="activeTuning.id === tuning.id"
@select="handleSelect(tuning.id)"
>
<template v-if="isCustom(tuning.id)" #action>
<UiIconButton
icon="close"
variant="plain"
:label="t('selector.delete', { name: tuning.name })"
@click="deleteCustomTuning(tuning.id)"
/>
</template>
</UiListRow>
</div>
<template #meta>
<span class="card-strings">{{ tuning.strings }} {{ t('tuner.strSuffix') }}</span>
<span v-if="isCustom(tuning.id)" class="badge-custom">{{ t('selector.custom') }}</span>
</template>
<!-- Thinnest string first, as on the chips -->
<span v-for="(str, i) in [...tuning.tuning].reverse()" :key="i" class="string-note"
>{{ formatNote(str.note, tuning.preferFlats) }}{{ str.octave }}</span
>
<template v-if="isCustom(tuning.id)" #action>
<UiIconButton
icon="close"
variant="plain"
:label="t('selector.delete', { name: tuning.name })"
@click="deleteCustomTuning(tuning.id)"
/>
</template>
</UiListRow>
</div>
</Transition>
</UiSheet>
</template>

Expand Down
Loading
Loading