Repository navigation
Composition over configuration for FeatureTrainingContent
#97222
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
Merged
tgolen
merged 35 commits into
Expensify:main
from
gijoe0295:refactor/composition-over-configuration-feature-training
Aug 27, 2026
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
49846f7
Extract shared context
gijoe0295 15f2b4d
Extract button row components
gijoe0295 e5eea08
Extract text content components
gijoe0295 72b5135
Extract util buttons
gijoe0295 c92cedc
Extract illustration component
gijoe0295 de6bf5f
Extract wrappers
gijoe0295 50275bf
Extract pagination components
gijoe0295 377ab2e
Extract scrollable wrapper hook
gijoe0295 c44aea7
Extract base component
gijoe0295 8db3044
Extract carousel component
gijoe0295 9006953
Extract types and export components
gijoe0295 898d33d
Use the new feature training carousel in AI features promo modal
gijoe0295 5a90684
Use the new feature training composition in feature training modal
gijoe0295 d025b95
Update FeatureTrainingModal usages
gijoe0295 40eb832
Update FeatureTraining composition usages
gijoe0295 a75cf5b
Update comment
gijoe0295 a3a014c
Update UI test usage
gijoe0295 7fc4b4a
Remove deprecated components
gijoe0295 92e2a57
Merge branch 'main' of github.com:gijoe0295/App into refactor/composi…
gijoe0295 c92fb92
Merge branch 'main' of github.com:gijoe0295/App into refactor/composi…
gijoe0295 fe2504e
Extract body text component
gijoe0295 aa82bba
Fix fmt
gijoe0295 9b131de
Probe measure body text instead
gijoe0295 bcd54c3
Update AIFeaturesPromoModal usage
gijoe0295 0ec3572
Update AutoSubmitModal usage
gijoe0295 6c40276
Update FeatureTrainingModal usages
gijoe0295 3b7713d
Remove ButtonRow in 1-button pages
gijoe0295 297eab8
Update MigratedUserWelcomeModal usage
gijoe0295 8f1a625
Update SubmitPlanWelcomeModal usage
gijoe0295 c46c150
Update ChangePolicyEducationalModal usage
gijoe0295 624e04b
Remove ButtonRow from UI test
gijoe0295 85562f5
Fix knip check
gijoe0295 3ca752d
Fix https://github.com/Expensify/App/issues/95853
gijoe0295 77b86f8
Let consumers call onClose in onConfirm
gijoe0295 14c6dcf
Fix CONSISTENCY-13
gijoe0295 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 variables from '@styles/variables'; | ||
|
|
||
| import React, {useCallback, useMemo, useState} from 'react'; | ||
|
|
||
| import type {FeatureTrainingActionsValue, FeatureTrainingStateValue} from './context'; | ||
| import type {FeatureTrainingProps} from './types'; | ||
|
|
||
| import {FeatureTrainingActionsContext, FeatureTrainingStateContext} from './context'; | ||
| import useScrollableWrapper from './hooks/useScrollableWrapper'; | ||
|
|
||
| function FeatureTraining({ | ||
| onConfirm, | ||
| onClose, | ||
| onWillShowAgainChange, | ||
| shouldUseScrollView = false, | ||
| width = variables.featureTrainingModalWidth, | ||
| confirmSentryLabel, | ||
| children, | ||
| }: FeatureTrainingProps) { | ||
| const [willShowAgain, setWillShowAgain] = useState(true); | ||
| const {Wrapper, wrapperProps} = useScrollableWrapper({shouldUseScrollView, width}); | ||
|
|
||
| const toggleWillShowAgain = useCallback(() => { | ||
| onWillShowAgainChange?.(!willShowAgain); | ||
| setWillShowAgain((prev) => !prev); | ||
| }, [onWillShowAgainChange, willShowAgain]); | ||
|
|
||
| // Closing after confirm is the consumer's responsibility — call it inside onConfirm when desired. | ||
| const handleConfirm = useCallback(() => { | ||
| onConfirm?.(willShowAgain); | ||
| }, [onConfirm, willShowAgain]); | ||
|
|
||
| const handleClose = useCallback(() => onClose?.(), [onClose]); | ||
|
|
||
| const stateValue = useMemo<FeatureTrainingStateValue>( | ||
| () => ({ | ||
| willShowAgain, | ||
| shouldShowLoadingImmediatelyOnPress: undefined, | ||
| isCarousel: false, | ||
| confirmSentryLabel, | ||
| currentPage: undefined, | ||
| pageCount: undefined, | ||
| isLastPage: undefined, | ||
| contentMinHeight: undefined, | ||
| }), | ||
| [willShowAgain, confirmSentryLabel], | ||
| ); | ||
|
|
||
| const actionsValue = useMemo<FeatureTrainingActionsValue>( | ||
| () => ({ | ||
| toggleWillShowAgain, | ||
| handleConfirm, | ||
| handleClose, | ||
| advance: undefined, | ||
| goBack: undefined, | ||
| }), | ||
| [toggleWillShowAgain, handleConfirm, handleClose], | ||
| ); | ||
|
|
||
| return ( | ||
| <FeatureTrainingStateContext.Provider value={stateValue}> | ||
| <FeatureTrainingActionsContext.Provider value={actionsValue}> | ||
| <Wrapper {...wrapperProps}>{children}</Wrapper> | ||
| </FeatureTrainingActionsContext.Provider> | ||
| </FeatureTrainingStateContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| FeatureTraining.displayName = 'FeatureTraining'; | ||
|
|
||
| export default FeatureTraining; |
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.
Uh oh!
There was an error while loading. Please reload this page.