mirror of
https://github.com/garraflavatra/rolens.git
synced 2024-12-01 13:20:54 +00:00
Striped grid
This commit is contained in:
parent
57ac72af5d
commit
82c30f7772
@ -9,6 +9,7 @@
|
|||||||
export let activeKey = '';
|
export let activeKey = '';
|
||||||
export let activeChildKey = '';
|
export let activeChildKey = '';
|
||||||
export let level = 0;
|
export let level = 0;
|
||||||
|
export let striped = true;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
let childrenOpen = {};
|
let childrenOpen = {};
|
||||||
@ -90,6 +91,7 @@
|
|||||||
on:dblclick={() => doubleClick(item[key])}
|
on:dblclick={() => doubleClick(item[key])}
|
||||||
on:contextmenu|preventDefault={evt => showContextMenu(evt, item)}
|
on:contextmenu|preventDefault={evt => showContextMenu(evt, item)}
|
||||||
class:selected={activeKey === item[key] && !activeChildKey}
|
class:selected={activeKey === item[key] && !activeChildKey}
|
||||||
|
class:striped
|
||||||
>
|
>
|
||||||
<td class="has-toggle">
|
<td class="has-toggle">
|
||||||
{#if item.children?.length}
|
{#if item.children?.length}
|
||||||
@ -117,6 +119,7 @@
|
|||||||
<svelte:self
|
<svelte:self
|
||||||
{columns}
|
{columns}
|
||||||
{key}
|
{key}
|
||||||
|
{striped}
|
||||||
bind:activeKey={activeChildKey}
|
bind:activeKey={activeChildKey}
|
||||||
showHeaders={false}
|
showHeaders={false}
|
||||||
items={item.children}
|
items={item.children}
|
||||||
@ -128,6 +131,14 @@
|
|||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
tr.striped:nth-of-type(even) td {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
tr.selected td {
|
||||||
|
background-color: #00008b !important;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
padding: 0.3rem;
|
padding: 0.3rem;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@ -145,11 +156,6 @@
|
|||||||
max-width: 25em;
|
max-width: 25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr.selected td {
|
|
||||||
background-color: #00008b;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
button.toggle {
|
button.toggle {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
export let activeKey = '';
|
export let activeKey = '';
|
||||||
export let activeChildKey = '';
|
export let activeChildKey = '';
|
||||||
export let showHeaders = true;
|
export let showHeaders = true;
|
||||||
export let level = 0;
|
export let striped = true;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class:grid={level === 0} class:subgrid={level > 0}>
|
<div class="grid">
|
||||||
{#if actions?.length}
|
{#if actions?.length}
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
{#each actions as action}
|
{#each actions as action}
|
||||||
@ -37,7 +37,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<GridItems {items} {columns} {key} bind:activeKey bind:activeChildKey on:select on:selectChild on:trigger />
|
<GridItems {items} {columns} {key} {striped} bind:activeKey bind:activeChildKey on:select on:selectChild on:trigger />
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -48,9 +48,6 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
.subgrid {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
@ -64,7 +61,7 @@
|
|||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
/* table-layout: fixed; */
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
table thead {
|
table thead {
|
||||||
|
@ -20,8 +20,10 @@
|
|||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
for (const item of data) {
|
for (const item of data) {
|
||||||
const newItem = {};
|
const newItem = {};
|
||||||
newItem.key = item[key];
|
newItem.key = key;
|
||||||
newItem.children = dissectObject(item);
|
newItem.value = item[key];
|
||||||
|
newItem.type = getType(item[key]);
|
||||||
|
newItem.children = dissectObject(item, key);
|
||||||
newItem.menu = item.menu;
|
newItem.menu = item.menu;
|
||||||
items = [ ...items, newItem ];
|
items = [ ...items, newItem ];
|
||||||
}
|
}
|
||||||
@ -53,9 +55,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dissectObject(object) {
|
function dissectObject(object, exclude) {
|
||||||
const entries = [ ...Array.isArray(object) ? object.entries() : Object.entries(object) ];
|
const entries = [ ...Array.isArray(object) ? object.entries() : Object.entries(object) ];
|
||||||
return entries.map(([ key, value ]) => {
|
return entries.filter(([ key ]) => key != exclude).map(([ key, value ]) => {
|
||||||
key = key + '';
|
key = key + '';
|
||||||
const type = getType(value);
|
const type = getType(value);
|
||||||
const child = { key, value, type, menu: value.menu };
|
const child = { key, value, type, menu: value.menu };
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
border: none;
|
||||||
border-left: 1px solid #ccc;
|
border-left: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
.host button:hover {
|
.host button:hover {
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
|
|
||||||
{#if host && connection}
|
{#if host && connection}
|
||||||
<Grid
|
<Grid
|
||||||
|
striped={false}
|
||||||
columns={[ { key: 'id' }, { key: 'collCount', right: true } ]}
|
columns={[ { key: 'id' }, { key: 'collCount', right: true } ]}
|
||||||
items={Object.keys(connection.databases).map(dbKey => ({
|
items={Object.keys(connection.databases).map(dbKey => ({
|
||||||
id: dbKey,
|
id: dbKey,
|
||||||
|
Loading…
Reference in New Issue
Block a user