Skip to content

Commit 49ca282

Browse files
committed
Replace radio button with links
1 parent a0a8921 commit 49ca282

File tree

3 files changed

+45
-31
lines changed

3 files changed

+45
-31
lines changed

src/App.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
2-
import { ref, onMounted, computed } from "vue"
2+
import { ref, onMounted, computed, watch } from "vue"
33
44
import AssistanceModal from "./components/AssistanceModal.vue"
55
import TroubleshooterStep from "./components/TroubleshooterStep.vue"
6-
import { getSteps, generateReport, type Option } from "./troubleshooter"
6+
import { getSteps, generateReport } from "./troubleshooter"
77
88
const sleep = (m: number) => new Promise((r) => setTimeout(r, m))
99
@@ -24,14 +24,11 @@ const needsAssistance = computed(() => {
2424
2525
const report = computed(() => generateReport(steps.value))
2626
27-
function choose(option: Option) {
28-
document.location.assign(option.hash)
27+
watch(hash, (hash) => {
2928
window.plausible("ArduinoJson Troubleshooter", {
30-
props: {
31-
hash: document.location.hash,
32-
},
29+
props: { hash },
3330
})
34-
}
31+
})
3532
3633
async function copyReport() {
3734
await navigator.clipboard.writeText(report.value)
@@ -61,7 +58,6 @@ async function copyReport() {
6158
<TroubleshooterStep
6259
:key="step.hash"
6360
:step="step"
64-
@choose="choose"
6561
:active="idx == steps.length - 1"
6662
/>
6763
</Transition>

src/components/TroubleshooterStep.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
import { inject, onMounted, useTemplateRef } from "vue"
33
44
import TroubleshooterStepOption from "./TroubleshooterStepOption.vue"
5-
import type { Option, Step } from "@/troubleshooter"
5+
import type { Step } from "@/troubleshooter"
66
77
const debug = inject<boolean>("debug")
88
9-
const emit = defineEmits<{
10-
choose: [Option]
11-
}>()
12-
139
defineProps<{
1410
step: Step
1511
active?: boolean
@@ -43,7 +39,6 @@ onMounted(() => {
4339
v-for="option in step.options"
4440
:key="option.hash"
4541
:option="option"
46-
@click="emit('choose', option)"
4742
/>
4843
</div>
4944
<p v-if="debug" class="small">

src/components/TroubleshooterStepOption.vue

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,50 @@ defineProps<{
77
}>()
88
99
const debug = inject("debug")
10-
11-
const emit = defineEmits(["check"])
1210
</script>
1311

1412
<template>
15-
<div class="form-check">
16-
<input
17-
type="radio"
18-
:id="option.inputId"
19-
class="form-check-input"
20-
:checked="option.selected"
21-
@click="$emit('check')"
22-
:disabled="option.missing"
23-
/>
24-
<label
25-
class="form-check-label"
26-
:for="option.inputId"
27-
v-html="option.label"
28-
></label>
13+
<div>
14+
<a
15+
:href="option.hash"
16+
:class="{
17+
active: option.selected,
18+
disabled: option.missing,
19+
}"
20+
>
21+
<span class="checkmark"></span>
22+
<span v-html="option.label"></span>
23+
</a>
2924
<div v-if="debug" class="d-block mb-2 small text-muted">
3025
{{ option.summary }}
3126
</div>
3227
</div>
3328
</template>
29+
30+
<style scoped>
31+
a {
32+
color: var(--bs-body-color);
33+
text-decoration: none;
34+
display: flex;
35+
align-items: center;
36+
}
37+
38+
.checkmark {
39+
border: 1px solid #ccc;
40+
border-radius: 50%;
41+
width: 1em;
42+
height: 1em;
43+
margin-right: 0.8ch;
44+
content: "";
45+
}
46+
47+
a.active .checkmark {
48+
color: white;
49+
border: 0.3em solid #00828a;
50+
}
51+
52+
a.disabled {
53+
opacity: 0.5;
54+
pointer-events: none;
55+
}
56+
</style>

0 commit comments

Comments
 (0)