-
Notifications
You must be signed in to change notification settings - Fork 149
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
1 changed file
with
28 additions
and
29 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,46 +1,45 @@ | ||
<template> | ||
<div :class="classes" :style="style" @click="onClick"> | ||
<t-button size="large" theme="primary" :class="[`${name}__button`]" v-bind="btnProps" :icon="() => iconTNode"> | ||
<t-button | ||
size="large" | ||
theme="primary" | ||
:shape="props.text ? 'round' : 'circle'" | ||
:class="[`${name}__button`]" | ||
v-bind="buttonProps" | ||
:icon="() => iconTNode" | ||
> | ||
{{ text }} | ||
</t-button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent, getCurrentInstance } from 'vue'; | ||
import { computed, defineProps, defineEmits, getCurrentInstance } from 'vue'; | ||
import { renderTNode, useEmitEvent } from '../shared'; | ||
import props from './props'; | ||
import fabProps from './props'; | ||
import config from '../config'; | ||
import TButton, { ButtonProps } from '../button'; | ||
import TButton from '../button'; | ||
const { prefix } = config; | ||
const name = `${prefix}-fab`; | ||
export default defineComponent({ | ||
export default { | ||
name, | ||
components: { TButton }, | ||
props, | ||
emits: ['click'], | ||
setup(props, context) { | ||
const internalInstance = getCurrentInstance(); | ||
const iconTNode = computed(() => renderTNode(internalInstance, 'icon')); | ||
const emitEvent = useEmitEvent(props, context.emit); | ||
const classes = computed(() => ({ | ||
[`${name}`]: true, | ||
})); | ||
const btnProps = computed<ButtonProps>(() => ({ shape: props.text ? 'round' : 'circle', ...props.buttonProps })); | ||
const onClick = (e: MouseEvent) => emitEvent('click', { e }); | ||
return { | ||
name, | ||
classes, | ||
btnProps, | ||
iconTNode, | ||
onClick, | ||
}; | ||
}, | ||
}); | ||
}; | ||
</script> | ||
|
||
<script lang="ts" setup> | ||
const props = defineProps(fabProps); | ||
const emit = defineEmits(['click']); | ||
const internalInstance = getCurrentInstance(); | ||
const iconTNode = computed(() => renderTNode(internalInstance, 'icon')); | ||
const emitEvent = useEmitEvent(props, emit); | ||
const classes = computed(() => ({ | ||
[`${name}`]: true, | ||
})); | ||
const onClick = (e: MouseEvent) => emitEvent('click', { e }); | ||
</script> |