@bailaya/react 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,39 +6,37 @@
|
|
|
6
6
|
|
|
7
7
|
`@bailaya/react` builds on top of **@bailaya/core** to provide:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
* A **`BailayaProvider`** + **`useBailayaClient`** context
|
|
10
|
+
* React **hooks** for fetching all core data (with `loading`, `error`, `data`, and `refetch`)
|
|
11
|
+
* **Components** with sensible Tailwind defaults (and full styling slots)
|
|
12
|
+
* Full TypeScript support, including localized text & date formatting
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
> Works **with or without Tailwind**. If you don’t use Tailwind, just override the class props (or use the render props) to apply your own styling.
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- Date formatting via Intl
|
|
35
|
-
- Custom text labels
|
|
18
|
+
* **Context + client** (`BailayaProvider` + `useBailayaClient`)
|
|
19
|
+
* **Hooks** (all return `{ data, error, loading, refetch }`)
|
|
20
|
+
|
|
21
|
+
* `useStudioProfile(overrideId?)`
|
|
22
|
+
* `useUserProfile(userId)`
|
|
23
|
+
* `useInstructors(overrideId?)`
|
|
24
|
+
* `useClasses(from?, overrideId?)`
|
|
25
|
+
* `useClassesByType(typeName, from?, overrideId?)`
|
|
26
|
+
* **Components** (all props overridable)
|
|
27
|
+
|
|
28
|
+
* `<StudioProfileCard />`
|
|
29
|
+
* `<UserProfileCard />`
|
|
30
|
+
* `<InstructorList />`
|
|
31
|
+
* `<ClassSchedule />`
|
|
32
|
+
* `<ClassScheduleByType />`
|
|
33
|
+
* `<StudioDescription />`
|
|
36
34
|
|
|
37
35
|
## Installation
|
|
38
36
|
|
|
39
37
|
```bash
|
|
40
38
|
npm install @bailaya/react
|
|
41
|
-
|
|
39
|
+
```
|
|
42
40
|
|
|
43
41
|
or with Yarn:
|
|
44
42
|
|
|
@@ -51,6 +49,52 @@ yarn add @bailaya/react
|
|
|
51
49
|
> * `"react": ">=17"`
|
|
52
50
|
> * `"react-dom": ">=17"`
|
|
53
51
|
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Tailwind Setup (optional)
|
|
55
|
+
|
|
56
|
+
If your app uses Tailwind, add this glob so JIT scans our package classes:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
// tailwind.config.js or tailwind.config.ts
|
|
60
|
+
module.exports = {
|
|
61
|
+
content: [
|
|
62
|
+
'./node_modules/@bailaya/**/*.{js,mjs,ts,tsx}',
|
|
63
|
+
],
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
> If you’re not using Tailwind, skip this section.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Styling without Tailwind
|
|
72
|
+
|
|
73
|
+
You can use all components in non-Tailwind projects:
|
|
74
|
+
|
|
75
|
+
* Pass your own `className`/`*ClassName` props to inject your CSS classes.
|
|
76
|
+
* Or use `renderItem` / `renderProfile` props to fully control markup.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { InstructorList } from '@bailaya/react'
|
|
80
|
+
|
|
81
|
+
export function Team() {
|
|
82
|
+
return (
|
|
83
|
+
<InstructorList
|
|
84
|
+
className="team"
|
|
85
|
+
itemClassName="card"
|
|
86
|
+
imageWrapperClassName="avatarWrap"
|
|
87
|
+
imageClassName="avatar"
|
|
88
|
+
bodyClassName="cardBody"
|
|
89
|
+
nameClassName="cardTitle"
|
|
90
|
+
bioClassName="cardText"
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
54
98
|
## Quick Start
|
|
55
99
|
|
|
56
100
|
First, wrap your app with **BailayaProvider**:
|
|
@@ -69,8 +113,6 @@ export default function App() {
|
|
|
69
113
|
}
|
|
70
114
|
```
|
|
71
115
|
|
|
72
|
-
---
|
|
73
|
-
|
|
74
116
|
### Using a Hook
|
|
75
117
|
|
|
76
118
|
```tsx
|
|
@@ -96,8 +138,6 @@ export function TeamSection() {
|
|
|
96
138
|
}
|
|
97
139
|
```
|
|
98
140
|
|
|
99
|
-
---
|
|
100
|
-
|
|
101
141
|
### Using a Component
|
|
102
142
|
|
|
103
143
|
```tsx
|
|
@@ -107,10 +147,7 @@ import { StudioProfileCard } from "@bailaya/react";
|
|
|
107
147
|
export function Dashboard() {
|
|
108
148
|
return (
|
|
109
149
|
<div className="max-w-md mx-auto">
|
|
110
|
-
<StudioProfileCard
|
|
111
|
-
locale="en"
|
|
112
|
-
className="bg-white rounded-lg shadow p-6"
|
|
113
|
-
/>
|
|
150
|
+
<StudioProfileCard locale="en" />
|
|
114
151
|
</div>
|
|
115
152
|
);
|
|
116
153
|
}
|