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-30 17:05:28 +03:00
|
|
|
import EnsoTextInputWidget from '@/components/widgets/EnsoTextInputWidget.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)
|
|
|
|
|
2024-01-30 17:05:28 +03:00
|
|
|
// === Numeric props ===
|
2023-10-29 22:02:07 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
2024-01-30 17:05:28 +03:00
|
|
|
// === Text props ===
|
|
|
|
|
|
|
|
const text = ref('')
|
|
|
|
|
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>
|
2024-01-30 17:05:28 +03:00
|
|
|
<Variant title="text" :meta="{ customBackground: backgroundColor }">
|
|
|
|
<EnsoTextInputWidget v-model="text" />
|
|
|
|
|
|
|
|
<template #controls>
|
|
|
|
<HstText v-model="text" title="v-model" />
|
|
|
|
</template>
|
|
|
|
</Variant>
|
2023-10-29 22:02:07 +03:00
|
|
|
<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>
|