forked from AkkomaGang/akkoma-fe
add some styling to the selectable-list component
This commit is contained in:
parent
f6e9f28745
commit
3a318dc373
2 changed files with 22 additions and 4 deletions
|
@ -21,7 +21,7 @@ const SelectableList = {
|
|||
},
|
||||
methods: {
|
||||
toggle (checked, item) {
|
||||
const oldChecked = this.isChecked(item)
|
||||
const oldChecked = this.isSelected(item)
|
||||
if (checked !== oldChecked) {
|
||||
const key = this.getKey(item)
|
||||
if (checked) {
|
||||
|
@ -31,7 +31,7 @@ const SelectableList = {
|
|||
}
|
||||
}
|
||||
},
|
||||
isChecked (item) {
|
||||
isSelected (item) {
|
||||
return this.selected.indexOf(this.getKey(item)) !== -1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<template>
|
||||
<div class="selectable-list">
|
||||
<div v-for="item in items" :key="getKey(item)">
|
||||
<Checkbox :checked="isChecked(item)" @change="checked => toggle(checked, item)" />
|
||||
<div v-for="item in items" :key="getKey(item)" class="selectable-list-item" :class="{ 'selectable-list-item-selected': isSelected(item) }">
|
||||
<div class="selectable-list-checkbox-wrapper">
|
||||
<Checkbox :checked="isSelected(item)" @change="checked => toggle(checked, item)" />
|
||||
</div>
|
||||
<slot name="item" :item="item" />
|
||||
</div>
|
||||
<div class="selectable-list-empty-content faint" v-if="items.length === 0">
|
||||
|
@ -13,7 +15,23 @@
|
|||
<script src="./selectable_list.js"></script>
|
||||
|
||||
<style lang="scss">
|
||||
@import '../../_variables.scss';
|
||||
|
||||
.selectable-list {
|
||||
&-item {
|
||||
display: flex;
|
||||
|
||||
&-selected {
|
||||
background-color: $fallback--lightBg;
|
||||
background-color: var(--lightBg, $fallback--lightBg);
|
||||
}
|
||||
}
|
||||
|
||||
&-checkbox-wrapper {
|
||||
padding: 10px;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
&-empty-content {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
|
|
Loading…
Reference in a new issue