File tree 6 files changed +58
-3
lines changed
6 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const {
12
12
striped,
13
13
offsetStripe,
14
14
compact,
15
+ maxHeight,
15
16
className
16
17
} = Astro .props
17
18
@@ -21,11 +22,15 @@ const classes = [
21
22
striped && styles [` striped-${striped }s ` ],
22
23
offsetStripe && styles .offset ,
23
24
compact && styles .compact ,
25
+ maxHeight && styles .scroll ,
24
26
className
25
27
]
26
28
---
27
29
28
- <div class:list ={ classes } >
30
+ <div
31
+ class:list ={ classes }
32
+ style ={ maxHeight ? ` max-height:${maxHeight } ` : undefined }
33
+ >
29
34
<table >
30
35
{ headings ?.length && (
31
36
<thead >
Original file line number Diff line number Diff line change 11
11
export let striped: TableProps [' striped' ] = null
12
12
export let offsetStripe: TableProps [' offsetStripe' ] = false
13
13
export let compact: TableProps [' compact' ] = false
14
+ export let maxHeight: TableProps [' maxHeight' ] = 0
14
15
export let className: TableProps [' className' ] = ' '
15
16
16
17
const classes = classNames ([
19
20
striped && styles [` striped-${striped }s ` ],
20
21
offsetStripe && styles .offset ,
21
22
compact && styles .compact ,
23
+ maxHeight && styles .scroll ,
22
24
className
23
25
])
24
26
</script >
25
27
26
- <div class ={classes }>
28
+ <div class ={classes } style ={ maxHeight ? ` max-height:${ maxHeight } ` : null } >
27
29
<table >
28
30
{#if headings ?.length }
29
31
<thead >
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const Table = ({
12
12
striped,
13
13
offsetStripe,
14
14
compact,
15
+ maxHeight,
15
16
className
16
17
} : TableProps ) => {
17
18
const classes = classNames ( [
@@ -20,11 +21,16 @@ const Table = ({
20
21
striped && styles [ `striped-${ striped } s` ] ,
21
22
offsetStripe && styles . offset ,
22
23
compact && styles . compact ,
24
+ maxHeight && styles . scroll ,
23
25
className
24
26
] )
25
27
28
+ const styleVariables = {
29
+ ...( maxHeight && { 'max-height' : maxHeight } )
30
+ } as React . CSSProperties
31
+
26
32
return (
27
- < div className = { classes } >
33
+ < div className = { classes } style = { styleVariables } >
28
34
< table >
29
35
{ headings ?. length && (
30
36
< thead >
Original file line number Diff line number Diff line change 57
57
@include spacing (py- xxs, px- sm);
58
58
}
59
59
}
60
+
61
+ & .scroll {
62
+ @include spacing (pr- sm);
63
+
64
+ thead {
65
+ @include position (sticky , t0);
66
+ @include background (primary- 70);
67
+ box-shadow : 0 .5px 0 var (--w-color-primary-50 );
68
+ }
69
+ }
60
70
}
Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ export type TableProps = {
6
6
striped ?: 'column' | 'row' | null
7
7
offsetStripe ?: boolean
8
8
compact ?: boolean
9
+ maxHeight ?: number
9
10
className ?: string
10
11
}
Original file line number Diff line number Diff line change @@ -46,6 +46,29 @@ const overflowTable = {
46
46
' ✅'
47
47
]),
48
48
}
49
+
50
+ const scrollTable = {
51
+ headings: [' Keyword' , ' CSS' ],
52
+ data: [
53
+ [' none' , ' 0' ],
54
+ [' xxs' , ' 2px' ],
55
+ [' xs' , ' 5px' ],
56
+ [' sm' , ' 10px' ],
57
+ [' md' , ' 15px' ],
58
+ [' default' , ' 20px' ],
59
+ [' lg' , ' 25px' ],
60
+ [' xl' , ' 30px' ],
61
+ [' 2xl' , ' 35px' ],
62
+ [' 3xl' , ' 40px' ],
63
+ [' 4xl' , ' 45px' ],
64
+ [' 5xl' , ' 50px' ],
65
+ [' 6xl' , ' 55px' ],
66
+ [' 7xl' , ' 60px' ],
67
+ [' 8xl' , ' 65px' ],
68
+ [' 9xl' , ' 70px' ],
69
+ [' 10xl' , ' 75px' ]
70
+ ]
71
+ }
49
72
---
50
73
51
74
<Layout >
@@ -148,6 +171,14 @@ const overflowTable = {
148
171
striped = " column"
149
172
/>
150
173
</ComponentWrapper >
174
+
175
+ <ComponentWrapper title = " Scroll table" >
176
+ <section.component
177
+ { ... scrollTable }
178
+ maxHeight = " 250px"
179
+ striped = " column"
180
+ />
181
+ </ComponentWrapper >
151
182
</div >
152
183
))}
153
184
</Layout >
You can’t perform that action at this time.
0 commit comments