Skip to content

Commit 4e02bcd

Browse files
paodbjavier-godoy
authored andcommitted
feat: initial implementation
1 parent 1d01150 commit 4e02bcd

File tree

19 files changed

+396
-93
lines changed

19 files changed

+396
-93
lines changed

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1-
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/template-addon)
2-
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/app-layout-addon.svg)](https://vaadin.com/directory/component/template-addon)
3-
[![Build Status](https://jenkins.flowingcode.com/job/template-addon/badge/icon)](https://jenkins.flowingcode.com/job/template-addon)
1+
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/flip-card-addon)
2+
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/flip-card--addon.svg)](https://vaadin.com/directory/component/flip-card-addon)
3+
[![Build Status](https://jenkins.flowingcode.com/job/FlipCard-addon/badge/icon)](https://jenkins.flowingcode.com/job/FlipCard-addon)
44

5-
# Template Add-on
5+
# Flip Card Add-on
66

7-
This is a template project for building new Vaadin 24 add-ons
7+
Wrapper component for [Flip Card Web Component](https://www.npmjs.com/package/flip-card-wc).
88

99
## Features
1010

11-
* List the features of your add-on in here
11+
* Card component can flip on hover or on click
12+
* Styling can be overriden through CSS variables
13+
14+
### Styling
15+
16+
The Flip Card Web Component includes CSS variables that help style the component. Below are the `default` values:
17+
```css
18+
--flip-card-height: 100px;
19+
--flip-card-transition-duration: 800ms;
20+
--flip-card-border-radius: 4px;
21+
--flip-card-box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
22+
--flip-card-background-color-front: white;
23+
--flip-card-background-color-back: white;
24+
--flip-card-transition-timing-function: ease;
25+
```
1226

1327
## Online demo
1428

15-
[Online demo here](http://addonsv24.flowingcode.com/template)
29+
[Online demo here](http://addonsv24.flowingcode.com/flipcard)
1630

1731
## Download release
1832

19-
[Available in Vaadin Directory](https://vaadin.com/directory/component/template-addon)
33+
[Available in Vaadin Directory](https://vaadin.com/directory/component/flip-card-addon)
2034

2135
### Maven install
2236

@@ -25,7 +39,7 @@ Add the following dependencies in your pom.xml file:
2539
```xml
2640
<dependency>
2741
<groupId>org.vaadin.addons.flowingcode</groupId>
28-
<artifactId>template-addon</artifactId>
42+
<artifactId>flip-card-addon</artifactId>
2943
<version>X.Y.Z</version>
3044
</dependency>
3145
```
@@ -49,7 +63,7 @@ To see the demo, navigate to http://localhost:8080/
4963

5064
## Release notes
5165

52-
See [here](https://github.com/FlowingCode/TemplateAddon/releases)
66+
See [here](https://github.com/FlowingCode/FlipCard/releases)
5367

5468
## Issue tracking
5569

@@ -74,7 +88,7 @@ Then, follow these steps for creating a contibution:
7488

7589
This add-on is distributed under Apache License 2.0. For license terms, see LICENSE.txt.
7690

77-
TEMPLATE_ADDON is written by Flowing Code S.A.
91+
Flip Card Add-on is written by Flowing Code S.A.
7892

7993
# Developer Guide
8094

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>org.vaadin.addons.flowingcode</groupId>
8-
<artifactId>template-addon</artifactId>
8+
<artifactId>flip-card-addon</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
10-
<name>Template Add-on</name>
11-
<description>Template Add-on for Vaadin Flow</description>
10+
<name>Flip Card Add-on</name>
11+
<description>Flip Card Add-on for Vaadin Flow</description>
1212

1313
<properties>
14-
<vaadin.version>24.1.2</vaadin.version>
14+
<vaadin.version>24.1.4</vaadin.version>
1515
<selenium.version>4.10.0</selenium.version>
1616
<maven.compiler.source>17</maven.compiler.source>
1717
<maven.compiler.target>17</maven.compiler.target>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2020
<drivers.dir>${project.basedir}/drivers</drivers.dir>
2121
<jetty.version>11.0.12</jetty.version>
22-
<flowingcode.commons.demo.version>3.6.0</flowingcode.commons.demo.version>
22+
<flowingcode.commons.demo.version>3.7.1</flowingcode.commons.demo.version>
2323
<frontend.hotdeploy>true</frontend.hotdeploy>
2424
</properties>
2525

@@ -38,9 +38,9 @@
3838
</licenses>
3939

4040
<scm>
41-
<url>https://github.com/FlowingCode/AddonStarter24</url>
42-
<connection>scm:git:git://github.com/FlowingCode/AddonStarter24.git</connection>
43-
<developerConnection>scm:git:ssh://[email protected]:/FlowingCode/AddonStarter24.git</developerConnection>
41+
<url>https://github.com/FlowingCode/FlipCard</url>
42+
<connection>scm:git:git://github.com/FlowingCode/FlipCard.git</connection>
43+
<developerConnection>scm:git:ssh://[email protected]:/FlowingCode/FlipCard.git</developerConnection>
4444
<tag>master</tag>
4545
</scm>
4646

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*-
2+
* #%L
3+
* Flip Card Add-on
4+
* %%
5+
* Copyright (C) 2023 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.flipcard;
21+
22+
import com.vaadin.flow.component.Component;
23+
import com.vaadin.flow.component.Tag;
24+
import com.vaadin.flow.component.dependency.JsModule;
25+
import com.vaadin.flow.component.dependency.NpmPackage;
26+
import com.vaadin.flow.component.html.Div;
27+
import com.vaadin.flow.dom.Element;
28+
29+
/**
30+
* Representation of a Flip Card component.
31+
*
32+
* This component is a wrapper for Flip Card Web Component
33+
* (https://www.npmjs.com/package/flip-card-wc)
34+
*
35+
* @author Paola De Bartolo / Flowing Code
36+
*
37+
*/
38+
@SuppressWarnings("serial")
39+
@NpmPackage(value = "flip-card-wc", version = "1.3.0")
40+
@JsModule("flip-card-wc/dist/flip-card-wc.js")
41+
@Tag("flip-card")
42+
public class FlipCard extends Div {
43+
44+
public enum FlipCardVariant {
45+
HOVER, CLICK;
46+
}
47+
48+
public FlipCard(Component frontComponent, Component backComponent) {
49+
this.setFrontComponent(frontComponent);
50+
this.setBackComponent(backComponent);
51+
}
52+
53+
public FlipCard(Component frontComponent, Component backComponent, FlipCardVariant variant) {
54+
this(frontComponent, backComponent);
55+
this.setVariant(variant);
56+
}
57+
58+
/**
59+
* Sets the mechanism of how the card flips.
60+
*
61+
* @param variant the variant type that specifies the flip behavior of the card
62+
*/
63+
public void setVariant(FlipCardVariant variant) {
64+
this.getElement().setProperty("variant", variant.name().toLowerCase());
65+
}
66+
67+
/**
68+
* Returns the variant value that represents the current flip behavior of the card.
69+
*
70+
* @return the current variant value
71+
*/
72+
public FlipCardVariant getVariant() {
73+
return FlipCardVariant.valueOf(
74+
this.getElement().getProperty("variant", FlipCardVariant.HOVER.name()).toUpperCase());
75+
}
76+
77+
/**
78+
* Sets the component that will be display on the front side of the card.
79+
*
80+
* @param component the front side component
81+
*/
82+
public void setFrontComponent(Component component) {
83+
Element frontElement = component.getElement();
84+
frontElement.setAttribute("slot", "front");
85+
this.getElement().appendChild(frontElement);
86+
}
87+
88+
/**
89+
* Sets the component that will be display on the back side of the card.
90+
*
91+
* @param component the back side component
92+
*/
93+
public void setBackComponent(Component component) {
94+
Element backElement = component.getElement();
95+
backElement.setAttribute("slot", "back");
96+
this.getElement().appendChild(backElement);
97+
}
98+
99+
}

src/main/java/com/flowingcode/vaadin/addons/template/TemplateAddon.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/main/resources/META-INF/frontend/styles/static_addon_styles

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/resources/META-INF/resources/static_addon_resources

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/test/java/com/flowingcode/vaadin/addons/DemoLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*-
22
* #%L
3-
* Template Add-on
3+
* Flip Card Add-on
44
* %%
55
* Copyright (C) 2023 Flowing Code
66
* %%

src/test/java/com/flowingcode/vaadin/addons/template/DemoView.java renamed to src/test/java/com/flowingcode/vaadin/addons/flipcard/DemoView.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*-
22
* #%L
3-
* Template Add-on
3+
* Flip Card Add-on
44
* %%
55
* Copyright (C) 2023 Flowing Code
66
* %%
@@ -17,8 +17,7 @@
1717
* limitations under the License.
1818
* #L%
1919
*/
20-
21-
package com.flowingcode.vaadin.addons.template;
20+
package com.flowingcode.vaadin.addons.flipcard;
2221

2322
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
2423
import com.vaadin.flow.router.BeforeEnterEvent;
@@ -31,6 +30,6 @@ public class DemoView extends VerticalLayout implements BeforeEnterObserver {
3130

3231
@Override
3332
public void beforeEnter(BeforeEnterEvent event) {
34-
event.forwardTo(TemplateDemoView.class);
33+
event.forwardTo(FlipCardDemoView.class);
3534
}
3635
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*-
2+
* #%L
3+
* Flip Card Add-on
4+
* %%
5+
* Copyright (C) 2023 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.flipcard;
21+
22+
import java.time.LocalDateTime;
23+
import com.flowingcode.vaadin.addons.demo.DemoSource;
24+
import com.flowingcode.vaadin.addons.flipcard.FlipCard.FlipCardVariant;
25+
import com.vaadin.flow.component.datetimepicker.DateTimePicker;
26+
import com.vaadin.flow.component.formlayout.FormLayout;
27+
import com.vaadin.flow.component.html.Div;
28+
import com.vaadin.flow.component.html.H4;
29+
import com.vaadin.flow.component.html.Image;
30+
import com.vaadin.flow.component.html.Paragraph;
31+
import com.vaadin.flow.component.icon.Icon;
32+
import com.vaadin.flow.component.icon.VaadinIcon;
33+
import com.vaadin.flow.component.textfield.TextArea;
34+
import com.vaadin.flow.component.textfield.TextField;
35+
import com.vaadin.flow.router.PageTitle;
36+
import com.vaadin.flow.router.Route;
37+
38+
@SuppressWarnings("serial")
39+
@DemoSource
40+
@PageTitle("Flip Card as Info Card Demo")
41+
@Route(value = "flip-card/info-card", layout = FlipCardDemoView.class)
42+
public class FlipCardAsInfoCardDemo extends Div {
43+
44+
public FlipCardAsInfoCardDemo() {
45+
Div onHoverFront = new Div();
46+
onHoverFront.setClassName("front-card");
47+
onHoverFront.add(new Image("images/helsinki.jpg", ""));
48+
49+
Div onHoverBack = new Div();
50+
onHoverBack.setClassName("back-card");
51+
onHoverBack.add(new H4("Picture Information"), createDetailsForm());
52+
53+
FlipCard onHoverFlipCard = new FlipCard(onHoverFront, onHoverBack);
54+
onHoverFlipCard.setClassName("flip-card-info-card");
55+
add(onHoverFlipCard);
56+
57+
Div onClickFront = new Div();
58+
onClickFront.setClassName("front-card");
59+
onClickFront.add(new Image("images/helsinki.jpg", ""));
60+
61+
Div onClickBack = new Div();
62+
onClickBack.setClassName("back-card");
63+
onClickBack.add(new H4("Picture Information"), createDetailsForm());
64+
65+
FlipCard onClickFlipCard = new FlipCard(onClickFront, onClickBack, FlipCardVariant.CLICK);
66+
onClickFlipCard.setClassName("flip-card-info-card");
67+
add(onClickFlipCard);
68+
}
69+
70+
private FormLayout createDetailsForm() {
71+
FormLayout formLayout = new FormLayout();
72+
formLayout.getStyle().set("--vaadin-form-item-label-width", "2em");
73+
74+
TextField name = new TextField();
75+
name.setValue("helsinki.jpg");
76+
name.setReadOnly(true);
77+
name.setWidthFull();
78+
formLayout.addFormItem(name, new Icon("lumo", "photo"));
79+
80+
DateTimePicker date = new DateTimePicker();
81+
date.setValue(LocalDateTime.of(2018, 6, 4, 9, 14));
82+
date.setReadOnly(true);
83+
date.setWidthFull();
84+
formLayout.addFormItem(date, new Icon("lumo", "calendar"));
85+
86+
TextArea description = new TextArea();
87+
description.setValue("Harbour of Katajanokka, Helsinki, Finland");
88+
description.setReadOnly(true);
89+
description.setWidthFull();
90+
formLayout.addFormItem(description, new Icon("lumo", "menu"));
91+
92+
Paragraph deviceInfo = new Paragraph();
93+
deviceInfo.setText(
94+
"Device information \n NIKON CORPORATION NIKON D3400 \n ƒ/9 | 1/320s | 24mm | ISO100 | EXP 0 | No flash");
95+
deviceInfo.getStyle().set("white-space", "pre-line");
96+
formLayout.addFormItem(deviceInfo, new Icon(VaadinIcon.CAMERA));
97+
98+
return formLayout;
99+
}
100+
}

0 commit comments

Comments
 (0)