@yunlefun/vue 0.4.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/components/YlfAccordion.vue +12 -7
- package/components/YlfAgentCard.vue +108 -0
- package/components/YlfAgentStatus.vue +69 -0
- package/components/YlfAgentTask.vue +85 -0
- package/components/YlfButton.vue +145 -28
- package/components/YlfCard.vue +10 -4
- package/components/YlfCheckbox.vue +70 -7
- package/components/YlfCloud.vue +193 -0
- package/components/YlfDialog.vue +53 -21
- package/components/YlfDropdownMenu.vue +41 -5
- package/components/YlfInput.vue +67 -0
- package/components/YlfLogo.vue +7 -5
- package/components/YlfNavigation.vue +84 -0
- package/components/YlfNavigationLink.vue +59 -0
- package/components/YlfNavigationTrigger.vue +53 -0
- package/components/YlfPopover.vue +43 -7
- package/components/YlfRadioGroup.vue +41 -6
- package/components/YlfScrollFade.vue +66 -0
- package/components/YlfSegmentedControl.vue +80 -10
- package/components/YlfSelect.vue +72 -34
- package/components/YlfSlider.vue +16 -5
- package/components/YlfSwitch.vue +30 -4
- package/components/YlfTabs.vue +12 -4
- package/components/YlfTooltip.vue +29 -4
- package/components/_navigation.scss +38 -0
- package/components/accordion/demo.vue +1 -1
- package/components/agent-card/demo.vue +17 -0
- package/components/agent-card/index.md +25 -0
- package/components/agent-status/demo.vue +38 -0
- package/components/agent-status/index.md +20 -0
- package/components/agent-task/demo.vue +15 -0
- package/components/agent-task/index.md +25 -0
- package/components/agent.ts +2 -0
- package/components/button/demo.vue +21 -0
- package/components/button/index.md +20 -11
- package/components/cloud/demo.vue +92 -0
- package/components/cloud/index.md +66 -0
- package/components/cloud.ts +4 -0
- package/components/input/demo.vue +22 -0
- package/components/input/index.md +19 -0
- package/components/navigation/demo.vue +104 -0
- package/components/navigation/index.md +90 -0
- package/components/navigation-indicator.ts +114 -0
- package/components/scroll-fade/demo.vue +49 -0
- package/components/scroll-fade/index.md +40 -0
- package/components/scroll-fade.ts +52 -0
- package/dist/ag-ui.cjs +132 -0
- package/dist/ag-ui.d.cts +25 -0
- package/dist/ag-ui.d.mts +25 -0
- package/dist/ag-ui.d.ts +25 -0
- package/dist/ag-ui.mjs +130 -0
- package/dist/components/YlfAgentCard.vue.d.ts +24 -0
- package/dist/components/YlfAgentStatus.vue.d.ts +13 -0
- package/dist/components/YlfAgentTask.vue.d.ts +23 -0
- package/dist/components/YlfAvatar.vue.d.ts +1 -1
- package/dist/components/YlfButton.vue.d.ts +8 -5
- package/dist/components/YlfCloud.vue.d.ts +15 -0
- package/dist/components/YlfDialog.vue.d.ts +5 -5
- package/dist/components/YlfDropdownMenu.vue.d.ts +2 -2
- package/dist/components/YlfInput.vue.d.ts +18 -0
- package/dist/components/YlfNavigation.vue.d.ts +23 -0
- package/dist/components/YlfNavigationLink.vue.d.ts +21 -0
- package/dist/components/YlfNavigationTrigger.vue.d.ts +18 -0
- package/dist/components/YlfPopover.vue.d.ts +3 -3
- package/dist/components/YlfProgress.vue.d.ts +1 -1
- package/dist/components/YlfScrollFade.vue.d.ts +24 -0
- package/dist/components/YlfSeparator.vue.d.ts +2 -2
- package/dist/components/YlfSwitch.vue.d.ts +1 -1
- package/dist/components/YlfTabs.vue.d.ts +3 -3
- package/dist/components/YlfTooltip.vue.d.ts +3 -3
- package/dist/components/agent.d.ts +2 -0
- package/dist/components/cloud.d.ts +3 -0
- package/dist/components/navigation-indicator.d.ts +14 -0
- package/dist/components/scroll-fade.d.ts +3 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +9 -2
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.mjs +3 -1
- package/package.json +20 -6
|
@@ -7,6 +7,12 @@ title_zh: 按钮
|
|
|
7
7
|
|
|
8
8
|
状态按钮与徽标使用同一套多巴胺色板:成功为鲜绿、提醒为明黄、危险为珊瑚橙,文字使用配套的同色相深色 token。
|
|
9
9
|
|
|
10
|
+
## 品牌入口
|
|
11
|
+
|
|
12
|
+
首页或活动区的主入口使用 `variant="hero" size="xl"`:深蓝到青蓝渐变、白色文案、柔光投影,以及 56px 点击高度。明暗主题均保留深色渐变和白字,不使用偏亮的天空装饰渐变作为按钮底色。悬停时加深颜色,键盘聚焦使用双色外圈,减少动态效果时关闭位移。
|
|
13
|
+
|
|
14
|
+
每个区块保留一个 hero 主入口。日常保存、确认和导航使用 `primary` 或次级变体。`tone` 和 `appearance` 不改变 hero 的专用配色;颜色与阴影统一由 `--ylf-hero-*` 提供,业务可保留自己的路由行为封装。
|
|
15
|
+
|
|
10
16
|
## Registry
|
|
11
17
|
|
|
12
18
|
Button 可以通过 URL 将组件源码和共享品牌 token 复制进业务项目;命令、边界和发布验收见 [Registry 分发](/guide/registry)。稳定基础组件仍优先通过 `@yunlefun/vue` 使用。
|
|
@@ -17,17 +23,18 @@ Button 可以通过 URL 将组件源码和共享品牌 token 复制进业务项
|
|
|
17
23
|
|
|
18
24
|
## Props
|
|
19
25
|
|
|
20
|
-
| 属性 | 说明
|
|
21
|
-
| ------------ |
|
|
22
|
-
| `variant` | 风格
|
|
23
|
-
| `tone` | 强调色,仅作用于 `accent`
|
|
24
|
-
| `appearance` | `accent` 与状态变体的强调程度
|
|
25
|
-
| `size` | 尺寸
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
26
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
27
|
+
| ------------ | -------------------------------- | ----------------------------------------------------------------------------------------- | ---------- |
|
|
28
|
+
| `variant` | 风格 | `primary \| hero \| accent \| secondary \| soft \| ghost \| success \| warning \| danger` | `primary` |
|
|
29
|
+
| `tone` | 强调色,仅作用于 `accent` | `blue \| sun \| cyan \| coral \| pink \| green` | `blue` |
|
|
30
|
+
| `appearance` | `accent` 与状态变体的强调程度 | `solid \| soft \| outline` | `solid` |
|
|
31
|
+
| `size` | 尺寸 | `sm \| md \| lg \| xl` | `md` |
|
|
32
|
+
| `iconOnly` | 方形图标按钮,必须提供可访问名称 | `boolean` | `false` |
|
|
33
|
+
| `round` | 胶囊圆角(云是软的) | `boolean` | `true` |
|
|
34
|
+
| `block` | 占满整行宽度 | `boolean` | `false` |
|
|
35
|
+
| `loading` | 加载态 | `boolean` | `false` |
|
|
36
|
+
| `disabled` | 禁用 | `boolean` | `false` |
|
|
37
|
+
| `tag` | 渲染标签,如 `'a'` | `string` | `'button'` |
|
|
31
38
|
|
|
32
39
|
`accent` 的 `tone` 可选 `blue | sun | cyan | coral | pink | green`,默认为 `blue`(晴空蓝)。其他变体保持自己的品牌或状态语义,不受 `tone` 影响。旧 `aurora` 值仍可接收,效果映射到 `accent`。
|
|
33
40
|
|
|
@@ -43,3 +50,5 @@ Button 可以通过 URL 将组件源码和共享品牌 token 复制进业务项
|
|
|
43
50
|
| 名称 | 说明 |
|
|
44
51
|
| ------- | --------------------------------------------- |
|
|
45
52
|
| `click` | 点击时触发(`disabled` / `loading` 下不触发) |
|
|
53
|
+
|
|
54
|
+
纯图标按钮尺寸为 32px(`sm`)、36px(`md`)、44px(`lg` / `xl`),粗指针下点击区域至少 44px。提供 `aria-label`,并组合 `YlfTooltip` 展示提示。默认 `type="button"`,提交表单时显式传入 `type="submit"`。
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { YlfCloudShape } from '../cloud'
|
|
3
|
+
import { computed, ref, useId } from 'vue'
|
|
4
|
+
|
|
5
|
+
const shape = ref<YlfCloudShape>('billow')
|
|
6
|
+
const haze = ref([0])
|
|
7
|
+
const volumetric = ref(true)
|
|
8
|
+
const face = ref(false)
|
|
9
|
+
const volumetricId = useId()
|
|
10
|
+
const faceId = useId()
|
|
11
|
+
|
|
12
|
+
const shapes: { value: YlfCloudShape, label: string }[] = [
|
|
13
|
+
{ value: 'billow', label: '积云' },
|
|
14
|
+
{ value: 'heap', label: '堆云' },
|
|
15
|
+
{ value: 'bank', label: '云堤' },
|
|
16
|
+
{ value: 'puff', label: '团云' },
|
|
17
|
+
{ value: 'wisp', label: '薄云' },
|
|
18
|
+
]
|
|
19
|
+
const hazeValue = computed(() => haze.value[0] / 100)
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div class="flex flex-col gap-5">
|
|
24
|
+
<div class="cloud-demo__sky">
|
|
25
|
+
<!-- 远处的云混入天空色,近处保持清晰:同一组件靠 --ylf-cloud-haze 拉开层次。 -->
|
|
26
|
+
<YlfCloud shape="wisp" class="cloud-demo__far" style="--ylf-cloud-haze: 0.7" />
|
|
27
|
+
<YlfCloud shape="bank" class="cloud-demo__mid" style="--ylf-cloud-haze: 0.4" />
|
|
28
|
+
<YlfCloud
|
|
29
|
+
:shape="shape"
|
|
30
|
+
:volumetric="volumetric"
|
|
31
|
+
:face="face"
|
|
32
|
+
class="cloud-demo__near"
|
|
33
|
+
:style="{ '--ylf-cloud-haze': hazeValue, '--ylf-cloud-face-opacity': face ? 0.85 : 0 }"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<YlfSegmentedControl v-model="shape" :options="shapes" label="云朵形状" />
|
|
37
|
+
<div class="flex flex-col gap-2">
|
|
38
|
+
<YlfSlider v-model="haze" label="空气透视" />
|
|
39
|
+
<p class="m-0 text-sm op-70">
|
|
40
|
+
--ylf-cloud-haze:{{ hazeValue.toFixed(2) }}
|
|
41
|
+
</p>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="flex flex-wrap items-center gap-6">
|
|
44
|
+
<label class="flex items-center gap-2 text-sm" :for="volumetricId">
|
|
45
|
+
<YlfSwitch :id="volumetricId" v-model="volumetric" size="sm" />
|
|
46
|
+
体积光
|
|
47
|
+
</label>
|
|
48
|
+
<label class="flex items-center gap-2 text-sm" :for="faceId">
|
|
49
|
+
<YlfSwitch :id="faceId" v-model="face" size="sm" />
|
|
50
|
+
小脸
|
|
51
|
+
</label>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<style scoped>
|
|
57
|
+
.cloud-demo__sky {
|
|
58
|
+
position: relative;
|
|
59
|
+
height: 220px;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
border-radius: var(--ylf-radius-lg);
|
|
62
|
+
background: linear-gradient(180deg, var(--ylf-c-sky), var(--ylf-cloud-haze-color));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.cloud-demo__sky > * {
|
|
66
|
+
position: absolute;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cloud-demo__far {
|
|
70
|
+
top: 8%;
|
|
71
|
+
right: -6%;
|
|
72
|
+
width: 46%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cloud-demo__mid {
|
|
76
|
+
bottom: -8%;
|
|
77
|
+
left: -8%;
|
|
78
|
+
width: 62%;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cloud-demo__near {
|
|
82
|
+
bottom: 0;
|
|
83
|
+
left: 50%;
|
|
84
|
+
width: min(380px, 70%);
|
|
85
|
+
translate: -50% 0;
|
|
86
|
+
transition: translate var(--ylf-duration-slow) var(--ylf-ease-spring);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.cloud-demo__near:hover {
|
|
90
|
+
translate: -50% -6px;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cloud
|
|
3
|
+
title_zh: 云朵
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
云乐坊各站点共用的云朵插画:五种轮廓、左上方来光、顶部逆光描边与空气透视,配色来自 `@yunlefun/ui` 的 `--ylf-cloud-*` token,随明暗主题切换。纯装饰,`aria-hidden="true"`,不接收指针事件。
|
|
7
|
+
|
|
8
|
+
## 选择轮廓
|
|
9
|
+
|
|
10
|
+
画布统一为 `490 × 250`,轮廓都是一条连续曲线,缩放或翻转后不会露出圆形拼接。同一画面中混用不同轮廓,避免重复。
|
|
11
|
+
|
|
12
|
+
- `billow`:层层鼓起的主云,适合视觉焦点。
|
|
13
|
+
- `heap`:宽厚的近景积云,右侧更高。
|
|
14
|
+
- `bank`:贴着地平线的扁长云堤。
|
|
15
|
+
- `puff`:圆鼓鼓的小团云,适合空状态或吉祥物。
|
|
16
|
+
- `wisp`:远处拉长的薄云。
|
|
17
|
+
|
|
18
|
+
## 层次与性能
|
|
19
|
+
|
|
20
|
+
用 `--ylf-cloud-haze`(0–1)表达远近:数值越大,云体、阴影越接近 `--ylf-cloud-haze-color`,底部阴影和逆光描边同步减弱。把它写在组件或父元素上即可。
|
|
21
|
+
|
|
22
|
+
`volumetric` 用高斯模糊塑造亮面体积,只给一两朵焦点云开启;其余云使用渐变近似,降低绘制开销。
|
|
23
|
+
|
|
24
|
+
## 小脸与动效
|
|
25
|
+
|
|
26
|
+
`face` 只渲染一张默认隐藏的小脸,由宿主设置 `--ylf-cloud-face-opacity` 唤醒,例如悬停、聚焦或被戳之后设为 `0.85`;淡入使用 `--ylf-duration-slow`。眼睛偶尔眨一下。
|
|
27
|
+
|
|
28
|
+
组件本身不移动。漂浮、入场、被戳回弹由宿主添加,软的位移使用 `--ylf-ease-spring` 与 `--ylf-duration-slow`,颜色与透明度使用 `--ylf-ease-standard`。开启“减少动态效果”时,这些时长归零,眨眼停止;宿主自己的循环动画也要处理该偏好。
|
|
29
|
+
|
|
30
|
+
## Props
|
|
31
|
+
|
|
32
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
33
|
+
| ------------ | ------------------------------- | ---------------------------------------- | -------- |
|
|
34
|
+
| `shape` | 云朵轮廓 | `billow \| heap \| bank \| puff \| wisp` | `billow` |
|
|
35
|
+
| `volumetric` | 用模糊滤镜塑造亮面体积 | `boolean` | `false` |
|
|
36
|
+
| `face` | 渲染隐藏的小脸,由 CSS 变量唤醒 | `boolean` | `false` |
|
|
37
|
+
|
|
38
|
+
## CSS 变量
|
|
39
|
+
|
|
40
|
+
| 变量 | 说明 | 默认值(浅色 / 深色) |
|
|
41
|
+
| -------------------------- | ---------------------------------- | --------------------- |
|
|
42
|
+
| `--ylf-cloud-haze` | 空气透视强度,0 为近景,1 融入天空 | `0` |
|
|
43
|
+
| `--ylf-cloud-haze-color` | 远处云融入的天空色 | `#9cc6ef` / `#1f3354` |
|
|
44
|
+
| `--ylf-cloud-face-opacity` | 小脸透明度 | `0` |
|
|
45
|
+
| `--ylf-cloud-highlight` | 亮面 | `#fffefa` / `#a6bcd8` |
|
|
46
|
+
| `--ylf-cloud-body` | 云体 | `#f2f8ff` / `#3e5679` |
|
|
47
|
+
| `--ylf-cloud-shade` | 背光面 | `#c6dff5` / `#1c2b44` |
|
|
48
|
+
| `--ylf-cloud-shadow` | 底部阴影 | `#83addb` / `#0a1424` |
|
|
49
|
+
| `--ylf-cloud-rim` | 顶部逆光描边 | `#ffffff` / `#cfdff2` |
|
|
50
|
+
| `--ylf-cloud-face` | 小脸颜色 | `#5a7fae` / `#0e1a2d` |
|
|
51
|
+
|
|
52
|
+
深色主题默认是月光下的夜空蓝。站点有自己的天空时,在天空容器上覆盖这组 token,例如黄昏:
|
|
53
|
+
|
|
54
|
+
```css
|
|
55
|
+
.dark .my-sky {
|
|
56
|
+
--ylf-cloud-highlight: #fff0e7;
|
|
57
|
+
--ylf-cloud-body: #e8d7ed;
|
|
58
|
+
--ylf-cloud-shade: #b6a5d0;
|
|
59
|
+
--ylf-cloud-shadow: #8377ad;
|
|
60
|
+
--ylf-cloud-rim: #ffd9c4;
|
|
61
|
+
--ylf-cloud-face: #6d5a92;
|
|
62
|
+
--ylf-cloud-haze-color: #a48cc4;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
轮廓列表也可从包根入口取得:`import { ylfCloudShapes } from '@yunlefun/vue'`,类型为 `YlfCloudShape`。token 随 `@yunlefun/ui` 0.0.7 发布;未加载共享样式时组件回退到浅色配色。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, useId } from 'vue'
|
|
3
|
+
|
|
4
|
+
const name = ref('')
|
|
5
|
+
const id = useId()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div class="grid max-w-sm w-full gap-4">
|
|
10
|
+
<label :for="id" class="grid gap-2">
|
|
11
|
+
名称
|
|
12
|
+
<YlfInput :id="id" v-model="name" name="name" autocomplete="name" placeholder="输入名称" />
|
|
13
|
+
</label>
|
|
14
|
+
<YlfInput size="sm" aria-label="紧凑输入" placeholder="紧凑输入" />
|
|
15
|
+
<YlfInput model-value="只读内容" aria-label="只读内容" readonly />
|
|
16
|
+
<YlfInput model-value="暂不可用" aria-label="暂不可用" disabled />
|
|
17
|
+
<div class="grid gap-2">
|
|
18
|
+
<YlfInput invalid aria-label="名称" :aria-describedby="`${id}-error`" />
|
|
19
|
+
<span :id="`${id}-error`" class="text-sm text-[var(--ylf-status-danger-text)]">请输入名称。</span>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Input
|
|
3
|
+
title_zh: 输入框
|
|
4
|
+
description: 复用原生输入行为,统一表单与紧凑工作台的输入框。
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`YlfInput` 保留原生输入行为,与 Select 共用一致的表面、圆角和密度。使用可见标签;错误信息通过 `aria-describedby` 关联到输入框。
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
12
|
+
| ------------ | ------------------- | ---------- | ------- |
|
|
13
|
+
| `modelValue` | 文本值(`v-model`) | `string` | `''` |
|
|
14
|
+
| `size` | 控件密度 | `sm \| md` | `md` |
|
|
15
|
+
| `invalid` | 标记输入值无效 | `boolean` | `false` |
|
|
16
|
+
|
|
17
|
+
`id`、`name`、`type`、`required`、`disabled`、`readonly`、`placeholder`、`autocomplete` 等原生属性和 `input`、`blur` 等事件直接透传。保留输入法组合事件行为。组件面向文本值;需要数字解析时使用专用数值控件。
|
|
18
|
+
|
|
19
|
+
默认点击高度至少 44px,紧凑模式 34px,粗指针下增大至 44px。错误状态仍需提供可读的错误说明。
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, shallowRef } from 'vue'
|
|
3
|
+
import YlfDropdownMenu from '../YlfDropdownMenu.vue'
|
|
4
|
+
import YlfNavigation from '../YlfNavigation.vue'
|
|
5
|
+
import YlfNavigationLink from '../YlfNavigationLink.vue'
|
|
6
|
+
import YlfNavigationTrigger from '../YlfNavigationTrigger.vue'
|
|
7
|
+
|
|
8
|
+
const current = shallowRef('blog')
|
|
9
|
+
const site = shallowRef('website')
|
|
10
|
+
const items = [
|
|
11
|
+
{ id: 'help', label: '帮助' },
|
|
12
|
+
{ id: 'membership', label: '会员' },
|
|
13
|
+
{ id: 'blog', label: '博客' },
|
|
14
|
+
{ id: 'updates', label: '日志' },
|
|
15
|
+
]
|
|
16
|
+
const sites = [
|
|
17
|
+
{ value: 'website', label: '官网' },
|
|
18
|
+
{ value: 'apps', label: '应用' },
|
|
19
|
+
{ value: 'studio', label: '工作室' },
|
|
20
|
+
]
|
|
21
|
+
const siteLabel = computed(() => sites.find(item => item.value === site.value)?.label)
|
|
22
|
+
const currentLabel = computed(() => items.find(item => item.id === current.value)?.label)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div class="ylf-navigation-demo">
|
|
27
|
+
<div class="ylf-navigation-demo__header">
|
|
28
|
+
<div class="ylf-navigation-demo__brand">
|
|
29
|
+
<strong>云乐坊</strong>
|
|
30
|
+
<YlfDropdownMenu :items="sites" @select="site = $event">
|
|
31
|
+
<template #trigger>
|
|
32
|
+
<YlfNavigationTrigger>{{ siteLabel }}</YlfNavigationTrigger>
|
|
33
|
+
</template>
|
|
34
|
+
</YlfDropdownMenu>
|
|
35
|
+
</div>
|
|
36
|
+
<YlfNavigation label="主导航预览">
|
|
37
|
+
<YlfNavigationLink
|
|
38
|
+
v-for="item in items"
|
|
39
|
+
:key="item.id"
|
|
40
|
+
:href="`#${item.id}`"
|
|
41
|
+
:active="current === item.id"
|
|
42
|
+
@click.prevent="current = item.id"
|
|
43
|
+
>
|
|
44
|
+
{{ item.label }}
|
|
45
|
+
</YlfNavigationLink>
|
|
46
|
+
</YlfNavigation>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<p class="ylf-navigation-demo__status" aria-live="polite">
|
|
50
|
+
当前选择:{{ siteLabel }} / {{ currentLabel }}
|
|
51
|
+
</p>
|
|
52
|
+
<div class="ylf-navigation-demo__vertical">
|
|
53
|
+
<YlfNavigation label="抽屉导航预览" orientation="vertical">
|
|
54
|
+
<YlfNavigationLink
|
|
55
|
+
v-for="item in items"
|
|
56
|
+
:key="item.id"
|
|
57
|
+
:href="`#${item.id}`"
|
|
58
|
+
:active="current === item.id"
|
|
59
|
+
@click.prevent="current = item.id"
|
|
60
|
+
>
|
|
61
|
+
{{ item.label }}
|
|
62
|
+
</YlfNavigationLink>
|
|
63
|
+
</YlfNavigation>
|
|
64
|
+
</div>
|
|
65
|
+
<YlfNavigationTrigger disabled>
|
|
66
|
+
更多站点
|
|
67
|
+
</YlfNavigationTrigger>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<style scoped>
|
|
72
|
+
.ylf-navigation-demo {
|
|
73
|
+
display: grid;
|
|
74
|
+
justify-items: start;
|
|
75
|
+
gap: var(--ylf-space-4);
|
|
76
|
+
width: 100%;
|
|
77
|
+
}
|
|
78
|
+
.ylf-navigation-demo__header {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-wrap: wrap;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: var(--ylf-space-4);
|
|
83
|
+
width: 100%;
|
|
84
|
+
padding-block: var(--ylf-space-2);
|
|
85
|
+
border-bottom: 1px solid var(--ylf-c-border);
|
|
86
|
+
}
|
|
87
|
+
.ylf-navigation-demo__brand {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: var(--ylf-space-3);
|
|
91
|
+
}
|
|
92
|
+
.ylf-navigation-demo__status {
|
|
93
|
+
margin: 0;
|
|
94
|
+
color: var(--ylf-c-text-2);
|
|
95
|
+
font-size: var(--ylf-text-sm);
|
|
96
|
+
}
|
|
97
|
+
.ylf-navigation-demo__vertical {
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
width: min(100%, 280px);
|
|
100
|
+
padding: var(--ylf-space-2);
|
|
101
|
+
border: 1px solid var(--ylf-c-border);
|
|
102
|
+
border-radius: var(--ylf-radius);
|
|
103
|
+
}
|
|
104
|
+
</style>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Navigation
|
|
3
|
+
title_zh: 站点导航
|
|
4
|
+
description: 有呼吸感的站点导航,区分当前位置、悬停和键盘焦点,支持路由链接与站点切换。
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`YlfNavigation` 组织链接,`YlfNavigationLink` 标记当前页面,`YlfNavigationTrigger` 为站点切换等下拉菜单提供统一入口。适合官网、内容站和应用页头;页内面板切换请使用 Tabs。
|
|
8
|
+
|
|
9
|
+
## 间距与状态
|
|
10
|
+
|
|
11
|
+
- 所有入口至少 44px 高;正文 14px / 500;水平链接间距 8px,垂直链接间距 4px。
|
|
12
|
+
- 默认中性文字,悬停使用中性浅底;当前页为晴空蓝,水平导航增加 16×2px 短线,垂直导航使用浅蓝底。
|
|
13
|
+
- 键盘焦点使用内收 2px 轮廓,不替代当前页标记,也不向相邻入口扩张。
|
|
14
|
+
- 水平导航默认用同一条下划线随 `active` 移动,过渡读取 `--ylf-duration-normal`(240ms)与 `--ylf-ease-standard`。快速连续切换会从当前位置转向新目标;布局换行、链接尺寸变化时重新对齐。首次出现不从左侧飞入,无当前页时隐藏,垂直导航保留背景标记。减少动态效果时即时定位,也可用 `:animated="false"` 保留静态下划线。
|
|
15
|
+
- 品牌与站点切换建议间隔 12px,品牌组与导航建议间隔 16px。页头高度、响应式断点及账户区域由应用布局决定。
|
|
16
|
+
- 颜色、圆角、字号与动效读取共享 token;支持局部主题及减少动态效果。
|
|
17
|
+
|
|
18
|
+
## 接入
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import YlfNavigation from '@yunlefun/vue/components/YlfNavigation.vue'
|
|
23
|
+
import YlfNavigationLink from '@yunlefun/vue/components/YlfNavigationLink.vue'
|
|
24
|
+
import '@yunlefun/ui/css'
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<YlfNavigation label="主导航">
|
|
29
|
+
<YlfNavigationLink href="/docs">
|
|
30
|
+
帮助
|
|
31
|
+
</YlfNavigationLink>
|
|
32
|
+
<YlfNavigationLink href="/blog" active>
|
|
33
|
+
博客
|
|
34
|
+
</YlfNavigationLink>
|
|
35
|
+
</YlfNavigation>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Nuxt / Vue Router 使用 `as-child` 将样式、当前页语义和事件合并到单个链接,避免嵌套 `<a>`。应用负责计算 `active`,每组仅一个当前页。路由、认证请求和埋点不进入设计组件。
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<YlfNavigationLink :active="route.path.startsWith('/blog')" as-child>
|
|
43
|
+
<NuxtLink to="/blog">博客</NuxtLink>
|
|
44
|
+
</YlfNavigationLink>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`YlfNavigationTrigger` 放进 `YlfDropdownMenu` 的 `trigger` 插槽,或 Reka `DropdownMenuTrigger as-child`。菜单负责开关状态、`aria-expanded`、焦点恢复与键盘操作;按钮读取这些属性绘制展开状态,不维护第二份 `open`。
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<YlfDropdownMenu :items="sites" @select="switchSite">
|
|
51
|
+
<template #trigger>
|
|
52
|
+
<YlfNavigationTrigger>官网</YlfNavigationTrigger>
|
|
53
|
+
</template>
|
|
54
|
+
</YlfDropdownMenu>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
水平导航允许换行。手机页头需要收起时,由应用在自己的断点切换到有可访问名称的抽屉,在抽屉内使用 `orientation="vertical"`;不在公共组件内硬编码屏幕宽度或业务链接。
|
|
58
|
+
|
|
59
|
+
## Props
|
|
60
|
+
|
|
61
|
+
### YlfNavigation
|
|
62
|
+
|
|
63
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
64
|
+
| ------------- | -------------------------------------- | ------------------------ | ------------ |
|
|
65
|
+
| `label` | 必填的可访问名称,同页多个导航应可区分 | `string` | — |
|
|
66
|
+
| `orientation` | 排列方向与当前页标记样式 | `horizontal \| vertical` | `horizontal` |
|
|
67
|
+
| `animated` | 水平当前页下划线的移动动画 | `boolean` | `true` |
|
|
68
|
+
|
|
69
|
+
### YlfNavigationLink
|
|
70
|
+
|
|
71
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
72
|
+
| --------- | ------------------------------------ | --------- | ------- |
|
|
73
|
+
| `active` | 当前页面,输出 `aria-current="page"` | `boolean` | `false` |
|
|
74
|
+
| `asChild` | 将属性合并到插槽的单个链接 | `boolean` | `false` |
|
|
75
|
+
|
|
76
|
+
`href`、`target`、`rel`、可访问属性和事件透传到实际链接。不要给不可访问的页面伪造禁用链接:根据产品需求隐藏入口或显示说明。
|
|
77
|
+
|
|
78
|
+
### YlfNavigationTrigger
|
|
79
|
+
|
|
80
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
81
|
+
| ---------- | -------------- | --------- | ------- |
|
|
82
|
+
| `disabled` | 原生按钮禁用态 | `boolean` | `false` |
|
|
83
|
+
|
|
84
|
+
三个组件均提供默认插槽。Trigger 的插槽为按钮文案,箭头由组件绘制;其余原生属性与事件透传到按钮,默认 `type="button"`。
|
|
85
|
+
|
|
86
|
+
## 验收重点
|
|
87
|
+
|
|
88
|
+
用 Tab 顺序访问链接与触发器,Enter 打开链接或菜单,Escape 关闭菜单后焦点回到触发器。当前位置与相邻焦点应可同时辨认。检查浅色、深色、390px、768px 与桌面,手机入口保留 44px 点击高度。
|
|
89
|
+
|
|
90
|
+
视觉参考:[Header navigations — Untitled UI / Dribbble](https://dribbble.com/shots/17564385-Header-navigations-Untitled-UI)。规则来自云乐坊主站的实际导航验证,不复制参考稿的品牌或业务内容。
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
import { onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
/** Shared geometry for native documentation menus and YlfNavigation. No routing ownership. */
|
|
5
|
+
export function useNavigationIndicator(root: Readonly<Ref<HTMLElement | null>>, options: {
|
|
6
|
+
links: (root: HTMLElement) => HTMLElement[]
|
|
7
|
+
active: (link: HTMLElement) => boolean
|
|
8
|
+
attributes: string[]
|
|
9
|
+
enabled?: () => boolean
|
|
10
|
+
}) {
|
|
11
|
+
const indicator = shallowRef<{ x: number, y: number } | null>(null)
|
|
12
|
+
let frame: number | undefined
|
|
13
|
+
let resizeObserver: ResizeObserver | undefined
|
|
14
|
+
let mutationObserver: MutationObserver | undefined
|
|
15
|
+
let connectedElement: HTMLElement | null = null
|
|
16
|
+
const observedLinks = new Set<HTMLElement>()
|
|
17
|
+
|
|
18
|
+
function update() {
|
|
19
|
+
const element = root.value
|
|
20
|
+
const active = element && options.links(element).find(options.active)
|
|
21
|
+
if (!element || !active || options.enabled?.() === false) {
|
|
22
|
+
indicator.value = null
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
const bounds = element.getBoundingClientRect()
|
|
26
|
+
const target = active.getBoundingClientRect()
|
|
27
|
+
if (!bounds.width || !target.width || !target.height) {
|
|
28
|
+
indicator.value = null
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
// Convert viewport coordinates to the padding box, including scaled previews.
|
|
32
|
+
const scaleX = element.offsetWidth ? bounds.width / element.offsetWidth : 1
|
|
33
|
+
const scaleY = element.offsetHeight ? bounds.height / element.offsetHeight : 1
|
|
34
|
+
const x = (target.left - bounds.left + target.width / 2) / scaleX - element.clientLeft + element.scrollLeft - 8
|
|
35
|
+
const y = (target.bottom - bounds.top) / scaleY - element.clientTop + element.scrollTop - 6
|
|
36
|
+
if (indicator.value?.x !== x || indicator.value?.y !== y)
|
|
37
|
+
indicator.value = { x, y }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function scheduleUpdate() {
|
|
41
|
+
if (!root.value || frame !== undefined)
|
|
42
|
+
return
|
|
43
|
+
frame = requestAnimationFrame(() => {
|
|
44
|
+
frame = undefined
|
|
45
|
+
update()
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function observeLinks() {
|
|
50
|
+
const current = new Set(root.value ? options.links(root.value) : [])
|
|
51
|
+
for (const link of observedLinks) {
|
|
52
|
+
if (!current.has(link)) {
|
|
53
|
+
resizeObserver?.unobserve(link)
|
|
54
|
+
observedLinks.delete(link)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const link of current) {
|
|
58
|
+
if (!observedLinks.has(link)) {
|
|
59
|
+
resizeObserver?.observe(link)
|
|
60
|
+
observedLinks.add(link)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function disconnect() {
|
|
66
|
+
if (frame !== undefined)
|
|
67
|
+
cancelAnimationFrame(frame)
|
|
68
|
+
frame = undefined
|
|
69
|
+
resizeObserver?.disconnect()
|
|
70
|
+
mutationObserver?.disconnect()
|
|
71
|
+
observedLinks.clear()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function connect() {
|
|
75
|
+
if (root.value === connectedElement)
|
|
76
|
+
return
|
|
77
|
+
disconnect()
|
|
78
|
+
indicator.value = null
|
|
79
|
+
const element = root.value
|
|
80
|
+
connectedElement = element
|
|
81
|
+
if (!element)
|
|
82
|
+
return
|
|
83
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
84
|
+
resizeObserver = new ResizeObserver(scheduleUpdate)
|
|
85
|
+
resizeObserver.observe(element)
|
|
86
|
+
}
|
|
87
|
+
observeLinks()
|
|
88
|
+
mutationObserver = new MutationObserver((mutations) => {
|
|
89
|
+
if (mutations.some(mutation => mutation.type === 'childList'))
|
|
90
|
+
observeLinks()
|
|
91
|
+
scheduleUpdate()
|
|
92
|
+
})
|
|
93
|
+
mutationObserver.observe(element, {
|
|
94
|
+
subtree: true,
|
|
95
|
+
childList: true,
|
|
96
|
+
attributes: true,
|
|
97
|
+
attributeFilter: options.attributes,
|
|
98
|
+
})
|
|
99
|
+
scheduleUpdate()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
onMounted(() => {
|
|
103
|
+
connect()
|
|
104
|
+
window.addEventListener('resize', scheduleUpdate)
|
|
105
|
+
})
|
|
106
|
+
watch(root, connect, { flush: 'post' })
|
|
107
|
+
if (options.enabled)
|
|
108
|
+
watch(options.enabled, scheduleUpdate, { flush: 'post' })
|
|
109
|
+
onBeforeUnmount(() => {
|
|
110
|
+
disconnect()
|
|
111
|
+
window.removeEventListener('resize', scheduleUpdate)
|
|
112
|
+
})
|
|
113
|
+
return indicator
|
|
114
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useTemplateRef } from 'vue'
|
|
3
|
+
import YlfScrollFade from '../YlfScrollFade.vue'
|
|
4
|
+
|
|
5
|
+
withDefaults(defineProps<{ label?: string, itemLabel?: string }>(), {
|
|
6
|
+
label: '最近打开',
|
|
7
|
+
itemLabel: '项目',
|
|
8
|
+
})
|
|
9
|
+
const list = useTemplateRef<HTMLUListElement>('list')
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<YlfScrollFade :viewport="list" class="scroll-demo">
|
|
14
|
+
<ul ref="list" :aria-label="label" tabindex="0" class="scroll-demo-list">
|
|
15
|
+
<li v-for="entry in 12" :key="entry">
|
|
16
|
+
{{ itemLabel }} {{ entry }}
|
|
17
|
+
</li>
|
|
18
|
+
</ul>
|
|
19
|
+
</YlfScrollFade>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<style scoped>
|
|
23
|
+
.scroll-demo {
|
|
24
|
+
width: min(100%, 24rem);
|
|
25
|
+
border: 1px solid var(--ylf-c-border);
|
|
26
|
+
border-radius: var(--ylf-radius, 14px);
|
|
27
|
+
background: var(--ylf-c-surface, #fff);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.scroll-demo-list {
|
|
31
|
+
max-height: 9rem;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
scroll-padding-block: 24px;
|
|
36
|
+
list-style: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.scroll-demo-list:focus-visible {
|
|
40
|
+
outline-offset: -3px;
|
|
41
|
+
}
|
|
42
|
+
.scroll-demo-list li {
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding: 8px 14px;
|
|
45
|
+
}
|
|
46
|
+
.scroll-demo-list li + li {
|
|
47
|
+
border-top: 1px solid var(--ylf-c-border);
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Scroll Fade
|
|
3
|
+
title_zh: 滚动渐变
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
滚动区域默认使用 `YlfScrollFade` 提示边缘外还有内容。列表全部可见时不显示渐变,滚到边界时自动移除对应一侧的渐变。组件尊重系统的减少透明度和强制颜色偏好。
|
|
7
|
+
|
|
8
|
+
用组件包裹实际滚动的元素,通过 `viewport` 传入模板引用。滚动元素继续负责高度、`overflow`、键盘焦点和语义。自定义背景时,将同一个颜色或主题变量传给 `surface`。可用 `size` 调整渐变高度,默认 24px。
|
|
9
|
+
|
|
10
|
+
```vue
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import YlfScrollFade from '@yunlefun/vue/components/YlfScrollFade.vue'
|
|
13
|
+
import { useTemplateRef } from 'vue'
|
|
14
|
+
|
|
15
|
+
const list = useTemplateRef<HTMLUListElement>('list')
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<YlfScrollFade :viewport="list" class="panel">
|
|
20
|
+
<ul ref="list" aria-label="最近打开" tabindex="0" class="viewport">
|
|
21
|
+
<li v-for="entry in 12" :key="entry">
|
|
22
|
+
项目 {{ entry }}
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
</YlfScrollFade>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<style scoped>
|
|
29
|
+
.panel {
|
|
30
|
+
background: var(--ylf-c-surface, #fff);
|
|
31
|
+
}
|
|
32
|
+
.viewport {
|
|
33
|
+
max-height: 8rem;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
scroll-padding-block: 24px;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`YlfSelect` 已内置滚动渐变。带固定表头等特殊结构可以从 `@yunlefun/vue/components/scroll-fade` 导入 `useScrollFade`,获取两侧的透明度变量,按布局放置渐变。
|