File tree 6 files changed +69
-43
lines changed
6 files changed +69
-43
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,18 @@ const classes = [
22
22
---
23
23
24
24
<section class:list ={ classes } data-id =" w-tabs" >
25
- <div class =" tabs" >
26
- { items .map (item => (
27
- <button
28
- data-value = { item .value }
29
- class :list = { [item .active && ' active' ]}
30
- disabled = { item .disabled }
31
- >
32
- <Fragment set :html = { item .label } />
33
- </button >
34
- ))}
25
+ <div class =" tabs-wrapper" >
26
+ <div class =" tabs" >
27
+ { items .map (item => (
28
+ <button
29
+ data-value = { item .value }
30
+ class :list = { [item .active && ' active' ]}
31
+ disabled = { item .disabled }
32
+ >
33
+ <Fragment set :html = { item .label } />
34
+ </button >
35
+ ))}
36
+ </div >
35
37
</div >
36
38
<div class =" tab-content" >
37
39
<slot />
@@ -46,7 +48,9 @@ const classes = [
46
48
const target = event.target as HTMLDivElement
47
49
48
50
if (target.dataset.value) {
49
- const tabContent = target.parentElement?.nextElementSibling as HTMLDivElement
51
+ const tabContent = target.parentElement
52
+ ?.parentElement
53
+ ?.nextElementSibling as HTMLDivElement
50
54
51
55
Array.from(tabContent.children)
52
56
.forEach((element: any) => {
Original file line number Diff line number Diff line change 35
35
</script >
36
36
37
37
<section class ={classes }>
38
- <div class =" tabs" >
39
- {#each items as item }
40
- <button
41
- class:active ={active ? active === item .value : item .active }
42
- disabled ={item .disabled }
43
- on:click ={() => setTab (item .value )}
44
- >
45
- {@html item .label }
46
- </button >
47
- {/each }
38
+ <div class =" tabs-wrapper" >
39
+ <div class =" tabs" >
40
+ {#each items as item }
41
+ <button
42
+ class:active ={active ? active === item .value : item .active }
43
+ disabled ={item .disabled }
44
+ on:click ={() => setTab (item .value )}
45
+ >
46
+ {@html item .label }
47
+ </button >
48
+ {/each }
49
+ </div >
48
50
</div >
49
51
<div class ="tab-content" bind:this ={tabContainer }>
50
52
<slot />
Original file line number Diff line number Diff line change @@ -50,16 +50,18 @@ const Tabs = ({
50
50
51
51
return (
52
52
< section className = { classes } >
53
- < div className = "tabs" >
54
- { items . map ( ( item , index ) => (
55
- < button
56
- key = { index }
57
- disabled = { item . disabled }
58
- dangerouslySetInnerHTML = { { __html : item . label } }
59
- onClick = { ( ) => setTab ( item . value ) }
60
- className = { isActive ( item ) }
61
- />
62
- ) ) }
53
+ < div className = "tabs-wrapper" >
54
+ < div className = "tabs" >
55
+ { items . map ( ( item , index ) => (
56
+ < button
57
+ key = { index }
58
+ disabled = { item . disabled }
59
+ dangerouslySetInnerHTML = { { __html : item . label } }
60
+ onClick = { ( ) => setTab ( item . value ) }
61
+ className = { isActive ( item ) }
62
+ />
63
+ ) ) }
64
+ </ div >
63
65
</ div >
64
66
< div className = "tab-content" ref = { tabContainer } >
65
67
{ children }
Original file line number Diff line number Diff line change 35
35
}
36
36
}
37
37
38
- & .even .tabs {
39
- width : auto ;
40
-
41
- button {
42
- flex : 1 ;
43
- justify-content : center ;
44
- }
38
+ & .even .tabs button {
39
+ flex : 1 ;
40
+ justify-content : center ;
45
41
}
46
42
47
43
& .vertical {
56
52
.tabs {
57
53
flex-direction : column ;
58
54
gap : 5px ;
59
- margin-bottom : 0 ;
60
55
61
56
button {
62
57
padding : 10px ;
67
62
}
68
63
}
69
64
}
65
+
66
+ .tab-content {
67
+ margin-top : 0 ;
68
+ }
69
+ }
70
+
71
+ .tabs-wrapper {
72
+ overflow : auto ;
70
73
}
71
74
72
75
.tabs {
73
76
border-bottom : 2px solid #252525 ;
74
- margin-bottom : 20px ;
75
77
display : flex ;
76
78
gap : 10px ;
77
- flex-wrap : wrap ;
78
79
79
80
button {
80
81
@include Transition (color );
90
91
display : flex ;
91
92
align-items : center ;
92
93
gap : 10px ;
94
+ flex-shrink : 0 ;
93
95
94
96
svg {
95
97
pointer-events : none ;
110
112
}
111
113
}
112
114
115
+ .tab-content {
116
+ margin-top : 20px ;
117
+ }
118
+
113
119
[data-tab ] {
114
120
display : none ;
115
121
118
124
}
119
125
}
120
126
}
127
+
128
+ @include Media (' xs' ) {
129
+ .w-tabs {
130
+ & .even .tabs {
131
+ width : auto ;
132
+ }
133
+ }
134
+ }
Original file line number Diff line number Diff line change @@ -159,7 +159,11 @@ const sections = [
159
159
</ComponentWrapper >
160
160
161
161
<ComponentWrapper title = " Overflown tabs" >
162
- <section.component items = { overflowTabs } />
162
+ <section.component items = { overflowTabs } >
163
+ <div data-tab = " tab-1" data-active = " true" >Intro tab</div >
164
+ <div data-tab = " tab-2" >Tab 2</div >
165
+ <div data-tab = " tab-3" >Tab 3</div >
166
+ </section.component >
163
167
</ComponentWrapper >
164
168
</div >
165
169
))}
Original file line number Diff line number Diff line change 7
7
<head >
8
8
<meta charset =" utf-8" />
9
9
<link rel =" icon" type =" image/svg+xml" href =" /img/favicon.svg" />
10
- <meta name =" viewport" content =" width=device-width" />
10
+ <meta name =" viewport" content =" width=device-width, initial-scale=1, shrink-to-fit=no " />
11
11
<title >Webcore</title >
12
12
</head >
13
13
<body >
You can’t perform that action at this time.
0 commit comments