mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-18 12:34:25 +08:00
feat(typography/text): as
prop
This commit is contained in:
parent
5c59550f54
commit
1056684d2e
@ -23,6 +23,7 @@ text
|
||||
|delete|`boolean`|`false`||
|
||||
|code|`boolean`|`false`||
|
||||
|depth|`'primary' \| 'secondary' \| 'tertiary'`|`null`||
|
||||
|as|`string`|`null`|What tag should be this component be rendered as. Won't work when `code` or `del` is set.|
|
||||
|
||||
### P Props
|
||||
|Name|Type|Default|Description|
|
||||
|
@ -1,23 +1,18 @@
|
||||
# Text
|
||||
Use different type of text to display different kind of info.
|
||||
```html
|
||||
<n-text type="info">Info</n-text>
|
||||
<n-text type="success">Success</n-text>
|
||||
<n-text type="warning">Warning</n-text>
|
||||
<n-text type="error">Error</n-text>
|
||||
<n-text strong>Strong</n-text>
|
||||
<n-text italic>Italic</n-text>
|
||||
<n-text underline>Underline</n-text>
|
||||
<n-text delete>Delete</n-text>
|
||||
<n-text code>Code</n-text>
|
||||
<n-text code delete>Code</n-text>
|
||||
<n-text depth="primary">Primary Depth</n-text>
|
||||
<n-text depth="secondary">Secondary Depth</n-text>
|
||||
<n-text depth="tertiary">Tertiary Depth</n-text>
|
||||
```
|
||||
```css
|
||||
.n-text {
|
||||
display: inline-block;
|
||||
margin: 0 8px 12px 0;
|
||||
}
|
||||
<n-text type="info">Info</n-text>
|
||||
<n-text type="success">Success</n-text>
|
||||
<n-text type="warning">Warning</n-text>
|
||||
<n-text type="error">Error</n-text>
|
||||
<n-text strong>Strong</n-text>
|
||||
<n-text italic>Italic</n-text>
|
||||
<n-text underline>Underline</n-text>
|
||||
<n-text delete>Delete</n-text>
|
||||
<n-text code>Code</n-text>
|
||||
<n-text code delete>Code</n-text>
|
||||
<n-text depth="primary">Primary Depth</n-text>
|
||||
<n-text depth="secondary">Secondary Depth</n-text>
|
||||
<n-text depth="tertiary">Tertiary Depth</n-text>
|
||||
<n-text as="div">As Div</n-text>
|
||||
```
|
@ -22,6 +22,7 @@ text
|
||||
|delete|`boolean`|`false`||
|
||||
|code|`boolean`|`false`||
|
||||
|depth|`'primary' \| 'secondary' \| 'tertiary'`|`null`||
|
||||
|as|`string`|`null`|需要被渲染为什么标签,在 `code` 和 `del` 设定的情况下不生效|
|
||||
|
||||
### P Props
|
||||
|名称|类型|默认值|说明|
|
||||
|
@ -1,23 +1,18 @@
|
||||
# 文本
|
||||
用不同类型的文本展示各种信息。
|
||||
```html
|
||||
<n-text type="info">Info</n-text>
|
||||
<n-text type="success">Success</n-text>
|
||||
<n-text type="warning">Warning</n-text>
|
||||
<n-text type="error">Error</n-text>
|
||||
<n-text strong>Strong</n-text>
|
||||
<n-text italic>Italic</n-text>
|
||||
<n-text underline>Underline</n-text>
|
||||
<n-text delete>Delete</n-text>
|
||||
<n-text code>Code</n-text>
|
||||
<n-text code delete>Code</n-text>
|
||||
<n-text depth="primary">Primary Depth</n-text>
|
||||
<n-text depth="secondary">Secondary Depth</n-text>
|
||||
<n-text depth="tertiary">Tertiary Depth</n-text>
|
||||
```
|
||||
```css
|
||||
.n-text {
|
||||
display: inline-block;
|
||||
margin: 0 8px 12px 0;
|
||||
}
|
||||
<n-text type="info">Info</n-text>
|
||||
<n-text type="success">Success</n-text>
|
||||
<n-text type="warning">Warning</n-text>
|
||||
<n-text type="error">Error</n-text>
|
||||
<n-text strong>Strong</n-text>
|
||||
<n-text italic>Italic</n-text>
|
||||
<n-text underline>Underline</n-text>
|
||||
<n-text delete>Delete</n-text>
|
||||
<n-text code>Code</n-text>
|
||||
<n-text code delete>Code</n-text>
|
||||
<n-text depth="primary">Primary Depth</n-text>
|
||||
<n-text depth="secondary">Secondary Depth</n-text>
|
||||
<n-text depth="tertiary">Tertiary Depth</n-text>
|
||||
<n-text as="div">作为 Div</n-text>
|
||||
```
|
||||
|
@ -29,9 +29,9 @@
|
||||
'n-text--underline': underline,
|
||||
[`n-text--${depth}-depth`]: depth
|
||||
}"
|
||||
v-on="$listeners"
|
||||
><slot /></del>
|
||||
<span
|
||||
<component
|
||||
:is="as || 'span'"
|
||||
v-else
|
||||
class="n-text"
|
||||
:class="{
|
||||
@ -45,7 +45,9 @@
|
||||
'n-text--underline': underline,
|
||||
[`n-text--${depth}-depth`]: depth
|
||||
}"
|
||||
><slot /></span>
|
||||
>
|
||||
<slot />
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -89,6 +91,10 @@ export default {
|
||||
return ['primary', 'secondary', 'tertiary'].includes(value)
|
||||
},
|
||||
default: null
|
||||
},
|
||||
as: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,6 @@
|
||||
}
|
||||
@include b(text) {
|
||||
@include once {
|
||||
display: inline-block;
|
||||
transition: color .3s $--n-ease-in-out-cubic-bezier;
|
||||
@include m(strong) {
|
||||
font-weight: $--n-strong-weight;
|
||||
|
Loading…
Reference in New Issue
Block a user