Registry Mirror
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/template-addon)
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/app-layout-addon.svg)](https://vaadin.com/directory/component/template-addon)
[![Build Status](https://jenkins.flowingcode.com/job/template-addon/badge/icon)](https://jenkins.flowingcode.com/job/template-addon)
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/share-easy-addon)
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/share-easy-addon.svg)](https://vaadin.com/directory/component/share-easy-addon)
[![Build Status](https://jenkins.flowingcode.com/job/ShareEasy-addon/badge/icon)](https://jenkins.flowingcode.com/job/ShareEasy-addon)

# Template Add-on
# Share Easy Add-on

This is a template project for building new Vaadin 24 add-ons
Share Easy provides easy social media sharing capabilities by displaying a social media menu that can have different modes and customizations.

This component is a wrapper of [Sharee](https://github.com/parsagholipour/sharee) package.

## Features

* List the features of your add-on in here
- Default social media drivers to share links easily: Copy, Twitter, Facebook, Linkedin, Whatsapp, Telegram.
- Modes to display the Easy Share menu: Fixed, Normal, Hover, Text, Dropdown.
- By defaut, locale and keys are in English but custom locales and keys can be defined.

## Online demo

[Online demo here](http://addonsv24.flowingcode.com/template)
[Online demo here](http://addonsv24.flowingcode.com/share-easy)

## Download release

[Available in Vaadin Directory](https://vaadin.com/directory/component/template-addon)
[Available in Vaadin Directory](https://vaadin.com/directory/component/share-easy-addon)

### Maven install

Expand All @@ -25,7 +29,7 @@ Add the following dependencies in your pom.xml file:
```xml
<dependency>
<groupId>org.vaadin.addons.flowingcode</groupId>
<artifactId>template-addon</artifactId>
<artifactId>share-easy-addon</artifactId>
<version>X.Y.Z</version>
</dependency>
```
Expand All @@ -49,7 +53,7 @@ To see the demo, navigate to http://localhost:8080/

## Release notes

See [here](https://github.com/FlowingCode/TemplateAddon/releases)
See [here](https://github.com/FlowingCode/ShareEasy/releases)

## Issue tracking

Expand All @@ -74,13 +78,21 @@ Then, follow these steps for creating a contibution:

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

TEMPLATE_ADDON is written by Flowing Code S.A.
Share Easy Add-on is written by Flowing Code S.A.

# Developer Guide

## Getting started

Add your code samples in this section
```java
/* Fixed mode */
FixedShareEasy.create().forComponent(this);

/* Normal mode */
Div div = new Div();
NormalShareEasy.create().withNoTitle(true).forComponent(div);
add(div);
```

## Special configuration when using Spring

Expand Down
2 changes: 1 addition & 1 deletion assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>flowing-addon</id>
<id>share-easy-addon</id>

<formats>
<format>zip</format>
Expand Down
25 changes: 15 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.vaadin.addons.flowingcode</groupId>
<artifactId>template-addon</artifactId>
<artifactId>share-easy-addon</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Template Add-on</name>
<description>Template Add-on for Vaadin Flow</description>
<name>Share Easy Add-on</name>
<description>Share Eady Add-on for Vaadin Flow</description>

<properties>
<vaadin.version>24.1.2</vaadin.version>
<vaadin.version>24.1.4</vaadin.version>
<selenium.version>4.10.0</selenium.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<drivers.dir>${project.basedir}/drivers</drivers.dir>
<jetty.version>11.0.12</jetty.version>
<flowingcode.commons.demo.version>3.6.0</flowingcode.commons.demo.version>
<flowingcode.commons.demo.version>3.7.1</flowingcode.commons.demo.version>
<frontend.hotdeploy>true</frontend.hotdeploy>
</properties>

Expand All @@ -38,9 +38,9 @@
</licenses>

<scm>
<url>https://github.com/FlowingCode/AddonStarter24</url>
<connection>scm:git:git://github.com/FlowingCode/AddonStarter24.git</connection>
<developerConnection>scm:git:ssh://git@github.com:/FlowingCode/AddonStarter24.git</developerConnection>
<url>https://github.com/FlowingCode/ShareEsy</url>
<connection>scm:git:git://github.com/FlowingCode/ShareEsy.git</connection>
<developerConnection>scm:git:ssh://git@github.com:/FlowingCode/ShareEsy.git</developerConnection>
<tag>master</tag>
</scm>

Expand Down Expand Up @@ -96,7 +96,7 @@
<id>flowing-releases</id>
<url>https://maven.flowingcode.com/releases</url>
</repository>
</repositories>
</repositories>

<pluginRepositories>
<pluginRepository>
Expand Down Expand Up @@ -167,6 +167,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -209,12 +212,14 @@
<configuration>
<licenseName>apache_v2</licenseName>
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
<excludes>
<exclude>**/style.css</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*-
* #%L
* Share Easy Add-on
* %%
* Copyright (C) 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.flowingcode.vaadin.addons.shareeasy;

import java.util.HashMap;
import java.util.Map;
import com.flowingcode.vaadin.addons.shareeasy.enums.Driver;
import com.flowingcode.vaadin.addons.shareeasy.enums.Locale;
import com.flowingcode.vaadin.addons.shareeasy.util.CustomDriverOptions;
import com.flowingcode.vaadin.addons.shareeasy.util.LanguageKeys;
import com.flowingcode.vaadin.addons.shareeasy.util.Options;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dependency.NpmPackage;
import elemental.json.JsonObject;

/**
* BaseSharee represents the base class for creating Sharee instances.
*
* @param <T> The actual implementation class type, extending BaseSharee
*
* @author Paola De Bartolo / Flowing Code
*/
@NpmPackage(value = "sharee", version = "1.1.13")
@JsModule("./src/fc-sharee-connector.js")
@CssImport("./styles/fc-share-easy/style.css")
class BaseShareEasy<T extends BaseShareEasy<T>> {

private Component component;

private Options options = new Options();

Map<String, CustomDriverOptions> customDrivers = new HashMap<>();

/**
* Sets the share link for the shared content.
*
* @param shareLink The URL to be shared
* @return The current instance of the BaseSharee class
*/
public T withShareLink(String shareLink) {
this.options.setShareLink(shareLink);
return (T) this;
}

/**
* Sets the share text for the shared content.
*
* @param shareText The text to be shared
* @return The current instance of the BaseSharee class
*/
public T withShareText(String shareText) {
this.options.setShareText(shareText);
return (T) this;
}

/**
* Enables or disables the ripple effect.
*
* @param ripple True to enable the ripple effect, false to disable
* @return The current instance of the BaseSharee class
*/
public T withRipple(boolean ripple) {
this.options.setRipple(ripple);
return (T) this;
}

/**
* Sets the duration of the show transition for sharing.
*
* @param showTransitionDuration The duration of the show transition
* @return The current instance of the BaseSharee class
*/
public T withShowTransitionDuration(String showTransitionDuration) {
this.options.setShowTransitionDuration(showTransitionDuration);
return (T) this;
}

/**
* Sets the language to be displayed. Default value is "en" for English. Default values are listed
* in {@link Locale Locale}. Custom locales can be defined.
*
* @param locale The language code, e.g., "en" for English
* @return The current instance of the BaseSharee class
*/
public T withLocale(Locale locale) {
this.options.setLocale(locale.getName());
return (T) this;
}

/**
* Sets the social media drivers to be displayed. Default values are listed in {@link Driver
* Driver}.
*
* @param drivers An array of social media driver names
* @return The current instance of the BaseSharee class
*/
T withDrivers(Driver[] drivers) {
this.options.setDrivers(drivers);
return (T) this;
}

/**
* Initializes the Sharee component with the specified Vaadin component.
*
* @param component The Vaadin component to associate with the Sharee instance
*/
public void forComponent(Component component) {
this.component = component;
createSharee();
}

/**
* Gets the JSON representation of the Sharee options.
*
* @return The JsonObject representing the Sharee options
*/
protected JsonObject getJsonObjectOptions() {
return options.getJsonObject();
}

private void createSharee() {
String shareeOptions = getJsonObjectOptions().toJson();
if (!customDrivers.isEmpty()) {
for(CustomDriverOptions options : customDrivers.values()) {
component.getElement().executeJs("fcShareeConnector.addCustomDriver(this, $0)",
options.getJsonObject().toJson());
}
component.getElement().executeJs("fcShareeConnector.createWithCustomDrivers(this, $0)",
shareeOptions);
} else {
component.getElement().executeJs("fcShareeConnector.create(this, $0)", shareeOptions);
}
}

/**
* Sets custom language keys for the default locale.
*
* @param languageKeys The custom language keys
* @return The current instance of the BaseSharee class
*/
public T withCustomLanguageKeys(LanguageKeys languageKeys) {
this.options.setLanguageKeys(languageKeys);
return (T) this;
}

/**
* Sets custom language keys for the specified locale.
*
* @param locale The language code
* @param languageKeys The custom language keys
* @return The current instance of the BaseSharee class
*/
public T withCustomLanguageKeys(String locale, LanguageKeys languageKeys) {
this.options.setLocale(locale);
this.options.setLanguageKeys(languageKeys);
return (T) this;
}

/**
* Sets custom drivers (new social options).
*
* @param customDrivers The custom drivers
* @return The current instance of the BaseSharee class
*/
public T withCustomDrivers(Map<String, CustomDriverOptions> customDrivers) {
this.customDrivers = new HashMap<>(customDrivers);
return (T) this;
}

}
Loading