Skip to content

Commit 324a1bf

Browse files
committed
Documentation
1 parent 8bf58a7 commit 324a1bf

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

README.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ In general the API for an component can be classified into these groups:
111111

112112
## Static Factory Methods
113113

114-
These methods are used to create a component. They are usually named after the component and return an instance of the newly created component:
114+
These methods are used to create a component. They are usually named after the component, are overloaded to accept required and optional arguments, and return an instance of the newly created component:
115+
116+
```java
117+
Button button1 = button("Click me!");
118+
Button button2 = button("PatternFly", "https://www.patternfly.org");
119+
```
120+
121+
## Add Methods
122+
123+
These methods add subcomponents to a main component. They are usually called `add<SubComponent>()` and return the main component so that the method call can be chained with other methods.
115124

116125
```java
117-
Button button = button("Click me!");
118126
Dropdown dropdown = dropdown()
119127
.addToggle(menuToggle("Dropdown"))
120128
.addMenu(menu()
@@ -123,20 +131,47 @@ Dropdown dropdown = dropdown()
123131
.addItem(actionMenuItem("item-0", "Action"))))))
124132
```
125133

126-
## Add Methods
134+
## Builder / Modifier Methods
127135

128-
These methods add subcomponents to a main component. They are usually called `add<SubComponent>()` and return the main component so that the method call can be chained with other methods.
136+
These methods modify the current componemt. They return the current component so that the method call can be chained with other methods.
129137

138+
```java
139+
Card card = card()
140+
.flat()
141+
.rounded()
142+
.large();
143+
```
130144

145+
## ARIA Related Methods
131146

132-
## Builder / Modifier Methods
147+
These methods set ARIA related attributes in the component. They're usually named `aria<Attribute>()` and return the component so that the method call can be chained with other methods.
133148

134-
## ARIA Related Methods
149+
```java
150+
Navigation navigation = navigation(flat)
151+
.ariaScrollBackLabel("← back")
152+
.ariaScrollForwardLabel("→ forward");
153+
```
135154

136155
## Event Handlers
137156

157+
These methods add event handlers for various event to the component. They are usually named `on<Event>()` and return the component so that the method call can be chained with other methods.
158+
159+
```java
160+
Drawer drawer = drawer().id("drw")
161+
.onToggle((e, c, expanded) -> console.log("Drawer expanded: " + expanded));
162+
```
163+
138164
## Public API / Getters
139165

166+
These methods do something with the component or return a value, a property or some other kind of information.
167+
168+
```java
169+
Switch switch_ = switch_("id", "name");
170+
boolean value = switch_.value();
171+
```
172+
173+
---
174+
140175
The best way to experience the API is to take a look at the code snippets of the various components and layouts in the [showcase](https://patternfly-java.github.io/).
141176

142177
# PatternFly Support

0 commit comments

Comments
 (0)