-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement WorkflowCardBody Component #319
Merged
ektaghag-eaton
merged 12 commits into
release/R31
from
feature/blui-5099-workflowcardBodyCompoenent
Jan 24, 2024
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
187a3bc
add workflowCardBody component
ektaghag-eaton 73eb41d
add example for workflowcardbody
ektaghag-eaton 764c1f9
Fixed user menu import error
surajeaton b741a7f
Added husky hook
surajeaton a0d7a1d
Test husky
surajeaton 0476d40
Fixed prettier
surajeaton 1af925a
remove husky changes from this PR
ektaghag-eaton 725f5a3
Combine instruction and body example
ektaghag-eaton c90c7de
add styling for instruction
ektaghag-eaton 6824c0e
remove duplicate jsdocs comment
ektaghag-eaton d48d426
update test case
ektaghag-eaton 0751110
fix prettier
ektaghag-eaton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
login-workflow/example/src/screens/WorkFlowCardExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { SafeAreaView, ScrollView } from 'react-native'; | ||
import { Header } from '@brightlayer-ui/react-native-components'; | ||
import { StackNavigationProp } from '@react-navigation/stack'; | ||
import { RootStackParamList } from '../navigation'; | ||
import { WorkflowCardBody, WorkflowCardInstructions } from '@brightlayer-ui/react-native-auth-workflow'; | ||
import { HelperText, TextInput } from 'react-native-paper'; | ||
import { useThemeContext } from '../context/ThemeContext'; | ||
import { useExtendedTheme } from '@brightlayer-ui/react-native-themes'; | ||
import { UserMenuExample } from '../components/UserMenuExample'; | ||
import { toggleRTL } from './home'; | ||
|
||
type AppProps = { | ||
navigation: StackNavigationProp<RootStackParamList, 'WorkFlowCardExample'>; | ||
}; | ||
|
||
const WorkFlowCardExample: React.FC<AppProps> = ({ navigation }): JSX.Element => { | ||
const theme = useExtendedTheme(); | ||
const { theme: themeType, setTheme } = useThemeContext(); | ||
const [errorFilledText, setErrorFilledText] = React.useState('Hello'); | ||
const [hasError, setHasError] = React.useState(true); | ||
|
||
return ( | ||
<> | ||
<Header | ||
title={'Workflow Card Example'} | ||
icon={{ name: 'menu' }} | ||
onIconPress={(): void => { | ||
navigation.openDrawer(); | ||
}} | ||
actionItems={[ | ||
{ | ||
icon: { name: 'more' }, | ||
onPress: (): void => {}, | ||
component: ( | ||
<UserMenuExample | ||
onToggleRTL={toggleRTL} | ||
onToggleTheme={(): void => setTheme(themeType === 'light' ? 'dark' : 'light')} | ||
/> | ||
), | ||
}, | ||
]} | ||
/> | ||
<SafeAreaView style={{ backgroundColor: theme.colors.background, flex: 1 }}> | ||
<ScrollView> | ||
<WorkflowCardInstructions instructions={'Test Instructions'} /> | ||
<WorkflowCardBody> | ||
<TextInput | ||
label="TextInput" | ||
mode="flat" | ||
left={<TextInput.Icon icon="email" />} | ||
right={<TextInput.Icon icon="menu-down" />} | ||
value={errorFilledText} | ||
underlineColor={theme.colors.surface} | ||
onChangeText={(value: string): void => { | ||
setErrorFilledText(value); | ||
setHasError(value.length > 4); | ||
}} | ||
error={hasError} | ||
/> | ||
<HelperText type="error" visible={hasError} style={{ marginBottom: 8 }}> | ||
Error Message | ||
</HelperText> | ||
</WorkflowCardBody> | ||
</ScrollView> | ||
</SafeAreaView> | ||
</> | ||
); | ||
}; | ||
|
||
export default WorkFlowCardExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './home'; | ||
export * from './pageOne'; | ||
export * from './pageTwo'; | ||
export * from './WorkFlowCardExample'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
login-workflow/src/__tests__/components/WorkflowCard/WorkflowCardBody-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @format | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { cleanup } from '@testing-library/react-native'; | ||
import renderer from 'react-test-renderer'; | ||
import { WorkflowCardBody } from 'src/components/WorkflowCard'; | ||
import { Text } from 'react-native-paper'; | ||
|
||
describe('WorkflowCardBody Test', () => { | ||
afterEach(cleanup); | ||
it('WorkflowCardBody renders correctly', () => { | ||
const rendered = renderer | ||
.create( | ||
<WorkflowCardBody> | ||
<Text>This is workflow card body content.</Text> | ||
</WorkflowCardBody> | ||
) | ||
.toJSON(); | ||
expect(rendered).toBeTruthy(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
login-workflow/src/components/WorkflowCard/WorkflowCardBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
|
||
import { StyleSheet, ViewStyle } from 'react-native'; | ||
import { Card, CardContentProps } from 'react-native-paper'; | ||
import { useScreenWidth } from '../../hooks/useScreenWidth'; | ||
|
||
const makeStyles = ( | ||
isTablet: boolean | ||
): StyleSheet.NamedStyles<{ | ||
workflowBodyStyle: ViewStyle; | ||
}> => | ||
StyleSheet.create({ | ||
workflowBodyStyle: { | ||
flex: 1, | ||
// TODO: move this to common style | ||
marginHorizontal: isTablet ? 24 : 16, | ||
marginTop: 32, | ||
marginBottom: isTablet ? 32 : 24, | ||
paddingHorizontal: 0, | ||
}, | ||
}); | ||
|
||
/** | ||
* Component that renders the body content for the workflow card. | ||
* | ||
* @param children content to render in the WorkflowCardBody | ||
* | ||
* @category Component | ||
*/ | ||
|
||
export const WorkflowCardBody: React.FC<CardContentProps> = (props) => { | ||
const { children, style, ...otherCardContentProps } = props; | ||
const isTablet = useScreenWidth(); | ||
const defaultStyles = makeStyles(isTablet); | ||
return ( | ||
<Card.Content style={[defaultStyles.workflowBodyStyle, style]} {...otherCardContentProps}> | ||
{children} | ||
</Card.Content> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './WorkflowCardInstructions'; | ||
export * from './WorkflowCardBody'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
maybe something like this..