1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6 | };
|
7 |
|
8 | import { adoptedStyle, customElement, property } from '@mantou/gem/lib/decorators';
|
9 | import { html } from '@mantou/gem/lib/element';
|
10 | import { createCSSSheet, css, styleMap, classMap } from '@mantou/gem/lib/utils';
|
11 | import { theme } from '../lib/theme';
|
12 | import { DuoyunScrollBaseElement } from './base/scroll';
|
13 | import './use';
|
14 | const style = createCSSSheet(css `
|
15 | :host(:where(:not([hidden]))) {
|
16 | --size: 1.5em;
|
17 | line-height: var(--size);
|
18 | display: block;
|
19 | }
|
20 | .item {
|
21 | position: relative;
|
22 | padding-inline-start: var(--size);
|
23 | }
|
24 | .line,
|
25 | .dot {
|
26 | position: absolute;
|
27 | content: '';
|
28 | left: calc(var(--size) / 4);
|
29 | }
|
30 | .line {
|
31 | top: var(--size);
|
32 | bottom: 0;
|
33 | transform: translateX(-50%);
|
34 | width: 2px;
|
35 | background-color: ${theme.borderColor};
|
36 | }
|
37 | .last {
|
38 | display: none;
|
39 | }
|
40 | .dot {
|
41 | top: calc(var(--size) / 2);
|
42 | box-sizing: border-box;
|
43 | width: calc(var(--size) / 2);
|
44 | aspect-ratio: 1;
|
45 | transform: translate(-50%, -50%);
|
46 | }
|
47 | .circle {
|
48 | border-radius: 50%;
|
49 | color: ${theme.informativeColor};
|
50 | border: 2px solid currentColor;
|
51 | }
|
52 | .desc {
|
53 | color: ${theme.describeColor};
|
54 | padding-block-end: 0.5em;
|
55 | }
|
56 | `);
|
57 |
|
58 |
|
59 |
|
60 | let DuoyunTimelineElement = class DuoyunTimelineElement extends DuoyunScrollBaseElement {
|
61 | constructor() {
|
62 | super();
|
63 | this.render = () => {
|
64 | const events = this.events;
|
65 | if (!events)
|
66 | return html ``;
|
67 | return html `
|
68 | ${events.map(({ title, description, icon, color }, index) => html `
|
69 | <div role="listitem" class="item">
|
70 | <div class=${classMap({ line: true, last: index === events.length - 1 })}></div>
|
71 | <dy-use
|
72 | class=${classMap({ dot: true, circle: !icon })}
|
73 | style=${styleMap({ color })}
|
74 | .element=${icon}
|
75 | ></dy-use>
|
76 | <div class="title">${title}</div>
|
77 | <div class="desc">${description}</div>
|
78 | </div>
|
79 | `)}
|
80 | `;
|
81 | };
|
82 | this.internals.role = 'list';
|
83 | }
|
84 | };
|
85 | __decorate([
|
86 | property
|
87 | ], DuoyunTimelineElement.prototype, "events", void 0);
|
88 | DuoyunTimelineElement = __decorate([
|
89 | customElement('dy-timeline'),
|
90 | adoptedStyle(style)
|
91 | ], DuoyunTimelineElement);
|
92 | export { DuoyunTimelineElement };
|
93 |
|
\ | No newline at end of file |