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

241 lines
4.6 KiB
Vue
Raw Normal View History

2020-10-17 18:06:57 +00:00
<template>
<table>
2020-10-17 18:06:57 +00:00
<thead>
<tr>
2020-10-21 08:31:59 +00:00
<th class="iconColumn" />
2020-10-17 18:06:57 +00:00
<th class="nameColumn">
2020-10-18 09:49:17 +00:00
{{ t('radio', 'Name') }}
2020-10-17 18:06:57 +00:00
</th>
2020-10-21 08:31:59 +00:00
<th class="actionColumn" />
2020-10-17 18:06:57 +00:00
</tr>
</thead>
2020-10-19 19:23:26 +00:00
<tbody>
<template v-if="stationData[0].type!=='folder'">
<tr
v-for="(station, idx) in stationData"
:key="idx"
:class="{ selected: idx === activeItem}">
<td @click="doPlay(idx, station)">
<blur-hash-image
class="stationIcon"
width="32"
height="32"
:hash="station.blurHash"
:src="station.favicon" />
<span :class="{ 'icon-starred': favorites.flat().includes(station.stationuuid) }" />
</td>
<td class="nameColumn" @click="doPlay(idx, station)">
<span class="innernametext">
{{ station.name }}
</span>
</td>
<td class="actionColumn">
<Actions>
<ActionButton
v-if="!favorites.flat().includes(station.stationuuid)"
icon="icon-star"
:close-after-click="true"
@click="doFavor(idx, station)">
{{ t('radio', 'Add to favorites') }}
</ActionButton>
<ActionButton
v-if="favorites.flat().includes(station.stationuuid)"
icon="icon-star"
:close-after-click="true"
@click="doFavor(idx, station)">
{{ t('radio', 'Remove from favorites') }}
</ActionButton>
<ActionButton
icon="icon-info"
:close-after-click="true"
@click="toggleSidebar(station)">
{{ t('radio', 'Details') }}
</ActionButton>
</Actions>
</td>
</tr>
</template>
<template v-if="stationData[0].type==='folder'">
<tr
v-for="(station, idx) in stationData"
:key="idx"
@click="doPlay(idx, station)">
<td>
<span class="icon-folder" />
</td>
<td class="nameColumn">
<span class="innernametext">
{{ station.name }}
</span>
</td>
<td class="actionColumn" />
</tr>
</template>
2020-10-17 18:06:57 +00:00
</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: {
2020-11-08 08:35:08 +00:00
favorites: {
type: Array,
default() { return [] },
},
2020-10-17 18:06:57 +00:00
stationData: {
type: Array,
default() { return [] },
},
},
2020-10-22 11:53:40 +00:00
data: () => ({
activeItem: null,
}),
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-11-14 11:37:51 +00:00
toggleSidebar(station) {
this.$emit('toggleSidebar', station)
},
},
2020-10-17 18:06:57 +00:00
}
</script>
<style lang="scss">
/* Workaround wrong positioning
actions popover menu
https://github.com/nextcloud/nextcloud-vue/issues/1384 */
body {
min-height: 100%;
height: auto;
}
2020-10-17 18:06:57 +00:00
table {
width: 100%;
min-width: 250px;
2020-10-21 08:05:18 +00:00
table-layout:fixed;
position: relative;
2020-10-17 18:06:57 +00:00
thead {
background-color: var(--color-main-background-translucent);
z-index: 60;
position: sticky;
2020-11-15 22:39:03 +00:00
top: 50px;
2020-10-17 18:06:57 +00:00
th {
border-bottom: 1px solid var(--color-border);
padding: 15px;
height: 50px;
}
th, th a {
color: var(--color-text-maxcontrast);
}
2020-10-21 08:31:59 +00:00
th.iconColumn {
padding: 0px;
width: 72px;
}
2020-10-17 18:06:57 +00:00
th.nameColumn {
width: 100%;
}
2020-10-21 08:31:59 +00:00
th.actionColumn {
2020-10-21 08:02:38 +00:00
width: 72px;
}
2020-10-17 18:06:57 +00:00
}
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;
span.icon-folder {
display: block;
background-size: cover;
width: 30px;
height: 30px;
}
2020-10-17 18:06:57 +00:00
}
tr {
height: 51px;
background-color: var(--color-background-light);
transition: opacity 500ms ease 0s;
2020-10-17 18:06:57 +00:00
tr:hover, tr:focus, tr.mouseOver td {
background-color: var(--color-background-hover);
}
2020-10-20 13:03:20 +00:00
}
2020-11-08 08:14:50 +00:00
tr td * {
cursor: pointer;
}
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;
}
2020-11-18 13:21:33 +00:00
td.nameColumn {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-right: 0px;
}
2020-10-21 08:31:59 +00:00
td.nameColumn .innernametext {
2020-10-17 18:06:57 +00:00
color: var(--color-main-text);
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
}
2020-10-19 19:23:26 +00:00
.icon-starred {
background-image: var(--icon-star-dark-fc0);
background-size: 16px 16px;
background-repeat: no-repeat;
background-position: center;
min-width: 16px;
min-height: 16px;
2020-10-20 13:03:20 +00:00
right: -7px;
2020-11-08 08:06:21 +00:00
top: -38px;
margin-bottom: -38px;
2020-10-20 13:03:20 +00:00
float: right;
position: relative;
2020-11-08 08:14:50 +00:00
pointer-events: none;
2020-10-19 19:23:26 +00:00
}
2020-10-17 18:06:57 +00:00
}
}
</style>