feat: add basic

This commit is contained in:
aibayanyu 2023-03-06 07:28:23 +08:00
parent 9603871a40
commit 770471fc3d
2 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1,33 @@
import { computed, defineComponent } from 'vue'
import type { CSSInterpolation } from '@antd-tiny-vue/cssinjs'
import { useStyleRegister } from '@antd-tiny-vue/cssinjs'
import type { ThemeToken } from '../theme'
import { useToken } from '../theme'
export const generateButtonStyle = (prefixCls: string, token: ThemeToken): CSSInterpolation => ({
[`.${prefixCls}`]: {
backgroundColor: token.primaryColor,
padding: '10px 20px',
'&:hover': {
backgroundColor: 'red'
}
}
})
const Button = defineComponent({
name: 'AButton',
setup() {
const prefixCls = 'ant-btn'
const [theme, token, hashId] = useToken()
const info = computed<any>(() => ({
theme: theme.value,
token: token.value,
path: [prefixCls],
hashId: hashId.value
}))
const wrapSSR = useStyleRegister(info, () => [generateButtonStyle(prefixCls, token.value as any)])
return () => wrapSSR(<button class={[prefixCls, hashId.value]}></button>)
}
})
export default Button

View File

@ -7,10 +7,14 @@ title: 基础按钮
</docs> </docs>
<script lang="ts" setup></script> <script lang="ts" setup>
import Button from '../../../components/button'
</script>
<template> <template>
<div>按钮</div> <div>
<Button />
</div>
</template> </template>
<style scoped></style> <style scoped></style>