Skip to content

Commit

Permalink
change path for example templates in documentation
Browse files Browse the repository at this point in the history
explain example templates
modify the steps to create new templates
  • Loading branch information
Min Htet Oo authored and Min Htet Oo committed Jan 26, 2024
1 parent dd0f44a commit b459410
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ This template serves as a quick way to start building your own decentralized ren

## How and what?

This repository boilerplate code is spinned up from [Create Vite](https://github.com/vitejs/vite/tree/main/packages/create-vite). As of now, [Create React App](https://github.com/facebook/create-react-app) is no longer featured in React documentation. Can observe [future roadmap](https://github.com/reactjs/react.dev/pull/5487#issuecomment-1409720741) on CRA meanwhile.
This repository boilerplate code is spinned up from [Create React App](https://github.com/facebook/create-react-app).

The decentralized renderer code here is based off OpenAttestation's [decentralized-renderer-react-template](https://github.com/Open-Attestation/decentralized-renderer-react-template), but with **some changes** as mentioned below.

## Notable changes

To stay as simple and less opinionated as possible, these are omitted:

- Styling libraries. (Recommended to use [Tailwind](https://tailwindcss.com/docs/installation), otherwise can use module.css directly)
- Testing frameworks.
- [Core components](https://github.com/Open-Attestation/decentralized-renderer-react-template/tree/master/examples/core).
- CI pipelines.
- Avoid CRA ejected webpack config, leave it to Vite.

> You are expected to setup your own tests, styling according to your needs.
## Main dependancies

- `@govtechsg/decentralized-renderer-react-components`
- `@govtechsg/open-attestation` (If you need types, else can be omitted)
- `@tradetrust-tt/tradetrust`
- `react`
- `react-dom`

Expand All @@ -43,19 +40,32 @@ npm run start

Head off to `http://localhost:6006/` to see storybook, while `http://127.0.0.1:8080/` to see your actual document rendered in a dummy application.

### Creating new templates
### Example Templates

This repository contains a collection of example templates located in the `/src/templates` directory. These templates serve as references and guides for setting up your own templates to suit your specific needs.

All of these templates are built using core components located under the `/src/core`. Additionally, they all utilize a QR code component to generate QR codes for easy sharing and access to relevant information.

1. Bill of Lading
The "Bill of Lading" template provides a basic example.

1. Create your new sample documents json in `src/documents/<YOUR_SAMPLE>/<YOUR_DOCUMENT>.json`. Be sure they conform to either OpenAttestation [v2](https://schema.openattestation.com/2.0/schema.json) or [v3](https://schema.openattestation.com/3.0/schema.json) schema.
2. Invoice Template
The "Invoice Template" showcases the use of a privacy filter to automatically redact sensitive information, ensuring data security and privacy.

2. Create a new "[Layout](https://github.com/Open-Attestation/adr/blob/master/decentralised_rendering.md#definitions)" within `src/components/<YOUR_LAYOUT>`. Ensure your "Layout" name is the same as `template.name` defined in your sample documents json.
3. XML Renderer
The "XML Renderer" template demonstrates how to use XML data to dynamically render content within your template.

Feel free to explore these examples and adapt them to your own projects.

### Creating new templates

3. Create your "Views" (templates) within `src/components/<YOUR_LAYOUT>/<YOUR_TEMPLATES>`.
1. Create your new sample documents json in `src/templates/<YOUR_SAMPLE>/<YOUR_DOCUMENT>.json`. Be sure they conform to either OpenAttestation [v2](https://schema.openattestation.com/2.0/schema.json) or [v3](https://schema.openattestation.com/3.0/schema.json) schema.

4. Develop whatever you need using storybook, passing in your sample documents json.
2. Develop whatever you need using storybook, passing in your sample documents json.

5. When done, remember to register the new template to `templateRegistry` in `src/components/DecentralizedRenderer`.
3. When done, remember to register the new template to `registry` in `src/templates/index.tsx`.

> You can follow the template samples provided in `src/components/SampleV2` and `src/components/SampleV3`.
> You can follow the template samples provided under `src/templates` folder.
### Build and host

Expand Down

0 comments on commit b459410

Please sign in to comment.