-
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
Chore/9630-UseDesignSystemSnackbarComponent #10298
Open
oddballdave
wants to merge
28
commits into
develop
Choose a base branch
from
chore/9630-UseDesignSystemSnackbarComponent
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3f5c125
Incorporated SnackbarProvider
oddballdave 4289723
Incorporated Design System Snackbar Component into all Benefits screens
oddballdave 8ce113a
Incorporated Design System Snackbar Component into all Health screens
oddballdave 7a1fa17
Incorporated Design System Snackbar Component into all Home screens
oddballdave dbd2db7
Incorporated Design System Snackbar Component into all Payments screens
oddballdave 487ff8d
Removed global snackBar and other related references
oddballdave 6439410
Removed SnackBar component, snackBarSlice and related references
oddballdave 5e25f8d
Patched Design System Snackbar to memoize useSnackbar
oddballdave 4d4e0f6
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave 1940541
Pod and project updates
oddballdave 9228e5d
Removed unused import
oddballdave 81cb504
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave 8f660fb
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave ff4da29
Add back screenListeners to hide the snackbar when it's not handled i…
oddballdave 1c15325
Adjusted NAV_BAR_HEIGHT to its actual value and added marginBottom to…
oddballdave ad853bb
Added screenListeners to hide snackbar when navigating
oddballdave 6b3d569
Set snackbar offset to 0 for screens where there is no bottom navigat…
oddballdave a6013e9
Removed unused vama_snackbar_null
oddballdave ec3c641
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave 0580fb5
Reverted patch changes to adjust NAV_BAR_HEIGHT and marginBottom
oddballdave c36561f
Added snackBarBottomOffset back to the theme and started using it as …
oddballdave c830268
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave d1626ec
Fixed linter warning
oddballdave 63b4ec8
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave b9d4b2c
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave d0c2f9a
Modifications to use new design system snackbar
oddballdave 7d8568f
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave ee7371d
Merge branch 'develop' into chore/9630-UseDesignSystemSnackbarComponent
oddballdave 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
67 changes: 67 additions & 0 deletions
67
VAMobile/patches/@department-of-veterans-affairs+mobile-component-library+0.27.1.patch
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,67 @@ | ||
diff --git a/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/Snackbar.tsx b/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/Snackbar.tsx | ||
index 6b2f54d..8931ba9 100644 | ||
--- a/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/Snackbar.tsx | ||
+++ b/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/Snackbar.tsx | ||
@@ -160,6 +160,7 @@ export const Snackbar: FC<SnackbarProps> = (toast) => { | ||
minHeight: 44, | ||
padding: spacing.vadsSpaceSm, | ||
marginHorizontal: spacing.vadsSpaceLg, | ||
+ marginBottom: spacing.vadsSpaceLg, | ||
rowGap: spacing.vadsSpace2xs, | ||
}, | ||
} | ||
diff --git a/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbar.tsx b/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbar.tsx | ||
index 2e5c464..a696fa9 100644 | ||
--- a/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbar.tsx | ||
+++ b/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbar.tsx | ||
@@ -1,4 +1,4 @@ | ||
-import { useContext } from 'react' | ||
+import { useCallback, useContext, useMemo } from 'react' | ||
|
||
import * as Toast from 'react-native-toast-notifications' | ||
|
||
@@ -22,9 +22,9 @@ export function useSnackbar() { | ||
throw new Error('useSnackbar must be used within a SnackbarProvider') | ||
} | ||
|
||
- const show = (message: string, snackbarOptions?: SnackbarOptions) => { | ||
- const { offset, setOffset } = context | ||
+ const { offset, setOffset } = context | ||
|
||
+ const show = useCallback((message: string, snackbarOptions?: SnackbarOptions) => { | ||
const customOffset = snackbarOptions?.offset | ||
|
||
// Custom offset if provided, else default | ||
@@ -43,11 +43,13 @@ export function useSnackbar() { | ||
|
||
toast.hideAll() | ||
toast.show(message, { data: snackbarOptions, duration }) | ||
- } | ||
- | ||
- return { | ||
- show, | ||
- hide: toast.hideAll, | ||
- isOpen: toast.isOpen, | ||
- } | ||
+ }, [defaultOffset, offset, screenReaderEnabled, setOffset, toast]) | ||
+ | ||
+ return useMemo( | ||
+ () => ({ | ||
+ show, | ||
+ hide: toast.hideAll, | ||
+ isOpen: toast.isOpen, | ||
+ }), [show, toast.hideAll, toast.isOpen] | ||
+ ) | ||
} | ||
diff --git a/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbarDefaultOffset.tsx b/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbarDefaultOffset.tsx | ||
index e7679fa..135c5fa 100644 | ||
--- a/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbarDefaultOffset.tsx | ||
+++ b/node_modules/@department-of-veterans-affairs/mobile-component-library/src/components/Snackbar/useSnackbarDefaultOffset.tsx | ||
@@ -1,6 +1,6 @@ | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context' | ||
|
||
-const NAV_BAR_HEIGHT = 60 | ||
+const NAV_BAR_HEIGHT = 56 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is somewhat a design decision, but am not sure pixel perfection is necessary here. Similar to the above of deferring to the app team, but I'd recommend against patching it vs having 4 pixels more in what is already somewhat arbitrary padding for a "floating" element. |
||
|
||
/** | ||
* Returns default Snackbar offset depending on safe area bottom inset |
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
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.
I see the justification for this in another comment:
The reason bottom margin was not included in the component is two fold:
The side margins were deemed acceptable to block presses as, paired with general padding for content, anything peeking should be very minimal.
I technically defer to the app team since we on the design system team long term are not responsible for how apps implement our components, but I'd recommend against patching this in as patches are frail and this is liable to break from future library changes we make to the component when updating while leveraging the offset should not.
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.
Thanks for the feedback. Just so we're all on the same page, the left screenshot below is the default location where the Snackbar gets positioned when a bottom navigation bar is present and no offset is specified. There are 4 units of vertical spacing between the top of the navbar and the Snackbar. The right screenshot shows the changes with the patch applied (20 units of vertical spacing). If we can live with the spacing on the left screenshot, then I can remove the patch easily enough. If we want more spacing but no patch, then the app will have to start passing offsets into all Snackbars. Please advise.
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.
I think the 4 units spacing is fine, but ultimately seems like a design decision. I believe the position is what it was with the old Snackbar so it'd be maintaining existing functionality and didn't come up during creating it or we'd likely have gone with a different default. As a "floating" element it can appear directly above other content regardless if it's 4 or 20 pixels from the Nav bar--the crux is not blocking the Nav bar so it's usable.
If the increased spacing is determined the way: I think a patch is fair way to go about it, but it would be better to update the default offset to 76 instead of using
marginBottom
. Longer term, we have done research into global overrides for certain design system parameters and the Snackbar offset definitely would be a good use case--but, in the absence of that yet existing, patching in a different default value seems like a reasonable workaround since when the global override exists then the only code change would be removing the patch and setting the global override in one spot.Not sure if @Sparowhawk or anyone else on the app side had thoughts since ultimately from the design system side we're just providing recommendations based on how the components were built/designed and consumer apps can do what they want.
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.
As a circle back: created a ticket to add a global override for the default Snackbar offset so it's documented as a desired future enhancement.