Build a React app optimized for mobile view with the following features:
-
Schema-Driven UI:
- The UI is driven by a configuration schema.
- The configuration is fetched from the backend (
BE
),AppConfig
, orRemoteConfig
.
-
Configuration Source:
- The configuration is initially fetched from one of the following sources: backend (
BE
),AppConfig
, orRemoteConfig
. - A static JSON file is used for configuration during development.
- The configuration is initially fetched from one of the following sources: backend (
-
Dynamic Grid Component Implementation:
- The app includes a dynamic grid component.
- The grid has configurable rows (
x
) and columns (y
). - The UI is designed to accommodate
x * y
items.
-
Grid Item Component:
- The grid items are represented by a
GridItem
component.
- The grid items are represented by a
-
Item Component Variants:
- The
GridItem
component has multiple variants to display different types of content.
- The
-
Redirection Configuration:
- Each item variant has redirection configurations.
- On click, it can navigate to a new tab or a new route/screen within the app.
-
Dynamic Variant Change:
- The variant of the
GridItem
component can be changed dynamically.
- The variant of the
Provide step-by-step instructions on how to set up the development environment and install dependencies.
# Clone the repository
git clone <repository-url>
# Change into the project directory
cd <project-directory>
# Install dependencies
npm install
# Runs the app in the development mode.\
# Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
npm start
# Builds the app for production to the `build` folder.\
npm run build
project-root/
├── public/
│ ├── index.html
│ ├── data
│ │ ├── schema.json
├── src/
│ ├── components/
│ ├── routes/
│ ├── App.js
│ ├── ElementMapper.js (A HOC Mapper that imports and returns the dynamic components)
│ └── index.js
├── .gitignore
├── .nvmrc
├── package.json
└── README.md
The schema.json
is placed at the public/data
. The JSON is responsible for dynamic components behavior and render behavior.
"screens": { # Schema for all the screens
"/": {
"id": 1,
"title": "home", # Name of the screen
"components": [ # List of Component
{
"id": "101", # key of Grid Component
"type": "grid", # Name of Grid Component
"props": {
"title": "Grid One", # Title of Grid Component
"rows": 3, # Number of rows for Component
"columns": 3, # Number of cols for Component
"items": [
{
"id": 1001, # key of Item Component
"type": "ItemVariant1", # Name of Item Component ItemVariant1/ItemVariant2
"props": {
"redirectType": "tab", # type of redirection route/tab
"redirectConfig": "https://example.com", # path for redirection
"image": "https://picsum.photos/200", # path for image
"title": "ItemVariant1 1", # title for grid Item
"description": "Description" # description for grid Item
}
}
]
}
}
]
}
}
# Pre-deployment script
npm run predeploy
# deployment script to deploy it to github pages
npm run deploy
Grid Component Grid Item Component Item Variant 1 (for Grid Item Component) Item Variant 2 (for Grid Item Component)
For now we are just using global styles.css
We are using static JSON for now.