@youversion/platform-react-ui 0.4.1
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/LICENSE +201 -0
- package/README.md +346 -0
- package/dist/components/SignInButton.d.ts +101 -0
- package/dist/components/SignInButton.d.ts.map +1 -0
- package/dist/components/SignInButton.stories.d.ts +88 -0
- package/dist/components/SignInButton.stories.d.ts.map +1 -0
- package/dist/components/bible-app-logo-lockup.d.ts +4 -0
- package/dist/components/bible-app-logo-lockup.d.ts.map +1 -0
- package/dist/components/bible-chapter-picker.d.ts +23 -0
- package/dist/components/bible-chapter-picker.d.ts.map +1 -0
- package/dist/components/bible-chapter-picker.stories.d.ts +50 -0
- package/dist/components/bible-chapter-picker.stories.d.ts.map +1 -0
- package/dist/components/bible-version-picker.d.ts +20 -0
- package/dist/components/bible-version-picker.d.ts.map +1 -0
- package/dist/components/bible-version-picker.stories.d.ts +36 -0
- package/dist/components/bible-version-picker.stories.d.ts.map +1 -0
- package/dist/components/bible-widget-view.d.ts +8 -0
- package/dist/components/bible-widget-view.d.ts.map +1 -0
- package/dist/components/bible-widget-view.stories.d.ts +26 -0
- package/dist/components/bible-widget-view.stories.d.ts.map +1 -0
- package/dist/components/icons/share.d.ts +4 -0
- package/dist/components/icons/share.d.ts.map +1 -0
- package/dist/components/icons/votd.d.ts +4 -0
- package/dist/components/icons/votd.d.ts.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/ui/accordion.d.ts +8 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/button-group.d.ts +12 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/item.d.ts +24 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/verse-of-the-day.d.ts +50 -0
- package/dist/components/verse-of-the-day.d.ts.map +1 -0
- package/dist/components/verse-of-the-day.stories.d.ts +50 -0
- package/dist/components/verse-of-the-day.stories.d.ts.map +1 -0
- package/dist/components/verse.d.ts +55 -0
- package/dist/components/verse.d.ts.map +1 -0
- package/dist/components/verse.stories.d.ts +40 -0
- package/dist/components/verse.stories.d.ts.map +1 -0
- package/dist/components/verse.test.d.ts +2 -0
- package/dist/components/verse.test.d.ts.map +1 -0
- package/dist/components/youversion-logo.d.ts +4 -0
- package/dist/components/youversion-logo.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAuthentication.d.ts +8 -0
- package/dist/hooks/useAuthentication.d.ts.map +1 -0
- package/dist/index.cjs +15124 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15084 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/providers/YVPErrorBoundary.d.ts +17 -0
- package/dist/providers/YVPErrorBoundary.d.ts.map +1 -0
- package/dist/providers/YVPErrorBoundary.test.d.ts +2 -0
- package/dist/providers/YVPErrorBoundary.test.d.ts.map +1 -0
- package/dist/providers/YVPProvider.d.ts +20 -0
- package/dist/providers/YVPProvider.d.ts.map +1 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/tailwind.css +2 -0
- package/dist/test/StorybookEnvCheck.d.ts +7 -0
- package/dist/test/StorybookEnvCheck.d.ts.map +1 -0
- package/dist/test/setup.d.ts +2 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +120 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# @youversion/platform-react-ui
|
|
2
|
+
|
|
3
|
+
React SDK for YouVersion Platform (web).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @youversion/platform-react-ui
|
|
9
|
+
# or
|
|
10
|
+
npm install @youversion/platform-react-ui
|
|
11
|
+
# or
|
|
12
|
+
yarn add @youversion/platform-react-ui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### Import the styles
|
|
18
|
+
|
|
19
|
+
For the components to be styled, import the CSS once at the app’s global entry.
|
|
20
|
+
|
|
21
|
+
- Next.js App Router: import in your app root (for example, [examples/nextjs/src/app/layout.tsx](examples/nextjs/src/app/layout.tsx:1))
|
|
22
|
+
```ts
|
|
23
|
+
// app/layout.tsx
|
|
24
|
+
import '@youversion/platform-react-ui/styles.css';
|
|
25
|
+
```
|
|
26
|
+
- Vite/SPA: import it once in your main entry file (e.g., main.tsx) or a global stylesheet that is imported there:
|
|
27
|
+
```ts
|
|
28
|
+
// main.tsx
|
|
29
|
+
import '@youversion/platform-react-ui/styles.css';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Add the Providers
|
|
33
|
+
|
|
34
|
+
Wrap your app with the required providers. YVPProvider handles authentication, while BibleSDKProvider enables Bible-related components like BibleTextView.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { BibleSDKProvider, YVPProvider } from '@youversion/platform-react-ui';
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<BibleSDKProvider appId="your-app-id">
|
|
42
|
+
<YVPProvider config={{ appId: 'your-app-id'}}>
|
|
43
|
+
<YourApp />
|
|
44
|
+
</YVPProvider>
|
|
45
|
+
</BibleSDKProvider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Theming
|
|
51
|
+
|
|
52
|
+
The React SDK’s theme is fully scoped to its own wrapper to avoid conflicts with host apps and ShadCN UI variables.
|
|
53
|
+
|
|
54
|
+
- Dark and light modes are controlled via the theme prop on [YVPProvider()](packages/ui/src/providers/YVPProvider.tsx:32)
|
|
55
|
+
- CSS variables are defined under the SDK wrapper only, preventing collisions with app-level variables
|
|
56
|
+
|
|
57
|
+
Basic usage (set dark or light):
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { BibleSDKProvider, YVPProvider } from '@youversion/platform-react-ui';
|
|
61
|
+
import '@youversion/platform-react-ui/styles.css';
|
|
62
|
+
|
|
63
|
+
export default function App() {
|
|
64
|
+
return (
|
|
65
|
+
<BibleSDKProvider appId="YOUR_APP_ID">
|
|
66
|
+
<YVPProvider
|
|
67
|
+
config={{ appId: 'YOUR_APP_ID'}}
|
|
68
|
+
theme="dark" // 'light' | 'dark' (default is 'light')
|
|
69
|
+
>
|
|
70
|
+
<YourApp />
|
|
71
|
+
</YVPProvider>
|
|
72
|
+
</BibleSDKProvider>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Toggle theme at runtime:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { useState } from 'react';
|
|
81
|
+
import { BibleSDKProvider, YVPProvider } from '@youversion/platform-react-ui';
|
|
82
|
+
import '@youversion/platform-react-ui/styles.css';
|
|
83
|
+
|
|
84
|
+
export default function App() {
|
|
85
|
+
const [theme, setTheme] = useState<'light' | 'dark'>('light');
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<BibleSDKProvider appId="YOUR_APP_ID">
|
|
89
|
+
<YVPProvider
|
|
90
|
+
config={{ appId: 'YOUR_APP_ID' }}
|
|
91
|
+
theme={theme}
|
|
92
|
+
>
|
|
93
|
+
<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
|
|
94
|
+
Toggle theme
|
|
95
|
+
</button>
|
|
96
|
+
<YourApp />
|
|
97
|
+
</YVPProvider>
|
|
98
|
+
</BibleSDKProvider>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Customizing Styles
|
|
104
|
+
|
|
105
|
+
The React SDK uses scoped CSS variables prefixed with `--yv-` to avoid conflicts with your app's styles. You can override these variables to customize colors, fonts, and Bible reader appearance.
|
|
106
|
+
|
|
107
|
+
### Overriding CSS Variables
|
|
108
|
+
|
|
109
|
+
Add custom styles after importing `@youversion/platform-react-ui/styles.css`:
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
[data-yv-sdk] {
|
|
113
|
+
/* Override theme colors */
|
|
114
|
+
--yv-primary: #your-color;
|
|
115
|
+
--yv-background: #your-bg-color;
|
|
116
|
+
|
|
117
|
+
/* Override Bible reader styles */
|
|
118
|
+
--yv-reader-font-size: 18px;
|
|
119
|
+
--yv-reader-line-height: 1.5;
|
|
120
|
+
--yv-reader-font-family: 'Your Font', serif;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Key Customizable Variables
|
|
125
|
+
|
|
126
|
+
#### Theme Colors
|
|
127
|
+
- `--yv-background`, `--yv-foreground`: Main background and text colors
|
|
128
|
+
- `--yv-primary`, `--yv-primary-foreground`: Primary button colors
|
|
129
|
+
- `--yv-secondary`, `--yv-secondary-foreground`: Secondary colors
|
|
130
|
+
- `--yv-muted`, `--yv-muted-foreground`: Muted text colors
|
|
131
|
+
- `--yv-accent`, `--yv-accent-foreground`: Accent colors
|
|
132
|
+
- `--yv-destructive`, `--yv-destructive-foreground`: Error/destructive colors
|
|
133
|
+
|
|
134
|
+
#### Bible Reader
|
|
135
|
+
- `--yv-reader-font-family`: Font stack for Bible text (defaults to Inter and Source Serif Pro)
|
|
136
|
+
- `--yv-reader-font-size`: Font size for verses (default: 20px)
|
|
137
|
+
- `--yv-reader-line-height`: Line height for verses (default: 1.625)
|
|
138
|
+
- `--yv-red`, `--yv-red-dark-mode`: Color for words of Jesus
|
|
139
|
+
|
|
140
|
+
#### Color Palettes
|
|
141
|
+
The SDK includes predefined palettes (teal, blue, purple, etc.) that can be overridden or used in your components via Tailwind classes like `yv:text-teal-30`.
|
|
142
|
+
|
|
143
|
+
## Components
|
|
144
|
+
|
|
145
|
+
### SignInButton
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { SignInButton } from '@youversion/platform-react-ui';
|
|
149
|
+
|
|
150
|
+
export default function Page() {
|
|
151
|
+
return (
|
|
152
|
+
<main className="flex flex-col items-center gap-4">
|
|
153
|
+
<SignInButton />
|
|
154
|
+
</main>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Verse
|
|
160
|
+
|
|
161
|
+
The Verse component provides sub-components for rendering Bible verses.
|
|
162
|
+
|
|
163
|
+
#### Verse.Text
|
|
164
|
+
|
|
165
|
+
Renders a single verse with superscript number and text.
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { Verse } from '@youversion/platform-react-ui';
|
|
169
|
+
|
|
170
|
+
export default function Page() {
|
|
171
|
+
return (
|
|
172
|
+
<Verse.Text number={16} text="For God so loved the world..." size="lg" />
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Props:
|
|
178
|
+
- `number`: The verse number.
|
|
179
|
+
- `text`: The verse text.
|
|
180
|
+
- `size`: Optional size variant ('default' | 'lg', default: 'default').
|
|
181
|
+
|
|
182
|
+
#### Verse.Html
|
|
183
|
+
|
|
184
|
+
Renders HTML content for Bible verses with optional styling.
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { Verse } from '@youversion/platform-react-ui';
|
|
188
|
+
|
|
189
|
+
export default function Page() {
|
|
190
|
+
return (
|
|
191
|
+
<Verse.Html html="<p>Verse content</p>" fontFamily="serif" fontSize={20} lineHeight={1.5} />
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Props:
|
|
197
|
+
- `html`: The HTML content of the verse(s).
|
|
198
|
+
- `fontFamily`: Optional font family for the text.
|
|
199
|
+
- `fontSize`: Optional font size in pixels.
|
|
200
|
+
- `lineHeight`: Optional line height.
|
|
201
|
+
|
|
202
|
+
### BibleTextView
|
|
203
|
+
|
|
204
|
+
Renders Bible verses or passages from the YouVersion API. Requires the app to be wrapped with `BibleSDKProvider`.
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
import { BibleTextView } from '@youversion/platform-react-ui';
|
|
208
|
+
|
|
209
|
+
export default function Page() {
|
|
210
|
+
return (
|
|
211
|
+
<BibleTextView
|
|
212
|
+
reference="JHN.3.16"
|
|
213
|
+
versionId={1}
|
|
214
|
+
fontFamily="serif"
|
|
215
|
+
fontSize={20}
|
|
216
|
+
lineHeight={1.5}
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Props:
|
|
223
|
+
- `reference`: The Bible reference (e.g., "JHN.3.16" for John 3:16).
|
|
224
|
+
- `versionId`: The Bible version ID (e.g., 1 for KJV).
|
|
225
|
+
- `fontFamily`: Optional font family for the text.
|
|
226
|
+
- `fontSize`: Optional font size in pixels.
|
|
227
|
+
- `lineHeight`: Optional line height.
|
|
228
|
+
|
|
229
|
+
## Hooks
|
|
230
|
+
|
|
231
|
+
### useAuthentication
|
|
232
|
+
|
|
233
|
+
Provides the auth state and actions (sign in/out, fetch profile). See implementation in [/src/hooks/useAuthentication.ts](./src/hooks/useAuthentication.ts).
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
import { useAuthentication } from '@youversion/platform-react-ui';
|
|
237
|
+
|
|
238
|
+
export function AuthControls() {
|
|
239
|
+
const { isAuthenticated, isLoading, signIn, signOut, fetchUserInfo } = useAuthentication();
|
|
240
|
+
|
|
241
|
+
if (isLoading) return <p>Loading…</p>;
|
|
242
|
+
|
|
243
|
+
return isAuthenticated ? (
|
|
244
|
+
<div className="flex items-center gap-2">
|
|
245
|
+
<button onClick={() => fetchUserInfo()} className="rounded-md px-4 py-2 bg-secondary text-secondary-foreground">
|
|
246
|
+
Fetch profile
|
|
247
|
+
</button>
|
|
248
|
+
<button onClick={() => signOut()} className="rounded-md px-4 py-2 bg-destructive text-white">
|
|
249
|
+
Sign out
|
|
250
|
+
</button>
|
|
251
|
+
</div>
|
|
252
|
+
) : (
|
|
253
|
+
<button onClick={() => signIn()} className="rounded-md px-4 py-2 bg-primary text-primary-foreground">
|
|
254
|
+
Sign in with YouVersion
|
|
255
|
+
</button>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
### Project Structure
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
packages/ui/
|
|
267
|
+
├── .storybook/ # Storybook configuration
|
|
268
|
+
├── src/
|
|
269
|
+
│ ├── components/ # UI components (SignInButton, etc.)
|
|
270
|
+
│ ├── hooks/ # React hooks (useAuthentication)
|
|
271
|
+
│ ├── lib/ # Utility functions
|
|
272
|
+
│ ├── providers/ # YVPProvider and context
|
|
273
|
+
│ ├── styles/ # Global styles and CSS
|
|
274
|
+
│ └── test/ # Test utilities
|
|
275
|
+
├── scripts/ # Build scripts
|
|
276
|
+
├── chromatic.config.json # Chromatic visual regression config
|
|
277
|
+
└── package.json
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Storybook
|
|
281
|
+
|
|
282
|
+
Storybook is used for component development and documentation.
|
|
283
|
+
|
|
284
|
+
**Environment Setup:**
|
|
285
|
+
|
|
286
|
+
Copy the `.env.example` file into a `.env.local` file in `packages/ui/` with the following environment variables for Storybook to work properly:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Required for Storybook components that interact with YouVersion API
|
|
290
|
+
STORYBOOK_YOUVERSION_APP_ID="your-app-id"
|
|
291
|
+
|
|
292
|
+
# Optional: Required for Chromatic visual regression testing
|
|
293
|
+
CHROMATIC_PROJECT_TOKEN="your-chromatic-token"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Start Storybook:**
|
|
297
|
+
```bash
|
|
298
|
+
pnpm storybook
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Build Storybook:**
|
|
302
|
+
```bash
|
|
303
|
+
pnpm build-storybook
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Visual Testing with Chromatic
|
|
307
|
+
|
|
308
|
+
Chromatic provides visual regression testing for Storybook components.
|
|
309
|
+
|
|
310
|
+
**Run Chromatic:**
|
|
311
|
+
```bash
|
|
312
|
+
pnpm chromatic
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
This command:
|
|
316
|
+
- Uses `dotenv` to load `.env.local`
|
|
317
|
+
- Requires `CHROMATIC_PROJECT_TOKEN` in `.env.local` (see Storybook section above)
|
|
318
|
+
- Runs visual regression tests on component stories
|
|
319
|
+
- Only tests changed components (see [chromatic.config.json](chromatic.config.json))
|
|
320
|
+
|
|
321
|
+
### Commands
|
|
322
|
+
|
|
323
|
+
See [package.json](package.json) for all available scripts:
|
|
324
|
+
- `pnpm build` - Build all outputs (CSS, JS, types)
|
|
325
|
+
- `pnpm dev` - Watch mode for development
|
|
326
|
+
- `pnpm test` - Run Vitest tests
|
|
327
|
+
- `pnpm test:watch` - Run tests in watch mode
|
|
328
|
+
- `pnpm typecheck` - Type check without emitting
|
|
329
|
+
- `pnpm lint` - Run ESLint
|
|
330
|
+
|
|
331
|
+
## Troubleshooting
|
|
332
|
+
|
|
333
|
+
- Styles not applied:
|
|
334
|
+
- Ensure you imported `@youversion/platform-react-ui/styles.css` at your app's global entry (e.g., [examples/nextjs/src/app/layout.tsx](../../examples/nextjs/src/app/layout.tsx)).
|
|
335
|
+
- Do not import the CSS from inside component modules.
|
|
336
|
+
- Next.js error “Global CSS cannot be imported from within node_modules”:
|
|
337
|
+
- Move the import to your root layout (App Router)
|
|
338
|
+
- Storybook components not working:
|
|
339
|
+
- Ensure `STORYBOOK_YOUVERSION_APP_ID` is set in `.env.local`
|
|
340
|
+
- Components will use fallback demo values if environment variables are not set
|
|
341
|
+
- Chromatic not running:
|
|
342
|
+
- Ensure `CHROMATIC_PROJECT_TOKEN` is set in `.env.local`
|
|
343
|
+
|
|
344
|
+
## License
|
|
345
|
+
|
|
346
|
+
License is TBD.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SignInWithYouVersionPermissionValues, type SignInWithYouVersionResult } from '@youversion/platform-core';
|
|
3
|
+
interface SignInAuthProps {
|
|
4
|
+
/**
|
|
5
|
+
* Called when the sign-in flow fails.
|
|
6
|
+
* @param error - The error thrown by the sign-in flow.
|
|
7
|
+
*/
|
|
8
|
+
onAuthError?: (error: Error) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Called when the sign-in flow succeeds.
|
|
11
|
+
* @param result - The result of the sign-in flow.
|
|
12
|
+
*/
|
|
13
|
+
onSuccess?: (result: SignInWithYouVersionResult) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Permissions that are requested but not required for sign-in to succeed.
|
|
16
|
+
*/
|
|
17
|
+
optionalPermissions?: SignInWithYouVersionPermissionValues[];
|
|
18
|
+
/**
|
|
19
|
+
* Permissions that must be granted for sign-in to succeed.
|
|
20
|
+
*/
|
|
21
|
+
requiredPermissions?: SignInWithYouVersionPermissionValues[];
|
|
22
|
+
}
|
|
23
|
+
export interface SignInButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, SignInAuthProps {
|
|
24
|
+
/**
|
|
25
|
+
* The background color of the button.
|
|
26
|
+
*
|
|
27
|
+
* This is not correlated with the theme of the device (i.e. dark mode or light mode)
|
|
28
|
+
*/
|
|
29
|
+
background?: 'light' | 'dark';
|
|
30
|
+
/**
|
|
31
|
+
* The radius of the button.
|
|
32
|
+
*
|
|
33
|
+
* - `rounded` - The button has rounded corners.
|
|
34
|
+
* - `rectangular` - The button has rectangular corners.
|
|
35
|
+
*/
|
|
36
|
+
radius?: 'rounded' | 'rectangular';
|
|
37
|
+
/**
|
|
38
|
+
* The size of the button.
|
|
39
|
+
*
|
|
40
|
+
* - `default` - The default button size.
|
|
41
|
+
* - `short` - A shorter button size.
|
|
42
|
+
* - `icon` - A button size for icons.
|
|
43
|
+
*/
|
|
44
|
+
size?: 'default' | 'short' | 'icon';
|
|
45
|
+
/**
|
|
46
|
+
* The variant of the button.
|
|
47
|
+
*
|
|
48
|
+
* - `default` - Button without contrast border.
|
|
49
|
+
* - `outline` - Button with contrast border.
|
|
50
|
+
*/
|
|
51
|
+
variant?: 'default' | 'outline';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* SignInButton - Initiates the YouVersion OAuth sign-in flow on click.
|
|
55
|
+
*
|
|
56
|
+
* Key behaviors:
|
|
57
|
+
* - Prevents default click behavior and triggers the SDK `signIn` method.
|
|
58
|
+
* - Calls `onSuccess` with the SignInWithYouVersionResult when sign-in succeeds.
|
|
59
|
+
* - Calls `onAuthError` when the underlying sign-in flow throws.
|
|
60
|
+
*
|
|
61
|
+
* @param {SignInButtonProps} props - Component props (see {@link SignInButtonProps}).
|
|
62
|
+
* @returns {React.ReactElement} A button element that starts the sign-in flow.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* import { SignInButton, SignInWithYouVersionPermission } from '@youversion/platform-react-ui';
|
|
66
|
+
* import { useAuthentication } from '@youversion/platform-react-ui';
|
|
67
|
+
*
|
|
68
|
+
* export default function UnauthenticatedView() {
|
|
69
|
+
* const auth = useAuthentication();
|
|
70
|
+
*
|
|
71
|
+
* return (
|
|
72
|
+
* <div>
|
|
73
|
+
* {auth.error && <p className="text-red-600">Error: {auth.error.message}</p>}
|
|
74
|
+
* <SignInButton
|
|
75
|
+
* requiredPermissions={[SignInWithYouVersionPermission.bibles]}
|
|
76
|
+
* optionalPermissions={[SignInWithYouVersionPermission.highlights]}
|
|
77
|
+
* onSuccess={(result) => console.log('signed in', result)}
|
|
78
|
+
* onAuthError={(err) => console.error(err)}
|
|
79
|
+
* />
|
|
80
|
+
* </div>
|
|
81
|
+
* );
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // Example: different button styles shown in the example app
|
|
86
|
+
* <SignInButton /> // default light background, labeled
|
|
87
|
+
* <SignInButton size="short" variant="outline" /> // shorter label with outline
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Example showing permission enum usage from the example app
|
|
91
|
+
* import { SignInWithYouVersionPermission } from '@youversion/platform-react-ui';
|
|
92
|
+
*
|
|
93
|
+
* <SignInButton
|
|
94
|
+
* requiredPermissions={[SignInWithYouVersionPermission.bibles]}
|
|
95
|
+
* optionalPermissions={[SignInWithYouVersionPermission.highlights]}
|
|
96
|
+
* />
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
export declare const SignInButton: React.ForwardRefExoticComponent<SignInButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=SignInButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignInButton.d.ts","sourceRoot":"","sources":["../../src/components/SignInButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,oCAAoC,EACzC,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AAMnC,UAAU,eAAe;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,mBAAmB,CAAC,EAAE,oCAAoC,EAAE,CAAC;IAC7D;;OAEG;IACH,mBAAmB,CAAC,EAAE,oCAAoC,EAAE,CAAC;CAC9D;AAED,MAAM,WAAW,iBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,eAAe;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,YAAY,6FAwHxB,CAAC"}
|