Skip to content

Commit 3fb34de

Browse files
committed
feat: Add useFormState() hook to @green-stack/core
1 parent ed0cae4 commit 3fb34de

File tree

17 files changed

+964
-50
lines changed

17 files changed

+964
-50
lines changed

apps/next/next.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { withExpo } = require("@expo/next-adapter");
22

33
/** @type {import('next').NextConfig} */
4-
const nextConfig = withExpo({
4+
const mainNextConfig = {
55
reactStrictMode: true,
66
swcMinify: true,
77
transpilePackages: [
@@ -25,6 +25,11 @@ const nextConfig = withExpo({
2525
}
2626
]
2727
}
28-
});
28+
}
29+
30+
/** @type {import('next').NextConfig} */
31+
const nextConfig = withExpo(mainNextConfig);
2932

3033
module.exports = nextConfig;
34+
35+
module.exports.mainNextConfig = mainNextConfig;
Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from 'react'
2-
import { View, Text, Link } from '../components/styled'
2+
import { View, Text, Link, Pressable } from '../components/styled'
33
import { useRouter } from '@green-stack/navigation/useRouter'
44
import { ArrowLeftFilled } from '../icons/ArrowLeftFilled'
55
import { schema, z } from '@green-stack/schemas'
66

77
/* --- Props ----------------------------------------------------------------------------------- */
88

99
const BackButtonProps = schema('BackButtonProps', {
10+
color: z.string().default('#FFFFFF'),
1011
backLink: z.string().default('/'),
1112
})
1213

@@ -16,36 +17,48 @@ type BackButtonProps = z.input<typeof BackButtonProps>
1617

1718
const BackButton = (props: BackButtonProps) => {
1819
// Props
19-
const { backLink } = BackButtonProps.applyDefaults(props)
20+
const { color, backLink } = BackButtonProps.applyDefaults(props)
2021

2122
// Routing
2223
const { canGoBack, back } = useRouter()
2324

2425
// Vars
2526
const showBackButton = canGoBack()
2627

27-
// -- Render --
28+
// -- Prerender --
2829

29-
return (
30-
<View className="flex flex-row absolute top-8 web:top-0 left-0 p-4 items-center">
31-
<ArrowLeftFilled fill="#FFFFFF" size={18} />
30+
const innerBackButton = (
31+
<View className="flex flex-row p-4 items-center">
32+
<ArrowLeftFilled fill={color} size={18} />
3233
<View className="w-[5px]" />
33-
{showBackButton ? (
34-
<Text
35-
className="text-white text-lg"
36-
onPress={back}
37-
>
38-
{`Back`}
39-
</Text>
40-
) : (
41-
<Link href={backLink} className="text-white text-lg no-underline">
42-
{`Back`}
43-
</Link>
44-
)}
34+
<Text
35+
className={`text-lg text-[${color}]`}
36+
style={{ color }}
37+
>
38+
{`Back`}
39+
</Text>
4540
</View>
4641
)
42+
43+
// -- Render --
44+
45+
return showBackButton ? (
46+
<Pressable
47+
className={`absolute top-8 web:top-0 left-0`} // @ts-ignore
48+
onPress={back}
49+
>
50+
{innerBackButton}
51+
</Pressable>
52+
) : (
53+
<Link
54+
className={`absolute top-8 web:top-0 left-0 text-[${color}] no-underline`}
55+
href={backLink}
56+
>
57+
{innerBackButton}
58+
</Link>
59+
)
4760
}
4861

4962
/* --- Exports --------------------------------------------------------------------------------- */
5063

51-
export default BackButton
64+
export default BackButton

features/@app-core/components/styled.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { KnownRoutes } from '@app/registries/routeManifest.generated'
22
import { styled } from 'nativewind'
3-
import { Text as RNText, View as RNView, ScrollView as RNScrollView } from 'react-native'
3+
import {
4+
Text as RNText,
5+
View as RNView,
6+
Pressable as RNPressable,
7+
} from 'react-native'
48
import { Link as UniversalLink } from '@green-stack/navigation/Link'
59
import { UniversalLinkProps } from '@green-stack/navigation/Link.types'
610
import { Image as UniversalImage } from '@green-stack/components/Image'
@@ -10,6 +14,7 @@ import { Image as UniversalImage } from '@green-stack/components/Image'
1014
export const View = styled(RNView, '')
1115
export const Text = styled(RNText, '')
1216
export const Image = styled(UniversalImage, '')
17+
export const Pressable = styled(RNPressable, '')
1318

1419
/* --- Typography ------------------------------------------------------------------------------ */
1520

0 commit comments

Comments
 (0)