File tree 14 files changed +446
-7
lines changed
14 files changed +446
-7
lines changed Original file line number Diff line number Diff line change
1
+ < div class ="Tabs ">
2
+
3
+ < nav class ="Tabs-nav ">
4
+ < a href ="# " class ="Tabs-link is-active "> Tab 1</ a >
5
+ < a href ="# " class ="Tabs-link "> Tab 2</ a >
6
+ </ nav > <!-- //.Tabs-nav -->
7
+
8
+ < div class ="Tab is-active ">
9
+ Tab 1 Content
10
+ </ div > <!-- //.Tab -->
11
+
12
+ < div class ="Tab ">
13
+ Tab 2 Content
14
+ </ div > <!-- //.Tab -->
15
+
16
+ </ div > <!-- //.Tabs -->
Original file line number Diff line number Diff line change
1
+ <?php
2
+ $ nav_count = 0 ;
3
+ $ tab_count = 0 ;
4
+ ?>
5
+ <?php if ( have_rows ( 'tabs ' ) ): ?>
6
+
7
+ <div class="Tabs">
8
+
9
+ <?php while ( have_rows ( 'tabs ' ) ): the_row (); ?>
10
+ <nav class="Tabs-nav">
11
+ <a href="#" class="Tabs-link <?php echo ( $ nav_count == 0 ? 'is-active ' : '' ); ?> "><?php the_sub_field ( 'tab_title ' ); ?> </a>
12
+ </nav><!-- //.Tabs-nav -->
13
+ <?php $ nav_count ++; ?>
14
+ <?php endwhile ; ?>
15
+
16
+ <?php while ( have_rows ( 'tabs ' ) ): the_row (); ?>
17
+ <div class="Tab <?php echo ( $ tab_count == 0 ? 'is-active ' : '' ); ?> ">
18
+ <?php the_sub_field ( 'tab_content ' ); ?>
19
+ </div><!-- //.Tab -->
20
+ <?php $ tab_count ++; ?>
21
+ <?php endwhile ; ?>
22
+
23
+ </div><!-- //.Tabs -->
24
+
25
+ <?php endif ; ?>
Original file line number Diff line number Diff line change
1
+ {% raw %}<div class =" Tabs" >
2
+
3
+ <nav class =" Tabs-nav" >
4
+
5
+ {% for tab in post.get_field ( ' tabs' ) %}
6
+ <a href =" #" class =" Tabs-link {{ (loop .first ) ? ' is-active' : ' ' }}" >{{tab .tab_title }}</a >
7
+ {% endfor %}
8
+
9
+ </nav ><!-- //.Tabs-nav -->
10
+
11
+ {% for tab in post.get_field ( ' tabs' ) %}
12
+ <div class =" Tab {{ (loop .first ) ? ' is-active' : ' ' }}" >
13
+ {{tab .tab_content }}
14
+ </div ><!-- //.Tab -->
15
+ {% endfor %}
16
+
17
+ </div ><!-- //.Tabs --> {% endraw %}
Original file line number Diff line number Diff line change
1
+ .Tabs-link {
2
+ background : #f9f9f9 ;
3
+ color : #ccc ;
4
+ display : inline-block ;
5
+ padding : 10px 15px ;
6
+ text-decoration : none ;
7
+ transition : all 0.3s ease-in-out ;
8
+
9
+ & :hover ,
10
+ & .is-active {
11
+ background : #eee ;
12
+ color : #222 ;
13
+ }
14
+ }
15
+
16
+ .Tab {
17
+ border : 2px solid #eee ;
18
+ display : none ;
19
+ padding : 30px 15px ;
20
+
21
+ & .is-active {
22
+ display : block ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change 11
11
< nav class ="Tabs-nav ">
12
12
< a href ="# " class ="Tabs-link is-active "> Tab 1</ a >
13
13
< a href ="# " class ="Tabs-link "> Tab 2</ a >
14
- </ nav >
14
+ </ nav > <!-- //.Tabs-nav -->
15
15
< div class ="Tab is-active ">
16
16
Tab 1 Content
17
- </ div >
17
+ </ div > <!-- //.Tab -->
18
18
< div class ="Tab ">
19
19
Tab 2 Content
20
- </ div >
20
+ </ div > <!-- //.Tab -->
21
21
</ div > <!-- //.Tabs -->
22
22
23
23
< script src ="js/component.js "> </ script >
Original file line number Diff line number Diff line change @@ -7,4 +7,39 @@ category: ui
7
7
iframe_height : medium
8
8
---
9
9
10
- <iframe {% if page.iframe_height %}class =" h-{{ page.iframe_height }} " {% endif %} src =" {{ site.baseurl }}/component/{{ page.path_slug }}/example.html " ></iframe >
10
+ <iframe {% if page.iframe_height %}class =" h-{{ page.iframe_height }} " {% endif %} src =" {{ site.baseurl }}/component/{{ page.path_slug }}/example.html " ></iframe >
11
+
12
+ ## Advanced Custom Fields
13
+ If working with ACF, you will want to utilize the following fields:
14
+
15
+ ** Repeater Field: ` tabs ` **
16
+
17
+ Fields:
18
+ * Text: ` tab_title `
19
+ * WYSIWYG: ` tab_content `
20
+
21
+ ## Markup
22
+
23
+ {% include partials/tabs.md %}
24
+
25
+ ## Styles
26
+
27
+ ### CSS
28
+ ``` css
29
+ {% include _relative css /component .css %}
30
+ ```
31
+
32
+ ### Sass
33
+ ``` scss
34
+ {% include _relative css /component .scss %}
35
+ ```
36
+
37
+ ## Javascript
38
+ ### Plugin
39
+ ```js
40
+ {% include _relative js /component .js %}
41
+ ```
42
+ ### Usage
43
+ ```js
44
+ {% include _relative js /component-usage .js %}
45
+ ```
Original file line number Diff line number Diff line change 25
25
// If we don't have tabs, jump out
26
26
if ( ! tabs ) return ;
27
27
28
+ // Click handler function to go to tab on click
28
29
function tabClickHandler ( link , index ) {
29
30
link . addEventListener ( 'click' , function ( e ) {
30
31
e . preventDefault ( ) ;
31
32
goToTab ( index ) ;
32
33
} ) ;
33
34
}
34
35
36
+ // Add appropriate classes based on the current index
35
37
function goToTab ( index ) {
36
38
if ( index !== activeIndex && index >= 0 && index <= tabLinks . length ) {
37
39
tabLinks [ activeIndex ] . classList . remove ( 'is-active' ) ;
54
56
55
57
}
56
58
59
+ // Loop through the links and set the clickhandler
57
60
Array . prototype . map . call ( tabLinks , function ( value , index ) {
58
61
var link = value ;
59
62
tabClickHandler ( link , index ) ;
64
67
}
65
68
} ) ;
66
69
70
+ // Loop through containers and add appropriate attributes
67
71
Array . prototype . map . call ( tabContainers , function ( value , index ) {
68
72
var content = value ;
69
73
Original file line number Diff line number Diff line change
1
+ < div class ="Tabs ">
2
+
3
+ < nav class ="Tabs-nav ">
4
+ < a href ="# " class ="Tabs-link is-active "> Tab 1</ a >
5
+ < a href ="# " class ="Tabs-link "> Tab 2</ a >
6
+ </ nav > <!-- //.Tabs-nav -->
7
+
8
+ < div class ="Tab is-active ">
9
+ Tab 1 Content
10
+ </ div > <!-- //.Tab -->
11
+
12
+ < div class ="Tab ">
13
+ Tab 2 Content
14
+ </ div > <!-- //.Tab -->
15
+
16
+ </ div > <!-- //.Tabs -->
Original file line number Diff line number Diff line change
1
+ <?php
2
+ $ nav_count = 0 ;
3
+ $ tab_count = 0 ;
4
+ ?>
5
+ <?php if ( have_rows ( 'tabs ' ) ): ?>
6
+
7
+ <div class="Tabs">
8
+
9
+ <?php while ( have_rows ( 'tabs ' ) ): the_row (); ?>
10
+ <nav class="Tabs-nav">
11
+ <a href="#" class="Tabs-link <?php echo ( $ nav_count == 0 ? 'is-active ' : '' ); ?> "><?php the_sub_field ( 'tab_title ' ); ?> </a>
12
+ </nav><!-- //.Tabs-nav -->
13
+ <?php $ nav_count ++; ?>
14
+ <?php endwhile ; ?>
15
+
16
+ <?php while ( have_rows ( 'tabs ' ) ): the_row (); ?>
17
+ <div class="Tab <?php echo ( $ tab_count == 0 ? 'is-active ' : '' ); ?> ">
18
+ <?php the_sub_field ( 'tab_content ' ); ?>
19
+ </div><!-- //.Tab -->
20
+ <?php $ tab_count ++; ?>
21
+ <?php endwhile ; ?>
22
+
23
+ </div><!-- //.Tabs -->
24
+
25
+ <?php endif ; ?>
Original file line number Diff line number Diff line change
1
+ {% raw %}<div class =" Tabs" >
2
+
3
+ <nav class =" Tabs-nav" >
4
+
5
+ {% for tab in post.get_field ( ' tabs' ) %}
6
+ <a href =" #" class =" Tabs-link {{ (loop .first ) ? ' is-active' : ' ' }}" >{{tab .tab_title }}</a >
7
+ {% endfor %}
8
+
9
+ </nav ><!-- //.Tabs-nav -->
10
+
11
+ {% for tab in post.get_field ( ' tabs' ) %}
12
+ <div class =" Tab {{ (loop .first ) ? ' is-active' : ' ' }}" >
13
+ {{tab .tab_content }}
14
+ </div ><!-- //.Tab -->
15
+ {% endfor %}
16
+
17
+ </div ><!-- //.Tabs --> {% endraw %}
Original file line number Diff line number Diff line change
1
+ .Tabs-link {
2
+ background : #f9f9f9 ;
3
+ color : #ccc ;
4
+ display : inline-block ;
5
+ padding : 10px 15px ;
6
+ text-decoration : none ;
7
+ transition : all 0.3s ease-in-out ;
8
+
9
+ & :hover ,
10
+ & .is-active {
11
+ background : #eee ;
12
+ color : #222 ;
13
+ }
14
+ }
15
+
16
+ .Tab {
17
+ border : 2px solid #eee ;
18
+ display : none ;
19
+ padding : 30px 15px ;
20
+
21
+ & .is-active {
22
+ display : block ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change 11
11
< nav class ="Tabs-nav ">
12
12
< a href ="# " class ="Tabs-link is-active "> Tab 1</ a >
13
13
< a href ="# " class ="Tabs-link "> Tab 2</ a >
14
- </ nav >
14
+ </ nav > <!-- //.Tabs-nav -->
15
15
< div class ="Tab is-active ">
16
16
Tab 1 Content
17
- </ div >
17
+ </ div > <!-- //.Tab -->
18
18
< div class ="Tab ">
19
19
Tab 2 Content
20
- </ div >
20
+ </ div > <!-- //.Tab -->
21
21
</ div > <!-- //.Tabs -->
22
22
23
23
< script src ="js/component.js "> </ script >
You can’t perform that action at this time.
0 commit comments