-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,16 @@ | ||
<template> | ||
<button | ||
type="button" | ||
:class="classes" | ||
:style="style" | ||
@change="emit('myChangeEvent', 0)" | ||
@click="emit('myClickEvent', 0)" | ||
> | ||
{{ label }} | ||
</button> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import './button.css'; | ||
import { computed } from 'vue'; | ||
const props = withDefaults( | ||
defineProps<{ | ||
/** | ||
* The label of the button | ||
*/ | ||
label: string; | ||
/** | ||
* Whether the button is disabled | ||
*/ | ||
disabled: boolean; | ||
/** | ||
* primary or secondary button | ||
*/ | ||
primary?: boolean; | ||
/** | ||
* size of the button | ||
*/ | ||
size?: 'small' | 'medium' | 'large'; | ||
/** | ||
* background color of the button | ||
*/ | ||
backgroundColor?: string; | ||
}>(), | ||
{ primary: false } | ||
); | ||
<script setup lang="ts"> | ||
defineProps<{ disabled: boolean; label: string }>(); | ||
const emit = defineEmits<{ | ||
(e: 'myChangeEvent', id: number): void; | ||
(e: 'myClickEvent', id: number): void; | ||
}>(); | ||
</script> | ||
|
||
const classes = computed(() => ({ | ||
'storybook-button': true, | ||
'storybook-button--primary': props.primary, | ||
'storybook-button--secondary': !props.primary, | ||
[`storybook-button--${props.size || 'medium'}`]: true, | ||
})); | ||
<template> | ||
<button :disabled="disabled" @change="emit('myChangeEvent', 0)" @click="emit('myClickEvent', 0)"> | ||
{{ label }} | ||
</button> | ||
</template> | ||
|
||
const style = computed(() => ({ | ||
backgroundColor: props.backgroundColor, | ||
})); | ||
</script> | ||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
code/renderers/vue3/src/__tests__/composeStories/Button.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<template> | ||
<button type="button" :class="classes" :style="style" @click="emit('myClickEvent', 0)"> | ||
{{ label }} | ||
</button> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed } from 'vue'; | ||
const props = withDefaults( | ||
defineProps<{ | ||
/** | ||
* The label of the button | ||
*/ | ||
label: string; | ||
/** | ||
* primary or secondary button | ||
*/ | ||
primary?: boolean; | ||
/** | ||
* size of the button | ||
*/ | ||
size?: 'small' | 'medium' | 'large'; | ||
/** | ||
* background color of the button | ||
*/ | ||
backgroundColor?: string; | ||
}>(), | ||
{ primary: false } | ||
); | ||
const emit = defineEmits<{ | ||
(e: 'myClickEvent', id: number): void; | ||
}>(); | ||
const classes = computed(() => ({ | ||
'storybook-button': true, | ||
'storybook-button--primary': props.primary, | ||
'storybook-button--secondary': !props.primary, | ||
[`storybook-button--${props.size || 'medium'}`]: true, | ||
})); | ||
const style = computed(() => ({ | ||
backgroundColor: props.backgroundColor, | ||
})); | ||
</script> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters