Skip to content

Commit cb3399d

Browse files
authored
Update SDK and component reference layout (stack-auth#338)
1 parent 33002bc commit cb3399d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4443
-2422
lines changed

docs/fern/custom-script.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,60 @@
1-
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId setPersonProperties".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]); posthog.init('phc_vIUFi0HzHo7oV26OsaZbUASqxvs8qOmap1UBYAutU4k',{api_host: "https://stack-auth.com/consume", ui_host: 'https://eu.posthog.com', person_profiles: 'identified_only' })
1+
function initPostHog() {
2+
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId setPersonProperties".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]); posthog.init('phc_vIUFi0HzHo7oV26OsaZbUASqxvs8qOmap1UBYAutU4k',{api_host: "https://stack-auth.com/consume", ui_host: 'https://eu.posthog.com', person_profiles: 'identified_only' })
3+
}
4+
5+
function replaceStackLinkTo() {
6+
const codeBlocks = document.querySelectorAll(`code.code-block`);
7+
for (const codeBlock of codeBlocks) {
8+
const codeBlockSpans = codeBlock.querySelectorAll(`.line > span:last-child:not(.stack-replaced-link-to)`);
9+
for (const codeSpan of codeBlockSpans) {
10+
codeSpan.classList.add("stack-replaced-link-to");
11+
if (codeSpan.textContent.trim().startsWith("//$stack-link-to:")) {
12+
const href = codeSpan.textContent.trim().slice(17);
13+
const tr = codeSpan.closest(`tr`);
14+
tr.classList.add(`stack-clickable-row`);
15+
if (href.startsWith("#") && window.location.href.includes("localhost")) {
16+
if (!document.getElementById(href.slice(1))) {
17+
tr.classList.add(`stack-clickable-row-missing`);
18+
}
19+
}
20+
tr.addEventListener(`click`, () => {
21+
window.location.href = href;
22+
});
23+
codeSpan.remove();
24+
}
25+
}
26+
}
27+
}
28+
29+
function replaceEmptyTabs() {
30+
const tabs = document.querySelectorAll(`.small-codeblock-tabs button:not(.stack-replaced-empty-tab)`);
31+
for (const tab of tabs) {
32+
tab.classList.add(`stack-replaced-empty-tab`);
33+
if (tab.textContent.trim() === "<<empty>>") {
34+
tab.remove();
35+
}
36+
}
37+
}
38+
39+
function runRenderActions() {
40+
try {
41+
replaceStackLinkTo();
42+
replaceEmptyTabs();
43+
requestAnimationFrame(runRenderActions);
44+
} catch (e) {
45+
console.error(e);
46+
alert(`Error during custom script while running render actions. This message will only be shown on localhost.\n\n${e} ${e.message} ${e.stack}`);
47+
}
48+
}
49+
50+
async function main() {
51+
initPostHog();
52+
runRenderActions();
53+
}
54+
55+
main().catch((e) => {
56+
console.error(e);
57+
if (window.location.href.includes("localhost")) {
58+
alert(`Error during custom script. This message will only be shown on localhost.\n\n${e} ${e.message} ${e.stack}`);
59+
}
60+
});

docs/fern/docs.yml

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,67 +112,97 @@ navigation:
112112
path: ./docs/pages/others/self-host.mdx
113113
- tab: components
114114
layout:
115+
- page: All Components
116+
icon: fa-regular fa-globe
117+
path: ./docs/pages/components/overview.mdx
115118
- section: Components
116119
contents:
117120
- page: <UserButton />
121+
icon: fa-solid fa-square-code
118122
path: ./docs/pages/components/user-button.mdx
119123
- page: <SelectedTeamSwitcher />
124+
icon: fa-solid fa-square-code
120125
path: ./docs/pages/components/selected-team-switcher.mdx
121126
- page: <AccountSettings />
127+
icon: fa-solid fa-square-code
122128
path: ./docs/pages/components/account-settings.mdx
123129
- page: <SignIn />
130+
icon: fa-solid fa-square-code
124131
path: ./docs/pages/components/sign-in.mdx
125132
- page: <SignUp />
133+
icon: fa-solid fa-square-code
126134
path: ./docs/pages/components/sign-up.mdx
127135
- page: <CredentialSignIn />
136+
icon: fa-solid fa-square-code
128137
path: ./docs/pages/components/credential-sign-in.mdx
129138
- page: <CredentialSignUp />
139+
icon: fa-solid fa-square-code
130140
path: ./docs/pages/components/credential-sign-up.mdx
131141
- page: <OAuthButton />
142+
icon: fa-solid fa-square-code
132143
path: ./docs/pages/components/oauth-button.mdx
133144
- page: <OAuthButtonGroup />
145+
icon: fa-solid fa-square-code
134146
path: ./docs/pages/components/oauth-button-group.mdx
135147
- section: Utilities
136148
contents:
137149
- page: <StackHandler />
150+
icon: fa-solid fa-square-u
138151
path: ./docs/pages/components/stack-handler.mdx
139152
- page: <StackProvider />
153+
icon: fa-solid fa-square-u
140154
path: ./docs/pages/components/stack-provider.mdx
141155
- page: <StackTheme />
156+
icon: fa-solid fa-square-u
142157
path: ./docs/pages/components/stack-theme.mdx
143158
- tab: sdk
144159
layout:
145-
- section: Classes
160+
- page: SDK Overview
161+
icon: fa-regular fa-globe
162+
path: ./docs/pages/sdk/overview.mdx
163+
- section: Objects
146164
contents:
147-
- page: User
148-
path: ./docs/pages/sdk/user.mdx
149165
- page: StackApp
150-
path: ./docs/pages/sdk/stack-app.mdx
166+
icon: fa-duotone fa-square-t
167+
path: ./docs/pages/sdk/objects/stack-app.mdx
168+
- section: Types
169+
contents:
170+
- page: ContactChannel
171+
icon: fa-duotone fa-square-t
172+
path: ./docs/pages/sdk/types/contact-channel.mdx
173+
- page: Project
174+
icon: fa-duotone fa-square-t
175+
path: ./docs/pages/sdk/types/project.mdx
151176
- page: Team
152-
path: ./docs/pages/sdk/team.mdx
153-
- page: TeamUser
154-
path: ./docs/pages/sdk/team-user.mdx
155-
- page: TeamProfile
156-
path: ./docs/pages/sdk/team-profile.mdx
177+
icon: fa-duotone fa-square-t
178+
path: ./docs/pages/sdk/types/team.mdx
157179
- page: TeamPermission
158-
path: ./docs/pages/sdk/team-permission.mdx
159-
- page: Project
160-
path: ./docs/pages/sdk/project.mdx
161-
- page: ContactChannel
162-
path: ./docs/pages/sdk/contact-channel.mdx
180+
icon: fa-duotone fa-square-t
181+
path: ./docs/pages/sdk/types/team-permission.mdx
182+
- page: TeamProfile
183+
icon: fa-duotone fa-square-t
184+
path: ./docs/pages/sdk/types/team-profile.mdx
185+
- page: TeamUser
186+
icon: fa-duotone fa-square-t
187+
path: ./docs/pages/sdk/types/team-user.mdx
188+
- page: User
189+
icon: fa-duotone fa-square-t
190+
path: ./docs/pages/sdk/types/user.mdx
163191
# - page: ConnectedAccount
164-
# path: ./docs/pages/sdk/connected-account.mdx
192+
# path: ./docs/pages/sdk/types/connected-account.mdx
165193
- section: Hooks
166194
contents:
167-
- page: useUser()
168-
path: ./docs/pages/sdk/use-user.mdx
169195
- page: useStackApp()
170-
path: ./docs/pages/sdk/use-stack-app.mdx
196+
icon: fa-duotone fa-square-h
197+
path: ./docs/pages/sdk/hooks/use-stack-app.mdx
198+
- page: useUser()
199+
icon: fa-duotone fa-square-h
200+
path: ./docs/pages/sdk/hooks/use-user.mdx
171201
- tab: api
172202
layout:
173203
- page: API Overview
174204
icon: fa-regular fa-globe
175-
path: ./docs/pages/rest-api/auth.mdx
205+
path: ./docs/pages/rest-api/overview.mdx
176206
- api: Client API
177207
slug: client
178208
api-name: client

docs/fern/docs/pages/components/account-settings.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ slug: components/account-settings
44

55
Renders an account settings page with customizable sidebar items and optional full-page layout.
66

7+
<div className="stack-white-image-showcase">
8+
<img src="../imgs/account-settings.png" alt="AccountSettings" />
9+
</div>
10+
711
## Props
812

913
- `fullPage` (optional): `boolean` - If true, renders the component in full-page mode.
@@ -31,4 +35,4 @@ export default function MyAccountPage() {
3135
/>
3236
);
3337
}
34-
```
38+
```

