button-group
Segmented order type selector
Segmented order type selector
Загрузка превью…
src/button-group/c-button-group-42.vue
<script setup lang="ts">
import { ref } from "vue"
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
const orderTypes = [
{
id: "market",
label: "Market",
tooltip: "Execute immediately at best available price",
icon: "trending-up",
},
{
id: "limit",
label: "Limit",
tooltip: "Execute only at your specified price or better",
icon: "target",
},
{
id: "stop",
label: "Stop",
tooltip: "Trigger a market order at stop level",
icon: "shield-alert",
},
{
id: "stop-limit",
label: "Stop-Limit",
tooltip: "Trigger a limit order at stop level",
icon: "shield-check",
},
]
const active = ref("market")
</script>
<template>
<ButtonGroup>
<TooltipProvider>
<Tooltip v-for="type in orderTypes" :key="type.id">
<TooltipTrigger as-child>
<Button
variant="outline"
:class="active === type.id ? 'bg-muted' : ''"
@click="active = type.id"
>
<svg
v-if="type.icon === 'trending-up'"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="lucide lucide-trending-up"
>
<path d="M16 7h6v6" />
<path d="m22 7-8.5 8.5-5-5L2 17" />
</svg>
<svg
v-else-if="type.icon === 'target'"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="lucide lucide-target"
>
<circle cx="12" cy="12" r="10" />
<circle cx="12" cy="12" r="6" />
<circle cx="12" cy="12" r="2" />
</svg>
<svg
v-else-if="type.icon === 'shield-alert'"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="lucide lucide-shield-alert"
>
<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" />
<path d="M12 8v4" />
<path d="M12 16h.01" />
</svg>
<svg
v-else
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="lucide lucide-shield-check"
>
<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" />
<path d="m9 12 2 2 4-4" />
</svg>
{{ type.label }}
</Button>
</TooltipTrigger>
<TooltipContent class="max-w-52 text-center">
{{ type.tooltip }}
</TooltipContent>
</Tooltip>
</TooltipProvider>
</ButtonGroup>
</template>
Установка
npx shadcn-vue@latest add https://revueui.rootapi.dev/r/c-button-group-42.jsonЗависимости реестра
Источник: порт из ReUI (Keenthemes, MIT)