-
Notifications
You must be signed in to change notification settings - Fork 317
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
Conversation
|
// import Example from '../features/Authenticator/Demo/Example'; | ||
import Example from '../features/Authenticator/Styles/Example'; | ||
// import { Demo as InAppDemo } from '../features/InAppMessaging'; |
There was a problem hiding this comment.
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
return <Button onPress={signOut}>Sign Out</Button>; | ||
} | ||
|
||
function App() { |
There was a problem hiding this comment.
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
<Button | ||
onPress={resendCode} | ||
variant="secondary" | ||
style={styles.buttonSecondary} | ||
> | ||
{getResendCodeText()} | ||
</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this outside the Footer
to align it with the other subcomponents
<FormFields isPending={isPending} fields={fieldsWithHandlers} /> | ||
{error ? <ErrorMessage>{error}</ErrorMessage> : null} | ||
<Button onPress={handleFormSubmit} style={styles.buttonPrimary}> | ||
{isPending ? 'Verifying...' : getVerifyText()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the Verifying...
to align with other Authenticator
implementations
function useThemedStyles<Style>(getStyle: (theme: StrictTheme) => Style) { | ||
const theme = useTheme(); | ||
return useMemo(() => getStyle(theme), [getStyle, theme]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move this to this to live with theming in a follow up, needs to be able to handle additional params
buttonPrimary: { | ||
marginVertical: space.medium, | ||
}, | ||
buttonPrimaryLabel: {}, // themed value only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These empty objects are temporary until we have added subcomponent theming support
'error' | 'Footer' | 'isPending' | ||
> & { | ||
buttons: DefaultButtons; | ||
body?: React.ReactNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be retyped/refactored so it can handle style
props for subcomponents that require unique content, for example SetupTOTP
return censoredVal; | ||
}; | ||
|
||
const DefaultFormFields: DefaultRadioFormFieldsComponent = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been named DefaultRadioFormFields
, will address in a follow up PR
level = 3, | ||
...rest | ||
}: DefaultHeaderProps): JSX.Element | null { | ||
return children ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only render the Heading
when a child is provided to prevent whitespace from being rendered
@@ -19,6 +19,7 @@ export const defaultTexts = { | |||
ENTER_USERNAME: 'Enter your username', | |||
FAMILY_NAME: 'Family Name', | |||
GIVEN_NAME: 'Given Name', | |||
FORGOT_PASSWORD: 'Forgot Password?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -16,7 +16,6 @@ export const getThemedStyles = (theme: StrictTheme): ErrorMessageStyles => { | |||
flexDirection: 'row', | |||
paddingHorizontal: space.xs, | |||
paddingVertical: space.xl, | |||
width: '100%', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
fieldErrorStyle?: FieldErrorsProps['style']; | ||
fieldLabelStyle?: StyleProp<TextStyle>; | ||
fieldStyle?: StyleProp<TextStyle>; | ||
style?: StyleProp<ViewStyle>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we piggyback a fieldRequiredStyle
? :) I can add it as follow-up as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Good call (separate PR preferred)
packages/react-native/src/Authenticator/Defaults/VerifyUser/__tests__/VerifyUser.spec.tsx
Show resolved
Hide resolved
examples/react-native/index.js
Outdated
@@ -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; |
There was a problem hiding this comment.
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
buttonPrimaryLabel: {}, // themed value only | ||
buttonSecondary: { | ||
marginVertical: space.xs, | ||
minWidth: '50%', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to allow the secondary buttons to "stack" if scenarios where button labels are long-ish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of changes
Add
DefaultContent
component to align component structure and styling across RNA subcomponents, as well as lay out the groundwork for passingstyle
on the subcomponentsIssue #, if available
NA
Description of how you validated changes
Manually tested, unit tests
Checklist
yarn test
passessideEffects
field updatedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.