Skip to content

Commit 864fab0

Browse files
committed
Adding card component and story.
1 parent ba67dae commit 864fab0

File tree

5 files changed

+76
-7
lines changed

5 files changed

+76
-7
lines changed

src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import Slider from './components/Slider.vue';
55

66
<template>
77
<div>
8-
<Slider>test</Slider>
8+
<Slider name="one">test</Slider>
9+
<Slider name="two"></Slider>
910
<a href="https://vitejs.dev" target="_blank">
1011
<img src="/vite.svg" class="logo" alt="Vite logo" />
1112
</a>

src/components/Card.stories.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { Meta, StoryObj } from '@storybook/vue3';
2+
3+
import Card from './Card.vue';
4+
5+
const meta: Meta<typeof Card> = {
6+
component: Card,
7+
};
8+
9+
//👇 This default export determines where your story goes in the story list
10+
export default meta;
11+
type Story = StoryObj<typeof Card>;
12+
13+
/*
14+
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
15+
* See https://storybook.js.org/docs/api/csf
16+
* to learn how to use render functions.
17+
*/
18+
export const Primary: Story = {
19+
render: (args) => ({
20+
components: { Card },
21+
setup() {
22+
return { args };
23+
},
24+
template: '<Card v-bind="args" />',
25+
}),
26+
args: {
27+
//👇 The args you need here will depend on your component
28+
heading: 'This is heading',
29+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
30+
},
31+
};

src/components/Card.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div class="card">
3+
<h3 class="title">{{ heading }}</h3>
4+
<p class="text">{{ text }}</p>
5+
</div>
6+
</template>
7+
<script setup lang="ts">
8+
9+
defineProps({
10+
heading: String,
11+
text: String
12+
})
13+
</script>
14+
<style scoped>
15+
.card {
16+
padding: 10px;
17+
border: 2px solid #cef;
18+
}
19+
</style>

src/components/Slider.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<script setup lang="ts">
22
3-
import {ref} from 'vue';
3+
import { ref } from 'vue';
44
const value = ref(0)
5+
defineProps(['name'])
56
</script>
67

78
<template>
8-
<h3>
9-
Slider
10-
</h3>
11-
<input type="range" v-model="value" />
12-
<div class="test">{{ value }}</div>
9+
<div>
10+
<h3>
11+
{{ $props.name }}
12+
</h3>
13+
<input type="range" v-model="value" />
14+
<div class="test">{{ value }}</div>
15+
</div>
1316
</template>

src/components/Text.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup lang="ts">
2+
import { ref } from 'vue';
3+
const text = ref(0)
4+
const props = defineProps(['name'])
5+
</script>
6+
7+
<template>
8+
<div>
9+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
10+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
11+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
12+
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
13+
</div>
14+
</template>
15+

0 commit comments

Comments
 (0)