Skip to content

Commit c910748

Browse files
committed
chore: Merge changes from 'with/green-stack'
2 parents 0dd6d9c + c176bf9 commit c910748

File tree

106 files changed

+6803
-883
lines changed

Some content is hidden

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

106 files changed

+6803
-883
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ See [How to choose cross-platform tech](https://dev.to/codinsonn/why-use-react-n
4949
> "The best way to learn is through the Pull Requests"
5050
> -- Theo / @t3dotgg
5151
52-
[![Screenshot of list of Plugin Branches](https://github.com/user-attachments/assets/f2d4d836-c2ad-4249-bc53-de2ab7d5aac1)](https://github.com/Aetherspace/universal-app-router/pulls)
52+
[![Screenshot of list of Plugin Branches](https://github.com/user-attachments/assets/f2d4d836-c2ad-4249-bc53-de2ab7d5aac1)](https://github.com/FullProduct-dev/universal-app-router/pulls)
5353

5454
**PR & branch based plugins will provide you with the ability to:**
5555

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
'use client'
1+
"use client"
22
export { default, dynamic } from '@app/core/routes/demos/forms/index'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
'use client'
1+
"use client"
22
export { default } from '@app/core/routes/demos/images/index'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
'use client'
1+
"use client"
22
export { default } from '@app/core/routes/demos/markdown/index'

apps/next/app/(generated)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
'use client'
1+
"use client"
22
export { default } from '@app/core/routes/index'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
'use client'
1+
"use client"
22
export { default } from '@app/core/routes/subpages/[slug]/index'

apps/next/app/layout.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
/* @jsxImportSource react */
22
import NextServerRootLayout from './NextServerRootLayout'
3+
import { createMetadata } from '@app/utils/server/metadata'
4+
import { appConfig } from '@app/config'
5+
6+
/* --- Web Default Metadata -------------------------------------------------------------------- */
7+
8+
export const metadata = createMetadata({
9+
...(appConfig.baseURL ? { metadataBase: new URL(appConfig.baseURL) } : {}),
10+
title: appConfig.title || appConfig.appName,
11+
description: appConfig.description || appConfig.appDescription,
12+
openGraph: {
13+
title: appConfig.openGraph.title || appConfig.title || appConfig.appName,
14+
description: appConfig.openGraph.description || appConfig.description || appConfig.appDescription,
15+
url: appConfig.openGraph.url || appConfig.baseURL,
16+
siteName: appConfig.openGraph.siteName || appConfig.title || appConfig.appName,
17+
}
18+
})
19+
20+
/* --- Web Root Layout ------------------------------------------------------------------------- */
321

422
// -i- We render the server layout as a react server component first
523
// -i- This includes the document / html skeleton & styles for SSR

apps/next/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NextRequest, NextResponse } from 'next/server'
2-
import { createMiddlewareHeaderContext } from '@green-stack/utils/apiUtils'
2+
import { createMiddlewareContext } from '@green-stack/utils/apiUtils'
33
import type { RequestContext } from '@app/core/middleware/createRequestContext'
44

55
/* --- Middleware ------------------------------------------------------------------------------ */
@@ -30,7 +30,7 @@ export const middleware = async (req: NextRequest) => {
3030
// Execute the request handler (and pass the request context header)
3131
const res = NextResponse.next({
3232
request: {
33-
headers: await createMiddlewareHeaderContext(req, headerContext, extraHeaders),
33+
headers: await createMiddlewareContext(req, headerContext, extraHeaders),
3434
},
3535
})
3636

features/@app-core/appConfig.ts

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ export const isServer = isWeb && typeof window === 'undefined'
2323

2424
export const isExpoGo = Constants?.appOwnership === 'expo' || !!Constants?.expoVersion
2525

26+
export const isDocs = process.env.NEXT_PUBLIC_APP_ENV === 'docs'
2627
export const isExpo = isExpoGo || process.env.EXPO_PUBLIC_APP_ENV === 'expo'
27-
export const isNext = (!isExpo && isWeb) || process.env.NEXT_PUBLIC_APP_ENV === 'next'
28+
export const isNext = (!isExpo && isWeb) || process.env.NEXT_PUBLIC_APP_ENV === 'next' || isDocs
2829

2930
export const isWebLocalServer = isWeb && isServer && process.env.PORT === '3000'
3031
export const isWebLocalhost = isWeb && (globalThis?.location?.hostname === 'localhost' || isWebLocalServer)
@@ -61,7 +62,9 @@ export const isMobileSize = isServer ? undefined : Dimensions.get('window').widt
6162
/** --- appConfig ------------------------------------------------------------------------------ */
6263
/** -i- App config variables powered by env vars universally, and including some expo contants config on mobile */
6364
export const appConfig = {
64-
// - Flags -
65+
66+
// --- Flags ---
67+
6568
isProd,
6669
isDev,
6770
isWeb,
@@ -71,34 +74,61 @@ export const appConfig = {
7174
isServer,
7275
isExpo,
7376
isNext,
77+
isDocs,
7478
isLocal,
7579
isWebLocalhost,
7680
isNextLocal,
7781
isExpoGo,
7882
isExpoWebLocal,
7983
isExpoMobileLocal,
8084
isMobileSize,
81-
// - Server URLs -
85+
86+
// --- Server URLs ---
87+
8288
baseURL,
8389
backendURL,
8490
apiURL,
8591
graphURL,
86-
// - Secrets -
87-
// Don't use NEXT_PUBLIC_ / EXPO_PUBLIC_ prefixes here to make sure these are undefined client-side
92+
93+
// --- Secrets ---
94+
95+
// -!- Don't use NEXT_PUBLIC_ / EXPO_PUBLIC_ prefixes here to make sure these are undefined client-side
8896
appSecret: process.env.APP_SECRET,
89-
// - Drivers -
97+
98+
// --- Drivers ---
99+
90100
drivers: createDriverConfig({
91101
db: DRIVER_OPTIONS.db.mockDB,
92102
}),
93-
// - Constants -
103+
104+
// --- Web Default Metadata ---
105+
106+
// -i- Can be overwritten on each route using Next.js metadata exports (RSC only, so no "use client" routes)
107+
// -i- https://nextjs.org/docs/app/building-your-application/optimizing/metadata
108+
109+
title: 'My Universal App',
110+
description: 'TODO: Add description',
111+
openGraph: {
112+
title: 'My Universal App',
113+
description: 'TODO: Add description',
114+
url: baseURL,
115+
siteName: 'TODO: Set your site name',
116+
},
117+
118+
// --- Mobile Metadata ---
119+
94120
appName: Constants?.manifest2?.name || Constants?.manifest?.name,
95121
appVersion: Constants?.manifest2?.version || Constants?.manifest?.version,
96122
appDescription: Constants?.manifest2?.description || Constants?.manifest?.description,
97123
appIcon: Constants?.manifest2?.icon || Constants?.manifest?.icon,
98124
appSlug: Constants?.manifest2?.slug || Constants?.manifest?.slug,
99125
appScheme: Constants?.manifest2?.scheme || Constants?.manifest?.scheme,
100126
appHostUri: Constants?.expoConfig?.hostUri,
127+
128+
// --- Constants ---
129+
101130
debugMode: Constants?.debugMode,
131+
102132
} as const
103133

104134
/* --- Debug ----------------------------------------------------------------------------------- */
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### `children` vs `text` prop
2+
3+
You can pass either `props.children` or `props.text` to the Button component. If you pass `props.children`, it will render the children as the button content. This supports JSX and other React Components. Whereas `props.text` only supports actual text strings.
4+
5+
If you pass both, `props.children` will be used instead `props.text`.
6+
7+
### `style` prop
8+
9+
Instead of using just `className`, you can also pass a `style` prop. We will combine the styles from `className` and `style` props. This allows you to use inline styles for dynamic styling while still applying CSS classes.
10+
11+
If both classNames and `style` prop influence the same style, the `style` prop will take precedence.
12+
13+
### `onPress` event handlers
14+
15+
Just like react-native's Pressable, our `Button` component supports the `onPress` prop, alongside other event handlers:
16+
17+
- [`onPress()`](https://reactnative.dev/docs/pressable#onpress) - Called when a touch is released.
18+
- [`onPressIn()`](https://reactnative.dev/docs/pressable#onpressin) - Called when a touch is initiated.
19+
- [`onPressOut()`](https://reactnative.dev/docs/pressable#onpressout) - Called when a touch is released, after `onPressIn`.
20+
- [`onHoverIn()`](https://reactnative.dev/docs/pressable#onhoverin) - Called when the pointer enters the button area.
21+
- [`onHoverOut()`](https://reactnative.dev/docs/pressable#onhoverout) - Called when the pointer leaves the button area.
22+
- [`onLongPress()`](https://reactnative.dev/docs/pressable#onlongpress) - Called when a long press gesture is detected.
23+
- [`onBlur()`](https://reactnative.dev/docs/pressable#onblur) - Called when the button loses focus.
24+
- [`onFocus()`](https://reactnative.dev/docs/pressable#onfocus) - Called when the button gains focus.
25+
26+
Naturally, when `props.disabled` is `true`, all event handlers will be ignored.
27+
28+
If you pass both `href` and `onPress` props, we will try to execute both. Giving preference to the `onPress` handler first.

0 commit comments

Comments
 (0)