File tree Expand file tree Collapse file tree 13 files changed +252
-0
lines changed
docs/components_page/components Expand file tree Collapse file tree 13 files changed +252
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Testing of callbacks in non-Python Carousel snippets.
3
+ """
4
+
5
+ from pathlib import Path
6
+
7
+ import dash .testing .wait as wait
8
+
9
+ from .helpers import load_jl_app , load_r_app
10
+
11
+ HERE = Path (__file__ ).parent
12
+
13
+
14
+ def test_r_carousel (dashr ):
15
+ r_app = load_r_app ((HERE .parent / "carousel" / "callback.R" ), "carousel" )
16
+ dashr .start_server (r_app )
17
+ check_carousel_callbacks (dashr )
18
+
19
+
20
+ def test_jl_carousel (dashjl ):
21
+ jl_app = load_jl_app (
22
+ (HERE .parent / "carousel" / "callback.jl" ), "carousel"
23
+ )
24
+ dashjl .start_server (jl_app )
25
+ check_carousel_callbacks (dashjl )
26
+
27
+
28
+ def check_carousel_callbacks (runner ):
29
+
30
+ runner .find_element (
31
+ "label[for='_dbcprivate_radioitems_slide-number_input_1']"
32
+ ).click ()
33
+
34
+ wait .until (
35
+ lambda : runner .find_elements ("div.carousel-item" )[1 ].get_attribute (
36
+ "class"
37
+ )
38
+ == "carousel-item active" ,
39
+ timeout = 4 ,
40
+ )
Original file line number Diff line number Diff line change
1
+ library(dashBootstrapComponents )
2
+ library(dashHtmlComponents )
3
+
4
+ carousel <- htmlDiv(
5
+ list (
6
+ dbcCarousel(
7
+ id = " carousel" ,
8
+ items = list (
9
+ list (key = " 1" , src = " /static/images/slide1.svg" ),
10
+ list (key = " 2" , src = " /static/images/slide2.svg" ),
11
+ list (key = " 3" , src = " /static/images/slide3.svg" )
12
+ ),
13
+ controls = FALSE ,
14
+ indicators = FALSE ,
15
+ interval = FALSE
16
+ ),
17
+ dbcRadioItems(
18
+ id = " slide-number" ,
19
+ options = list (
20
+ list (label = " Slide 1" , value = 0 ),
21
+ list (label = " Slide 2" , value = 1 ),
22
+ list (label = " Slide 3" , value = 2 )
23
+ ),
24
+ value = 0 ,
25
+ inline = TRUE
26
+ )
27
+ )
28
+ )
29
+
30
+ app $ callback(
31
+ output(" carousel" , " active_index" ),
32
+ list (input(" slide-number" , " value" )),
33
+ function (idx ) {
34
+ return (idx )
35
+ }
36
+ )
Original file line number Diff line number Diff line change
1
+ using DashBootstrapComponents, DashHtmlComponents
2
+
3
+ carousel = html_div ([
4
+ dbc_carousel (
5
+ id= " carousel" ,
6
+ items= [
7
+ Dict (" key" => " 1" , " src" => " /static/images/slide1.svg" ),
8
+ Dict (" key" => " 2" , " src" => " /static/images/slide2.svg" ),
9
+ Dict (" key" => " 3" , " src" => " /static/images/slide3.svg" ),
10
+ ],
11
+ controls= false ,
12
+ indicators= false ,
13
+ interval= false ,
14
+ ),
15
+
16
+ dbc_radioitems (
17
+ id= " slide-number" ,
18
+ options= [
19
+ Dict (" label" => " Slide 1" , " value" => 0 ),
20
+ Dict (" label" => " Slide 2" , " value" => 1 ),
21
+ Dict (" label" => " Slide 3" , " value" => 2 ),
22
+ ],
23
+ value= 0 ,
24
+ inline= true ,
25
+ ),
26
+ ]);
27
+
28
+ callback! (
29
+ app,
30
+ Output (" carousel" , " active_index" ),
31
+ Input (" slide-number" , " value" ),
32
+ ) do idx
33
+ return idx
34
+ end ;
Original file line number Diff line number Diff line change
1
+ library(dashBootstrapComponents )
2
+
3
+ carousel <- dbcCarousel(
4
+ items = list (
5
+ list (
6
+ key = " 1" ,
7
+ src = " /static/images/slide1.svg" ,
8
+ header = " With header " ,
9
+ caption = " and caption"
10
+ ),
11
+ list (
12
+ key = " 2" ,
13
+ src = " /static/images/slide2.svg" ,
14
+ header = " With header only" ,
15
+ caption = " "
16
+ ),
17
+ list (
18
+ key = " 3" ,
19
+ src = " /static/images/slide3.svg" ,
20
+ header = " " ,
21
+ caption = " This slide has a caption only"
22
+ )
23
+ )
24
+ )
25
+
26
+
27
+
28
+
Original file line number Diff line number Diff line change
1
+ using DashBootstrapComponents
2
+
3
+ carousel = dbc_carousel (
4
+ items= [
5
+ Dict (
6
+ " key" => " 1" ,
7
+ " src" => " /static/images/slide1.svg" ,
8
+ " header" => " With header " ,
9
+ " caption" => " and caption" ,
10
+ ),
11
+ Dict (
12
+ " key" => " 2" ,
13
+ " src" => " /static/images/slide2.svg" ,
14
+ " header" => " With header only" ,
15
+ " caption" => " " ,
16
+ ),
17
+ Dict (
18
+ " key" => " 3" ,
19
+ " src" => " /static/images/slide3.svg" ,
20
+ " header" => " " ,
21
+ " caption" => " This slide has a caption only" ,
22
+ ),
23
+ ]
24
+ );
Original file line number Diff line number Diff line change
1
+ library(dashBootstrapComponents )
2
+
3
+ carousel <- dbcCarousel(
4
+ items = list (
5
+ list (key = " 1" , src = " /static/images/slide1.svg" ),
6
+ list (key = " 2" , src = " /static/images/slide2.svg" ),
7
+ list (key = " 3" , src = " /static/images/slide3.svg" )
8
+ ),
9
+ controls = TRUE ,
10
+ indicators = FALSE
11
+ )
Original file line number Diff line number Diff line change
1
+ using DashBootstrapComponents
2
+
3
+ carousel = dbc_carousel (
4
+ items= [
5
+ Dict (" key" => " 1" , " src" => " /static/images/slide1.svg" ),
6
+ Dict (" key" => " 2" , " src" => " /static/images/slide2.svg" ),
7
+ Dict (" key" => " 3" , " src" => " /static/images/slide3.svg" ),
8
+ ],
9
+ controls= true ,
10
+ indicators= false ,
11
+ );
Original file line number Diff line number Diff line change
1
+ library(dashBootstrapComponents )
2
+
3
+ carousel <- dbcCarousel(
4
+ items = list (
5
+ list (key = " 1" , src = " /static/images/slide1.svg" ),
6
+ list (key = " 2" , src = " /static/images/slide2.svg" ),
7
+ list (key = " 3" , src = " /static/images/slide3.svg" )
8
+ ),
9
+ className = " carousel-fade"
10
+ )
Original file line number Diff line number Diff line change
1
+ using DashBootstrapComponents
2
+
3
+ carousel = dbc_carousel (
4
+ items= [
5
+ Dict (" key" => " 1" , " src" => " /static/images/slide1.svg" ),
6
+ Dict (" key" => " 2" , " src" => " /static/images/slide2.svg" ),
7
+ Dict (" key" => " 3" , " src" => " /static/images/slide3.svg" ),
8
+ ],
9
+ className= " carousel-fade" ,
10
+ );
Original file line number Diff line number Diff line change
1
+ library(dashBootstrapComponents )
2
+
3
+ carousel <- dbcCarousel(
4
+ items = list (
5
+ list (key = " 1" , src = " /static/images/slide1.svg" ),
6
+ list (key = " 2" , src = " /static/images/slide2.svg" ),
7
+ list (key = " 3" , src = " /static/images/slide3.svg" )
8
+ ),
9
+ controls = TRUE ,
10
+ indicators = TRUE
11
+ )
You can’t perform that action at this time.
0 commit comments