docs: optimize feature list page (#3137)

* docs: optimize feature list page

* docs(feature-page): add isCloud popover

* docs: add interface IComponentConfig

* docs: add badge feature list
This commit is contained in:
Kagol 2025-03-18 14:13:33 +08:00 committed by GitHub
parent 11a5e37e82
commit f231b598d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 288 additions and 49 deletions

View File

@ -130,5 +130,112 @@ export default {
},
codeFiles: ['offset.vue']
}
],
features: [
{
id: 'basic',
name: '基础',
description:
'通过 value 设置角标内容(一般是数字),通过 default 插槽或者 data 属性设置需要显示角标的元素或文本。',
support: {
value: true
},
cloud: {
value: true
},
apis: ['value', 'data', '#default'],
demos: ['basic-usage', 'slot-default']
},
{
id: 'type',
name: '类型',
description: '支持 primary / success / warning / danger(默认) / info 5种类型。',
support: {
value: true
},
cloud: {
value: false
},
apis: ['type'],
demos: ['type']
},
{
id: 'dot',
name: '小圆点',
description: '只显示一个小圆点,不显示数字',
support: {
value: true
},
cloud: {
value: true
},
apis: ['is-dot'],
demos: ['is-dot']
},
{
id: 'max',
name: '最大值',
description: '超出最大值会显示 {max}+',
support: {
value: true
},
cloud: {
value: true
},
apis: ['max'],
demos: ['max']
},
{
id: 'link',
name: '超链接',
description: '可以设置 href / target 进行超链接跳转,效果同 <a> 标签',
support: {
value: true
},
cloud: {
value: false
},
apis: ['href', 'target'],
demos: ['link']
},
{
id: 'custom',
name: '自定义标记',
description: '自定义标记内容和类型',
support: {
value: true
},
cloud: {
value: false
},
apis: ['badge-class', '#content'],
demos: ['badge-class', 'slot-content']
},
{
id: 'hidden',
name: '隐藏标记',
description: '动态隐藏标记',
support: {
value: true
},
cloud: {
value: false
},
apis: ['hidden'],
demos: ['dynamic-hidden']
},
{
id: 'offset',
name: '标记位置',
description: '标记位置的偏移量可以设置x、y轴的偏移量支持字符串、数字、百分比格式[0, -8]',
support: {
value: true
},
cloud: {
value: false
},
apis: ['offset'],
demos: ['offset']
}
]
}

View File

