From 2f362226a766c60fc12c2991430f552c6b0988d6 Mon Sep 17 00:00:00 2001 From: jenson <1763417179@qq.com> Date: Thu, 28 Oct 2021 15:54:51 +0800 Subject: [PATCH 01/13] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E5=9F=BA=E7=A1=80=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/time-axis-item/index.tsx | 16 ++++++------ devui/time-axis/src/time-axis-types.ts | 12 +++++++-- devui/time-axis/src/time-axis.scss | 25 +++++++------------ devui/time-axis/src/time-axis.tsx | 17 +++++++++++-- docs/components/time-axis/index.md | 23 +++++++++-------- 5 files changed, 55 insertions(+), 38 deletions(-) diff --git a/devui/time-axis/src/components/time-axis-item/index.tsx b/devui/time-axis/src/components/time-axis-item/index.tsx index 15fae566..6a710b26 100644 --- a/devui/time-axis/src/components/time-axis-item/index.tsx +++ b/devui/time-axis/src/components/time-axis-item/index.tsx @@ -1,4 +1,4 @@ -import {defineComponent} from 'vue' +import {defineComponent, nextTick, onMounted, ref, watch} from 'vue' import {timeAxisItemProps, TimeAxisItemProps} from './types' import './index.scss' @@ -13,17 +13,19 @@ export default defineComponent({ return (
- - {props.time} - +
+ {props.time} +
-
-
+
- {props.text} +
+ {props.text} +
) diff --git a/devui/time-axis/src/time-axis-types.ts b/devui/time-axis/src/time-axis-types.ts index eb00d1b4..0a5bd2d8 100644 --- a/devui/time-axis/src/time-axis-types.ts +++ b/devui/time-axis/src/time-axis-types.ts @@ -1,6 +1,9 @@ import type { PropType, ExtractPropTypes } from 'vue' export type DataDirection = 'vertical' | 'horizontal' - +export type LineStyle = { + style: 'solid'|'dashed'|'dotted'|'none' + color:string +} export interface DataItem { @@ -8,9 +11,14 @@ export interface DataItem { time: string //文本内容 text: string - // lineStyle?: Object<{}> //可选,自定义时间圈颜色 dotColor?: string + //分界线的样式 + lineStyle?: LineStyle + + + + customDot?: string | HTMLElement //时间点类型 type?: 'primary' | 'success' | 'danger' | 'warning' diff --git a/devui/time-axis/src/time-axis.scss b/devui/time-axis/src/time-axis.scss index 0a78557f..96c02ad7 100644 --- a/devui/time-axis/src/time-axis.scss +++ b/devui/time-axis/src/time-axis.scss @@ -34,16 +34,12 @@ $devui-time-axis-item-dot-size: 18px; &-data-left { text-align: end; - margin-bottom: 24px; - height: $devui-time-axis-item-dot-size; - line-height: $devui-time-axis-item-dot-size; - flex: 1; } + &-data-left, &-data-right { margin-bottom: 24px; - height: $devui-time-axis-item-dot-size; - line-height: $devui-time-axis-item-dot-size; + margin-top: -2px; flex: 1; } @@ -94,7 +90,7 @@ $devui-time-axis-item-dot-size: 18px; &-line { position: relative; min-width: 20px; - width: calc(50% - calc(#{$devui-time-axis-item-dot-size} / 2)); + width: calc(100% - #{$devui-time-axis-item-dot-size}); border-bottom-width: 2px; border-bottom-color: $devui-dividing-line; } @@ -107,18 +103,15 @@ $devui-time-axis-item-dot-size: 18px; } } - &-data-top { - text-align: center; - display: flex; - align-items: flex-end; - padding: 0 12px; - flex: 1; - } - + &-data-top, &-data-bottom { text-align: center; - padding: 0 12px; + padding: 0 6px; flex: 1; + + > div { + transform: translateX(-50%); + } } &-line-style { diff --git a/devui/time-axis/src/time-axis.tsx b/devui/time-axis/src/time-axis.tsx index 03ae7416..5023c57e 100644 --- a/devui/time-axis/src/time-axis.tsx +++ b/devui/time-axis/src/time-axis.tsx @@ -1,4 +1,4 @@ -import { defineComponent } from 'vue' +import {defineComponent, nextTick, onMounted, ref} from 'vue' import { timeAxisProps, TimeAxisProps } from './time-axis-types' import TimeAxisItem from './components/time-axis-item' import './time-axis.scss' @@ -9,9 +9,22 @@ export default defineComponent({ props: timeAxisProps, emits: [], setup(props: TimeAxisProps, ctx) { + + const timeAxis = ref(); + let marginLeft = 35; + onMounted(() => { + nextTick(() => { + const el = timeAxis.value; + if(props.direction==='horizontal'){ + marginLeft = (el?.firstElementChild?.clientWidth||0)/2 + } + }); + }); + + return () => { return ( -
+
{ props.data.map(item=> ) } diff --git a/docs/components/time-axis/index.md b/docs/components/time-axis/index.md index 4740b68c..b4377464 100644 --- a/docs/components/time-axis/index.md +++ b/docs/components/time-axis/index.md @@ -34,26 +34,26 @@ export default defineComponent({ const data = ref([ { text: 'Download', - time: '2021-07-28' + time: '2021-10-1' }, { text: 'Check', - time: '2021-07-29', + time: '2021-10-2', dotColor: 'var(--devui-success)' }, { text: 'Build', - time: '2021-07-30', + time: '2021-10-3', dotColor: 'var(--devui-danger)' }, { text: 'Depoy', - time: '2021-07-31', + time: '2021-10-4', dotColor: 'var(--devui-warning)' }, { text: 'End', - time: '2021-08-01', + time: '2021-10-5', dotColor: 'var(--devui-waiting)' } ]) @@ -68,20 +68,21 @@ export default defineComponent({ ::: + + ### d-time-axis -d-time-axis 参数 | 参数 | 类型 | 默认 | 说明 | 跳转 Demo | | ------------ | ---- | ---- | ---- | --------- | | direction | `'vertical'\|'horizontal'` | `vertical` | 设置时间轴方向 | [基本用法](#基本用法) | -| data | `array` | `[]` | 列表数据(具体参数如下) | [基本用法](#基本用法) | +| data | `object[]` | `[]` | 列表数据(具体见[data参数](#data参数)) | [基本用法](#基本用法) | -data 参数 +#### data参数 | 参数 | 类型 | 默认 | 说明 | 跳转 Demo | | ---- | ---- | ---- | ---- | ---- | -| time|`string`| -- | 可选,时间 | | -| text |`string` | -- | 可选,文本内容 | | -| dotColor | `string` | -- | 可选,自定义时间圈颜色 | | +| time|`string`| -- | 可选,时间 | [基本用法](#基本用法) | +| text |`string` | -- | 可选,文本内容 | [基本用法](#基本用法) | +| dotColor | `string` | -- | 可选,自定义时间圈颜色 | [基本用法](#基本用法) | -- Gitee From 222a767e906674e052d3a7f366df43bb91cb19ac Mon Sep 17 00:00:00 2001 From: jenson <1763417179@qq.com> Date: Mon, 1 Nov 2021 13:18:21 +0800 Subject: [PATCH 02/13] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/devui/time-axis/index.ts | 7 +- .../src/components/time-axis-item/index.tsx | 15 ++- .../src/components/time-axis-item/types.ts | 19 +-- .../devui/time-axis/src/time-axis-types.ts | 19 +-- .../devui/time-axis/src/time-axis.tsx | 7 +- .../docs/components/time-axis/index.md | 108 ++++++++++++++++-- 6 files changed, 132 insertions(+), 43 deletions(-) diff --git a/packages/devui-vue/devui/time-axis/index.ts b/packages/devui-vue/devui/time-axis/index.ts index 4edffd52..06029110 100644 --- a/packages/devui-vue/devui/time-axis/index.ts +++ b/packages/devui-vue/devui/time-axis/index.ts @@ -1,17 +1,20 @@ import type { App } from 'vue' import TimeAxis from './src/time-axis' +import TimeAxisItem from './src/components/time-axis-item' TimeAxis.install = function(app: App): void { app.component(TimeAxis.name, TimeAxis) + app.component(TimeAxisItem.name, TimeAxisItem) } -export { TimeAxis } +export { TimeAxis,TimeAxisItem } export default { title: 'TimeAxis 时间轴', category: '数据展示', - status: '10%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 + status: '20%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 install(app: App): void { app.use(TimeAxis as any) + app.use(TimeAxisItem as any) } } diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx index 6a710b26..5e0b7a7f 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx @@ -9,6 +9,7 @@ export default defineComponent({ emits: [], setup(props: TimeAxisItemProps, ctx) { const itemClass = 'devui-time-axis-item' + console.log(ctx.slots) return () => { return (
@@ -17,14 +18,18 @@ export default defineComponent({ {props.time}
-
-
-
+
+ { + ctx.slots.dot? +
{ctx.slots.dot?.()}
: +
+ } + +
- {props.text} + {ctx.slots.default()}
diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts index fba08a5e..930d6626 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts @@ -1,19 +1,22 @@ import type { PropType, ExtractPropTypes } from 'vue' - - - +import type { LineStyle } from '../../time-axis-types' export const timeAxisItemProps = { time: { type: String, }, - text: { - type: String, - }, - //可选,自定义时间圈颜色 dotColor: { type: String - } + }, + //分界线的样式 + lineStyle: { + type: String as PropType, + default: 'solid' + }, + //分界线的样式 + lineColor: { + type: String + }, } as const export type TimeAxisItemProps = ExtractPropTypes diff --git a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts index 0a5bd2d8..fc2567d3 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts +++ b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts @@ -1,9 +1,6 @@ import type { PropType, ExtractPropTypes } from 'vue' export type DataDirection = 'vertical' | 'horizontal' -export type LineStyle = { - style: 'solid'|'dashed'|'dotted'|'none' - color:string -} +export type LineStyle = 'solid' | 'dashed' | 'dotted' | 'none' export interface DataItem { @@ -15,11 +12,12 @@ export interface DataItem { dotColor?: string //分界线的样式 lineStyle?: LineStyle - - - - + //分界线的样式 + lineColor?: string + //自定义点 customDot?: string | HTMLElement + + //时间点类型 type?: 'primary' | 'success' | 'danger' | 'warning' status?: 'runned' | 'running' | '' @@ -36,11 +34,6 @@ export const timeAxisProps = { direction: { type: String as PropType, default: 'vertical' - }, - //列表数据 - data: { - type: Array as PropType, - default:()=>[] } } as const diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.tsx b/packages/devui-vue/devui/time-axis/src/time-axis.tsx index 5023c57e..80df9d1f 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.tsx +++ b/packages/devui-vue/devui/time-axis/src/time-axis.tsx @@ -9,7 +9,6 @@ export default defineComponent({ props: timeAxisProps, emits: [], setup(props: TimeAxisProps, ctx) { - const timeAxis = ref(); let marginLeft = 35; onMounted(() => { @@ -20,14 +19,10 @@ export default defineComponent({ } }); }); - - return () => { return (
- { - props.data.map(item=> ) - } + {ctx.slots.default?.()}
) } diff --git a/packages/devui-vue/docs/components/time-axis/index.md b/packages/devui-vue/docs/components/time-axis/index.md index b4377464..079c253e 100644 --- a/packages/devui-vue/docs/components/time-axis/index.md +++ b/packages/devui-vue/docs/components/time-axis/index.md @@ -8,7 +8,7 @@ ### 基本用法 -通过 direction 配置时间线排列方向,默认值为`vertical`。 +通过 `direction` 属性配置时间线排列方向,默认值为`vertical`。 :::demo ```vue @@ -20,7 +20,17 @@ {{ item }} - + + + {{item.text}} + + +
@@ -31,7 +41,7 @@ export default defineComponent({ setup() { const list = ref(['horizontal', 'vertical']) const choose = ref('horizontal') - const data = ref([ + const timeAxisList = ref([ { text: 'Download', time: '2021-10-1' @@ -57,7 +67,7 @@ export default defineComponent({ dotColor: 'var(--devui-waiting)' } ]) - return {data, list, choose} + return {timeAxisList, list, choose} } }) @@ -68,21 +78,101 @@ export default defineComponent({ ::: +### 自定义样式 +:::demo -### d-time-axis +```vue + + + + + +``` + +::: + +### d-time-axis | 参数 | 类型 | 默认 | 说明 | 跳转 Demo | | ------------ | ---- | ---- | ---- | --------- | -| direction | `'vertical'\|'horizontal'` | `vertical` | 设置时间轴方向 | [基本用法](#基本用法) | -| data | `object[]` | `[]` | 列表数据(具体见[data参数](#data参数)) | [基本用法](#基本用法) | - +| direction | `'vertical'\|'horizontal'` | `vertical` | 设置时间轴方向 | [基本用法](#基本用法) | -#### data参数 +### d-time-axis-item参数 | 参数 | 类型 | 默认 | 说明 | 跳转 Demo | | ---- | ---- | ---- | ---- | ---- | | time|`string`| -- | 可选,时间 | [基本用法](#基本用法) | | text |`string` | -- | 可选,文本内容 | [基本用法](#基本用法) | | dotColor | `string` | -- | 可选,自定义时间圈颜色 | [基本用法](#基本用法) | +| lineStyle| `'solid'\|'dashed'\|'dotted'\|'none'` | `solid` | 可选,设置线条样式 | [自定义样式](#自定义样式) | +| lineColor |`string` | -- | 可选,设置线条颜色 | [自定义样式](#自定义样式) | + +### 插槽 + +| 参数 | 描述 | 跳转 Demo | +| ------------ | ---- | --------- | +| dot | 自定义时间轴点 | [自定义样式](#自定义样式) | -- Gitee From 3663da1f886f0974e989a1c7788e3403e912a5c9 Mon Sep 17 00:00:00 2001 From: jenson <1763417179@qq.com> Date: Mon, 8 Nov 2021 15:21:44 +0800 Subject: [PATCH 03/13] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E5=86=85=E5=AE=B9=E6=89=80=E5=A4=84=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=BE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/time-axis-item/index.tsx | 45 +++++-- .../src/components/time-axis-item/types.ts | 5 + .../devui/time-axis/src/time-axis-types.ts | 11 ++ .../devui/time-axis/src/time-axis.scss | 22 +++- .../devui/time-axis/src/time-axis.tsx | 103 ++++++++++++---- .../docs/components/time-axis/index.md | 112 +++++++++++++++--- 6 files changed, 240 insertions(+), 58 deletions(-) diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx index 5e0b7a7f..2ce03812 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx @@ -9,30 +9,51 @@ export default defineComponent({ emits: [], setup(props: TimeAxisItemProps, ctx) { const itemClass = 'devui-time-axis-item' - console.log(ctx.slots) + console.log(JSON.stringify(ctx), JSON.stringify(props)) + + const renderTime = () => { + return ( +
+ { + ctx.slots.time + ? ctx.slots.time?.() + : props.time + } +
+ ) + } + const renderContent = () => { + return ( +
+ {ctx.slots.default?.(props)} +
+ ) + } + return () => { return (
-
- {props.time} -
+ {(props.position==='top'|| props.position==='left')?renderContent():renderTime()}
-
+
{ - ctx.slots.dot? -
{ctx.slots.dot?.()}
: -
+ ctx.slots.dot + ?
{ctx.slots.dot?.()}
+ :
} -
+
-
- {ctx.slots.default()} -
+ {(props.position==='bottom'|| props.position==='right')?renderContent():renderTime()}
+ ) } } diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts index 930d6626..d87a0243 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts @@ -1,5 +1,6 @@ import type { PropType, ExtractPropTypes } from 'vue' import type { LineStyle } from '../../time-axis-types' +export type Position = 'top' | 'bottom' | 'left' | 'right' export const timeAxisItemProps = { time: { type: String, @@ -17,6 +18,10 @@ export const timeAxisItemProps = { lineColor: { type: String }, + //分界线的样式 + position: { + type: String as PropType + }, } as const export type TimeAxisItemProps = ExtractPropTypes diff --git a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts index fc2567d3..bad2a5cc 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts +++ b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts @@ -1,5 +1,6 @@ import type { PropType, ExtractPropTypes } from 'vue' export type DataDirection = 'vertical' | 'horizontal' +export type Mode = 'normal' | 'alternative' export type LineStyle = 'solid' | 'dashed' | 'dotted' | 'none' @@ -34,6 +35,16 @@ export const timeAxisProps = { direction: { type: String as PropType, default: 'vertical' + }, + //设置居中 + center: { + type: Boolean, + default: (): boolean => false + }, + //设置排序方向 + mode: { + type: String as PropType, + default: 'normal' } } as const diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.scss b/packages/devui-vue/devui/time-axis/src/time-axis.scss index 96c02ad7..8d9f36d1 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.scss +++ b/packages/devui-vue/devui/time-axis/src/time-axis.scss @@ -75,6 +75,20 @@ $devui-time-axis-item-dot-size: 18px; align-items: center; position: relative; + &-center { + .devui-time-axis-item { + + &-data-top, + &-data-bottom { + text-align: center; + padding:0 6px; + > div { + transform: translateX(-50%); + } + } + } + } + .devui-time-axis-item { display: flex; flex-direction: column; @@ -89,7 +103,7 @@ $devui-time-axis-item-dot-size: 18px; &-line { position: relative; - min-width: 20px; + min-width: 60px; width: calc(100% - #{$devui-time-axis-item-dot-size}); border-bottom-width: 2px; border-bottom-color: $devui-dividing-line; @@ -105,13 +119,9 @@ $devui-time-axis-item-dot-size: 18px; &-data-top, &-data-bottom { - text-align: center; - padding: 0 6px; + padding-right:12px; flex: 1; - > div { - transform: translateX(-50%); - } } &-line-style { diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.tsx b/packages/devui-vue/devui/time-axis/src/time-axis.tsx index 80df9d1f..c289023c 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.tsx +++ b/packages/devui-vue/devui/time-axis/src/time-axis.tsx @@ -1,30 +1,87 @@ -import {defineComponent, nextTick, onMounted, ref} from 'vue' -import { timeAxisProps, TimeAxisProps } from './time-axis-types' +import {defineComponent, Fragment, nextTick, onMounted, reactive, ref, toRef, watch} from 'vue' +import {timeAxisProps, TimeAxisProps} from './time-axis-types' import TimeAxisItem from './components/time-axis-item' import './time-axis.scss' export default defineComponent({ - name: 'DTimeAxis', - components: { TimeAxisItem }, - props: timeAxisProps, - emits: [], - setup(props: TimeAxisProps, ctx) { - const timeAxis = ref(); - let marginLeft = 35; - onMounted(() => { - nextTick(() => { - const el = timeAxis.value; - if(props.direction==='horizontal'){ - marginLeft = (el?.firstElementChild?.clientWidth||0)/2 + name: 'DTimeAxis', + components: {TimeAxisItem}, + props: timeAxisProps, + emits: [], + setup(props: TimeAxisProps, ctx) { + console.log(TimeAxisItem) + const timeAxis = ref(); + const marginLeft = ref(0); + const style = reactive({ + marginLeft: '0px', + height: 'auto' + }) + const setStyle = () => { + style.height = 'auto' + style.marginLeft = '0px' + if (props.direction === 'horizontal') { + nextTick(() => { + const el = timeAxis.value; + if (props.center) { + //计算偏移量 + style.marginLeft = (el?.firstElementChild?.clientWidth || 0) / 2 + 'px' + } + //算出最大高度 + style.height = Math.max( + ...Array.from(el?.querySelectorAll('.devui-time-axis-item-data-top')).map(el => el.clientHeight), + ...Array.from(el?.querySelectorAll('.devui-time-axis-item-data-bottom')).map(el => el.clientHeight) + ) * 2 + + Math.max(...Array.from(el?.querySelectorAll('.devui-time-axis-item-axis')).map(el => el.clientHeight)) + + 'px' + }); + } + } + onMounted(() => { + setStyle() + }); + watch(toRef(props, 'direction'), () => { + setStyle() + }) + return () => { + const renderItem = () => { + const slots: any[] = ctx.slots.default?.() ?? []; + let children; + if (slots.length === 1 && slots[0].type === Fragment) { + children = slots[0].children || [] + } + return children.map((item, index) => { + if (props.direction === 'horizontal') { + //判断是否有自定义的位置信息,且是否正确 有,且正确直接用 + if (item.props.position === 'top' || item.props.position === 'bottom') return + //判断是否需要交替 + if (props.mode === 'alternative') { + return index % 2 == 0 ? : + } else { + //不需要交替的直接给默认值 + return + } + + } else { + if (item.props.position === 'left' || item.props.position === 'right') return + if (props.mode === 'alternative') { + return index % 2 == 0 ? : + } else { + return + } + } + }) + } + + + return ( +
+ {renderItem()} +
+ ) } - }); - }); - return () => { - return ( -
- {ctx.slots.default?.()} -
- ) } - } }) diff --git a/packages/devui-vue/docs/components/time-axis/index.md b/packages/devui-vue/docs/components/time-axis/index.md index 079c253e..5b0dc7ed 100644 --- a/packages/devui-vue/docs/components/time-axis/index.md +++ b/packages/devui-vue/docs/components/time-axis/index.md @@ -20,8 +20,9 @@ {{ item }} - + {{item.text}} -
@@ -39,8 +39,8 @@ import {defineComponent, ref} from 'vue' export default defineComponent({ setup() { - const list = ref(['horizontal', 'vertical']) - const choose = ref('horizontal') + const list = ref(['vertical', 'horizontal']) + const choose = ref('vertical') const timeAxisList = ref([ { text: 'Download', @@ -71,9 +71,6 @@ export default defineComponent({ } }) - - ``` ::: @@ -85,7 +82,7 @@ export default defineComponent({ ```vue - + @@ -219,7 +223,7 @@ export default defineComponent({ { text: 'Awesome', dotColor: 'var(--devui-success)', - title: '第三季度交付版本1.0', date: '2020/09/01' + title: '第三季度交付版本1.0', date: '2020/11/01' }, ]) return {timeAxisList} @@ -277,8 +281,9 @@ export default defineComponent({ | lineColor |`string` | -- | 可选,设置线条颜色 | [自定义样式](#自定义样式) | | position |`'top'\|'bottom'\|'left'\|'right'` | 当`direction`为`vertical`时默认:`right`,当`direction`为`horizontal`时,默认:`bottom` | 可选,设置内容存在的位置,若有time则time处在相反的位置 | [自定义内容位置](#自定义内容位置) | -### 插槽 +### d-time-axis-item插槽 | 参数 | 描述 | 跳转 Demo | | ------------ | ---- | --------- | | dot | 自定义时间轴点 | [自定义样式](#自定义样式) | +| extra | 自定义两个时间点间附加元素 | [自定义内容](#自定义内容) | -- Gitee From 3676e2409e3101aa13f9631e9f7b163f2ec8461a Mon Sep 17 00:00:00 2001 From: jenson <1763417179@qq.com> Date: Tue, 9 Nov 2021 11:35:44 +0800 Subject: [PATCH 07/13] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E7=BB=84=E4=BB=B6=E6=97=B6=E9=97=B4time?= =?UTF-8?q?=E7=9A=84=E4=BD=8D=E7=BD=AE=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/devui/time-axis/index.ts | 2 +- .../src/components/time-axis-item/index.scss | 102 ------------------ .../src/components/time-axis-item/index.tsx | 26 ++++- .../src/components/time-axis-item/types.ts | 7 +- .../devui/time-axis/src/time-axis-types.ts | 40 +++---- .../devui/time-axis/src/time-axis.scss | 6 +- .../devui/time-axis/src/time-axis.tsx | 29 +++-- .../docs/components/time-axis/index.md | 30 +++++- 8 files changed, 91 insertions(+), 151 deletions(-) diff --git a/packages/devui-vue/devui/time-axis/index.ts b/packages/devui-vue/devui/time-axis/index.ts index 06029110..c3d67f63 100644 --- a/packages/devui-vue/devui/time-axis/index.ts +++ b/packages/devui-vue/devui/time-axis/index.ts @@ -12,7 +12,7 @@ export { TimeAxis,TimeAxisItem } export default { title: 'TimeAxis 时间轴', category: '数据展示', - status: '20%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 + status: '80%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 install(app: App): void { app.use(TimeAxis as any) app.use(TimeAxisItem as any) diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss index a819cfa1..4c46ac03 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss @@ -37,71 +37,6 @@ } } -.devui-time-axis-item-vertical-time-bottom { - display: flex; - - .devui-time-axis-item-axis { - display: flex; - flex-direction: column; - align-items: center; - } - - .devui-time-axis-item-dot { - &, - & > svg { - width: 18px; - height: 18px; - } - - & > i { - font-size: 18px; - } - } - - .devui-time-axis-item-custom-dot { - width: 18px; - height: 18px; - text-align: center; - } - - .devui-time-axis-item-line-time-bottom { - position: relative; - height: calc(100% - 36px); - border-left-width: 2px; - border-left-color: $devui-dividing-line; - } - - .devui-time-axis-line-style { - &-dashed { - border-left-style: dashed; - } - - &-solid { - border-left-style: solid; - } - - &-none { - border-left-style: none; - } - } - - .devui-time-axis-middle-zone { - position: absolute; - top: 50%; - transform: translate(-50%, -50%); - } - - .devui-time-axis-item-data-time-bottom { - margin-left: 12px; - margin-bottom: 40px; - } - - .devui-time-axis-item-template { - margin-left: 12px; - margin-bottom: 24px; - } -} - @keyframes devui-time-axis-running { 0% { transform: rotate(0deg); @@ -121,40 +56,3 @@ border-color: $devui-success; } } - -.devui-time-axis-item-data-hidden { - visibility: hidden; -} - -:host.devui-time-axis-item-horizontal-no-line { - width: auto !important; - - .devui-time-axis-item-data-horizontal-top { - width: max-content; - } - - .devui-time-axis-item-data-horizontal-bottom { - width: max-content; - } -} - -:host.devui-time-axis-item-vertical-no-line { - .devui-time-axis-item-data-time-bottom { - margin-bottom: 0; - } - - .devui-time-axis-item-data-vertical-left { - margin-bottom: 0; - } - - .devui-time-axis-item-data-vertical-right { - margin-bottom: 0; - } -} - -.devui-time-axis-item-horizontal-align-center { - position: relative; - width: fit-content; - transform: translateX(-50%); - left: 8px; -} diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx index b29f8bb1..627219cc 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx @@ -1,4 +1,5 @@ -import {defineComponent, nextTick, onMounted, ref, watch} from 'vue' +import {defineComponent, inject, nextTick, onMounted, ref, watch} from 'vue' +import type { TimeAxisRootType } from '../../time-axis-types' import {timeAxisItemProps, TimeAxisItemProps} from './types' import './index.scss' @@ -8,6 +9,7 @@ export default defineComponent({ props: timeAxisItemProps, emits: [], setup(props: TimeAxisItemProps, ctx) { + const timeAxis:TimeAxisRootType = inject('timeAxis') const itemClass = 'devui-time-axis-item' const renderTime = () => { return ( @@ -27,12 +29,26 @@ export default defineComponent({ ) } + const renderPosition = (types: string[]) => { + //如果有设置position的话,就直接用position的内容 + if (types.includes(props.position)) { + return renderContent() + } else { + //如果是horizontal直接返回时间 + if (timeAxis.props.direction === 'horizontal') { + return renderTime() + } else { + //如果有设定time-position,则left显示在这 + return props.timePosition === 'left' ? renderTime():'' + } + } + } return () => { return (
- {(props.position==='top'|| props.position==='left')?renderContent():renderTime()} + {renderPosition(['top','left'])}
{ @@ -42,15 +58,15 @@ export default defineComponent({ style={{borderColor: props.dotColor}} >
} - + {(timeAxis.props.direction === 'vertical'&&props.timePosition === 'bottom')?renderTime():''}
- {ctx.slots.extra?
{ctx.slots.extra()}
:''} + {ctx.slots.extra ?
{ctx.slots.extra()}
:''}
- {(props.position==='bottom'|| props.position==='right')?renderContent():renderTime()} + {renderPosition(['right','bottom'])}
diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts index d87a0243..01289a4a 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts @@ -1,5 +1,5 @@ import type { PropType, ExtractPropTypes } from 'vue' -import type { LineStyle } from '../../time-axis-types' +import type { LineStyle,TimePosition } from '../../time-axis-types' export type Position = 'top' | 'bottom' | 'left' | 'right' export const timeAxisItemProps = { time: { @@ -22,6 +22,11 @@ export const timeAxisItemProps = { position: { type: String as PropType }, + //设置时间位置 + timePosition: { + type: String as PropType, + default: 'left' + } } as const export type TimeAxisItemProps = ExtractPropTypes diff --git a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts index bad2a5cc..fa5d2106 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts +++ b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts @@ -1,35 +1,9 @@ -import type { PropType, ExtractPropTypes } from 'vue' +import type { PropType, ExtractPropTypes,SetupContext } from 'vue' export type DataDirection = 'vertical' | 'horizontal' export type Mode = 'normal' | 'alternative' +export type TimePosition = 'left' | 'bottom' export type LineStyle = 'solid' | 'dashed' | 'dotted' | 'none' - -export interface DataItem { - //时间 - time: string - //文本内容 - text: string - //可选,自定义时间圈颜色 - dotColor?: string - //分界线的样式 - lineStyle?: LineStyle - //分界线的样式 - lineColor?: string - //自定义点 - customDot?: string | HTMLElement - - - //时间点类型 - type?: 'primary' | 'success' | 'danger' | 'warning' - status?: 'runned' | 'running' | '' - position?: 'top' | 'bottom' | 'left' | 'right' - extraElement?: string | HTMLElement - iconClass?: string - data?: any -} - - - export const timeAxisProps = { //设置时间轴方向 direction: { @@ -45,7 +19,17 @@ export const timeAxisProps = { mode: { type: String as PropType, default: 'normal' + }, + //设置时间位置 + timePosition: { + type: String as PropType, + default: 'left' } } as const export type TimeAxisProps = ExtractPropTypes + +export interface TimeAxisRootType { + ctx: SetupContext + props: TimeAxisProps +} diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.scss b/packages/devui-vue/devui/time-axis/src/time-axis.scss index 8bf58de4..e4804133 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.scss +++ b/packages/devui-vue/devui/time-axis/src/time-axis.scss @@ -24,6 +24,7 @@ $devui-time-axis-item-dot-size: 18px; &-line { position: relative; height: calc(100% - #{$devui-time-axis-item-dot-size}); + min-height: 20px; border-left-width: 2px; border-left-color: $devui-dividing-line; @@ -32,6 +33,7 @@ $devui-time-axis-item-dot-size: 18px; top: 50%; transform: translate(-50%, -50%); } + &:first-child { display: none; } @@ -82,7 +84,6 @@ $devui-time-axis-item-dot-size: 18px; &-center { .devui-time-axis-item { - &-data-top, &-data-bottom { text-align: center; @@ -133,7 +134,6 @@ $devui-time-axis-item-dot-size: 18px; &-data-bottom { padding-right: 12px; flex: 1; - } &-line-style { @@ -161,7 +161,6 @@ $devui-time-axis-item-dot-size: 18px; } } } - } .devui-time-axis-item { @@ -170,6 +169,7 @@ $devui-time-axis-item-dot-size: 18px; & > svg { width: $devui-time-axis-item-dot-size; height: $devui-time-axis-item-dot-size; + flex-shrink: 0; } & > i { diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.tsx b/packages/devui-vue/devui/time-axis/src/time-axis.tsx index 85ab6aff..060a347d 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.tsx +++ b/packages/devui-vue/devui/time-axis/src/time-axis.tsx @@ -1,5 +1,5 @@ -import {defineComponent, Fragment, nextTick, onMounted, reactive, ref, toRef, watch} from 'vue' -import {timeAxisProps, TimeAxisProps} from './time-axis-types' +import {defineComponent, Fragment, nextTick, onMounted, provide, reactive, ref, toRef, watch} from 'vue' +import {timeAxisProps, TimeAxisProps,TimeAxisRootType} from './time-axis-types' import TimeAxisItem from './components/time-axis-item' import './time-axis.scss' @@ -9,6 +9,7 @@ export default defineComponent({ props: timeAxisProps, emits: [], setup(props: TimeAxisProps, ctx) { + provide('timeAxis', {ctx, props}) const timeAxis = ref(); const marginLeft = ref(0); const style = reactive({ @@ -42,6 +43,17 @@ export default defineComponent({ setStyle() }) return () => { + const renderPositionNode = (item, position?) => { + let timePosition:string = props.timePosition ? props.timePosition : 'left' + if(item.props?.timePosition||item.props?.['time-position']){ + timePosition = item.props.timePosition + } + return position + ? + : + } + + const renderItem = () => { const slots: any[] = ctx.slots.default?.() ?? []; let children; @@ -53,21 +65,20 @@ export default defineComponent({ return children.map((item, index) => { if (props.direction === 'horizontal') { //判断是否有自定义的位置信息,且是否正确 有,且正确直接用 - if (item.props?.position === 'top' || item.props?.position === 'bottom') return + if (item.props?.position === 'top' || item.props?.position === 'bottom') return renderPositionNode(item) //判断是否需要交替 if (props.mode === 'alternative') { - return index % 2 == 0 ? : + return renderPositionNode(item, index % 2 == 0 ? 'bottom' : 'top') } else { //不需要交替的直接给默认值 - return + return renderPositionNode(item, 'bottom') } - } else { - if (item.props?.position === 'left' || item.props?.position === 'right') return + if (item.props?.position === 'left' || item.props?.position === 'right') return renderPositionNode(item) if (props.mode === 'alternative') { - return index % 2 == 0 ? : + return renderPositionNode(item, index % 2 == 0 ? 'left' : 'right') } else { - return + return renderPositionNode(item, 'right') } } }) diff --git a/packages/devui-vue/docs/components/time-axis/index.md b/packages/devui-vue/docs/components/time-axis/index.md index 3870bcfd..1ff7bc0b 100644 --- a/packages/devui-vue/docs/components/time-axis/index.md +++ b/packages/devui-vue/docs/components/time-axis/index.md @@ -86,11 +86,13 @@ export default defineComponent({ + @@ -184,7 +186,9 @@ export default defineComponent({ @@ -262,6 +266,25 @@ export default defineComponent({ ::: +### 设置时间位置 + +:::demo + +```vue + +``` + +::: + ### d-time-axis | 参数 | 类型 | 默认 | 说明 | 跳转 Demo | @@ -269,6 +292,7 @@ export default defineComponent({ | direction | `'vertical'\|'horizontal'` | `vertical` | 设置时间轴方向 | [基本用法](#基本用法) | | center | `boolean`| `false` | 当方向为`horizontal`时,是否将内容设置居中 | [基本用法](#基本用法) | | mode | `'normal'\|'alternative'` | `normal` | 可选,`normal`模式下内容按默认方向排布, `alternative`模式下内容交替排布 | [自定义内容](#自定义内容) | +| time-position | `'left'\|'bottom'` | `left` | 可选,仅当`direction` 为 `vertical` 时定义时间参数位置(全局设置,当与`mode`属性冲突时以`mode`为准) | [自定义内容](#自定义内容) | ### d-time-axis-item参数 @@ -280,10 +304,12 @@ export default defineComponent({ | lineStyle| `'solid'\|'dashed'\|'dotted'\|'none'` | `solid` | 可选,设置线条样式 | [自定义样式](#自定义样式) | | lineColor |`string` | -- | 可选,设置线条颜色 | [自定义样式](#自定义样式) | | position |`'top'\|'bottom'\|'left'\|'right'` | 当`direction`为`vertical`时默认:`right`,当`direction`为`horizontal`时,默认:`bottom` | 可选,设置内容存在的位置,若有time则time处在相反的位置 | [自定义内容位置](#自定义内容位置) | +| time-position | `'left'\|'bottom'` | `left` | 可选,仅当`direction` 为 `vertical` 时定义时间参数位置(全局设置,当与`position`属性冲突时以`position`为准) | [自定义内容](#自定义内容) | ### d-time-axis-item插槽 | 参数 | 描述 | 跳转 Demo | | ------------ | ---- | --------- | | dot | 自定义时间轴点 | [自定义样式](#自定义样式) | +| time | 自定义时间 | [自定义样式](#自定义样式) | | extra | 自定义两个时间点间附加元素 | [自定义内容](#自定义内容) | -- Gitee From 7a872479702bcbd9a0e67850434c563e4b46fd46 Mon Sep 17 00:00:00 2001 From: jenson <1763417179@qq.com> Date: Tue, 9 Nov 2021 13:02:08 +0800 Subject: [PATCH 08/13] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E7=BB=84=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/devui/time-axis/index.ts | 2 +- .../src/components/time-axis-item/index.scss | 58 ------------------- .../src/components/time-axis-item/index.tsx | 44 +++++++++----- .../src/components/time-axis-item/types.ts | 6 ++ .../devui/time-axis/src/time-axis.scss | 54 +++++++++++++++++ .../devui/time-axis/src/time-axis.tsx | 6 +- .../docs/components/time-axis/index.md | 37 +++++++----- 7 files changed, 116 insertions(+), 91 deletions(-) delete mode 100644 packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss diff --git a/packages/devui-vue/devui/time-axis/index.ts b/packages/devui-vue/devui/time-axis/index.ts index c3d67f63..59ac2dbc 100644 --- a/packages/devui-vue/devui/time-axis/index.ts +++ b/packages/devui-vue/devui/time-axis/index.ts @@ -12,7 +12,7 @@ export { TimeAxis,TimeAxisItem } export default { title: 'TimeAxis 时间轴', category: '数据展示', - status: '80%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 + status: '90%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 install(app: App): void { app.use(TimeAxis as any) app.use(TimeAxisItem as any) diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss deleted file mode 100644 index 4c46ac03..00000000 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.scss +++ /dev/null @@ -1,58 +0,0 @@ -@import '../../../../style/theme/color'; - -.devui-time-axis-item-type { - &-primary { - border: 2px solid $devui-placeholder; - border-radius: 50%; - } - - &-right { - i { - color: $devui-success; - } - } - - &-danger { - path { - fill: $devui-danger; - } - - circle { - fill: $devui-light-text; - } - } - - &-warning { - i { - color: $devui-warning; - } - } - - &-running { - line-height: 16px; - text-align: center; - animation: devui-time-axis-running 1.5s linear infinite; - border: 2px solid $devui-success; - border-radius: 50%; - } -} - -@keyframes devui-time-axis-running { - 0% { - transform: rotate(0deg); - color: $devui-success; - border-color: $devui-success; - } - - 50% { - transform: rotate(180deg); - color: $devui-success; - border-color: $devui-success; - } - - 100% { - transform: rotate(360deg); - color: $devui-success; - border-color: $devui-success; - } -} diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx index 627219cc..6600a304 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx @@ -1,15 +1,15 @@ import {defineComponent, inject, nextTick, onMounted, ref, watch} from 'vue' -import type { TimeAxisRootType } from '../../time-axis-types' - -import {timeAxisItemProps, TimeAxisItemProps} from './types' -import './index.scss' +import type {TimeAxisRootType} from '../../time-axis-types' +import DIcon from '../../../../icon/src/icon' +import {timeAxisItemProps, TimeAxisItemProps, Type} from './types' export default defineComponent({ name: 'DTimeAxisItem', props: timeAxisItemProps, + components: {DIcon}, emits: [], setup(props: TimeAxisItemProps, ctx) { - const timeAxis:TimeAxisRootType = inject('timeAxis') + const timeAxis: TimeAxisRootType = inject('timeAxis') const itemClass = 'devui-time-axis-item' const renderTime = () => { return ( @@ -39,34 +39,48 @@ export default defineComponent({ return renderTime() } else { //如果有设定time-position,则left显示在这 - return props.timePosition === 'left' ? renderTime():'' + return props.timePosition === 'left' ? renderTime() : '' } } } + const setTypeIcon = (type: Type) => { + if (type === 'primary') { + return '' + } + return + } + const renderDot = () => { + if (ctx.slots.dot) { + return
{ctx.slots.dot?.()}
+ } else { + return (
+ {setTypeIcon(props.type)} +
) + } + + } return () => { return (
- {renderPosition(['top','left'])} + {renderPosition(['top', 'left'])}
{ - ctx.slots.dot - ?
{ctx.slots.dot?.()}
- :
+ renderDot() } - {(timeAxis.props.direction === 'vertical'&&props.timePosition === 'bottom')?renderTime():''} + {(timeAxis.props.direction === 'vertical' && props.timePosition === 'bottom') ? renderTime() : ''}
- {ctx.slots.extra ?
{ctx.slots.extra()}
:''} + {ctx.slots.extra ?
{ctx.slots.extra()}
: ''}
- {renderPosition(['right','bottom'])} + {renderPosition(['right', 'bottom'])}
diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts index 01289a4a..d4172592 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/types.ts @@ -1,6 +1,7 @@ import type { PropType, ExtractPropTypes } from 'vue' import type { LineStyle,TimePosition } from '../../time-axis-types' export type Position = 'top' | 'bottom' | 'left' | 'right' +export type Type = 'primary' | 'success' | 'warning' | 'error' export const timeAxisItemProps = { time: { type: String, @@ -26,6 +27,11 @@ export const timeAxisItemProps = { timePosition: { type: String as PropType, default: 'left' + }, + //时间点类型 + type: { + type: String as PropType, + default: 'primary' } } as const diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.scss b/packages/devui-vue/devui/time-axis/src/time-axis.scss index e4804133..6d15b4cc 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.scss +++ b/packages/devui-vue/devui/time-axis/src/time-axis.scss @@ -174,6 +174,7 @@ $devui-time-axis-item-dot-size: 18px; & > i { font-size: $devui-time-axis-item-dot-size; + vertical-align: 0; } } @@ -184,4 +185,57 @@ $devui-time-axis-item-dot-size: 18px; } } } + + &-type { + &-primary { + border: 2px solid $devui-placeholder; + border-radius: 50%; + } + + &-success { + i { + color: $devui-success; + } + } + + &-error { + i { + color: $devui-danger; + } + } + + &-warning { + i { + color: $devui-warning; + } + } + + &-running { + line-height: 16px; + text-align: center; + animation: devui-time-axis-running 1.5s linear infinite; + border: 2px solid $devui-success; + border-radius: 50%; + } + } +} + +@keyframes devui-time-axis-running { + 0% { + transform: rotate(0deg); + color: $devui-success; + border-color: $devui-success; + } + + 50% { + transform: rotate(180deg); + color: $devui-success; + border-color: $devui-success; + } + + 100% { + transform: rotate(360deg); + color: $devui-success; + border-color: $devui-success; + } } diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.tsx b/packages/devui-vue/devui/time-axis/src/time-axis.tsx index 060a347d..91e26335 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.tsx +++ b/packages/devui-vue/devui/time-axis/src/time-axis.tsx @@ -1,5 +1,5 @@ import {defineComponent, Fragment, nextTick, onMounted, provide, reactive, ref, toRef, watch} from 'vue' -import {timeAxisProps, TimeAxisProps,TimeAxisRootType} from './time-axis-types' +import {timeAxisProps, TimeAxisProps, TimeAxisRootType} from './time-axis-types' import TimeAxisItem from './components/time-axis-item' import './time-axis.scss' @@ -44,8 +44,8 @@ export default defineComponent({ }) return () => { const renderPositionNode = (item, position?) => { - let timePosition:string = props.timePosition ? props.timePosition : 'left' - if(item.props?.timePosition||item.props?.['time-position']){ + let timePosition: string = props.timePosition ? props.timePosition : 'left' + if (item.props?.timePosition || item.props?.['time-position']) { timePosition = item.props.timePosition } return position diff --git a/packages/devui-vue/docs/components/time-axis/index.md b/packages/devui-vue/docs/components/time-axis/index.md index 1ff7bc0b..571df207 100644 --- a/packages/devui-vue/docs/components/time-axis/index.md +++ b/packages/devui-vue/docs/components/time-axis/index.md @@ -178,6 +178,9 @@ export default defineComponent({ >
{{ item.title }}
发布日期:{{ item.date }}
+
版本状态: + {{item.status}} +
- - Download - Check - Build - Depoy - End + ``` @@ -294,7 +302,7 @@ export default defineComponent({ | mode | `'normal'\|'alternative'` | `normal` | 可选,`normal`模式下内容按默认方向排布, `alternative`模式下内容交替排布 | [自定义内容](#自定义内容) | | time-position | `'left'\|'bottom'` | `left` | 可选,仅当`direction` 为 `vertical` 时定义时间参数位置(全局设置,当与`mode`属性冲突时以`mode`为准) | [自定义内容](#自定义内容) | -### d-time-axis-item参数 +### d-time-axis-item | 参数 | 类型 | 默认 | 说明 | 跳转 Demo | | ---- | ---- | ---- | ---- | ---- | @@ -304,7 +312,8 @@ export default defineComponent({ | lineStyle| `'solid'\|'dashed'\|'dotted'\|'none'` | `solid` | 可选,设置线条样式 | [自定义样式](#自定义样式) | | lineColor |`string` | -- | 可选,设置线条颜色 | [自定义样式](#自定义样式) | | position |`'top'\|'bottom'\|'left'\|'right'` | 当`direction`为`vertical`时默认:`right`,当`direction`为`horizontal`时,默认:`bottom` | 可选,设置内容存在的位置,若有time则time处在相反的位置 | [自定义内容位置](#自定义内容位置) | -| time-position | `'left'\|'bottom'` | `left` | 可选,仅当`direction` 为 `vertical` 时定义时间参数位置(全局设置,当与`position`属性冲突时以`position`为准) | [自定义内容](#自定义内容) | +| time-position | `'left'\|'bottom'` | `left` | 可选,仅当`direction` 为 `vertical` 时定义时间参数位置(全局设置,当与`position`属性冲突时以`position`为准) | [设置时间位置](#设置时间位置) | +| type | `'primary' \| 'success' \| 'warning' \| 'error'` | `primary` | 可选,时间点类型 | [自定义内容](#自定义内容) | ### d-time-axis-item插槽 -- Gitee From 49cc325abcab11f0973c4cdba1f5777f8e17484c Mon Sep 17 00:00:00 2001 From: jenson <1763417179@qq.com> Date: Wed, 10 Nov 2021 14:50:06 +0800 Subject: [PATCH 09/13] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E7=BB=84=E4=BB=B6=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/time-axis-item/index.tsx | 7 ++-- .../devui/time-axis/src/time-axis-types.ts | 2 +- .../devui/time-axis/src/time-axis.scss | 14 ++++---- .../devui/time-axis/src/time-axis.tsx | 35 +++++++++++-------- .../docs/components/time-axis/index.md | 18 ++++------ 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx index 6600a304..42b64306 100644 --- a/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx +++ b/packages/devui-vue/devui/time-axis/src/components/time-axis-item/index.tsx @@ -13,7 +13,7 @@ export default defineComponent({ const itemClass = 'devui-time-axis-item' const renderTime = () => { return ( -
+
{ ctx.slots.time ? ctx.slots.time?.() @@ -24,7 +24,7 @@ export default defineComponent({ } const renderContent = () => { return ( -
+
{ctx.slots.default?.(props)}
) @@ -51,7 +51,7 @@ export default defineComponent({ } const renderDot = () => { if (ctx.slots.dot) { - return
{ctx.slots.dot?.()}
+ return
{ctx.slots.dot?.()}
} else { return (
) } - } return () => { diff --git a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts index fa5d2106..4ca37a47 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis-types.ts +++ b/packages/devui-vue/devui/time-axis/src/time-axis-types.ts @@ -13,7 +13,7 @@ export const timeAxisProps = { //设置居中 center: { type: Boolean, - default: (): boolean => false + default: false }, //设置排序方向 mode: { diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.scss b/packages/devui-vue/devui/time-axis/src/time-axis.scss index 6d15b4cc..24b1ec55 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.scss +++ b/packages/devui-vue/devui/time-axis/src/time-axis.scss @@ -178,13 +178,13 @@ $devui-time-axis-item-dot-size: 18px; } } - &:last-child { - .devui-time-axis-item-line { - &:last-child { - display: none; - } - } - } + //&:last-child { + // .devui-time-axis-item-line { + // &:last-child { + // display: none; + // } + // } + //} &-type { &-primary { diff --git a/packages/devui-vue/devui/time-axis/src/time-axis.tsx b/packages/devui-vue/devui/time-axis/src/time-axis.tsx index 91e26335..54fdda5d 100644 --- a/packages/devui-vue/devui/time-axis/src/time-axis.tsx +++ b/packages/devui-vue/devui/time-axis/src/time-axis.tsx @@ -43,14 +43,10 @@ export default defineComponent({ setStyle() }) return () => { - const renderPositionNode = (item, position?) => { - let timePosition: string = props.timePosition ? props.timePosition : 'left' - if (item.props?.timePosition || item.props?.['time-position']) { - timePosition = item.props.timePosition - } + const renderItemPosition = (item, position?) => { return position - ? - : + ? + : } @@ -63,22 +59,33 @@ export default defineComponent({ children = slots } return children.map((item, index) => { + //默认隐藏最后一条线 + if ((index + 1) === children.length) { + if (!item.props?.lineStyle && !item.props?.['line-style']) { + item = + } + } + //如果没有单独设置time-position属性,则以全局为准 + if (!item.props?.timePosition && !item.props?.['time-position']) { + item = + } + if (props.direction === 'horizontal') { //判断是否有自定义的位置信息,且是否正确 有,且正确直接用 - if (item.props?.position === 'top' || item.props?.position === 'bottom') return renderPositionNode(item) + if (item.props?.position === 'top' || item.props?.position === 'bottom') return item //判断是否需要交替 if (props.mode === 'alternative') { - return renderPositionNode(item, index % 2 == 0 ? 'bottom' : 'top') + return renderItemPosition(item, index % 2 == 0 ? 'bottom' : 'top') } else { //不需要交替的直接给默认值 - return renderPositionNode(item, 'bottom') + return renderItemPosition(item, 'bottom') } } else { - if (item.props?.position === 'left' || item.props?.position === 'right') return renderPositionNode(item) + if (item.props?.position === 'left' || item.props?.position === 'right') return item if (props.mode === 'alternative') { - return renderPositionNode(item, index % 2 == 0 ? 'left' : 'right') + return renderItemPosition(item, index % 2 == 0 ? 'left' : 'right') } else { - return renderPositionNode(item, 'right') + return renderItemPosition(item, 'right') } } }) @@ -90,7 +97,7 @@ export default defineComponent({ return (
diff --git a/packages/devui-vue/docs/components/time-axis/index.md b/packages/devui-vue/docs/components/time-axis/index.md index 571df207..01ae74f4 100644 --- a/packages/devui-vue/docs/components/time-axis/index.md +++ b/packages/devui-vue/docs/components/time-axis/index.md @@ -12,7 +12,6 @@ :::demo ```vue -