feat(button): tag prop

This commit is contained in:
07akioni 2021-05-19 12:03:35 +08:00
parent 7b9bd91f2e
commit b792f0b529
10 changed files with 60 additions and 37 deletions

View File

@ -1,5 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-button` add `tag` prop.
## 2.8.0
### Perf

View File

@ -1,5 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-button` 新增 `tag` 属性
## 2.8.0
### Perf

View File

@ -9,6 +9,7 @@ basic
dashed
size
text
tag
disabled
icon
events

View File

@ -0,0 +1,14 @@
# Tag
You can render button as different tags. For example `<a />`. 你可以把按钮渲染成不同的标签,比如 `<a />`
```html
<n-button
text
tag="a"
href="https://anyway.fm/news.php"
target="_blank"
type="primary"
>Anyway.News</n-button
>
```

View File

@ -1,6 +1,6 @@
# Text Button
Somebody also calls it `link` button.
Just look like text.
```html
<n-button text>

View File

@ -9,6 +9,7 @@ basic
dashed
size
text
tag
disabled
icon
events

View File

@ -0,0 +1,14 @@
# 标签
你可以把按钮渲染成不同的标签,比如 `<a />`
```html
<n-button
text
tag="a"
href="https://anyway.fm/news.php"
target="_blank"
type="primary"
>安妮薇时报</n-button
>
```

View File

@ -1,6 +1,6 @@
# 文本按钮
有些人也会叫他 `link` 按钮
长得就像文本
```html
<n-button text>

View File

@ -31,35 +31,14 @@ import style from './styles/button.cssr'
const buttonProps = {
...(useTheme.props as ThemeProps<ButtonTheme>),
color: String,
text: {
type: Boolean,
default: false
},
block: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
circle: {
type: Boolean,
default: false
},
text: Boolean,
block: Boolean,
loading: Boolean,
disabled: Boolean,
circle: Boolean,
size: String as PropType<Size>,
ghost: {
type: Boolean,
default: false
},
round: {
type: Boolean,
default: false
},
ghost: Boolean,
round: Boolean,
focusable: {
type: Boolean,
default: true
@ -68,14 +47,15 @@ const buttonProps = {
type: Boolean,
default: true
},
tag: {
type: String as PropType<keyof HTMLElementTagNameMap>,
default: 'button'
},
type: {
type: String as PropType<Type>,
default: 'default'
},
dashed: {
type: Boolean,
default: false
},
dashed: Boolean,
iconPlacement: {
type: String as PropType<'left' | 'right'>,
default: 'left'
@ -389,9 +369,9 @@ export default defineComponent({
}
},
render () {
const { $slots, mergedClsPrefix } = this
const { $slots, mergedClsPrefix, tag: Component } = this
return (
<button
<Component
ref="selfRef"
class={[
`${mergedClsPrefix}-button`,
@ -470,7 +450,7 @@ export default defineComponent({
style={this.customColorCssVars as CSSProperties}
/>
) : null}
</button>
</Component>
)
}
})

View File

@ -58,6 +58,7 @@ export default c([
user-select: none;
text-align: center;
cursor: pointer;
text-decoration: none;
transition:
color .3s var(--bezier),
background-color .3s var(--bezier),