nextcloud-app-radio/src/components/Table.vue

187 lines
3.4 KiB
Vue
Raw Normal View History

2020-10-17 18:06:57 +00:00
<template>
2020-10-19 19:23:26 +00:00
<table v-if="stationData" id="table">
2020-10-17 18:06:57 +00:00
<thead>
<tr>
<th />
<th class="nameColumn">
2020-10-18 09:49:17 +00:00
{{ t('radio', 'Name') }}
2020-10-17 18:06:57 +00:00
</th>
<th />
</tr>
</thead>
2020-10-19 19:23:26 +00:00
<tbody>
2020-10-19 18:06:07 +00:00
<tr
v-for="(station, idx) in stationData"
:key="idx"
:class="{ selected: idx === activeItem}">
2020-10-20 13:09:30 +00:00
<td @click="doPlay(idx, station)">
2020-10-17 18:06:57 +00:00
<div class="stationIcon"
2020-10-19 19:23:26 +00:00
:style="{ backgroundImage: `url('${ station.favicon }')` }">
2020-10-20 13:09:30 +00:00
<span :class="{ 'icon-starred': stationsFavored.includes(idx) }" />
2020-10-19 19:23:26 +00:00
</div>
2020-10-17 18:06:57 +00:00
</td>
2020-10-19 18:06:07 +00:00
<td class="filenameColumn" @click="doPlay(idx, station)">
2020-10-17 18:06:57 +00:00
<span class="innernametext">
{{ station.name }}
</span>
</td>
<td class="actionColumn">
<Actions>
2020-10-19 19:23:26 +00:00
<ActionButton icon="icon-star" :close-after-click="true" @click="doFavor(idx, station)">
2020-10-18 09:49:17 +00:00
{{ t('radio', 'Add to favorites') }}
2020-10-17 18:06:57 +00:00
</ActionButton>
<ActionButton icon="icon-info" :close-after-click="true">
2020-10-18 09:49:17 +00:00
{{ t('radio', 'Details') }}
2020-10-17 18:06:57 +00:00
</ActionButton>
</Actions>
</td>
</tr>
</tbody>
</table>
</template>
<script>
import Actions from '@nextcloud/vue/dist/Components/Actions'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
export default {
name: 'Table',
components: {
Actions,
ActionButton,
},
props: {
stationData: {
type: Array,
default() { return [] },
},
},
2020-10-19 18:06:07 +00:00
data() {
return {
activeItem: null,
2020-10-20 13:03:20 +00:00
stationsFavored: [1, 2],
2020-10-19 18:06:07 +00:00
}
},
methods: {
2020-10-19 18:06:07 +00:00
doPlay(idx, station) {
this.activeItem = idx
this.$emit('doPlay', station)
},
2020-10-19 19:23:26 +00:00
doFavor(idx, station) {
this.$emit('doFavor', station)
},
},
2020-10-17 18:06:57 +00:00
}
</script>
<style lang="scss">
table {
width: 100%;
min-width: 250px;
thead {
background-color: var(--color-main-background-translucent);
z-index: 60;
position: sticky;
position: -webkit-sticky;
top: 99px;
th {
border-bottom: 1px solid var(--color-border);
padding: 15px;
height: 50px;
}
th, th a {
color: var(--color-text-maxcontrast);
}
th.nameColumn {
width: 100%;
}
}
tbody {
td {
padding: 0 15px;
font-style: normal;
background-position: 8px center;
background-repeat: no-repeat;
border-bottom: 1px solid var(--color-border);
2020-10-19 19:23:26 +00:00
cursor: pointer;
2020-10-17 18:06:57 +00:00
}
tr {
height: 51px;
background-color: var(--color-background-light);
tr:hover, tr:focus, tr.mouseOver td {
background-color: var(--color-background-hover);
}
2020-10-20 13:03:20 +00:00
}
tr.selected {
background-color: var(--color-primary-light);
2020-10-19 18:06:07 +00:00
}
2020-10-17 18:06:57 +00:00
tr td:first-child {
padding-left: 40px;
width: 32px;
padding-right: 0px;
}
td.filenameColumn .innernametext {
color: var(--color-main-text);
text-overflow: ellipsis;
overflow: hidden;
position: relative;
vertical-align: top;
user-select: none;
2020-10-19 19:23:26 +00:00
cursor: pointer;
2020-10-17 18:06:57 +00:00
}
.stationIcon {
width: 32px;
height: 32px;
background-repeat: no-repeat;
background-size: contain;
background-position: center;
2020-10-20 13:03:20 +00:00
cursor: pointer;
2020-10-17 18:06:57 +00:00
}
2020-10-19 19:23:26 +00:00
.icon-starred {
background-image: var(--icon-star-dark-fc0);
vertical-align: middle;
background-size: 16px 16px;
display: inline-block;
background-repeat: no-repeat;
background-position: center;
min-width: 16px;
min-height: 16px;
2020-10-20 13:03:20 +00:00
cursor: pointer;
pointer-events: none;
right: -7px;
top: -7px;
float: right;
position: relative;
2020-10-19 19:23:26 +00:00
}
2020-10-17 18:06:57 +00:00
.actionColumn {
width: auto;
padding-right: 40px;
}
.filenameColumn {
width: 100%;
}
}
}
</style>