refactor(components): refactor card (#3367)

This commit is contained in:
三咲智子 2021-09-13 10:51:11 +08:00 committed by GitHub
parent 04d1d13905
commit 60da0daf98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 26 deletions

View File

@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import Card from '../src/index.vue'
import Card from '../src/card.vue'
const AXIOM = 'Rem is the best girl'

View File

@ -1,12 +1,8 @@
import { App } from 'vue'
import type { SFCWithInstall } from '@element-plus/utils/types'
import Card from './src/index.vue'
import { withInstall } from '@element-plus/utils/with-install'
Card.install = (app: App): void => {
app.component(Card.name, Card)
}
import Card from './src/card.vue'
const _Card = Card as SFCWithInstall<typeof Card>
export const ElCard = withInstall(Card)
export default ElCard
export default _Card
export const ElCard = _Card
export * from './src/card'

View File

@ -0,0 +1,19 @@
import { buildProp } from '@element-plus/utils/props'
import type { ExtractPropTypes } from 'vue'
import type { StyleValue } from '@element-plus/utils/types'
export const cardProps = {
header: {
type: String,
default: '',
},
bodyStyle: buildProp<StyleValue>({
type: [String, Object, Array],
default: '',
}),
shadow: {
type: String,
default: '',
},
} as const
export type CardProps = ExtractPropTypes<typeof cardProps>

View File

@ -13,24 +13,10 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import type { PropType } from 'vue'
import type { StyleValue } from '@element-plus/utils/types'
import { cardProps } from './card'
export default defineComponent({
name: 'ElCard',
props: {
header: {
type: String,
default: '',
},
bodyStyle: {
type: [String, Object, Array] as PropType<StyleValue>,
default: '' as StyleValue,
},
shadow: {
type: String,
default: '',
},
},
props: cardProps,
})
</script>