Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rna): add DefaultContent and override styles #3009

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/react-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { name as appName } from './app.json';
import { setupStorybook } from './storybook';

//TODO: replace with env var
const initStorybook = false;
const initStorybook = true;
Copy link
Contributor

@ioanabrooks ioanabrooks Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this should not go in


const { StorybookRoot } = setupStorybook(initStorybook);

Expand Down
4 changes: 2 additions & 2 deletions examples/react-native/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ PODS:
- React-Core
- react-native-netinfo (8.3.1):
- React-Core
- react-native-safe-area-context (4.3.3):
- react-native-safe-area-context (4.4.1):
- RCT-Folly
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -564,7 +564,7 @@ SPEC CHECKSUMS:
React-logger: f79dd3cc0f9b44f5611c6c7862badd891a862cf8
react-native-get-random-values: a6ea6a8a65dc93e96e24a11105b1a9c8cfe1d72a
react-native-netinfo: 1a6035d3b9780221d407c277ebfb5722ace00658
react-native-safe-area-context: b456e1c40ec86f5593d58b275bd0e9603169daca
react-native-safe-area-context: 99b24a0c5acd0d5dcac2b1a7f18c49ea317be99a
React-perflogger: 30ab8d6db10e175626069e742eead3ebe8f24fd5
React-RCTActionSheet: 4b45da334a175b24dabe75f856b98fed3dfd6201
React-RCTAnimation: d6237386cb04500889877845b3e9e9291146bc2e
Expand Down
6 changes: 3 additions & 3 deletions examples/react-native/src/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';

import { AuthenticatorDemo } from '../features/Authenticator';
// import Example from '../features/Authenticator/Demo/Example';
import Example from '../features/Authenticator/Styles/Example';
// import { Demo as InAppDemo } from '../features/InAppMessaging';
Comment on lines +3 to 5
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving forward we will use this structure for RN Example apps so we have a consistent import structure for using .env variables to dynamically load Example apps


const App = () => {
return <AuthenticatorDemo />;
// return <InAppDemo />;
return <Example />;
};

export default App;
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';

import { useDeepLinkingDebug } from '../../../hooks';

import { Authenticator, useAuthenticator } from '@aws-amplify/ui-react-native';
import { Amplify } from 'aws-amplify';

Expand All @@ -19,8 +17,6 @@ function SignOutButton() {
}

function App() {
useDeepLinkingDebug();

return (
<Authenticator.Provider>
<Authenticator>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { ReactNode } from 'react';
import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';

import { Authenticator, useAuthenticator } from '@aws-amplify/ui-react-native';
import { Amplify } from 'aws-amplify';

import { Button } from '../../../ui';

Amplify.configure({});

const MyHeader = ({
children,
style,
}: {
children?: ReactNode;
style?: StyleProp<ViewStyle>;
}) => (
<View style={style}>
<Text style={{ fontSize: 36 }}>{children}</Text>
</View>
);

function SignOutButton() {
const { signOut } = useAuthenticator();
return <Button onPress={signOut}>Sign Out</Button>;
}

function App() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting this example is not complete and will be used for the style prop handling example

return (
<Authenticator.Provider>
<Authenticator
components={{
SignIn: (props) => (
<Authenticator.SignIn {...props} Header={MyHeader} />
),
}}
>
<View style={style.container}>
<SignOutButton />
</View>
</Authenticator>
</Authenticator.Provider>
);
}

const style = StyleSheet.create({
container: { flex: 1, alignItems: 'center', justifyContent: 'center' },
});

export default App;
1 change: 0 additions & 1 deletion examples/react-native/src/features/Authenticator/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ const signUpProps = {
const verifyUserProps = {
...sharedProps,
...getComponentSlots(Authenticator.VerifyUser),
fields: [],
fields: [
{ name: 'email', type: 'radio' as const, value: 'jeff@example.com' },
ioanabrooks marked this conversation as resolved.
Show resolved Hide resolved
],
skipVerification: noop,
};

Expand Down
4 changes: 4 additions & 0 deletions packages/react-core/src/Authenticator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export {
Overrides as AuthenticatorComponentOverrides,
Defaults as AuthenticatorComponentDefaults,
DefaultProps as AuthenticatorComponentDefaultProps,
FooterComponent as AuthenticatorFooterComponent,
FormFieldsComponent as AuthenticatorFormFieldsComponent,
HeaderComponent as AuthenticatorHeaderComponent,
isComponentRouteKey as isAuthenticatorComponentRouteKey,
AuthenticatorRouteComponentKey,
AuthenticatorRouteComponentName,
AuthenticatorLegacyField,
AuthenticatorMachineContext,
Expand Down
4 changes: 4 additions & 0 deletions packages/react-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ export {
AuthenticatorComponentDefaults,
AuthenticatorComponentDefaultProps,
AuthenticatorComponentOverrides,
AuthenticatorFooterComponent,
AuthenticatorFormFieldsComponent,
AuthenticatorHeaderComponent,
AuthenticatorLegacyField,
AuthenticatorMachineContext,
AuthenticatorProvider,
AuthenticatorRouteComponentKey,
AuthenticatorRouteComponentName,
isAuthenticatorComponentRouteKey,
resolveAuthenticatorComponents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React from 'react';
import { authenticatorTextUtil } from '@aws-amplify/ui';

import { Button, ErrorMessage } from '../../../primitives';
import { DefaultFooter, DefaultFormFields, DefaultHeader } from '../../common';
import {
DefaultFooter,
DefaultTextFormFields,
DefaultHeader,
} from '../../common';
import { useFieldValues } from '../../hooks';

import { DefaultConfirmResetPasswordComponent } from '../types';
Expand Down Expand Up @@ -58,7 +62,7 @@ const ConfirmResetPassword: DefaultConfirmResetPasswordComponent = ({
};

ConfirmResetPassword.Footer = DefaultFooter;
ConfirmResetPassword.FormFields = DefaultFormFields;
ConfirmResetPassword.FormFields = DefaultTextFormFields;
ConfirmResetPassword.Header = DefaultHeader;

ConfirmResetPassword.displayName = COMPONENT_NAME;
Expand Down
Loading