-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathTable.svelte
64 lines (58 loc) · 1.87 KB
/
Table.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<script>
/**
* Set the size of the table
* @type {"xs" | "sm" | "md" | "lg" | "xl"}
*/
export let size = "lg";
/** Set to `true` to use zebra styles */
export let zebra = false;
/** Set to `true` to use static width */
export let useStaticWidth = false;
/** Set to `true` for the sortable variant */
export let sortable = false;
/** Set to `true` to enable a sticky header */
export let stickyHeader = false;
/**
* Set the style attribute on the `table` element
* @type {string}
*/
export let tableStyle = undefined;
</script>
{#if stickyHeader}
<section class:bx--data-table_inner-container="{true}" {...$$restProps}>
<table
class:bx--data-table="{true}"
class:bx--data-table--xs="{size === 'xs'}"
class:bx--data-table--sm="{size === 'sm'}"
class:bx--data-table--md="{size === 'md'}"
class:bx--data-table--lg="{size === 'lg'}"
class:bx--data-table--xl="{size === 'xl'}"
class:bx--data-table--sort="{sortable}"
class:bx--data-table--zebra="{zebra}"
class:bx--data-table--static="{useStaticWidth}"
class:bx--data-table--sticky-header="{stickyHeader}"
class:bx--data-table--visible-overflow-menu="{true}"
style="{tableStyle}"
>
<slot />
</table>
</section>
{:else}
<table
class:bx--data-table="{true}"
class:bx--data-table--xs="{size === 'xs'}"
class:bx--data-table--sm="{size === 'sm'}"
class:bx--data-table--md="{size === 'md'}"
class:bx--data-table--lg="{size === 'lg'}"
class:bx--data-table--xl="{size === 'xl'}"
class:bx--data-table--sort="{sortable}"
class:bx--data-table--zebra="{zebra}"
class:bx--data-table--static="{useStaticWidth}"
class:bx--data-table--sticky-header="{stickyHeader}"
class:bx--data-table--visible-overflow-menu="{true}"
{...$$restProps}
style="{tableStyle}"
>
<slot />
</table>
{/if}