@ -144,8 +144,8 @@ export default {
codeFiles: ['click.vue']
}
],
show: true, // 是否展示在官网文档中
cloud: true, // 是否是规范内的组件
show: true,
cloud: true,
features: [
{
id: 'type',
@ -154,15 +154,12 @@ export default {
value: true
},
description: '支持主要按钮、次要按钮、成功按钮、警告按钮、危险按钮、信息按钮、文字按钮7种类型。',
// 是否是规范内的特性
cloud: {
value: true,
remark: '规范只支持主要按钮、次要按钮、危险按钮、文本按钮4种不支持成功按钮、警告按钮、信息按钮。' // 有些特性并非全部在规范内,所以需要进行备注
remark: '规范只支持主要按钮、次要按钮、危险按钮、文本按钮4种不支持成功按钮、警告按钮、信息按钮。'
},
apis: ['type'], // 该特性涉及到哪些 API
demos: ['basic-usage'] // 该特性在哪些 Demo 中体现
apis: ['type'],
demos: ['basic-usage']
},
{
id: 'round',
@ -172,7 +169,7 @@ export default {
},
description: '按钮两边都是半圆形。',
cloud: {
value: true // 规范默认就是圆角
value: true
},
apis: ['round'],
demos: ['round']

View File

@ -0,0 +1,93 @@
export interface IComponentConfig {
/**
*
*/
column: string
/**
*
*/
owner: string
/**
*
*/
show: boolean
/**
*
*/
cloud: boolean
meta: {
/**
* 使
*/
deprecated: string
/**
*
*/
experimental: string
/**
*
*/
stable: string
/**
* Minor
*/
toBeRemoved: string
}
demos: {
demoId: string
name: {
'zh-CN': string
'en-US': string
}
desc: {
'zh-CN': string
'en-US': string
}
codeFiles: string[]
}[]
/**
*
*/
features: {
id: string
name: string
description: string
/**
*
*/
support: {
value: boolean
}
/**
*
*/
cloud: {
value: boolean
/**
*
*/
remark: string
}
/**
* API
*/
apis: string[]
/**
* Demo
*/
demos: string[]
}[]
}

View File

@ -1,10 +1,14 @@
<template>
<div class="ti-pt48 ti-pl48 ti-pr48">
<div class="markdown-body">
<h1 class="flex-center">
<div class="w1000 !mx-auto markdown-body">
<h1 class="ti-f-r ti-f-box-center">
组件特性列表
<span class="component-count" :title="`${componentCount} components`">{{ componentCount }}</span>
<span class="component-count" :title="`${featureCount} features`">{{ featureCount }}</span>
<tiny-tag size="small" type="success" :title="`${componentCount} components`" class="ml8">{{
componentCount
}}</tiny-tag>
<tiny-tag size="small" type="success" :title="`${featureCount} features`" class="ml8">{{
featureCount
}}</tiny-tag>
</h1>
<p>TinyVue 组件库包含 {{ componentCount }} 个灵活易用功能强大的组件</p>
@ -15,9 +19,34 @@
v-for="(component, componentIndex) of isCloud ? components.filter((item) => item.config.cloud) : components"
:key="component.name"
>
<h3 class="flex-center">
<h3 class="ti-f-r ti-f-box-center">
{{ componentIndex + 1 }}. {{ toUpperCamelCase(component.name) }}
<span class="component-count mr-xs">{{ component.config.features?.length || 0 }}</span>
<tiny-tag
size="small"
type="success"
class="ml8"
:title="`${component.config.features?.length || 0} features`"
>
{{ component.config.features?.length || 0 }}
</tiny-tag>
<tiny-popover trigger="hover" placement="top">
<p>
{{
component.config.features?.every((feature) => feature.cloud.value)
? '全部特性在规范内'
: '部分特性在规范内'
}}
</p>
<template #reference>
<i
:class="[
component.config.features?.every((feature) => feature.cloud.value) ? 'i-ti-cloud-full' : 'i-ti-cloud',
'ml4'
]"
v-if="component.config.cloud"
></i>
</template>
</tiny-popover>
</h3>
<tiny-layout v-if="component.config.features" :cols="24">
<tiny-row
@ -26,8 +55,40 @@
:style="{ marginTop: index === 0 ? '20px' : '0' }"
:gutter="8"
>
<tiny-col v-for="feature of groupFeature" :key="feature.id" :span="8">
<tiny-col v-for="feature of groupFeature" :key="feature.id" :span="8" class="ti-f-r ti-f-box-center">
{{ feature.name }}
<tiny-popover trigger="hover" placement="top">
<p>{{ feature.description }}</p>
<div>
Demos:
<span v-for="(demo, demoIndex) of feature.demos" :key="demoIndex">
<a
:href="origin + '/tiny-vue/zh-CN/os-theme/components/' + component.name + '#' + demo"
target="'_blank'"
>{{ demo }}</a
><tiny-divider direction="vertical" v-if="demoIndex !== feature.demos.length - 1"></tiny-divider>
</span>
</div>
<div>
APIs:
<span v-for="(api, apiIndex) of feature.apis" :key="apiIndex">
<a
:href="origin + '/tiny-vue/zh-CN/os-theme/components/' + component.name + '#api'"
target="'_blank'"
>{{ api }}</a
><tiny-divider direction="vertical" v-if="apiIndex !== feature.apis.length - 1"></tiny-divider>
</span>
</div>
<template #reference>
<tiny-icon-info-circle class="ti-ml4"></tiny-icon-info-circle>
</template>
</tiny-popover>
<tiny-popover trigger="hover" placement="top" v-if="feature.cloud.value">
<p>{{ feature.cloud.remark || '规范内的特性' }}</p>
<template #reference>
<i :class="[feature.cloud.remark ? 'i-ti-cloud' : 'i-ti-cloud-full', 'ml4']"></i>
</template>
</tiny-popover>
</tiny-col>
</tiny-row>
</tiny-layout>
@ -36,16 +97,23 @@
</div>
</template>
<script setup>
import { TinyLayout, TinyRow, TinyCol, TinySwitch } from '@opentiny/vue'
<script setup lang="ts">
import { TinyLayout, TinyRow, TinyCol, TinySwitch, TinyPopover, TinyDivider, TinyTag } from '@opentiny/vue'
import { IconInfoCircle } from '@opentiny/vue-icon'
import { onMounted, ref } from 'vue'
const TinyIconInfoCircle = IconInfoCircle()
const origin = ref('')
const componentCount = ref(0)
const featureCount = ref(0)
const components = ref([])
const isCloud = ref(false)
onMounted(async () => {
origin.value = location.origin
const componentDocs = import.meta.glob(`@demos/app/**/webdoc/*.js`)
for (const item in componentDocs) {
@ -84,33 +152,3 @@ const toUpperCamelCase = (str) =>
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join('')
</script>
<style scoped lang="less">
.flex-center {
display: flex;
align-items: center;
}
.component-count {
display: inline-flex;
align-items: center;
justify-content: center;
margin-left: 8px;
padding: 0 2px;
min-width: 16px;
height: 16px;
line-height: 16px;
text-align: center;
font-size: 14px;
font-weight: normal;
border: 1px solid #dfe1e6;
border-radius: 4px;
background-color: #f5f5f5;
color: #cfd0d3;
}
.markdown-body {
width: 1000px;
margin: 0 auto;
}
</style>

View File

@ -29,7 +29,11 @@ export default {
check:
'<svg viewBox="0 0 512 512"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"/></svg>',
playground:
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16"><g fill="none"><path d="M14.854 1.854a.5.5 0 1 0-.708-.708l-8 8L6 10l.854-.146l8-8z" fill="currentColor"></path><path d="M4.5 2A2.5 2.5 0 0 0 2 4.5v7A2.5 2.5 0 0 0 4.5 14h7a2.5 2.5 0 0 0 2.5-2.5v-5a.5.5 0 0 0-1 0v5a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 3 11.5v-7A1.5 1.5 0 0 1 4.5 3h5.005a.5.5 0 0 0 0-1H4.5z" fill="currentColor"></path></g></svg>'
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16"><g fill="none"><path d="M14.854 1.854a.5.5 0 1 0-.708-.708l-8 8L6 10l.854-.146l8-8z" fill="currentColor"></path><path d="M4.5 2A2.5 2.5 0 0 0 2 4.5v7A2.5 2.5 0 0 0 4.5 14h7a2.5 2.5 0 0 0 2.5-2.5v-5a.5.5 0 0 0-1 0v5a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 3 11.5v-7A1.5 1.5 0 0 1 4.5 3h5.005a.5.5 0 0 0 0-1H4.5z" fill="currentColor"></path></g></svg>',
cloud:
'<svg class="ti-mr4" viewBox="0 0 1024 1024" width="16" height="16"><path d="M811.4 418.7C765.6 297.9 648.9 212 512.2 212S258.8 297.8 213 418.6C127.3 441.1 64 519.1 64 612c0 110.5 89.5 200 199.9 200h496.2C870.5 812 960 722.5 960 612c0-92.7-63.1-170.7-148.6-193.3z m36.3 281c-23.4 23.4-54.5 36.3-87.6 36.3H263.9c-33.1 0-64.2-12.9-87.6-36.3-23.4-23.4-36.3-54.6-36.3-87.7 0-28 9.1-54.3 26.2-76.3 16.7-21.3 40.2-36.8 66.1-43.7l37.9-9.9 13.9-36.6c8.6-22.8 20.6-44.1 35.7-63.4 14.9-19.2 32.6-35.9 52.4-49.9 41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.2c19.9 14 37.5 30.8 52.4 49.9 15.1 19.3 27.1 40.7 35.7 63.4l13.8 36.5 37.8 10c54.3 14.5 92.1 63.8 92.1 120 0 33.1-12.9 64.3-36.3 87.7z"></path></svg>',
'cloud-full':
'<svg t="1742260979776" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6563" width="200" height="200"><path d="M811.4 418.7C765.6 297.9 648.9 212 512.2 212S258.8 297.8 213 418.6C127.3 441.1 64 519.1 64 612c0 110.5 89.5 200 199.9 200h496.2C870.5 812 960 722.5 960 612c0-92.7-63.1-170.7-148.6-193.3z m36.3 281c-23.4 23.4-54.5 36.3-87.6 36.3H263.9c-33.1 0-64.2-12.9-87.6-36.3-23.4-23.4-36.3-54.6-36.3-87.7 0-28 9.1-54.3 26.2-76.3 16.7-21.3 40.2-36.8 66.1-43.7l37.9-9.9 13.9-36.6c8.6-22.8 20.6-44.1 35.7-63.4 14.9-19.2 32.6-35.9 52.4-49.9 41.1-28.9 89.5-44.2 140-44.2s98.9 15.3 140 44.2c19.9 14 37.5 30.8 52.4 49.9 15.1 19.3 27.1 40.7 35.7 63.4l13.8 36.5 37.8 10c54.3 14.5 92.1 63.8 92.1 120 0 33.1-12.9 64.3-36.3 87.7z" p-id="6564" fill="#5cb300"></path></svg>'
}
}
})