docs/fern/docs/pages/components/credential-sign-in.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ slug: components/credential-sign-in
44

55
A component that renders a sign-in form with email and password fields.
66

7-
![CredentialSignIn](../imgs/credential-sign-in.png)
7+
<div className="stack-white-image-showcase">
8+
<img src="../imgs/credential-sign-in.png" alt="CredentialSignIn" height={233} />
9+
</div>
810

911
Note that if credential sign-in is disabled in the dashboard, this component will still render. However, attempting to use it will result in an error being thrown.
1012

@@ -27,4 +29,4 @@ export default function Page() {
2729
</div>
2830
);
2931
}
30-
```
32+
```

docs/fern/docs/pages/components/credential-sign-up.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ slug: components/credential-sign-up
44

55
A component that renders a sign-up form with email and password fields.
66

7-
![CredentialSignUp](../imgs/credential-sign-up.png)
7+
<div className="stack-white-image-showcase">
8+
<img src="../imgs/credential-sign-up.png" alt="CredentialSignUp" height={233} />
9+
</div>
810

911
Note that if credential sign-up is disabled in the dashboard, this component will still render. However, attempting to use it will result in an error being thrown.
1012

@@ -27,4 +29,4 @@ export default function Page() {
2729
</div>
2830
);
2931
}
30-
```
32+
```

