Skip to content

Commit b3b9772

Browse files
committed
Support item head color variants
1 parent 97541be commit b3b9772

File tree

3 files changed

+63
-12
lines changed

3 files changed

+63
-12
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export default Vue.extend({
7171
>
7272
<b-timeline
7373
:items="timelineItems"
74-
:reverse="true"
75-
:loading="true"
76-
:date-format="'dd/MM/yy HH:mm:ss'"
74+
:reverse="false"
75+
date-format="dd/MM/yy HH:mm:ss"
76+
variant="primary"
77+
loading
7778
/>
7879
</b-card>
7980
</div>
@@ -84,7 +85,7 @@ export default Vue.extend({
8485
- [x] Loading spinner
8586
- [x] Support `reverse` props
8687
- [x] Custom timestamp format
87-
- [ ] Support item head color variants
88+
- [x] Support item head color variants
8889
- [ ] Support custom icons
8990
- [ ] Refactor timeline and item into separate components
9091

dev/serve.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ export default Vue.extend({
4343
<bootstrap-vue-timeline
4444
:items="timelineItems"
4545
:reverse="false"
46-
:loading="true"
47-
:date-format="'dd/MM/yy HH:mm:ss'"
46+
date-format="dd/MM/yy HH:mm:ss"
47+
variant="primary"
48+
loading
4849
/>
4950
</b-card>
5051
</div>

src/bootstrap-vue-timeline.vue

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ export default /*#__PURE__*/{
1515
reverse: Boolean,
1616
loading: Boolean,
1717
dateFormat: String,
18+
variant: String,
1819
},
1920
methods: {
21+
bsVariant() {
22+
return this.variant || 'primary'
23+
},
2024
orderedItems() {
2125
let items = this.items
2226
if (this.loading) {
@@ -57,15 +61,15 @@ export default /*#__PURE__*/{
5761
:key="item.timestamp + item.title"
5862
class="flex-column align-items-start"
5963
>
60-
<div class="item-head" />
64+
<div :class="`item-head ${bsVariant()}`" />
6165
<div
6266
v-if="index !== itemsCount() - 1"
6367
class="item-tail"
6468
/>
6569

6670
<b-spinner
6771
v-if="item.spinner"
68-
variant="primary"
72+
:variant="bsVariant()"
6973
class="ml-4"
7074
/>
7175

@@ -74,7 +78,7 @@ export default /*#__PURE__*/{
7478
class="item-content"
7579
>
7680
<div class="d-flex w-100 justify-content-between">
77-
<h5 class="mt-2 mb-1">
81+
<h5 class="mb-1">
7882
{{ item.title }}
7983
</h5>
8084
<small
@@ -108,9 +112,6 @@ export default /*#__PURE__*/{
108112
}
109113
110114
.item-head {
111-
background-color: #1890ff;
112-
color: #1890ff;
113-
border-color: #1890ff;
114115
position: absolute;
115116
width: 10px;
116117
height: 10px;
@@ -132,4 +133,52 @@ export default /*#__PURE__*/{
132133
margin: 0 0 0 18px;
133134
word-break: break-word;
134135
}
136+
137+
.primary {
138+
background-color: #007bff;
139+
color: #007bff;
140+
border-color: #007bff;
141+
}
142+
143+
.secondary {
144+
background-color: #6c757d;
145+
color: #6c757d;
146+
border-color: #6c757d;
147+
}
148+
149+
.success {
150+
background-color: #28a745;
151+
color: #28a745;
152+
border-color: #28a745;
153+
}
154+
155+
.info {
156+
background-color: #17a2b8;
157+
color: #17a2b8;
158+
border-color: #17a2b8;
159+
}
160+
161+
.warning {
162+
background-color: #ffc107;
163+
color: #ffc107;
164+
border-color: #ffc107;
165+
}
166+
167+
.danger {
168+
background-color: #dc3545;
169+
color: #dc3545;
170+
border-color: #dc3545;
171+
}
172+
173+
.light {
174+
background-color: #f8f9fa;
175+
color: #f8f9fa;
176+
border-color: #f8f9fa;
177+
}
178+
179+
.dark {
180+
background-color: #343a40;
181+
color: #343a40;
182+
border-color: #343a40;
183+
}
135184
</style>

0 commit comments

Comments
 (0)