table component: style sticky table header

This commit is contained in:
Jonas Heinrich 2020-10-16 18:28:35 +02:00
parent faa9dc67c0
commit 6ecd8c59d6
2 changed files with 58 additions and 71 deletions

View File

@ -12,12 +12,12 @@
</template> </template>
</AppNavigation> </AppNavigation>
<AppContent> <AppContent>
<Breadcrumbs> <Breadcrumbs class="breadcrumbs">
<Breadcrumb title="Home" href="/" /> <Breadcrumb title="Home" href="/" />
<Breadcrumb title="Top" href="/Top" /> <Breadcrumb title="Top" href="/Top" />
</Breadcrumbs> </Breadcrumbs>
<Table <Table
:stationData="tableData" :station-data="tableData"
station-uuid="960b6cd6-0601-11e8-ae97-52543be04c81" station-uuid="960b6cd6-0601-11e8-ae97-52543be04c81"
station-isfav="false" station-isfav="false"
station-img="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/Radio_SRF_Virus.svg/205px-Radio_SRF_Virus.svg.png" /> station-img="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/Radio_SRF_Virus.svg/205px-Radio_SRF_Virus.svg.png" />
@ -50,7 +50,7 @@ export default {
}), }),
mounted() { mounted() {
const vm = this const vm = this
this.$jquery.getJSON('https://de1.api.radio-browser.info/json/stations/topclick?limit=10') this.$jquery.getJSON('https://de1.api.radio-browser.info/json/stations/topclick?limit=20')
.done(function(data) { .done(function(data) {
vm.tableData = data vm.tableData = data
}) })

View File

@ -12,7 +12,8 @@
<tbody v-if="stationData"> <tbody v-if="stationData">
<tr v-for="(obj, ind) in stationData" :key="ind"> <tr v-for="(obj, ind) in stationData" :key="ind">
<td> <td>
<div class="stationIcon" :style="style" /> <div class="stationIcon"
:style="{ backgroundImage: `url('${ obj.favicon }')` }" />
</td> </td>
<td class="filenameColumn"> <td class="filenameColumn">
<span class="innernametext"> <span class="innernametext">
@ -31,7 +32,6 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
{{ stationData }}
</table> </table>
</template> </template>
@ -63,28 +63,21 @@ export default {
default: '', default: '',
}, },
}, },
computed: {
style() {
return 'background-image: url(' + this.stationImg + ')'
},
},
} }
</script> </script>
<style lang="scss"> <style lang="scss">
table { table {
position: relative;
width: 100%; width: 100%;
min-width: 250px; min-width: 250px;
display: block;
flex-direction: column;
thead { thead {
position: sticky;
z-index: 60;
display: block;
background-color: var(--color-main-background-translucent); background-color: var(--color-main-background-translucent);
z-index: 60;
position: sticky;
position: -webkit-sticky;
top: 50px;
th { th {
border-bottom: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
@ -92,70 +85,64 @@ table {
height: 50px; height: 50px;
} }
th, th a {
color: var(--color-text-maxcontrast);
}
th.nameColumn { th.nameColumn {
width: 100%; width: 100%;
padding-left: 57px;
} }
} }
tbody { tbody {
display: table;
width: 100%;
}
} td {
table th, table th a {
color: var(--color-text-maxcontrast);
}
table td {
padding: 0 15px; padding: 0 15px;
font-style: normal; font-style: normal;
background-position: 8px center; background-position: 8px center;
background-repeat: no-repeat; background-repeat: no-repeat;
} border-bottom: 1px solid var(--color-border);
}
tr { tr {
height: 51px; height: 51px;
background-color: var(--color-background-light); background-color: var(--color-background-light);
tr:hover, tr:focus, tr.mouseOver td { tr:hover, tr:focus, tr.mouseOver td {
background-color: var(--color-background-hover); background-color: var(--color-background-hover);
} }
}
} tr td:first-child {
tr td:first-child {
padding-left: 40px; padding-left: 40px;
width: 32px; width: 32px;
padding-right: 0px; padding-right: 0px;
} }
td { td.filenameColumn .innernametext {
border-bottom: 1px solid var(--color-border);
}
td.filenameColumn .innernametext {
color: var(--color-main-text); color: var(--color-main-text);
} }
.stationIcon { .stationIcon {
width: 32px; width: 32px;
height: 32px; height: 32px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: contain; background-size: contain;
background-position: center; background-position: center;
} }
.actionColumn { .actionColumn {
width: auto; width: auto;
padding-right: 40px; padding-right: 40px;
} }
.filenameColumn { .filenameColumn {
width: 100%; width: 100%;
}
}
} }
</style> </style>