UNPKG

6.97 kBSCSSView Raw
1@mixin node-state(
2 $direction,
3 $background,
4 $color,
5 $dot-size: $s-2
6) {
7 position: relative;
8 #{$timeline-prefix}-item-timeline {
9 position: absolute;
10 @if $direction == 'rtl' {
11 left: auto;
12 right: 0;
13 } @else {
14 left: 0;
15 }
16 top: 0;
17 height: 100%;
18
19 #{$timeline-prefix}-item-node {
20 position: relative;
21 width: $timeline-item-node-size;
22 height: calc(#{$timeline-item-node-size} + #{$timeline-item-node-padding} * 2);
23 padding: $timeline-item-node-padding 0;
24 text-align: center;
25 @if $direction == 'rtl' {
26 float: right;
27 } @else {
28 float: left;
29 }
30 }
31
32 #{$timeline-prefix}-item-node#{$timeline-prefix}-item-node-custom {
33 width: $timeline-item-custom-node-size;
34 height: auto;
35 font-size: $timeline-item-custom-node-font-size;
36 word-break: break-all;
37 @if $direction == 'rtl' {
38 margin-right: calc(0px - (#{$timeline-item-custom-node-size} - #{$timeline-item-node-size}) / 2);
39 margin-left: 0;
40 } @else {
41 margin-left: calc(0px - (#{$timeline-item-custom-node-size} - #{$timeline-item-node-size}) / 2);
42 }
43 line-height: 1;
44 }
45
46 #{$timeline-prefix}-item-dot {
47 display: block;
48 position: absolute;
49 width: $dot-size;
50 height: $dot-size;
51 border-radius: 100%;
52 top: 50%;
53 margin-top: calc(0px - #{$dot-size} / 2);
54 left: 50%;
55 margin-left: calc(0px - #{$dot-size} / 2);
56 }
57
58 #{$timeline-prefix}-item-icon {
59 display: block;
60 position: absolute;
61 width: calc(#{$timeline-item-icon-size} + 4px);
62 height: calc(#{$timeline-item-icon-size} + 4px);
63 line-height: calc(#{$timeline-item-icon-size} + 4px);
64 border-radius: 100%;
65 top: 50%;
66 left: 50%;
67 margin-top: calc(0px - #{$timeline-item-icon-size} / 2 - 2px);
68 margin-left: calc(0px - #{$timeline-item-icon-size} / 2 - 2px);
69
70 #{$timeline-icon-prefix} {
71 @include icon-size($timeline-item-icon-size);
72 }
73 }
74
75 #{$timeline-prefix}-item-tail {
76 position: absolute;
77 width: auto;
78 height: calc(100% - (#{$timeline-item-node-size} + 2 * #{$timeline-item-node-padding}));
79 top: calc(#{$timeline-item-node-size} + 2 * #{$timeline-item-node-padding});
80 @if $direction == 'rtl' {
81 left: auto;
82 right: calc(#{$timeline-item-node-size} / 2);
83 } @else {
84 left: calc(#{$timeline-item-node-size} / 2);
85 }
86
87 i {
88 display: inline-block;
89 vertical-align: top;
90 height: 100%;
91 width: $timeline-item-tail-size;
92 position: relative;
93 background: $timeline-item-tail-color;
94 -webkit-transition: all $motion-duration-immediately $motion-linear;
95 transition: all $motion-duration-immediately $motion-linear;
96 }
97 }
98 }
99
100 #{$timeline-prefix}-item-content {
101 display: inline-block;
102 @if $direction == 'rtl' {
103 margin-right: calc(#{$timeline-item-content-margin-left} + #{$timeline-item-node-size});
104 margin-left: 0;
105 } @else {
106 margin-left: calc(#{$timeline-item-content-margin-left} + #{$timeline-item-node-size});
107 }
108 #{$timeline-prefix}-item-title {
109 margin: 0;
110 font-size: $timeline-item-title-font-size;
111 font-weight: $timeline-item-title-font-weight;
112 line-height: $font-lineheight-2;
113 margin-top: $timeline-item-title-margin-top;
114 overflow: hidden;
115 text-overflow: ellipsis;
116 white-space: nowrap;
117 color: $timeline-item-title-color;
118 @if $direction == 'rtl' {
119 text-align: right;
120 } @else {
121 text-align: left;
122 }
123 }
124
125 #{$timeline-prefix}-item-body {
126 margin: 0;
127 margin-top: $timeline-item-body-margin-top;
128 font-size: $timeline-item-body-font-size;
129 line-height: $font-lineheight-2;
130 color: $timeline-item-body-color;
131 @if $direction == 'rtl' {
132 text-align: right;
133 } @else {
134 text-align: left;
135 }
136 }
137
138 #{$timeline-prefix}-item-time {
139 margin: 0;
140 margin-top: $timeline-item-time-margin-top;
141 margin-bottom: $timeline-item-time-margin-bottom;
142 font-size: $timeline-item-time-font-size;
143 color: $timeline-item-time-color;
144 @if $direction == 'rtl' {
145 text-align: right;
146 } @else {
147 text-align: left;
148 }
149 }
150 }
151
152 // 时间轴左边存在内容的情况
153 &#{$timeline-prefix}-item-has-left-content {
154 & > #{$timeline-prefix}-item-left-content {
155 position: absolute;
156 width: $timeline-item-left-content-width;
157 display: inline-block;
158 font-size: $timeline-item-left-body-font-size;
159 color: $timeline-item-left-body-color;
160 line-height: $font-lineheight-2;
161 margin-top: $timeline-item-title-margin-top;
162 @if $direction == 'rtl' {
163 text-align: left;
164 padding-left: $timeline-item-content-margin-left;
165 padding-right: 0;
166 } @else {
167 text-align: right;
168 padding-right: $timeline-item-content-margin-left;
169 }
170 p {
171 word-break: break-word;
172 }
173 }
174 & > #{$timeline-prefix}-item-timeline {
175 @if $direction == 'rtl' {
176 margin-right: $timeline-item-left-content-width;
177 margin-left: 0;
178 } @else {
179 margin-left: $timeline-item-left-content-width;
180 }
181 }
182 & > #{$timeline-prefix}-item-content {
183 @if $direction == 'rtl' {
184 margin-right: calc(#{$timeline-item-left-content-width} + #{$timeline-item-content-margin-left} + #{$timeline-item-node-size});
185 margin-left: 0;
186 } @else {
187 margin-left: calc(#{$timeline-item-left-content-width} + #{$timeline-item-content-margin-left} + #{$timeline-item-node-size});
188 }
189 }
190 }
191 #{$timeline-prefix}-item-dot {
192 background: $background;
193 }
194
195 #{$timeline-prefix}-item-icon {
196 background: $background;
197 color: $color;
198 }
199}