ui-generator-lib
v1.0.5
Published
A library for generating user interfaces based on JSON files or PSD/JPG images.
Maintainers
Readme
UI Generator Library
Overview
The UI Generator Library is a JavaScript library that allows users to generate user interfaces based on JSON files or PSD/JPG images. It provides a flexible way to configure APIs, set alignment (horizontal or vertical), and apply custom styles to the generated UI components.
Features
- Generate UI from JSON or image files
- Configure API endpoints and parameters
- Set alignment for UI components
- Apply custom styles to UI elements
Installation
To install the UI Generator Library, use npm:
npm install ui-generator-libUsage
Importing the Library
To use the library, import it in your JavaScript file:
import { UIBuilder, JsonParser, ImageParser, ApiConfig } from 'ui-generator-lib';Generating UI from JSON
To generate a UI from a JSON file:
const jsonParser = new JsonParser();
const uiBuilder = new UIBuilder();
const jsonData = jsonParser.parseJson('path/to/your/file.json');
uiBuilder.buildUI(jsonData);Generating UI from Images
To generate a UI from a PSD or JPG file:
const imageParser = new ImageParser();
const uiBuilder = new UIBuilder();
const imageData = imageParser.parseImage('path/to/your/file.psd');
uiBuilder.buildUI(imageData);Configuring APIs
To configure API endpoints:
const apiConfig = new ApiConfig();
apiConfig.configureApi({
endpoint: 'https://api.example.com/data',
method: 'GET',
});Setting Alignment
To set the alignment of UI components:
import { setAlignment } from './utils/alignment';
setAlignment('horizontal'); // or 'vertical'Applying Styles
To apply custom styles to the UI components:
uiBuilder.applyStyles({
backgroundColor: 'blue',
color: 'white',
});API Reference
JsonParser
parseJson(filePath): Parses the JSON file and returns the data.validateJson(jsonData): Validates the structure of the JSON data.
ImageParser
parseImage(filePath): Parses the image file and extracts UI components.validateImage(imageData): Validates the integrity of the image data.
UIBuilder
buildUI(data): Constructs the user interface based on the provided data.applyStyles(styles): Applies custom styles to the UI components.
ApiConfig
configureApi(config): Configures API endpoints and parameters.validateApi(apiConfig): Validates the API configuration.
Alignment
setAlignment(direction): Sets the alignment of UI components (horizontal or vertical).
Contributing
Contributions are welcome! Please submit a pull request or open an issue for any enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
