-
Notifications
You must be signed in to change notification settings - Fork 4
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
feature/8467-UseDesignSystemAlertComponent #9022
Merged
Sparowhawk
merged 29 commits into
develop
from
feature/8467-UseDesignSystemAlertComponent
Aug 22, 2024
Merged
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a65ef1a
Upgrade mobile-component-library and eslint-config-mobile
alexandec 225a597
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec 4a9326d
Convert first set of components to use Alert component
alexandec 7c5120c
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec 7911bd8
Second set of conversions to Alert component
alexandec 02d0f93
Create and use AlertWithScroll component
alexandec eba1446
Remove adjustment to alert scroll position
alexandec 4355988
Change name to AlertWithHaptics
alexandec 1a88105
Further update to mobile-component-library
alexandec a0559db
Simplify MessageAlert changes
alexandec eeebcca
Update E2E mapping
alexandec 3e516ba
Replace and remove CollapsibleAlert component
alexandec 5b5d14d
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec 6699f6a
Unit test fixes
alexandec db0c20c
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec b0adffd
Fixes based on PR reviews
alexandec 74c0ccf
Unit test fix
alexandec 7505d99
Bump component-library to 0.20.3. Add mobile-assets and mobile-tokens…
narin 332529b
Update design system colors imports
narin 772299c
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec f24ece1
Convert additional AlertBoxes to AlertWithHaptics
alexandec a613bb9
Upgrade mobile-component-library and mobile-tokens to latest
alexandec fdaa27b
Use AlertWithHaptics on ClaimDetailsScreen
alexandec d9dcaa2
Spacing tweaks for alert content
alexandec 2b4a465
Remove extra spacing in WaygateWrapper alert
alexandec 6e0f4af
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec c759cf1
Improvements for CustomError and TakePhotos alerts
alexandec fa771f0
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec 8a7f9ec
Merge branch 'develop' into feature/8467-UseDesignSystemAlertComponent
alexandec 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
|
||
import { context, render, screen } from 'testUtils' | ||
|
||
import AlertWithHaptics from './AlertWithHaptics' | ||
|
||
context('AlertWithHaptics', () => { | ||
beforeEach(() => { | ||
render(<AlertWithHaptics variant="warning" header={'Warning title'} description={'My warning'} />) | ||
}) | ||
|
||
it('initializes correctly', () => { | ||
expect(screen.getByText('My warning')).toBeTruthy() | ||
expect(screen.getByRole('heading', { name: 'Warning title' })).toBeTruthy() | ||
}) | ||
}) |
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,54 @@ | ||
import React, { FC, RefObject, useEffect, useState } from 'react' | ||
import { ScrollView, View } from 'react-native' | ||
import { HapticFeedbackTypes } from 'react-native-haptic-feedback' | ||
|
||
import { Alert, AlertProps } from '@department-of-veterans-affairs/mobile-component-library/src/components/Alert/Alert' | ||
|
||
import { triggerHaptic } from 'utils/haptics' | ||
import { useAutoScrollToElement } from 'utils/hooks' | ||
|
||
export type AlertWithHapticsProps = AlertProps & { | ||
/** Optional boolean for determining when to focus on error alert boxes (e.g. onSaveClicked). Default is true */ | ||
focusOnError?: boolean | ||
/** Optional ref for the parent scrollView so we can scroll to the Alert */ | ||
scrollViewRef?: RefObject<ScrollView> | ||
} | ||
|
||
/** | ||
* Wrapper for the Alert component which triggers haptics and optionally scrolls | ||
*/ | ||
const AlertWithHaptics: FC<AlertWithHapticsProps> = ({ | ||
children, | ||
scrollViewRef, | ||
focusOnError = true, | ||
...alertProps | ||
}) => { | ||
const [scrollRef, viewRef, scrollToAlert] = useAutoScrollToElement() | ||
const [shouldFocus, setShouldFocus] = useState(true) | ||
const { variant, header, description } = alertProps | ||
|
||
useEffect(() => { | ||
if (variant === 'error' && scrollViewRef?.current && (header || description)) { | ||
scrollRef.current = scrollViewRef.current | ||
scrollToAlert() | ||
} | ||
setShouldFocus(focusOnError) | ||
}, [variant, focusOnError, scrollRef, scrollToAlert, scrollViewRef, header, description]) | ||
|
||
const vibrate = () => { | ||
if (variant === 'error') { | ||
triggerHaptic(HapticFeedbackTypes.notificationError) | ||
} else if (variant === 'warning') { | ||
triggerHaptic(HapticFeedbackTypes.notificationWarning) | ||
} | ||
} | ||
|
||
return ( | ||
<View ref={viewRef}> | ||
<Alert {...alertProps}>{children}</Alert> | ||
{shouldFocus && vibrate()} | ||
</View> | ||
) | ||
} | ||
|
||
export default AlertWithHaptics |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Did you want to bump this to be issuing linting warnings for Loading indicator? Not sure if that had been prioritized yet.
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.
Good call, I moved this back to 0.15.0