Skip to content

Commit b42b8b1

Browse files
authored
docs: installation guide for react package (#354)
* docs: installation guide for react package * docs: update top-level readme to include react and nuxt example app, minor corrections in contributing guide and pull request template
1 parent e28f142 commit b42b8b1

6 files changed

Lines changed: 87 additions & 3 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ https://github.com/six-group/six-webcomponents/blob/dev/.github/CONTRIBUTING.md#
2525

2626
<!-- Describe your changes in detail -->
2727
<!-- Why is this change required? What problem does it solve? -->
28-
<!-- If it resolves an open issue, please link to the issue here. For example "Resolves #1337" -->
28+
<!-- If it resolves an open issue, please link to the issue here. For example, "Resolves #1337" -->
2929

3030
### 📝 Checklist
3131

.github/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ guidelines:
6565

6666
## Development Setup
6767

68-
You will need [Node.js](https://nodejs.org) **version 16+**, and
69-
[NPM](https://www.npmjs.com/package/npm) **version 8**.
68+
You will need [Node.js](https://nodejs.org) **version 22+**, and
69+
[NPM](https://www.npmjs.com/package/npm) **version 10.9.x**.
7070

7171
After cloning the repository, run in root directory:
7272

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ There are example apps for Angular, Plain Javascript, Vue and React. You can fin
3838
| `examples/angular` | Angular demo app showing some components and features of the ui-library |
3939
| `examples/js` | Plain JS demo app showing some components and features the of ui-library |
4040
| `examples/vue` | Vue demo app showing some components and features of the ui-library |
41+
| `examples/react` | React demo app showing some components and features of the ui-library |
42+
| `examples/nuxt` | Nuxt demo app showing some components and features of the ui-library |
4143
| `docs` | API documentation built with VitePress |
4244

4345
## Credits

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default withMermaid({
5353
items: [
5454
{ text: 'Angular', link: '/guide/angular' },
5555
{ text: 'Vue', link: '/guide/vue' },
56+
{ text: 'React', link: '/guide/react' },
5657
],
5758
},
5859
{

docs/guide/react.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# React
2+
3+
We offer a
4+
[dedicated npm package for React](https://www.npmjs.com/package/@six-group/ui-library-react) to
5+
simplify the use of our web components. Find detailed steps in this guide to learn how to use it.
6+
7+
For more detailed usage examples, check the
8+
[React demo](https://six-group.github.io/six-webcomponents/demo/react) and its
9+
[source code](https://github.com/six-group/six-webcomponents/tree/main/examples/react).
10+
11+
## Setup
12+
13+
This installation guide assumes you are using [Vite](https://vitejs.dev/) as your build tool and
14+
[React Router](https://reactrouter.com/) as your dedicated React framework.
15+
16+
1. Install both the web components and React library:
17+
18+
```bash
19+
npm install @six-group/ui-library
20+
npm install @six-group/ui-library-react
21+
```
22+
23+
2. In your main.tsx file, import the styles:
24+
25+
```ts
26+
import '@six-group/ui-library/dist/ui-library/ui-library.css';
27+
```
28+
29+
## Using the Components
30+
31+
The components can be used just like any other React component.
32+
33+
1. Import the component with an import statement like this
34+
35+
```ts
36+
import { SixMenuItem } from '@six-group/ui-library-react';
37+
```
38+
39+
2. Use it in the template
40+
41+
```html
42+
<SixMenuItem value="logout">Logout</SixMenuItem>
43+
```
44+
45+
## Router
46+
47+
If you are using `react-router` and want to use `NavLink` attributes on the web components
48+
49+
```ts
50+
import { NavLink } from 'react-router';
51+
```
52+
53+
You can then use `router-link` on any component from the library like this:
54+
55+
```ts
56+
const getLinkClassName = ({ isActive }: { isActive: boolean }) =>
57+
`${styles[isActive ? 'active-link' : 'link']}`;
58+
```
59+
60+
```html
61+
<NavLink to={'/'} className={getLinkClassName}>
62+
<SixSidebarItemGroup name="Home" icon="home" />
63+
</NavLink>
64+
```
65+
66+
## Forms
67+
68+
If you want to use the web components in a form, you can check out the example in the React example
69+
app. We are not using any form library, but there are some good form libraries out there. Following
70+
a list of libraries, you can check out and which we recommend as a starting point:
71+
72+
- [react-hook-form](https://react-hook-form.com/)
73+
- [tanstack-form](https://tanstack.com/form/latest/docs/overview)
74+
75+
### Error Message Translations
76+
77+
For proper translation, set the lang attribute on the `html` element. Languages available are `en`,
78+
`de`, `it`, and `fr`.

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ hero:
1616
- theme: alt
1717
text: Vue Example
1818
link: https://six-group.github.io/six-webcomponents/demo/vue
19+
- theme: alt
20+
text: React Example (experimental)
21+
link: https://six-group.github.io/six-webcomponents/demo/react
1922
features:
2023
- title: Agnostic
2124
details:

0 commit comments

Comments
 (0)