Skip to content

Commit

Permalink
Flow, samples
Browse files Browse the repository at this point in the history
  • Loading branch information
hpehl committed Mar 8, 2024
1 parent fb9d5c6 commit a440178
Show file tree
Hide file tree
Showing 82 changed files with 20,191 additions and 496 deletions.
1,176 changes: 1,176 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Samples

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
env:
MVN: ./mvnw --show-version --batch-mode
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Set up JDK
id: setup-jdk
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
cache: maven
- name: Package
id: package
run: $MVN -P samples,prod clean package --projects org.jboss.elemento:elemento-samples-dist --also-make
- name: Publish
id: publish
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
folder: ./samples/dist/target/samples
target-folder: samples
clean: true
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- 'v*'

jobs:

deploy:
name: Deploy Maven Artifacts
runs-on: ubuntu-latest
Expand Down
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
*.iml
*.bak
*.iml
.classpath
.DS_Store
.idea
.settings
.parcel-cache
.project
.classpath
out
target
.settings
dependency-reduced-pom.xml
gwt-unitCache
hs_err*
node
node_modules
out
target
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Elemento now contains a very basic place manager. The place manager is minimal invasive and built around a few simple concepts:

- `Route`: Annotation that can be used to decorate pages. An annotation processor collects all classes annotated with `@Route` and generates an implementation of `Routes`.
- `Route`: Annotation that can be used to decorate pages. An annotation processor collects all classes annotated with `@Route` and generates an implementation of `Routes`.
- `Routes`: Provides a map of places and their corresponding pages.
- `Place`: Data class that represents a place in an application. A place is identified by a route, and can have an optional title and a custom root element.
- `Page`: Interface that represents a collection of HTML elements.
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Elemento simplifies working with GWT [Elemental2](https://github.com/google/elem
- Ready to be used with GWT and J2CL
- Minimal dependencies
- Elemental2 1.1.0 (`elemental2-core`, `elemental2-dom` and `elemental2-webstorage`)
- GWT project (`org.gwtproject.event:gwt-event` and `org.gwtproject.safehtml:gwt-safehtml`)
- GWT project (`org.gwtproject.event:gwt-event` and `org.gwtproject.safehtml:gwt-safehtml`)

**TOC**
**TOC**
* [Get Started](#get-started)
* [Builder API](#builder-api)
* [References](#references)
Expand Down Expand Up @@ -40,7 +40,7 @@ Elemento is available in [Maven Central](https://search.maven.org/search?q=g:org
<version>1.3.3</version>
</dependency>
```

In your GWT module inherit from `org.jboss.elemento.Core`:

```xml
Expand Down Expand Up @@ -111,7 +111,7 @@ final HTMLElement footer = footer()

# Event Handlers

Elemento provides methods to easily register event handlers. There are [constants](https://hal.github.io/elemento/org/jboss/elemento/EventType.html) for most of the known event types.
Elemento provides methods to easily register event handlers. There are [constants](https://hal.github.io/elemento/org/jboss/elemento/EventType.html) for most of the known event types.

You can either add event handlers when building the element hierarchy:

Expand Down Expand Up @@ -139,7 +139,7 @@ HTMLLIElement listItem = li()
.element();
```

or register them later using `EventType.bind()`:
or register them later using `EventType.bind()`:

```java
import org.gwtproject.event.shared.HandlerRegistration;
Expand Down Expand Up @@ -213,7 +213,7 @@ Elemento makes it easy to create custom elements. As for Elemento custom element
import static org.jboss.elemento.Elements.*;

class TodoItemElement implements IsElement<HTMLElement> {

private final HTMLElement root;
private final HTMLInputElement toggle;
private final HTMLElement label;
Expand All @@ -231,12 +231,12 @@ class TodoItemElement implements IsElement<HTMLElement> {
.element();
this.root.classList.toggle("completed", item.completed);
}

@Override
public HTMLElement element() {
return root;
}

// event handlers omitted
}
```
Expand All @@ -251,13 +251,13 @@ TodoItemElement[] itemElements = repository.items().stream()
.map(TodoItemElement::new)
.toArray();
ul().addAll(itemElements).element();
```
```

# Goodies

Besides the builder API, Elemento comes with a bunch of static helper methods that roughly fall into these categories:

1. Get notified when an element is attached to and detached from the DOM tree.
1. Get notified when an element is attached to and detached from the DOM tree.
1. Iterate over elements.
1. Methods to manipulate the DOM tree (add, insert and remove elements).
1. Methods to manipulate an element.
Expand All @@ -267,7 +267,7 @@ See the API documentation of [Elements](https://hal.github.io/elemento/org/jboss

## Attach / Detach

Implement `Attachable` to get notified when an element is attached to and detached from the DOM tree. The attachable interface provides a static method to easily register the callbacks to `attach(MutationRecord)` and `detach(MutationRecord)`:
Implement `Attachable` to get notified when an element is attached to and detached from the DOM tree. The attachable interface provides a static method to easily register the callbacks to `attach(MutationRecord)` and `detach(MutationRecord)`:

```java
import elemental2.dom.MutationRecord;
Expand All @@ -277,14 +277,14 @@ import static elemental2.dom.DomGlobal.console;
import static org.jboss.elemento.Elements.li;

class TodoItemElement implements IsElement<HTMLElement>, Attachable {

private final HTMLElement root;

TodoItemElement(TodoItem item) {
this.root = li().element();
Attachable.register(root, this);
}

@Override
public HTMLElement element() {
return root;
Expand Down Expand Up @@ -312,7 +312,7 @@ See the API documentation of [Elements](https://hal.github.io/elemento/org/jboss

# SVG & MathML

Elemento comes with basic support for SVG and MathML.
Elemento comes with basic support for SVG and MathML.

## SVG

Expand All @@ -334,7 +334,7 @@ In your GWT module inherit from `org.jboss.elemento.SVG`:
</module>
```

Finally, use the static methods in `org.jboss.elemento.svg.SVG` to create SVG elements.
Finally, use the static methods in `org.jboss.elemento.svg.SVG` to create SVG elements.

## MathML

Expand Down Expand Up @@ -363,9 +363,9 @@ Finally, use the static methods in `org.jboss.elemento.mathml.MathML` to create
Elemento offers a very basic router. The router is minimal invasive and built around a few simple concepts:

- `Route`: Annotation that can be used to decorate pages. An annotation processor collects all classes annotated with `@Route` and generates an implementation of `Routes`.
- `Routes`: Provides a map of places and their corresponding pages. This can be used to register all places in one go.
- `Place`: Data class that represents a place in an application. A place is identified by a route, and can have an optional title and a custom root element. If present the children of the root element are replaced by the elements of the page.
- `Page`: Simple interface that represents a collection of HTML elements. Implementations need to implement a single method: `Iterable<HTMLElement> elements()`
- `Routes`: Provides a map of places and their corresponding pages. This can be used to register all places in one go.
- `Place`: Data class that represents a place in an application. A place is identified by a route, and can have an optional title and a custom root element. If present the children of the root element are replaced by the elements of the page.
- `Page`: Simple interface that represents a collection of HTML elements. Implementations need to implement a single method: `Iterable<HTMLElement> elements()`
- `PlaceManager`: Class that keeps track of registered places, handles navigation events, and updates the DOM accordingly. The place manager can be customized using builder like methods and has a `start()` method to show the initial page.

```java
Expand Down Expand Up @@ -397,8 +397,8 @@ public class Application {

# Samples

Elemento comes with different [implementations](https://github.com/hal/elemento-samples) of the [TodoMVC](http://todomvc.com/) application using different frameworks:
Elemento comes with different [implementations](https://github.com/hal/elemento-samples) of the [TodoMVC](http://todomvc.com/) application using different frameworks:

- [GWT](https://github.com/hal/elemento-samples/tree/main/gwtproject)
- [J2CL](https://github.com/hal/elemento-samples/tree/main/j2cl)

Expand Down
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
<artifactId>elemento-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elemento-flow</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elemento-mathml</artifactId>
Expand Down
Loading

0 comments on commit a440178

Please sign in to comment.