Skip to content

Commit 3d4d0cb

Browse files
authored
Merge pull request #83 from ravijar/dev
New features & bug fixes
2 parents 04a3097 + 869e71f commit 3d4d0cb

File tree

26 files changed

+211
-66
lines changed

26 files changed

+211
-66
lines changed

README-DEV.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## test

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ The configuration file is an XML document containing <pages> as the root element
184184
```
185185
![hero-section-gif.gif](docs/resources/documentation/hero-section-gif.gif)
186186
187+
_React Code_ - [`HeoSection.jsx`](src/main/resources/templates/react/components/HeroSection.jsx) | _Default Styling_ - [`Herosection.css`](src/main/resources/templates/css/components/HeroSection.css)
188+
187189
ii. `Button` [Root/Child]
188190
- A button that supports various actions triggered on a click event.
189191
- **Functionality:**
@@ -232,7 +234,9 @@ The configuration file is an XML document containing <pages> as the root element
232234
</component>
233235
```
234236
235-
![button-gif.gif](docs/resources/documentation/button-gif.gif)
237+
![button-gif.gif](docs/resources/documentation/button-gif.gif)
238+
239+
_React Code_ - [`Button.jsx`](src/main/resources/templates/react/components/Button.jsx) | _Default Styling_ - [`Button.css`](src/main/resources/templates/css/components/Button.css)
236240
237241
iii. `Container` [Root/Child]
238242
- A **data-fetching** component that retrieves and displays information from a backend API or LocalStorage
@@ -272,6 +276,7 @@ The configuration file is an XML document containing <pages> as the root element
272276
</result>
273277
</component>
274278
```
279+
_React Code_ - [`Container.jsx`](src/main/resources/templates/react/components/Container.jsx) | _Default Styling_ - [`Container.css`](src/main/resources/templates/css/components/Container.css)
275280
276281
iv. `Form` [Root]
277282
- A form based on URL parameters and schema properties defined in an OpenAPI Specification (OAS) resource.
@@ -294,6 +299,8 @@ The configuration file is an XML document containing <pages> as the root element
294299
```
295300
![form-gif.gif](docs/resources/documentation/form-gif.gif)
296301
302+
_React Code_ - [`Form.jsx`](src/main/resources/templates/react/components/Form.jsx) | _Default Styling_ - [`Form.css`](src/main/resources/templates/css/components/Form.css)
303+
297304
v. `SearchBar` [Root/Child]
298305
- A search bar component that fetches data from a specified resource.
299306
- **Functionality:**
@@ -310,9 +317,10 @@ The configuration file is an XML document containing <pages> as the root element
310317
</component>
311318
</result>
312319
</component>
313-
314320
```
315321
322+
_React Code_ - [`SearchBar.jsx`](src/main/resources/templates/react/components/SearchBar.jsx) | _Default Styling_ - [`SearchBar.css`](src/main/resources/templates/css/components/SearchBar.css)
323+
316324
vi. `CardSection` [Result]
317325
- Displays a list of cards, where each card contains an **image**, **a title**, and **a description** related to an item.
318326
- **Functionality:**
@@ -329,6 +337,8 @@ The configuration file is an XML document containing <pages> as the root element
329337
```
330338
![card-section-gif.gif](docs/resources/documentation/card-section-gif.gif)
331339
340+
_React Code_ - [`CardSection.jsx`](src/main/resources/templates/react/components/CardSection.jsx) | _Default Styling_ - [`CardSection.css`](src/main/resources/templates/css/components/CardSection.css)
341+
332342
vii. `Card` [Result]
333343
- Displays an image, a title, a description, and additional data in a structured format.
334344
- **Functionality:**
@@ -352,6 +362,8 @@ The configuration file is an XML document containing <pages> as the root element
352362
```
353363
![card-gif.gif](docs/resources/documentation/card-gif.gif)
354364
365+
_React Code_ - [`Card.jsx`](src/main/resources/templates/react/components/Card.jsx) | _Default Styling_ - [`Card.css`](src/main/resources/templates/css/components/Card.css)
366+
355367
viii. `Alert` [Result]
356368
- Displays success or failure messages based on the API response.
357369
- **Functionality:**
@@ -365,6 +377,8 @@ The configuration file is an XML document containing <pages> as the root element
365377
```
366378
![alert-gif.gif](docs/resources/documentation/alert-gif.gif)
367379
380+
_React Code_ - [`Alert.jsx`](src/main/resources/templates/react/components/Alert.jsx) | _Default Styling_ - [`Alert.css`](src/main/resources/templates/css/components/Alert.css)
381+
368382
ix. `Table` [Result]
369383
- Displays data in a structured tabular format.
370384
- **Functionality:**
@@ -393,6 +407,8 @@ The configuration file is an XML document containing <pages> as the root element
393407
```
394408
![table-gif.gif](docs/resources/documentation/table-gif.gif)
395409
410+
_React Code_ - [`Table.jsx`](src/main/resources/templates/react/components/Table.jsx) | _Default Styling_ - [`Table.css`](src/main/resources/templates/css/components/Table.css)
411+
396412
4. Properties Tags
397413
398414
i. `<resource>` : Defines an API resource to be accessed by the component.

samples/petstore/pages.xml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@
2424
</component>
2525
</page>
2626

27+
<page name="SearchPets" route="/searchPets" navbar="false">
28+
<component type="SearchBar" id="petsSearchBar">
29+
<resource method="GET">/pets/{id}</resource>
30+
<result>
31+
<component type="CardSection" id="petsContainerCardSection">
32+
<assign key="id" title="name" description="description" image="imageURL"/>
33+
<route>/pets/{id}</route>
34+
</component>
35+
</result>
36+
</component>
37+
</page>
38+
2739
<page name="Pet" route="/pets/{id}" navbar="false">
2840
<component type="Container" id="petContainer">
2941
<resource method="GET">/pets/{id}</resource>
@@ -35,6 +47,9 @@
3547
<localStorage action="save">
3648
<assign key="cart"/>
3749
</localStorage>
50+
<result>
51+
<component type="Alert" id="petAddToCartButtonAlert"/>
52+
</result>
3853
</component>
3954
</component>
4055
</result>
@@ -54,6 +69,9 @@
5469
<localStorage action="remove">
5570
<assign key="cart"/>
5671
</localStorage>
72+
<result>
73+
<component type="Alert" id="removeFromCartButtonAlert"/>
74+
</result>
5775
</component>
5876
</component>
5977
</result>
@@ -78,7 +96,7 @@
7896
<text>Delete</text>
7997
<resource method="DELETE">/pets/{id}</resource>
8098
<result>
81-
<component type="Alert" id="deletePetFormAlert"/>
99+
<component type="Alert" id="deletePetButtonAlert"/>
82100
</result>
83101
</component>
84102
</component>
@@ -108,14 +126,4 @@
108126
</component>
109127
</page>
110128

111-
<page name="DeletePet" route="/deletePet/{id}" navbar="false">
112-
<component type="Form" id="deletePetForm">
113-
<resource method="DELETE">/pets/{id}</resource>
114-
<text>Delete Pet</text>
115-
<submit>Delete Pet</submit>
116-
<result>
117-
<component type="Alert" id="deletePetFormAlert"/>
118-
</result>
119-
</component>
120-
</page>
121129
</pages>

src/main/java/com/ravijar/core/ProjectManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ProjectManager {
3636
private final String[] cssComponentTemplates = {"InputField", "KeyValuePair", "Alert", "HeroSection", "SearchBar", "Button", "CardSection", "NavBar", "Form"};
3737
private final String[] projectSubDirs = {"styles/components", "styles/pages", "styles/custom_styles"};
3838
private final String[] buildSubDirs = {"build/src/components", "build/src/pages", "build/src/custom_styles", "build/src/common"};
39-
private final String[] npmPackages = {"react-router-dom", "@fortawesome/react-fontawesome", "@fortawesome/free-regular-svg-icons"};
39+
private final String[] npmPackages = {"react-router-dom", "@fortawesome/react-fontawesome", "@fortawesome/free-regular-svg-icons", "@fortawesome/free-solid-svg-icons"};
4040
private static final String SOURCE_ROOT_PATH="templates";
4141

4242
public ProjectManager() {

src/main/java/com/ravijar/model/freemarker/FreeMarkerSearchBar.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@Setter
99
@ToString
1010
public class FreeMarkerSearchBar extends FreeMarkerComponent{
11+
private String action;
1112
private OpenAPIResource resource;
1213
private FreeMarkerComponent resultComponent;
1314
}

src/main/java/com/ravijar/populator/ButtonPopulator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public void populate(Button source, FreeMarkerButton target) {
3131
if(source.getResource() != null) {
3232
target.setAction("resource");
3333
target.setResource(openAPIParser.getResourceData(source.getResource()));
34+
}
3435

36+
if(source.getResult() != null) {
3537
FreeMarkerComponent freeMarkerComponent = new PopulatorHelper(openAPIParser).switchComponent(source.getResult().getComponent(), target);
3638
freeMarkerComponent.setRole("result");
3739
target.setResultComponent(freeMarkerComponent);

src/main/java/com/ravijar/populator/SearchBarPopulator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public SearchBarPopulator(OpenAPIParser openAPIParser) {
1515

1616
public void populate(SearchBar source, FreeMarkerSearchBar target) {
1717
populateComponent(source, target);
18-
target.setResource(openAPIParser.getResourceData(source.getResource()));
18+
19+
if(source.getResource() != null) {
20+
target.setAction("resource");
21+
target.setResource(openAPIParser.getResourceData(source.getResource()));
22+
}
1923

2024
FreeMarkerComponent freeMarkerComponent = new PopulatorHelper(openAPIParser).switchComponent(source.getResult().getComponent(), target);
2125
freeMarkerComponent.setRole("result");
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
.search-bar {
22
display: flex;
33
align-items: center;
4-
width: 100%;
5-
max-width: 300px;
6-
margin: 0 auto;
4+
max-width: 250px;
75
border-radius: 20px;
6+
border: 2px solid #1A1A1A;
87
overflow: hidden;
9-
background-color: rgb(255, 255, 255);
8+
box-sizing: border-box;
9+
background-color: white;
1010
}
1111

1212
.search-input {
13-
flex-grow: 1;
13+
padding: 12px 16px;
14+
border-radius: 6px;
15+
font-family: inherit;
1416
border: none;
15-
padding: 5px 5px 5px 20px;
16-
font-size: 16px;
1717
outline: none;
18-
background-color: rgba(255, 255, 255, 0.5);
1918
}
2019

2120
.search-button {
22-
background-color: #007bff;
21+
background-color: white;
2322
flex-grow: 1;
24-
color: white;
2523
border: none;
26-
padding: 5px 10px;
27-
font-size: 16px;
24+
padding: 11px 10px;
25+
font-family: inherit;
2826
cursor: pointer;
29-
transition: background-color 0.3s ease;
30-
}
31-
32-
.search-button:hover {
33-
background-color: #0056b3;
3427
}

src/main/resources/templates/css/components/Table.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.custom-table thead {
2525
position: sticky;
2626
top: 0;
27-
z-index: 100;
27+
z-index: 2;
2828
background-color: #f4f4f4;
2929
}
3030

src/main/resources/templates/freemarker/css/Nest.ftl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<#switch component.type>
33
<#case "SearchBar">
44
z-index: 1;
5-
position: absolute;
6-
top: 60px;
7-
right: 30px;
5+
margin: 10px 10px 0 0;
6+
display: flex;
7+
justify-content: flex-end;
88
<#break>
99
<#case "Button">
1010
<#switch component.role>
@@ -18,9 +18,9 @@
1818
<#break>
1919
<#case "Form">
2020
z-index: 1;
21-
position: absolute;
22-
top: 60px;
23-
left:35%;
21+
margin-top: 20px;
22+
display: flex;
23+
justify-content: center;
2424
<#break>
2525
<#default>
2626

@@ -32,13 +32,13 @@
3232
<#switch component.resultComponent.type>
3333
<#case "Card">
3434
z-index: 1;
35-
position: absolute;
36-
top: 100px;
37-
left:25%;
35+
margin-top: 50px;
36+
display: flex;
37+
justify-content: center;
3838
<#break>
3939
<#case "Alert">
40-
z-index: 1;
41-
position: absolute;
40+
z-index: 10;
41+
position: fixed;
4242
top: 75px;
4343
right: 5px;
4444
<#break>

0 commit comments

Comments
 (0)