Make table responsive and vertically and horizontally scrollable
This commit is contained in:
parent
22fb849ad2
commit
bc562ffd6b
|
@ -8,6 +8,7 @@
|
||||||
export let dataProvider
|
export let dataProvider
|
||||||
export let columns
|
export let columns
|
||||||
export let showAutoColumns
|
export let showAutoColumns
|
||||||
|
export let rowCount = 8
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
const { styleable } = getContext("sdk")
|
const { styleable } = getContext("sdk")
|
||||||
|
@ -60,11 +61,12 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div use:styleable={$component.styles}>
|
||||||
|
<div
|
||||||
lang="en"
|
lang="en"
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
use:styleable={$component.styles}
|
class={`spectrum ${size || 'spectrum--medium'} ${theme || 'spectrum--light'}`}
|
||||||
class={`spectrum ${size || 'spectrum--medium'} ${theme || 'spectrum--light'}`}>
|
style={`height: ${rowCount * 55}px;`}>
|
||||||
<table class="spectrum-Table">
|
<table class="spectrum-Table">
|
||||||
<thead class="spectrum-Table-head">
|
<thead class="spectrum-Table-head">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -102,9 +104,28 @@
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.spectrum {
|
||||||
|
position: relative;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
tbody {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background-color: var(--spectrum-global-color-gray-100);
|
||||||
|
border-bottom: 1px solid
|
||||||
|
var(--spectrum-table-border-color, var(--spectrum-alias-border-color-mid));
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
.spectrum-Table-headCell-content {
|
.spectrum-Table-headCell-content {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -116,6 +137,9 @@
|
||||||
.spectrum-Table-cell {
|
.spectrum-Table-cell {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
|
border-bottom: 1px solid
|
||||||
|
var(--spectrum-table-border-color, var(--spectrum-alias-border-color-mid));
|
||||||
|
border-top: none !important;
|
||||||
}
|
}
|
||||||
.spectrum-Table-cell-content {
|
.spectrum-Table-cell-content {
|
||||||
height: 55px;
|
height: 55px;
|
||||||
|
|
Loading…
Reference in New Issue