forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#31060 from JKobrynski/migrateCollapsible…
…SectionToTypeScript [No QA] [TS Migration] Migrate CollapsibleSection to TypeScript
- Loading branch information
Showing
9 changed files
with
89 additions
and
102 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/components/CollapsibleSection/Collapsible/index.native.js
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/components/CollapsibleSection/Collapsible/index.native.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,10 @@ | ||
import React from 'react'; | ||
import CollapsibleRN from 'react-native-collapsible'; | ||
import CollapsibleProps from './types'; | ||
|
||
function Collapsible({isOpened = false, children}: CollapsibleProps) { | ||
return <CollapsibleRN collapsed={!isOpened}>{children}</CollapsibleRN>; | ||
} | ||
|
||
Collapsible.displayName = 'Collapsible'; | ||
export default Collapsible; |
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,8 @@ | ||
import React from 'react'; | ||
import {Collapse} from 'react-collapse'; | ||
import CollapsibleProps from './types'; | ||
|
||
function Collapsible({isOpened = false, children}: CollapsibleProps) { | ||
return <Collapse isOpened={isOpened}>{children}</Collapse>; | ||
} | ||
export default Collapsible; |
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,8 @@ | ||
import ChildrenProps from '@src/types/utils/ChildrenProps'; | ||
|
||
type CollapsibleProps = ChildrenProps & { | ||
/** Whether the section should start expanded. False by default */ | ||
isOpened?: boolean; | ||
}; | ||
|
||
export default CollapsibleProps; |
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,55 @@ | ||
import React, {useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import Icon from '@components/Icon'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; | ||
import Text from '@components/Text'; | ||
import styles from '@styles/styles'; | ||
import CONST from '@src/CONST'; | ||
import ChildrenProps from '@src/types/utils/ChildrenProps'; | ||
import Collapsible from './Collapsible'; | ||
|
||
type CollapsibleSectionProps = ChildrenProps & { | ||
/** Title of the Collapsible section */ | ||
title: string; | ||
}; | ||
|
||
function CollapsibleSection({title, children}: CollapsibleSectionProps) { | ||
const [isExpanded, setIsExpanded] = useState(false); | ||
|
||
/** | ||
* Expands/collapses the section | ||
*/ | ||
const toggleSection = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
const src = isExpanded ? Expensicons.UpArrow : Expensicons.DownArrow; | ||
|
||
return ( | ||
<View style={styles.mt4}> | ||
<PressableWithFeedback | ||
onPress={toggleSection} | ||
style={[styles.pb4, styles.flexRow]} | ||
role={CONST.ACCESSIBILITY_ROLE.BUTTON} | ||
accessibilityLabel={title} | ||
hoverDimmingValue={1} | ||
pressDimmingValue={0.2} | ||
> | ||
<Text | ||
style={[styles.flex1, styles.textStrong, styles.userSelectNone]} | ||
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} | ||
> | ||
{title} | ||
</Text> | ||
<Icon src={src} /> | ||
</PressableWithFeedback> | ||
<View style={styles.collapsibleSectionBorder} /> | ||
<Collapsible isOpened={isExpanded}> | ||
<View>{children}</View> | ||
</Collapsible> | ||
</View> | ||
); | ||
} | ||
|
||
export default CollapsibleSection; |