| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <view class="cl-timeline-item" :class="[pt.classNames]">
- <view class="cl-timeline-item__left">
- <cl-icon
- v-if="icon != ''"
- :name="icon"
- :size="34"
- :pt="{
- className: `${pt.icon?.className}`
- }"
- ></cl-icon>
- <view v-else class="cl-timeline-item__dot"></view>
- <view class="cl-timeline-item__line" v-if="!hideLine"></view>
- </view>
- <view
- class="cl-timeline-item__right"
- :class="[
- {
- 'is-icon': icon != '',
- 'is-title': title != ''
- }
- ]"
- >
- <cl-text
- v-if="title != ''"
- :pt="{
- className: parseClass([
- `mb-1 !font-bold ${pt.title?.className}`,
- [isDark, '!text-white', '!text-surface-900']
- ])
- }"
- >{{ title }}</cl-text
- >
- <cl-text
- v-if="content != ''"
- :pt="{
- className: `mb-2 !text-sm ${pt.content?.className}`
- }"
- >{{ content }}</cl-text
- >
- <slot></slot>
- <cl-text
- v-if="date != ''"
- :pt="{
- className: `!text-xs ${pt.date?.className}`
- }"
- color="info"
- >{{ date }}</cl-text
- >
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import { computed } from "vue";
- import { isDark, parseClass, parsePt } from "@/cool";
- import type { PassThroughProps } from "../../types";
- defineOptions({
- name: "cl-timeline-item"
- });
- const props = defineProps({
- pt: {
- type: Object,
- default: () => ({})
- },
- // 标题
- title: {
- type: String,
- default: ""
- },
- // 图标
- icon: {
- type: String,
- default: ""
- },
- // 内容
- content: {
- type: String,
- default: ""
- },
- // 日期
- date: {
- type: String,
- default: ""
- },
- // 是否隐藏线
- hideLine: {
- type: Boolean,
- default: false
- }
- });
- type PassThrough = {
- classNames?: string;
- icon?: PassThroughProps;
- title?: PassThroughProps;
- content?: PassThroughProps;
- date?: PassThroughProps;
- };
- const pt = computed(() => parsePt<PassThrough>(props.pt));
- </script>
- <style lang="scss" scoped>
- .cl-timeline-item {
- @apply flex flex-row w-full;
- overflow: visible;
- margin-bottom: 10rpx;
- &__left {
- @apply flex flex-col items-center h-full relative;
- width: 50rpx;
- margin-right: 10rpx;
- overflow: visible;
- }
- &__dot {
- @apply rounded-full bg-surface-300;
- height: 16rpx;
- width: 16rpx;
- }
- &__line {
- @apply bg-surface-300;
- width: 1rpx;
- flex: 1;
- margin-top: 10rpx;
- }
- &__right {
- @apply relative;
- top: -12rpx;
- flex: 1;
- margin-bottom: 40rpx;
- &.is-title {
- top: -12rpx;
- }
- &.is-icon {
- top: -4rpx;
- }
- }
- }
- </style>
|