-
Notifications
You must be signed in to change notification settings - Fork 166
[Draft] Switch Button, Checkbox, and RadioButton from View to Pressable #1070
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6969a9b
Have our Pressable export the stock pressable for not win32
Saadnajmi ba40921
move experimental button to pressable
Saadnajmi 804a3bb
Switch Button, Checkbox, RadioButton over
Saadnajmi fe0168b
Change files
Saadnajmi e887a96
fix depcheck
Saadnajmi ae7e533
Use Adapters in a few places
Saadnajmi 6c04982
update snapshots
Saadnajmi 70f5f43
update toggleButton and compoundButton
Saadnajmi 7757c6a
remove debug code
Saadnajmi 4bf09d6
add props to pressability
Saadnajmi 683f645
Modify our copy of Pressability to simplify code
Saadnajmi b795b35
Merge branch 'master' of github.com:microsoft/fluentui-react-native i…
Saadnajmi cd7c106
commit last changes from FHL
Saadnajmi 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,9 +96,9 @@ const pressable: React.FunctionComponent = () => { | |
const [hoverProps, hoverState] = useHoverState({}); | ||
|
||
return ( | ||
<Stack horizontal gap={5}> | ||
<Stack> | ||
<Square color="blue" /> | ||
<Pressable renderStyle={renderStyle}> | ||
<Pressable style={renderStyle}> | ||
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 prop was named as such because of an issue where the types for react native didn't support a function that returns a style. That's no longer the case, so we can just make this match ViewProps/PressableProps |
||
<Square /> | ||
</Pressable> | ||
<Square color="green" /> | ||
|
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-button-8e7135cc-279c-4a65-8dec-7c7a5ee4a3f4.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/button", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-checkbox-53aa3b26-4ed5-49ed-a3c8-9e9581322332.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/checkbox", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-experimental-button-cdda3789-b884-4252-a91f-11b6409349e9.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/experimental-button", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
...ge/@fluentui-react-native-experimental-checkbox-32e2a9b8-e742-48cb-9cf1-7b072193ef52.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/experimental-checkbox", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-interactive-hooks-48c2d29e-2d2e-4e4f-a5f8-f5c5c5e961c0.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/interactive-hooks", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-pressable-0ab1c643-f12b-4fcd-b113-23053f3aadaf.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/pressable", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-radio-group-ccbd2680-a163-400f-99d9-3f523076bedc.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/radio-group", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-native-tester-e42d1a54-0352-4e84-84b9-da4d1f334f99.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Switch Button, Checkbox, and Radiobutton to use Pressable", | ||
"packageName": "@fluentui-react-native/tester", | ||
"email": "sanajmi@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
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
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 |
---|---|---|
@@ -1,33 +1,3 @@ | ||
/** | ||
* This is primarily a fork of React Native's Touchable Mixin. | ||
* It has been repurposed as it's own standalone control for win32, | ||
* as it needs to support a richer set of functionality on the desktop. | ||
* The touchable variants can be rewritten as wrappers around TouchableWin32 | ||
* by passing the correct set of props down and managing state correctly. | ||
* | ||
* React Native's Touchable.js file (https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/Touchable.js) | ||
* provides an overview over how touchables work and interact with the gesture responder system. | ||
*/ | ||
'use strict'; | ||
import { Pressable } from 'react-native'; | ||
|
||
import { IUseStyling, composable } from '@uifabricshared/foundation-composable'; | ||
import { View } from 'react-native'; | ||
import { IPressableProps, IPressableType } from './Pressable.props'; | ||
import { mergeSettings } from '@uifabricshared/foundation-settings'; | ||
import { useAsPressable } from '@fluentui-react-native/interactive-hooks'; | ||
|
||
export const Pressable = composable<IPressableType>({ | ||
slots: { root: View }, | ||
usePrepareProps: (userProps: IPressableProps, useStyling: IUseStyling<IPressableType>) => { | ||
const { renderStyle, ...rest } = userProps; | ||
const { props, state } = useAsPressable(rest); | ||
const styleProps = useStyling(props); | ||
renderStyle && (props.style = renderStyle(state)); | ||
return { | ||
slotProps: mergeSettings<IPressableType['slotProps']>(styleProps, { root: props }), | ||
state: { state }, | ||
}; | ||
}, | ||
}); | ||
|
||
export default Pressable; | ||
export { Pressable }; |
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,31 @@ | ||
/** | ||
* This is primarily a fork of React Native's Touchable Mixin. | ||
* It has been repurposed as it's own standalone control for win32, | ||
* as it needs to support a richer set of functionality on the desktop. | ||
* The touchable variants can be rewritten as wrappers around TouchableWin32 | ||
* by passing the correct set of props down and managing state correctly. | ||
* | ||
* React Native's Touchable.js file (https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/Touchable.js) | ||
* provides an overview over how touchables work and interact with the gesture responder system. | ||
*/ | ||
'use strict'; | ||
|
||
import { IUseStyling, composable } from '@uifabricshared/foundation-composable'; | ||
import { View } from 'react-native'; | ||
import { IPressableProps, IPressableType } from './Pressable.props'; | ||
import { mergeSettings } from '@uifabricshared/foundation-settings'; | ||
import { useAsPressable } from '@fluentui-react-native/interactive-hooks'; | ||
|
||
export const Pressable = composable<IPressableType>({ | ||
slots: { root: View }, | ||
usePrepareProps: (userProps: IPressableProps, useStyling: IUseStyling<IPressableType>) => { | ||
const { props, state } = useAsPressable(userProps); | ||
const styleProps = useStyling(props); | ||
return { | ||
slotProps: mergeSettings<IPressableType['slotProps']>(styleProps, { root: props }), | ||
state: { state }, | ||
}; | ||
}, | ||
}); | ||
|
||
export default Pressable; |
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
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.
This made the Pressable test page look weird, where one square was off center. Removing both props fixed the issue.