mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2024-11-10 17:49:18 +08:00
Compare commits
5 Commits
bed231bfb2
...
e5896c093a
Author | SHA1 | Date | |
---|---|---|---|
e5896c093a | |||
5d5653d3bd | |||
682dc06cdc | |||
9f19ed8c74 | |||
f394f48853 |
43
.vitepress/config.ts
Normal file
43
.vitepress/config.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
import { resolve } from 'path'
|
||||||
|
import { defineConfig } from 'vitepress'
|
||||||
|
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
|
||||||
|
import VitePluginVitepressDemo from 'vite-plugin-vitepress-demo'
|
||||||
|
import getEnUSConfig from './config/en-US'
|
||||||
|
import getZhCNConfig from './config/zh-CN'
|
||||||
|
import { getRewrites } from './config/rewrites'
|
||||||
|
const baseSrc = fileURLToPath(new URL('./', import.meta.url))
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
rewrites: getRewrites(),
|
||||||
|
mpa: true,
|
||||||
|
lang: 'en-US',
|
||||||
|
ignoreDeadLinks: true,
|
||||||
|
locales: {
|
||||||
|
'zh-CN': {
|
||||||
|
lang: 'zh-CN',
|
||||||
|
title: 'vue3组件库站点',
|
||||||
|
label: '简体中文',
|
||||||
|
description: 'vue3组件库站点',
|
||||||
|
themeConfig: getZhCNConfig()
|
||||||
|
},
|
||||||
|
root: {
|
||||||
|
lang: 'en-US',
|
||||||
|
title: 'vue3 component library site',
|
||||||
|
label: 'English',
|
||||||
|
description: 'vue3 component library site',
|
||||||
|
themeConfig: getEnUSConfig()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
vite: {
|
||||||
|
plugins: [vueJsxPlugin(), VitePluginVitepressDemo()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'antd-tiny-vue': resolve(baseSrc, '../components')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
port: 1199
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
9
.vitepress/config/en-US/index.ts
Normal file
9
.vitepress/config/en-US/index.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import type { DefaultTheme } from 'vitepress'
|
||||||
|
import { getNav } from './nav'
|
||||||
|
import { getSidebar } from './sidebar'
|
||||||
|
|
||||||
|
export default (): DefaultTheme.Config => ({
|
||||||
|
nav: getNav(),
|
||||||
|
sidebar: getSidebar(),
|
||||||
|
i18nRouting: true
|
||||||
|
})
|
@ -3,7 +3,7 @@ import type { DefaultTheme } from 'vitepress'
|
|||||||
export const getNav = (): DefaultTheme.NavItem[] => {
|
export const getNav = (): DefaultTheme.NavItem[] => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
text: '组件',
|
text: 'Components',
|
||||||
link: '/components/'
|
link: '/components/'
|
||||||
}
|
}
|
||||||
]
|
]
|
48
.vitepress/config/en-US/sidebar.ts
Normal file
48
.vitepress/config/en-US/sidebar.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import type { DefaultTheme } from 'vitepress'
|
||||||
|
|
||||||
|
const componentsDir = `/components/`
|
||||||
|
|
||||||
|
export const getSidebar = (): DefaultTheme.Sidebar => {
|
||||||
|
return {
|
||||||
|
[componentsDir]: [
|
||||||
|
{
|
||||||
|
text: 'General',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: 'Button',
|
||||||
|
link: `${componentsDir}button/`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Layout',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Navigation',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Data Entry',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Data Display',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Feedback',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Other',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: 'ConfigProvider',
|
||||||
|
link: `${componentsDir}config-provider/`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
9
.vitepress/config/rewrites.ts
Normal file
9
.vitepress/config/rewrites.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export const getRewrites = (): Record<string, string> => {
|
||||||
|
return {
|
||||||
|
'site/index.md': 'index.md',
|
||||||
|
'site/index.zh-CN.md': 'zh-CN/index.md',
|
||||||
|
'site/components/index.md': 'components/index.md',
|
||||||
|
'site/components/index.zh-CN.md': 'zh-CN/components/index.md',
|
||||||
|
'components/:comp/index.zh-CN.md': 'zh-CN/components/:comp/index.md'
|
||||||
|
}
|
||||||
|
}
|
9
.vitepress/config/zh-CN/index.ts
Normal file
9
.vitepress/config/zh-CN/index.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import type { DefaultTheme } from 'vitepress'
|
||||||
|
import { getNav } from './nav'
|
||||||
|
import { getSidebar } from './sidebar'
|
||||||
|
|
||||||
|
export default (): DefaultTheme.Config => ({
|
||||||
|
nav: getNav(),
|
||||||
|
sidebar: getSidebar(),
|
||||||
|
i18nRouting: true
|
||||||
|
})
|
10
.vitepress/config/zh-CN/nav.ts
Normal file
10
.vitepress/config/zh-CN/nav.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import type { DefaultTheme } from 'vitepress'
|
||||||
|
|
||||||
|
export const getNav = (): DefaultTheme.NavItem[] => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
text: '组件',
|
||||||
|
link: '/zh-CN/components/'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
.vitepress/config/zh-CN/sidebar.ts
Normal file
47
.vitepress/config/zh-CN/sidebar.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import type { DefaultTheme } from 'vitepress'
|
||||||
|
const componentsDir = `/zh-CN/components/`
|
||||||
|
|
||||||
|
export const getSidebar = (): DefaultTheme.Sidebar => {
|
||||||
|
return {
|
||||||
|
[componentsDir]: [
|
||||||
|
{
|
||||||
|
text: '通用',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: 'Button 按钮',
|
||||||
|
link: `${componentsDir}button/`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '布局',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '导航',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '数据入录',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '数据展示',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '反馈',
|
||||||
|
items: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '其他',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: 'ConfigProvider',
|
||||||
|
link: `${componentsDir}config-provider/`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,8 @@ import type { Theme } from 'vitepress'
|
|||||||
// eslint-disable-next-line import/no-named-as-default
|
// eslint-disable-next-line import/no-named-as-default
|
||||||
import DefaultTheme from 'vitepress/theme'
|
import DefaultTheme from 'vitepress/theme'
|
||||||
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'
|
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'
|
||||||
import Antd from '../../../components'
|
// @ts-expect-error this is a local module
|
||||||
|
import Antd from 'antd-tiny-vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...DefaultTheme,
|
...DefaultTheme,
|
@ -1,6 +1,12 @@
|
|||||||
import { computed, defineComponent, onMounted, shallowRef } from 'vue'
|
import { computed, defineComponent, onMounted, shallowRef } from 'vue'
|
||||||
import { tryOnBeforeUnmount } from '@vueuse/core'
|
import { tryOnBeforeUnmount } from '@vueuse/core'
|
||||||
import { classNames, filterEmpty, getSlotsProps, runEvent, useState } from '@v-c/utils'
|
import {
|
||||||
|
classNames,
|
||||||
|
filterEmpty,
|
||||||
|
getSlotsProps,
|
||||||
|
runEvent,
|
||||||
|
useState
|
||||||
|
} from '@v-c/utils'
|
||||||
import { useProviderConfigState } from '../config-provider/context'
|
import { useProviderConfigState } from '../config-provider/context'
|
||||||
import warning from '../_util/warning'
|
import warning from '../_util/warning'
|
||||||
import Wave from '../_util/wave'
|
import Wave from '../_util/wave'
|
||||||
@ -24,7 +30,7 @@ function getLoadingConfig(loading: ButtonProps['loading']): LoadingConfigType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loading: !!loading,
|
loading,
|
||||||
delay: 0
|
delay: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,11 +43,15 @@ const Button = defineComponent({
|
|||||||
...buttonProps
|
...buttonProps
|
||||||
},
|
},
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
const { getPrefixCls, autoInsertSpaceInButton, direction } = useProviderConfigState()
|
const { getPrefixCls, autoInsertSpaceInButton, direction } =
|
||||||
|
useProviderConfigState()
|
||||||
const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls))
|
const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls))
|
||||||
const [wrapSSR, hashId] = useStyle(prefixCls)
|
const [wrapSSR, hashId] = useStyle(prefixCls)
|
||||||
const size = useSize(props)
|
const size = useSize(props)
|
||||||
const { compactSize, compactItemClassnames } = useCompactItemContext(prefixCls, direction)
|
const { compactSize, compactItemClassnames } = useCompactItemContext(
|
||||||
|
prefixCls,
|
||||||
|
direction
|
||||||
|
)
|
||||||
const sizeCls = computed(() => {
|
const sizeCls = computed(() => {
|
||||||
const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined }
|
const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined }
|
||||||
const sizeFullname = compactSize?.value || size.value
|
const sizeFullname = compactSize?.value || size.value
|
||||||
@ -54,7 +64,9 @@ const Button = defineComponent({
|
|||||||
return getLoadingConfig(props.loading)
|
return getLoadingConfig(props.loading)
|
||||||
})
|
})
|
||||||
|
|
||||||
const [innerLoading, setLoading] = useState<Loading>(loadingOrDelay.value.loading)
|
const [innerLoading, setLoading] = useState<Loading>(
|
||||||
|
loadingOrDelay.value.loading
|
||||||
|
)
|
||||||
const [hasTwoCNChar, setHasTwoCNChar] = useState(false)
|
const [hasTwoCNChar, setHasTwoCNChar] = useState(false)
|
||||||
|
|
||||||
let delayTimer: number | null = null
|
let delayTimer: number | null = null
|
||||||
@ -95,9 +107,17 @@ const Button = defineComponent({
|
|||||||
|
|
||||||
const icon = getSlotsProps(slots, props, 'icon')
|
const icon = getSlotsProps(slots, props, 'icon')
|
||||||
|
|
||||||
warning(!(typeof icon === 'string' && icon.length > 2), 'Button', `\`icon\` is using ReactNode instead of string naming in v4. Please check \`${icon}\` at https://ant.design/components/icon`)
|
warning(
|
||||||
|
!(typeof icon === 'string' && icon.length > 2),
|
||||||
|
'Button',
|
||||||
|
`\`icon\` is using ReactNode instead of string naming in v4. Please check \`${icon}\` at https://ant.design/components/icon`
|
||||||
|
)
|
||||||
|
|
||||||
warning(!(ghost && isUnBorderedButtonType(type)), 'Button', "`link` or `text` button can't be a `ghost` button.")
|
warning(
|
||||||
|
!(ghost && isUnBorderedButtonType(type)),
|
||||||
|
'Button',
|
||||||
|
"`link` or `text` button can't be a `ghost` button."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@ -105,7 +125,11 @@ const Button = defineComponent({
|
|||||||
const icon = getSlotsProps(slots, props, 'icon')
|
const icon = getSlotsProps(slots, props, 'icon')
|
||||||
const children = filterEmpty(slots.default?.())
|
const children = filterEmpty(slots.default?.())
|
||||||
const isNeedInserted = () => {
|
const isNeedInserted = () => {
|
||||||
return children.length === 1 && !slots.icon && isUnBorderedButtonType(props.type)
|
return (
|
||||||
|
children.length === 1 &&
|
||||||
|
!slots.icon &&
|
||||||
|
isUnBorderedButtonType(props.type)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixTwoCNChar = () => {
|
const fixTwoCNChar = () => {
|
||||||
@ -137,10 +161,13 @@ const Button = defineComponent({
|
|||||||
[`${prefixCls.value}-${shape}`]: shape !== 'default' && shape,
|
[`${prefixCls.value}-${shape}`]: shape !== 'default' && shape,
|
||||||
[`${prefixCls.value}-${type}`]: type,
|
[`${prefixCls.value}-${type}`]: type,
|
||||||
[`${prefixCls.value}-${sizeCls.value}`]: sizeCls.value,
|
[`${prefixCls.value}-${sizeCls.value}`]: sizeCls.value,
|
||||||
[`${prefixCls.value}-icon-only`]: !children && children !== 0 && !!iconType,
|
[`${prefixCls.value}-icon-only`]:
|
||||||
[`${prefixCls.value}-background-ghost`]: ghost && !isUnBorderedButtonType(type),
|
!children && children !== 0 && !!iconType,
|
||||||
|
[`${prefixCls.value}-background-ghost`]:
|
||||||
|
ghost && !isUnBorderedButtonType(type),
|
||||||
[`${prefixCls.value}-loading`]: innerLoading.value,
|
[`${prefixCls.value}-loading`]: innerLoading.value,
|
||||||
[`${prefixCls.value}-two-chinese-chars`]: hasTwoCNChar.value && autoInsertSpace && !innerLoading.value,
|
[`${prefixCls.value}-two-chinese-chars`]:
|
||||||
|
hasTwoCNChar.value && autoInsertSpace && !innerLoading.value,
|
||||||
[`${prefixCls.value}-block`]: block,
|
[`${prefixCls.value}-block`]: block,
|
||||||
[`${prefixCls.value}-dangerous`]: !!danger,
|
[`${prefixCls.value}-dangerous`]: !!danger,
|
||||||
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
|
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
|
||||||
@ -167,11 +194,7 @@ const Button = defineComponent({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
let buttonNode = (
|
let buttonNode = (
|
||||||
<button
|
<button {...attrs} onClick={handleClick} class={classes}>
|
||||||
{...attrs}
|
|
||||||
onClick={handleClick}
|
|
||||||
class={classes}
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
25
components/button/demo/basic.vue
Normal file
25
components/button/demo/basic.vue
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<docs lang="zh-CN">
|
||||||
|
---
|
||||||
|
title: 按钮类型
|
||||||
|
---
|
||||||
|
|
||||||
|
按钮有五种类型:主按钮、次按钮、虚线按钮、文本按钮和链接按钮。主按钮在同一个操作区域最多出现一次。
|
||||||
|
</docs>
|
||||||
|
|
||||||
|
<docs lang="en-US">
|
||||||
|
---
|
||||||
|
title: Type
|
||||||
|
---
|
||||||
|
|
||||||
|
There are `primary` button, `default` button, `dashed` button, `text` button and `link` button in antd.
|
||||||
|
</docs>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<a-button type="primary">Primary Button</a-button>
|
||||||
|
<a-button>Default Button</a-button>
|
||||||
|
<a-button type="dashed">Dashed Button</a-button>
|
||||||
|
<a-button type="text">Text Button</a-button>
|
||||||
|
<a-button type="link">Link Button</a-button>
|
||||||
|
</template>
|
@ -1,13 +0,0 @@
|
|||||||
<docs>
|
|
||||||
---
|
|
||||||
title: Basic
|
|
||||||
---
|
|
||||||
|
|
||||||
这是基础按钮
|
|
||||||
</docs>
|
|
||||||
|
|
||||||
<script lang="ts" setup></script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div></div>
|
|
||||||
</template>
|
|
@ -1 +1,67 @@
|
|||||||
# Button
|
# Button
|
||||||
|
|
||||||
|
To trigger an operation.
|
||||||
|
|
||||||
|
## When To Use
|
||||||
|
|
||||||
|
A button means an operation (or a series of operations). Clicking a button will trigger corresponding business logic.
|
||||||
|
|
||||||
|
In Ant Design we provide 5 types of button.
|
||||||
|
|
||||||
|
- Primary button: indicate the main action, one primary button at most in one section.
|
||||||
|
- Default button: indicate a series of actions without priority.
|
||||||
|
- Dashed button: used for adding action commonly.
|
||||||
|
- Text button: used for the most secondary action.
|
||||||
|
- Link button: used for external links.
|
||||||
|
|
||||||
|
And 4 other properties additionally.
|
||||||
|
|
||||||
|
- `danger`: used for actions of risk, like deletion or authorization.
|
||||||
|
- `ghost`: used in situations with complex background, home pages usually.
|
||||||
|
- `disabled`: when actions are not available.
|
||||||
|
- `loading`: add loading spinner in button, avoiding multiple submits too.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
<demo src="./demo/basic.vue"></demo>
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
Different button styles can be generated by setting Button properties. The recommended order is: `type` -> `shape` -> `size` -> `loading` -> `disabled`.
|
||||||
|
|
||||||
|
| Property | Description | Type | Default | Version |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| block | Option to fit button width to its parent width | boolean | false | |
|
||||||
|
| danger | Set the danger status of button | boolean | false | |
|
||||||
|
| disabled | Disabled state of button | boolean | false | |
|
||||||
|
| ghost | Make background transparent and invert text and border colors | boolean | false | |
|
||||||
|
| href | Redirect url of link button | string | - | |
|
||||||
|
| htmlType | Set the original html `type` of `button`, see: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | |
|
||||||
|
| icon | Set the icon component of button | ReactNode | - | |
|
||||||
|
| loading | Set the loading status of button | boolean \| { delay: number } | false | |
|
||||||
|
| shape | Can be set button shape | `default` \| `circle` \| `round` | `default` | |
|
||||||
|
| size | Set the size of button | `large` \| `middle` \| `small` | `middle` | |
|
||||||
|
| target | Same as target attribute of a, works when href is specified | string | - | |
|
||||||
|
| type | Can be set to `primary` `ghost` `dashed` `link` `text` `default` | string | `default` | |
|
||||||
|
| onClick | Set the handler to handle `click` event | (event: MouseEvent) => void | - | |
|
||||||
|
|
||||||
|
It accepts all props which native buttons support.
|
||||||
|
|
||||||
|
## Design Token
|
||||||
|
|
||||||
|
<ComponentTokenTable component="Button"></ComponentTokenTable>
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### How to remove space between 2 chinese characters?
|
||||||
|
|
||||||
|
Following the Ant Design specification, we will add one space between if Button (exclude Text button and Link button) contains two Chinese characters only. If you don't need that, you can use [ConfigProvider](/components/config-provider/#api) to set `autoInsertSpaceInButton` as `false`.
|
||||||
|
|
||||||
|
<img src="https://gw.alipayobjects.com/zos/antfincdn/MY%26THAPZrW/38f06cb9-293a-4b42-b183-9f443e79ffea.png" style="box-shadow: none; margin: 0; width: 100px" alt="Button with two Chinese characters" />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.site-button-ghost-wrapper {
|
||||||
|
padding: 16px;
|
||||||
|
background: rgb(190, 200, 200);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -1 +1,76 @@
|
|||||||
# Button 按钮
|
# Button 按钮
|
||||||
|
|
||||||
|
按钮用于开始一个即时操作。
|
||||||
|
|
||||||
|
## 何时使用
|
||||||
|
|
||||||
|
标记了一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。
|
||||||
|
|
||||||
|
在 Ant Design 中我们提供了五种按钮。
|
||||||
|
|
||||||
|
- 主按钮:用于主行动点,一个操作区域只能有一个主按钮。
|
||||||
|
- 默认按钮:用于没有主次之分的一组行动点。
|
||||||
|
- 虚线按钮:常用于添加操作。
|
||||||
|
- 文本按钮:用于最次级的行动点。
|
||||||
|
- 链接按钮:一般用于链接,即导航至某位置。
|
||||||
|
|
||||||
|
以及四种状态属性与上面配合使用。
|
||||||
|
|
||||||
|
- 危险:删除/移动/修改权限等危险操作,一般需要二次确认。
|
||||||
|
- 幽灵:用于背景色比较复杂的地方,常用在首页/产品页等展示场景。
|
||||||
|
- 禁用:行动点不可用的时候,一般需要文案解释。
|
||||||
|
- 加载中:用于异步操作等待反馈的时候,也可以避免多次提交。
|
||||||
|
|
||||||
|
[完整设计指南](https://ant.design/docs/spec/buttons-cn)
|
||||||
|
|
||||||
|
## 代码演示
|
||||||
|
|
||||||
|
<demo src="./demo/basic.vue"></demo>
|
||||||
|
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
通过设置 Button 的属性来产生不同的按钮样式,推荐顺序为:`type` -> `shape` -> `size` -> `loading` -> `disabled`。
|
||||||
|
|
||||||
|
按钮的属性说明如下:
|
||||||
|
|
||||||
|
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| block | 将按钮宽度调整为其父宽度的选项 | boolean | false | |
|
||||||
|
| danger | 设置危险按钮 | boolean | false | |
|
||||||
|
| disabled | 设置按钮失效状态 | boolean | false | |
|
||||||
|
| ghost | 幽灵属性,使按钮背景透明 | boolean | false | |
|
||||||
|
| href | 点击跳转的地址,指定此属性 button 的行为和 a 链接一致 | string | - | |
|
||||||
|
| htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 [HTML 标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` | |
|
||||||
|
| icon | 设置按钮的图标组件 | ReactNode | - | |
|
||||||
|
| loading | 设置按钮载入状态 | boolean \| { delay: number } | false | |
|
||||||
|
| shape | 设置按钮形状 | `default` \| `circle` \| `round` | `default` | |
|
||||||
|
| size | 设置按钮大小 | `large` \| `middle` \| `small` | `middle` | |
|
||||||
|
| target | 相当于 a 链接的 target 属性,href 存在时生效 | string | - | |
|
||||||
|
| type | 设置按钮类型 | `primary` \| `ghost` \| `dashed` \| `link` \| `text` \| `default` | `default` | |
|
||||||
|
| onClick | 点击按钮时的回调 | (event: MouseEvent) => void | - | |
|
||||||
|
|
||||||
|
支持原生 button 的其他所有属性。
|
||||||
|
|
||||||
|
## Design Token
|
||||||
|
|
||||||
|
<ComponentTokenTable component="Button"></ComponentTokenTable>
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### 如何移除两个汉字之间的空格?
|
||||||
|
|
||||||
|
根据 Ant Design 设计规范要求,我们会在按钮内(文本按钮和链接按钮除外)只有两个汉字时自动添加空格,如果你不需要这个特性,可以设置 [ConfigProvider](/zh-CN/components/config-provider/#api) 的 `autoInsertSpaceInButton` 为 `false`。
|
||||||
|
|
||||||
|
<img src="https://gw.alipayobjects.com/zos/antfincdn/MY%26THAPZrW/38f06cb9-293a-4b42-b183-9f443e79ffea.png" style="box-shadow: none; margin: 0; width: 100px" alt="移除两个汉字之间的空格" />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.site-button-ghost-wrapper {
|
||||||
|
padding: 16px;
|
||||||
|
background: rgb(190, 200, 200);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
## 设计指引
|
||||||
|
|
||||||
|
- [我的按钮究竟该放哪儿!?| Ant Design 4.0 系列分享](https://zhuanlan.zhihu.com/p/109644406)
|
||||||
|
1
components/config-provider/index.md
Normal file
1
components/config-provider/index.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# ConfigProvider
|
1
components/config-provider/index.zh-CN.md
Normal file
1
components/config-provider/index.zh-CN.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# ConfigProvider 全局配置
|
@ -1,5 +1,6 @@
|
|||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
import * as components from './components'
|
import * as components from './components'
|
||||||
|
import version from './version'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app: App) {
|
install(app: App) {
|
||||||
@ -9,5 +10,6 @@ export default {
|
|||||||
app.use(component)
|
app.use(component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
version
|
||||||
}
|
}
|
||||||
|
29
components/space/style/compact.tsx
Normal file
29
components/space/style/compact.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import type { FullToken, GenerateStyle } from '../../theme/internal'
|
||||||
|
/** Component only token. Which will handle additional calculation of alias token */
|
||||||
|
export interface ComponentToken {
|
||||||
|
// Component token here
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SpaceToken extends FullToken<'Space'> {
|
||||||
|
// Custom token here
|
||||||
|
}
|
||||||
|
|
||||||
|
const genSpaceCompactStyle: GenerateStyle<SpaceToken> = (token) => {
|
||||||
|
const { componentCls } = token
|
||||||
|
|
||||||
|
return {
|
||||||
|
[componentCls]: {
|
||||||
|
display: 'inline-flex',
|
||||||
|
'&-block': {
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%'
|
||||||
|
},
|
||||||
|
'&-vertical': {
|
||||||
|
flexDirection: 'column'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Export ==============================
|
||||||
|
export default genSpaceCompactStyle
|
54
components/space/style/index.tsx
Normal file
54
components/space/style/index.tsx
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import type { FullToken, GenerateStyle } from '../../theme/internal'
|
||||||
|
import { genComponentStyleHook } from '../../theme/internal'
|
||||||
|
import genSpaceCompactStyle from './compact'
|
||||||
|
|
||||||
|
/** Component only token. Which will handle additional calculation of alias token */
|
||||||
|
export interface ComponentToken {
|
||||||
|
// Component token here
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SpaceToken extends FullToken<'Space'> {
|
||||||
|
// Custom token here
|
||||||
|
}
|
||||||
|
|
||||||
|
const genSpaceStyle: GenerateStyle<SpaceToken> = (token) => {
|
||||||
|
const { componentCls } = token
|
||||||
|
|
||||||
|
return {
|
||||||
|
[componentCls]: {
|
||||||
|
display: 'inline-flex',
|
||||||
|
'&-rtl': {
|
||||||
|
direction: 'rtl'
|
||||||
|
},
|
||||||
|
'&-vertical': {
|
||||||
|
flexDirection: 'column'
|
||||||
|
},
|
||||||
|
'&-align': {
|
||||||
|
flexDirection: 'column',
|
||||||
|
'&-center': {
|
||||||
|
alignItems: 'center'
|
||||||
|
},
|
||||||
|
'&-start': {
|
||||||
|
alignItems: 'flex-start'
|
||||||
|
},
|
||||||
|
'&-end': {
|
||||||
|
alignItems: 'flex-end'
|
||||||
|
},
|
||||||
|
'&-baseline': {
|
||||||
|
alignItems: 'baseline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[`${componentCls}-item`]: {
|
||||||
|
'&:empty': {
|
||||||
|
display: 'none'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Export ==============================
|
||||||
|
export default genComponentStyleHook('Space', (token) => [
|
||||||
|
genSpaceStyle(token),
|
||||||
|
genSpaceCompactStyle(token)
|
||||||
|
])
|
@ -34,7 +34,7 @@ import type { ComponentToken as ButtonComponentToken } from '../../button/style'
|
|||||||
// import type { ComponentToken as SelectComponentToken } from '../../select/style'
|
// import type { ComponentToken as SelectComponentToken } from '../../select/style'
|
||||||
// import type { ComponentToken as SkeletonComponentToken } from '../../skeleton/style'
|
// import type { ComponentToken as SkeletonComponentToken } from '../../skeleton/style'
|
||||||
// import type { ComponentToken as SliderComponentToken } from '../../slider/style'
|
// import type { ComponentToken as SliderComponentToken } from '../../slider/style'
|
||||||
// import type { ComponentToken as SpaceComponentToken } from '../../space/style'
|
import type { ComponentToken as SpaceComponentToken } from '../../space/style'
|
||||||
// import type { ComponentToken as SpinComponentToken } from '../../spin/style'
|
// import type { ComponentToken as SpinComponentToken } from '../../spin/style'
|
||||||
// import type { ComponentToken as StepsComponentToken } from '../../steps/style'
|
// import type { ComponentToken as StepsComponentToken } from '../../steps/style'
|
||||||
// import type { ComponentToken as TableComponentToken } from '../../table/style'
|
// import type { ComponentToken as TableComponentToken } from '../../table/style'
|
||||||
@ -108,7 +108,7 @@ export interface ComponentTokenMap {
|
|||||||
// Upload?: UploadComponentToken
|
// Upload?: UploadComponentToken
|
||||||
// Tooltip?: TooltipComponentToken
|
// Tooltip?: TooltipComponentToken
|
||||||
// Table?: TableComponentToken
|
// Table?: TableComponentToken
|
||||||
// Space?: SpaceComponentToken
|
Space?: SpaceComponentToken
|
||||||
// Progress?: ProgressComponentToken
|
// Progress?: ProgressComponentToken
|
||||||
// Tour?: TourComponentToken
|
// Tour?: TourComponentToken
|
||||||
// QRCode?: QRCodeComponentToken
|
// QRCode?: QRCodeComponentToken
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Antd Tiny Vue</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script type="module" src="/src/main.ts"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||||||
<script lang="ts" setup></script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<router-view />
|
|
||||||
</template>
|
|
@ -1,5 +0,0 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
import App from './App.vue'
|
|
||||||
const app = createApp(App)
|
|
||||||
|
|
||||||
app.mount('#app')
|
|
@ -1,7 +0,0 @@
|
|||||||
<script lang="ts" setup></script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<!-- -->
|
|
||||||
</div>
|
|
||||||
</template>
|
|
@ -1,6 +0,0 @@
|
|||||||
import { defineConfig } from 'vite'
|
|
||||||
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
|
|
||||||
import vue from '@vitejs/plugin-vue'
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [vue(), vueJsxPlugin()]
|
|
||||||
})
|
|
32
package.json
32
package.json
@ -1,17 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "antd-tiny-vue",
|
"name": "antd-tiny-vue",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "this is a tiny antd components for vue3",
|
||||||
"keywords": [],
|
"keywords": [
|
||||||
|
"antd",
|
||||||
|
"ant-design-vue",
|
||||||
|
"ant-design",
|
||||||
|
"vue3",
|
||||||
|
"vue3-components",
|
||||||
|
"components"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "aibayanyu",
|
"author": "aibayanyu",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"dev": "vitepress dev site",
|
"dev": "vitepress dev",
|
||||||
"build:site": "vitepress build site",
|
"build:site": "vitepress build",
|
||||||
"preview": "vitepress preview site"
|
"preview": "vitepress preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/colors": "^7.0.0",
|
"@ant-design/colors": "^7.0.0",
|
||||||
@ -24,22 +31,21 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^17.5.0",
|
"@commitlint/cli": "^17.5.0",
|
||||||
"@commitlint/config-conventional": "^17.4.4",
|
"@commitlint/config-conventional": "^17.4.4",
|
||||||
"@mistjs/eslint-config-vue-jsx": "^0.0.3",
|
"@mistjs/eslint-config-vue-jsx": "^0.0.7",
|
||||||
"@mistjs/tsconfig": "^1.0.0",
|
"@mistjs/tsconfig": "^1.0.0",
|
||||||
"@mistjs/tsconfig-vue": "^0.0.3",
|
"@mistjs/tsconfig-vue": "^0.0.3",
|
||||||
"@types/node": "^18.15.9",
|
"@types/node": "^18.15.10",
|
||||||
"@vitejs/plugin-vue": "^4.1.0",
|
|
||||||
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
||||||
"eslint": "^8.36.0",
|
"eslint": "^8.36.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^13.2.0",
|
"lint-staged": "^13.2.0",
|
||||||
"prettier": "^2.8.7",
|
"prettier": "^2.8.7",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
|
"unbuild": "^1.1.2",
|
||||||
"vite": "^4.2.1",
|
"vite": "^4.2.1",
|
||||||
"vite-plugin-vitepress-demo": "2.0.0-beta.26",
|
"vite-plugin-vitepress-demo": "2.0.0-beta.28",
|
||||||
"vitepress": "1.0.0-alpha.63",
|
"vitepress": "1.0.0-alpha.69",
|
||||||
"vitest": "^0.28.5",
|
"vitest": "^0.28.5"
|
||||||
"vue-router": "^4.1.6"
|
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"peerDependencyRules": {
|
"peerDependencyRules": {
|
||||||
|
705
pnpm-lock.yaml
705
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
|||||||
import { defineConfig } from 'vitepress'
|
|
||||||
import { getNav } from './config/nav'
|
|
||||||
import { getSidebar } from './config/sidebar'
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
title: 'vue3组件库站点',
|
|
||||||
themeConfig: {
|
|
||||||
nav: getNav(),
|
|
||||||
sidebar: getSidebar()
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,12 +0,0 @@
|
|||||||
import type { DefaultTheme } from 'vitepress'
|
|
||||||
|
|
||||||
export const getSidebar = (): DefaultTheme.Sidebar => {
|
|
||||||
return {
|
|
||||||
'/components/': [
|
|
||||||
{
|
|
||||||
text: 'Button 按钮',
|
|
||||||
link: '/components/button/'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
# Button 按钮
|
|
||||||
|
|
||||||
按钮用于开始一个即时操作。
|
|
||||||
|
|
||||||
|
|
||||||
## 演示例子
|
|
||||||
|
|
||||||
|
|
||||||
<demo src="../../demos/button/basic.vue"></demo>
|
|
@ -1,3 +1 @@
|
|||||||
# 组件列表
|
# Components
|
||||||
|
|
||||||
* [button](./button/)
|
|
||||||
|
1
site/components/index.zh-CN.md
Normal file
1
site/components/index.zh-CN.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# 组件
|
@ -1,25 +0,0 @@
|
|||||||
<docs>
|
|
||||||
---
|
|
||||||
title: 基础按钮
|
|
||||||
---
|
|
||||||
|
|
||||||
这是一个Button的基础按钮
|
|
||||||
|
|
||||||
</docs>
|
|
||||||
|
|
||||||
<script lang="ts" setup></script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div style="display: flex; gap: 10px; padding-bottom: 10px">
|
|
||||||
<a-button>这是按钮</a-button>
|
|
||||||
<a-button type="primary">这是按钮</a-button>
|
|
||||||
<a-button
|
|
||||||
type="primary"
|
|
||||||
danger
|
|
||||||
>
|
|
||||||
这是按钮
|
|
||||||
</a-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
@ -10,7 +10,7 @@ hero:
|
|||||||
tagline: Simple, powerful, and performant. Meet the modern SSG framework you've always wanted.
|
tagline: Simple, powerful, and performant. Meet the modern SSG framework you've always wanted.
|
||||||
actions:
|
actions:
|
||||||
- theme: brand
|
- theme: brand
|
||||||
text: 组件
|
text: Components
|
||||||
link: /components/
|
link: /components/
|
||||||
- theme: alt
|
- theme: alt
|
||||||
text: View on GitHub
|
text: View on GitHub
|
||||||
|
28
site/index.zh-CN.md
Normal file
28
site/index.zh-CN.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
layout: home
|
||||||
|
|
||||||
|
title: Antd Tiny Vue
|
||||||
|
titleTemplate: Vite & Vue Powered Static Site Generator
|
||||||
|
|
||||||
|
hero:
|
||||||
|
name: Antd Tiny Vue
|
||||||
|
text: Vite & Vue Powered Static Site Generator
|
||||||
|
tagline: Simple, powerful, and performant. Meet the modern SSG framework you've always wanted.
|
||||||
|
actions:
|
||||||
|
- theme: brand
|
||||||
|
text: 组件
|
||||||
|
link: /zh-CN/components/
|
||||||
|
- theme: alt
|
||||||
|
text: View on GitHub
|
||||||
|
link: https://github.com/antd-tiny-vue/antd-tiny-vue
|
||||||
|
|
||||||
|
features:
|
||||||
|
- title: "Vite: The DX that can't be beat"
|
||||||
|
details: Feel the speed of Vite. Instant server start and lightning fast HMR that stays fast regardless of the app size.
|
||||||
|
- title: Designed to be simplicity first
|
||||||
|
details: With Markdown-centered content, it's built to help you focus on writing and deployed with minimum configuration.
|
||||||
|
- title: Power of Vue meets Markdown
|
||||||
|
details: Enhance your content with all the features of Vue in Markdown, while being able to customize your site with Vue.
|
||||||
|
- title: Fully static yet still dynamic
|
||||||
|
details: Go wild with true SSG + SPA architecture. Static on page load, but engage users with 100% interactivity from there.
|
||||||
|
---
|
@ -1,7 +0,0 @@
|
|||||||
import { defineConfig } from 'vite'
|
|
||||||
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
|
|
||||||
import VitePluginVitepressDemo from 'vite-plugin-vitepress-demo'
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [vueJsxPlugin(), VitePluginVitepressDemo()]
|
|
||||||
})
|
|
Loading…
Reference in New Issue
Block a user