Skip to content

Commit

Permalink
chore: adds a README.md to examples
Browse files Browse the repository at this point in the history
chore: adds MIT LICENSE file
chore: adds github actions build status for the repo
chore: adds examples directory link to the reference in the main README.md
  • Loading branch information
edusig committed Aug 14, 2023
1 parent d1ee988 commit 2172610
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 BLB Ventures

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Resource

[![build status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fblb-ventures%2Fresource%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/blb-ventures/resource/goto?ref=main)

Library to transform entity definition into form fields, form validation and formatted display values.

There is a backend implementation for Python with Strawberry GraphQL that generates this kinds of files here: https://github.com/blb-ventures/strawberry-resources
Expand Down Expand Up @@ -27,9 +29,9 @@ pnpm i @blb-ventures/resource

## Getting started

### Real use example
### Real usage example

I've put in the examples directory some React components we use in our projects to simplify rendering and validating a form from a list of fields.
I've put in the [examples directory](https://github.com/blb-ventures/resource/tree/main/examples) some React components we use in our projects to simplify rendering and validating a form from a list of fields.
The examples use react-hook-form, zod and mui and I'm open for suggestions on how to use with other libraries.

### Setup
Expand Down
25 changes: 25 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Examples

Currently there are only example files from what we actually use in production for BLB Ventures product's.

In our projects we usually use:

- ReactJS
- React Hook Form (with Zod)
- MUI (a implementation of Material UI in ReactJS)

## Directory Structure

```
├── react/
│ ├── hook-form-zod.tsx (The example component)
│ ├── resource-manager.ts (Example of an instance of Resource Manager (from this lib) being initialized)
│   └── components/
│ ├── form-control-wrapper.tsx (MUI wrapper for the form fields to add labels and helper/error texts)
│ ├── form-item.tsx (Wrapper around this lib ReactHookFormItem injecting the above FormControlWrapper and loading the initialized resource manager)
│ ├── form.tsx (A form component that injects react-hook-form methods into the child components)
│ └── resource-form.tsx (A utility to convert a list of fields from the resources.json info FormItem components and basically generate the form with validation)
└── resources.json (The definition of the fields of every entity)
```

About the `form.tsx` you can see more on the [official react-hook-form documentation example of this](https://react-hook-form.com/advanced-usage#SmartFormComponent)

0 comments on commit 2172610

Please sign in to comment.