Skip to content

Commit

Permalink
test: update radio story
Browse files Browse the repository at this point in the history
  • Loading branch information
toshusai committed Sep 11, 2024
1 parent be0f050 commit 0d0bfe9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
25 changes: 25 additions & 0 deletions packages/vue/src/components/CRadioGroup/CRadioGroup.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { h } from "vue";
import CRadioGroup from "./CRadioGroup.vue";

import StoryCRadioGroupBasic from "./stories/StoryCRadioGroupBasic.vue";
import StoryCRadioGroupUnControlled from "./stories/StoryCRadioGroupUnControlled.vue";
import { IconBuildingBank, IconCash, IconCreditCard } from "@tabler/icons-vue";

const meta = {
title: "inputs/CRadioGroup",
args: {
options: [],
},
component: CRadioGroup,
} satisfies Meta<typeof CRadioGroup>;

Expand Down Expand Up @@ -54,6 +58,27 @@ export const Disabled: Story = {
}),
};

export const Uncontrolled: Story = {
render: () =>
h(StoryCRadioGroupUnControlled, {
options: [
{
label: "Daily",
value: "daily",
},
{
label: "Weekly",
value: "weekly",
},
{
label: "Monthly",
value: "monthly",
},
],
uncontrolled: true,
}),
};

export const CustomOptions: Story = {
render: () => {
const spanStyle = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CRadioGroup, { RadioInputOption } from "../CRadioGroup.vue";
const picked = ref("");
const props = defineProps<{
options: RadioInputOption[];
size?: "M" | "L";
}>();
</script>

Expand All @@ -19,6 +20,11 @@ const props = defineProps<{
"
>
<div>Picked: {{ picked }}</div>
<CRadioGroup v-model="picked" name="radio" :options="props.options" />
<CRadioGroup
v-model="picked"
name="radio"
:options="props.options"
:size="size"
/>
</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup lang="ts">
import CRadioGroup, { RadioInputOption } from "../CRadioGroup.vue";
import CButton from "../../CButton/CButton.vue";
const props = defineProps<{
options: RadioInputOption[];
}>();
const handleSubmit = (e: Event) => {
e.preventDefault();
var formData = new FormData(e.target as HTMLFormElement);
const selected = formData.get("radio");
alert(`Selected: ${selected}`);
};
</script>

<template>
<form @submit="handleSubmit">
<div
style="
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16px;
"
>
<CRadioGroup name="radio" :options="props.options" />
<CButton type="submit" size="S">Submit</CButton>
</div>
</form>
</template>

0 comments on commit 0d0bfe9

Please sign in to comment.