Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 0d1b43a

Browse files
committed
fix: select client ui
1 parent e352e5a commit 0d1b43a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

demo/src/App.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<script setup lang="ts">
22
import CodeExample from './components/CodeExample.vue'
33
import { snippetz } from '@scalar/snippetz'
4-
import { type ClientId} from '@scalar/snippetz-core'
4+
import { type ClientId, type TargetId} from '@scalar/snippetz-core'
55
import { ref } from 'vue'
66
7+
const selectedTarget = ref<ClientId>('node')
78
const selectedClient = ref<ClientId>('undici')
9+
10+
function selectPlugin(plugin: { target: TargetId, client: ClientId }) {
11+
selectedTarget.value = plugin.target
12+
selectedClient.value = plugin.client
13+
}
814
</script>
915

1016
<template>
@@ -22,18 +28,18 @@ const selectedClient = ref<ClientId>('undici')
2228
Clients
2329
</h2>
2430

25-
<button v-for="plugin in snippetz().plugins()" :key="plugin.client" class="client" :class="{ 'client--selected': selectedClient === plugin.client }" @click="() => selectedClient = plugin.client">
26-
{{ plugin.client }}
31+
<button v-for="plugin in snippetz().plugins()" :key="plugin.client" class="client" :class="{ 'client--selected': selectedClient === plugin.client && selectedTarget === plugin.target }" @click="() => { selectPlugin(plugin) }">
32+
{{ plugin.target }}/{{ plugin.client }}
2733
</button>
2834

2935
<h2>
3036
Examples
3137
</h2>
3238

3339
<div class="examples">
34-
<CodeExample target="node" :client="selectedClient" :request="{ url: 'https://example.com' }"/>
35-
<CodeExample target="node" :client="selectedClient" :request="{ url: 'https://example.com', method: 'POST' }"/>
36-
<CodeExample target="node" :client="selectedClient" :request="{ url: 'https://example.com', method: 'POST', headers: [
40+
<CodeExample :target="selectedTarget" :client="selectedClient" :request="{ url: 'https://example.com' }"/>
41+
<CodeExample :target="selectedTarget" :client="selectedClient" :request="{ url: 'https://example.com', method: 'POST' }"/>
42+
<CodeExample :target="selectedTarget" :client="selectedClient" :request="{ url: 'https://example.com', method: 'POST', headers: [
3743
{
3844
name: 'Content-Type',
3945
value: 'application/json'

0 commit comments

Comments
 (0)