docs/fern/docs/pages/components/oauth-button-group.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
slug: components/oauth-button-group
33
---
44

5-
Renders all the available OAuth buttons for sign-in or sign-up functionality.
5+
Renders all the OAuth buttons enabled on the project dashboard.
66

7-
![OAuthButtonGroup](../imgs/oauth-button-group.png)
7+
<div className="stack-white-image-showcase">
8+
<img src="../imgs/oauth-button-group.png" alt="OAuthButtonGroup" height={240} />
9+
</div>
810

9-
Note that if there are no OAuth providers enabled in the dashboard, this component will be empty.
11+
<Callout>
12+
If there are no OAuth providers enabled in the dashboard, this component will be empty.
13+
</Callout>
1014

1115
## Props
1216

@@ -26,4 +30,4 @@ export default function Page() {
2630
);
2731
}
2832

29-
```
33+
```

docs/fern/docs/pages/components/oauth-button.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ slug: components/oauth-button
44

55
Renders a customized OAuth button for various providers to initiate sign-in or sign-up processes.
66

7-
![OAuthButton](../imgs/oauth-button.png)
7+
<div className="stack-white-image-showcase">
8+
<img src="../imgs/oauth-button.png" alt="OAuthButton" height={60} />
9+
</div>
810

911
Note that if the specific OAuth provider is disabled in the dashboard, this component will still render. However, attempting to use it will result in an error being thrown.
1012

@@ -32,4 +34,4 @@ export default function Page() {
3234

3335
```
3436

35-
The `OAuthButton` component automatically styles itself based on the provided OAuth provider and handles the sign-in or sign-up process when clicked.
37+
The `OAuthButton` component automatically styles itself based on the provided OAuth provider and handles the sign-in or sign-up process when clicked.

0 commit comments

Comments
 (0)