Skip to content

Commit 2186395

Browse files
javier-godoypaodb
authored andcommitted
style(readme): highlight code examples
1 parent 7f66f5f commit 2186395

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
**[EXPERIMENTAL]** A `Renderer` for Vaadin Flow that uses a component instance as template, intended for use as an alternative to `LitRenderer`.
1010

11-
```
11+
```java
1212
grid.addColumn(LiteRenderer.<Person>of(
1313
new Button("Update", ev->handleUpdate(LiteRenderer.getItem(ev, Item.class))),
1414
new Button("Update", ev->handleRemove(LiteRenderer.getItem(ev, Item.class)));
1515
```
1616

1717
Instead of:
1818

19-
```
19+
```java
2020
grid.addColumn(LitRenderer.<Person>of(
2121
"<button @click=\"${handleUpdate}\">Update</button>" +
2222
"<button @click=\"${handleRemove}\">Remove</button>")
@@ -95,7 +95,7 @@ Lite Renderer Add-On is written by Flowing Code S.A.
9595

9696

9797
- Use component instances as template:
98-
```
98+
```java
9999
Div template = new Div(
100100
new Image("${item.pictureUrl}", "Portrait of ${item.firstName} ${item.lastName}"),
101101
new Div("${item.firstName} ${item.lastName}"),
@@ -109,7 +109,7 @@ Lite Renderer Add-On is written by Flowing Code S.A.
109109
```
110110

111111
- `withAttribute` and `withListener` are fluent methods that allow setting attributes and listeners:
112-
```
112+
```java
113113
Div div = new Div("${item.firstName} ${item.lastName}");
114114
grid.addColumn(LiteRenderer.<Person>of(div)
115115
.withProperty("firstName", Person::firstName)
@@ -124,7 +124,7 @@ Lite Renderer Add-On is written by Flowing Code S.A.
124124
```
125125

126126
- Wrapping a component with `LiteComponent` allows fluent setters for attributes, properties, and listeners, removing the need for variables.
127-
```
127+
```java
128128
Div div = new Div("${item.firstName} ${item.lastName}");
129129
grid.addColumn(LiteRenderer.<Person>of(div)
130130
.withProperty("firstName", Person::firstName)
@@ -139,7 +139,7 @@ Lite Renderer Add-On is written by Flowing Code S.A.
139139
```
140140

141141
- Listeners can also receive more data in addition to the item:
142-
```
142+
```java
143143
TextField tf = new TextField();
144144
grid.addColumn(LiteRenderer.<Person>of(tf).withListener(tf, "change", (item, args) -> {
145145
Notification.show(item.firstName()
@@ -149,19 +149,19 @@ Lite Renderer Add-On is written by Flowing Code S.A.
149149
```
150150

151151
- The click event of a template `Button` is called when the button is clicked. Within the event listener, `LiteRenderer.getItem(ev, Person.class)` returns the current item:
152-
```
152+
```java
153153
grid.addColumn(LiteRenderer.<Person>of(new Button("Click", ev->{
154154
var item = LiteRenderer.getItem(ev, Person.class);
155155
Notification.show(item.firstName() + " " + item.lastName() + " Clicked!");
156156
})));
157157
```
158158

159159
- [Flow Viritin](https://vaadin.com/directory/component/flow-viritin) components enable more fluent method chaining:
160-
```
160+
```java
161161
grid.addColumn(LiteRenderer.<Person>of(
162162
VSpan.of("${item.firstName} ${item.lastName}")
163163
.withStyle("color", "${item.color}"))
164164
.withProperty("color", person->person.age()<18?"red":"blue")
165165
.withProperty("firstName", Person::firstName)
166166
.withProperty("lastName", Person::lastName));
167-
```
167+
```

0 commit comments

Comments
 (0)