@sanity/sdk-react 0.0.0-alpha.18 → 0.0.0-alpha.19
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 +7 -93
- package/dist/index.d.ts +4639 -0
- package/dist/index.js +952 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -27
- package/src/_exports/index.ts +57 -0
- package/src/components/Login/LoginLinks.test.tsx +1 -2
- package/src/components/auth/AuthBoundary.test.tsx +1 -1
- package/dist/_chunks-es/SanityInstanceContext.js +0 -6
- package/dist/_chunks-es/SanityInstanceContext.js.map +0 -1
- package/dist/_chunks-es/useLogOut.js +0 -73
- package/dist/_chunks-es/useLogOut.js.map +0 -1
- package/dist/components.d.ts +0 -154
- package/dist/components.js +0 -236
- package/dist/components.js.map +0 -1
- package/dist/context.d.ts +0 -47
- package/dist/context.js +0 -15
- package/dist/context.js.map +0 -1
- package/dist/hooks.d.ts +0 -4445
- package/dist/hooks.js +0 -660
- package/dist/hooks.js.map +0 -1
- package/src/_exports/components.ts +0 -3
- package/src/_exports/context.ts +0 -2
- package/src/_exports/hooks.ts +0 -52
package/README.md
CHANGED
|
@@ -45,110 +45,24 @@ npm run dev
|
|
|
45
45
|
4. Open the App in Sanity Dashboard with your organization ID
|
|
46
46
|
|
|
47
47
|
```
|
|
48
|
-
https://core.sanity.io/<your-organization-id>?dev=localhost:
|
|
48
|
+
https://core.sanity.io/<your-organization-id>?dev=http://localhost:3333
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
5.
|
|
51
|
+
5. Update the `src/App.tsx` file with your Sanity project and dataset
|
|
52
52
|
|
|
53
53
|
```tsx
|
|
54
54
|
// src/App.tsx
|
|
55
|
-
import {
|
|
56
|
-
|
|
57
|
-
import {useCurrentUser, useLogOut} from '@sanity/sdk-react/hooks'
|
|
58
|
-
|
|
59
|
-
import './App.css'
|
|
55
|
+
import {createSanityInstance} from '@sanity/sdk'
|
|
56
|
+
...
|
|
60
57
|
|
|
61
58
|
const sanityConfig: SanityConfigs = [
|
|
62
59
|
{
|
|
63
|
-
projectId: '
|
|
64
|
-
dataset: '
|
|
60
|
+
projectId: 'abc123',
|
|
61
|
+
dataset: 'production',
|
|
65
62
|
},
|
|
66
63
|
]
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<SanityApp sanityConfigs={sanityConfigs}>
|
|
71
|
-
<MyApp />
|
|
72
|
-
</SanityApp>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function MyApp() {
|
|
77
|
-
const currentUser = useCurrentUser()
|
|
78
|
-
const logout = useLogOut()
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div>
|
|
82
|
-
<h1>Hello, {currentUser?.name}!</h1>
|
|
83
|
-
<button onClick={logout}>Logout</button>
|
|
84
|
-
</div>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default App
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
6. Overwrite the `src/App.css` file with the following code:
|
|
92
|
-
|
|
93
|
-
```css
|
|
94
|
-
/* src/App.css */
|
|
95
|
-
#root {
|
|
96
|
-
margin: auto;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.sc-login-layout {
|
|
100
|
-
min-height: 100vh;
|
|
101
|
-
display: flex;
|
|
102
|
-
background: #f3f3f3;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.sc-login-layout__container {
|
|
106
|
-
margin: auto;
|
|
107
|
-
padding: 2rem;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.sc-login-layout__card {
|
|
111
|
-
background: white;
|
|
112
|
-
padding: 2rem;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.sc-login__title,
|
|
116
|
-
.sc-login-callback {
|
|
117
|
-
text-align: center;
|
|
118
|
-
margin-bottom: 2rem;
|
|
119
|
-
color: #333;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.sc-login-providers {
|
|
123
|
-
display: flex;
|
|
124
|
-
flex-direction: column;
|
|
125
|
-
gap: 1rem;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.sc-login-providers a {
|
|
129
|
-
padding: 0.8rem;
|
|
130
|
-
border: 1px solid #ddd;
|
|
131
|
-
text-decoration: none;
|
|
132
|
-
color: #333;
|
|
133
|
-
text-align: center;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.sc-login-footer {
|
|
137
|
-
margin-top: 2rem;
|
|
138
|
-
text-align: center;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.sc-login-footer__links {
|
|
142
|
-
list-style: none;
|
|
143
|
-
padding: 0;
|
|
144
|
-
display: flex;
|
|
145
|
-
justify-content: center;
|
|
146
|
-
gap: 1.5rem;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.sc-login-footer__link a {
|
|
150
|
-
font-size: 0.9rem;
|
|
151
|
-
}
|
|
65
|
+
...
|
|
152
66
|
```
|
|
153
67
|
|
|
154
68
|
## License
|