Skip to content

Commit a0e3ac1

Browse files
javier-godoypaodb
authored andcommitted
feat!: add support for shadow DOM styling
Close #41
1 parent 9016d55 commit a0e3ac1

File tree

7 files changed

+107
-7
lines changed

7 files changed

+107
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.flowingcode.addons.carousel</groupId>
66
<artifactId>carousel-addon</artifactId>
7-
<version>2.1.5-SNAPSHOT</version>
7+
<version>3.0.0-SNAPSHOT</version>
88
<name>Carousel Addon</name>
99
<description>Integration of @xpertsea/paper-slider for Vaadin 14+</description>
1010

src/main/java/com/flowingcode/vaadin/addons/carousel/Carousel.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.vaadin.flow.component.DomEvent;
2626
import com.vaadin.flow.component.EventData;
2727
import com.vaadin.flow.component.HasSize;
28+
import com.vaadin.flow.component.HasTheme;
2829
import com.vaadin.flow.component.Tag;
2930
import com.vaadin.flow.component.dependency.JsModule;
3031
import com.vaadin.flow.component.dependency.NpmPackage;
@@ -36,10 +37,10 @@
3637
* parameters, such as duration of transition, start position, maximum height and disabling swipe.
3738
*/
3839
@SuppressWarnings("serial")
39-
@Tag("l2t-paper-slider")
40+
@Tag("fc-l2t-paper-slider")
4041
@NpmPackage(value = "@polymer/iron-a11y-keys-behavior", version = "3.0.1")
41-
@JsModule("./paper-slider/l2t-paper-slider.js")
42-
public class Carousel extends Component implements HasSize {
42+
@JsModule("./paper-slider/fc-l2t-paper-slider.js")
43+
public class Carousel extends Component implements HasSize, HasTheme {
4344

4445
private static final String HIDE_NAV = "hideNav";
4546
private static final String DISABLE_SWIPE = "disableSwipe";
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*-
2+
* #%L
3+
* Carousel Addon
4+
* %%
5+
* Copyright (C) 2024 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
21+
22+
import './l2t-paper-slider.js';
23+
24+
import {ThemableMixin} from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
25+
26+
class FCL2TPaperSlider extends ThemableMixin(customElements.get('l2t-paper-slider')) {
27+
static get is() { return 'fc-l2t-paper-slider'; }
28+
29+
static get template() {
30+
return html`${super.template}`;
31+
}
32+
};
33+
34+
customElements.define(FCL2TPaperSlider.is, FCL2TPaperSlider);

src/main/resources/META-INF/resources/frontend/paper-slider/l2t-paper-slider.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ Polymer$0({
8686
display: box;
8787
display: -webkit-box;
8888
white-space: nowrap;
89-
@apply --paper-slider-styles;
9089
}
9190
9291
.slider__slides {
@@ -115,7 +114,6 @@ Polymer$0({
115114
left: 50%;
116115
-webkit-transform: translateX(-50%);
117116
transform: translateX(-50%);
118-
@apply --paper-slider-dot-container-styles;
119117
}
120118
121119
*[hidden] {
@@ -131,7 +129,6 @@ Polymer$0({
131129
background: var(--paper-slide-dot, rgba(255, 255, 255, .5));
132130
border-radius: 8px;
133131
cursor: pointer;
134-
@apply --paper-slide-dot-styles;
135132
}
136133
137134
.slider__dot:focus {

src/test/java/com/flowingcode/vaadin/addons/carousel/CarouselDemoView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public CarouselDemoView() {
3737
addDemo(ListenerDemo.class);
3838
addDemo(AutoProgressDemo.class);
3939
addDemo(SlideButtonsDemo.class);
40+
addDemo(CustomThemeDemo.class);
4041
setSizeFull();
4142
}
4243

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*-
2+
* #%L
3+
* Carousel Addon
4+
* %%
5+
* Copyright (C) 2018 - 2024 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.flowingcode.vaadin.addons.carousel;
21+
22+
import com.flowingcode.vaadin.addons.demo.DemoSource;
23+
import com.vaadin.flow.component.dependency.CssImport;
24+
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
25+
import com.vaadin.flow.router.PageTitle;
26+
import com.vaadin.flow.router.Route;
27+
28+
@PageTitle("Styling")
29+
@DemoSource
30+
@DemoSource("src/test/resources/META-INF/resources/frontend/carousel-demo-styles.css")
31+
@Route(value = "carousel/custom-theme", layout = CarouselDemoView.class)
32+
@SuppressWarnings("serial")
33+
@CssImport(value = "./carousel-demo-styles.css", themeFor = "fc-l2t-paper-slider")
34+
public class CustomThemeDemo extends VerticalLayout {
35+
36+
public CustomThemeDemo() {
37+
Slide s1 =
38+
new Slide(
39+
CarouselDemoView.createSlideContent(
40+
"Slide 1",
41+
"https://www.flowingcode.com/wp-content/uploads/2018/04/birthday-3021071_640.jpg"));
42+
Slide s2 =
43+
new Slide(
44+
CarouselDemoView.createSlideContent(
45+
"Slide 2",
46+
"https://2.bp.blogspot.com/-nvtIfgN8duc/XKUQh9VEyFI/AAAAAAAABT8/mE7P45E2uqwWlkKimAmes7fT2rdW9UDWwCEwYBhgL/s320/anniversary_1.jpg"));
47+
Slide s3 =
48+
new Slide(
49+
CarouselDemoView.createSlideContent(
50+
"Slide 3",
51+
"https://www.flowingcode.com/wp-content/uploads/2020/04/photo4blog-300x300.jpg"));
52+
Slide s4 =
53+
new Slide(
54+
CarouselDemoView.createSlideContent(
55+
"Slide 4",
56+
"https://www.flowingcode.com/wp-content/uploads/2021/03/happy_birthday_2.jpg"));
57+
58+
Carousel c = new Carousel(s1, s2, s3, s4);
59+
c.setSizeFull();
60+
c.setThemeName("custom-theme");
61+
62+
add(c);
63+
}
64+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:host([theme~="custom-theme"]) .slider__dots > span {
2+
background: purple;
3+
}

0 commit comments

Comments
 (0)