2023-10-29 22:02:07 +03:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { logEvent } from 'histoire/client'
|
2024-01-25 12:41:37 +03:00
|
|
|
import { computed, ref } from 'vue'
|
2023-10-29 22:02:07 +03:00
|
|
|
|
|
|
|
import CheckboxWidget from '@/components/widgets/CheckboxWidget.vue'
|
|
|
|
import DropdownWidget from '@/components/widgets/DropdownWidget.vue'
|
2024-01-25 12:41:37 +03:00
|
|
|
import NumericInputWidget from '@/components/widgets/NumericInputWidget.vue'
|
2023-10-29 22:02:07 +03:00
|
|
|
|
|
|
|
// === Checkbox props ===
|
|
|
|
|
|
|
|
const checkboxState = ref(false)
|
|
|
|
|
|
|
|
// === Slider props ===
|
|
|
|
|
|
|
|
const state = ref(0)
|
|
|
|
const min = ref(0)
|
|
|
|
const max = ref(100)
|
2024-01-25 12:41:37 +03:00
|
|
|
const withLimits = ref(true)
|
|
|
|
const sliderLimits = computed(() => {
|
|
|
|
return withLimits.value ? { min: min.value, max: max.value } : undefined
|
|
|
|
})
|
2023-10-29 22:02:07 +03:00
|
|
|
|
|
|
|
// === Dropdown props ===
|
|
|
|
|
|
|
|
const color = ref('#357ab9')
|
2024-01-25 12:41:37 +03:00
|
|
|
const backgroundColor = ref('#4778b4')
|
2023-10-29 22:02:07 +03:00
|
|
|
const selectedValue = ref('location')
|
|
|
|
const values = ref(['address', 'age', 'id', 'language', 'location', 'workplace'])
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<Story title="Widgets" group="graph" :layout="{ type: 'grid', width: 200 }" autoPropsDisabled>
|
2024-01-25 12:41:37 +03:00
|
|
|
<Variant title="checkbox" :meta="{ customBackground: backgroundColor }">
|
|
|
|
<CheckboxWidget v-model="checkboxState" />
|
2023-10-29 22:02:07 +03:00
|
|
|
|
|
|
|
<template #controls>
|
|
|
|
<HstCheckbox v-model="checkboxState" title="v-model" />
|
|
|
|
</template>
|
|
|
|
</Variant>
|
2024-01-25 12:41:37 +03:00
|
|
|
<Variant title="numeric" :meta="{ customBackground: backgroundColor }">
|
|
|
|
<NumericInputWidget v-model="state" :limits="sliderLimits" />
|
2023-10-29 22:02:07 +03:00
|
|
|
|
|
|
|
<template #controls>
|
|
|
|
<HstSlider v-model="state" title="v-model" :min="min" :max="max" />
|
2024-01-25 12:41:37 +03:00
|
|
|
<HstCheckbox v-model="withLimits" title="With limits" />
|
2023-10-29 22:02:07 +03:00
|
|
|
<HstNumber v-model="min" title="min" />
|
|
|
|
<HstNumber v-model="max" title="max" />
|
|
|
|
</template>
|
|
|
|
</Variant>
|
|
|
|
<Variant title="dropdown">
|
|
|
|
<div style="height: 140px">
|
|
|
|
<div style="position: relative">
|
|
|
|
<DropdownWidget
|
|
|
|
:color="color"
|
|
|
|
:values="values"
|
|
|
|
:selectedValue="selectedValue"
|
|
|
|
@click="(selectedValue = values[$event]!), logEvent('click', [$event])"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<template #controls>
|
|
|
|
<HstColorSelect v-model="color" title="color" />
|
|
|
|
<HstSelect v-model="selectedValue" title="selectedValue" :options="values" />
|
|
|
|
<HstJson v-model="values" title="values" />
|
|
|
|
</template>
|
|
|
|
</Variant>
|
|
|
|
</Story>
|
|
|
|
</template>
|