This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import { createComponent } from 'bumbag/utils'; | ||
import { Button, ButtonProps } from 'bumbag-native/Button'; | ||
|
||
import { HapticRoot, HapticRootProps } from './Haptic'; | ||
|
||
export type LocalHapticButtonProps = { | ||
hapticOptions?: { | ||
enableVibrateFallback?: HapticRootProps['enableVibrateFallback']; | ||
ignoreAndroidSystemSettings?: HapticRootProps['ignoreAndroidSystemSettings']; | ||
type?: HapticRootProps['type']; | ||
}; | ||
}; | ||
export type HapticButtonProps = ButtonProps & LocalHapticButtonProps; | ||
|
||
export const HapticButton = createComponent<HapticButtonProps>( | ||
(props) => { | ||
const { hapticOptions, ...restProps } = props; | ||
return ( | ||
<HapticRoot {...hapticOptions}> | ||
<Button {...restProps}>{props.children}</Button> | ||
</HapticRoot> | ||
); | ||
}, | ||
{ | ||
attach: { | ||
useProps: () => {}, | ||
displayName: 'native.Haptic.Button', | ||
}, | ||
themeKey: 'native.Haptic.Button', | ||
} | ||
); |
32 changes: 32 additions & 0 deletions
32
packages/bumbag-native-haptic/src/Haptic/HapticPressable.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,32 @@ | ||
import * as React from 'react'; | ||
import { createComponent } from 'bumbag/utils'; | ||
import { Pressable, PressableProps } from 'bumbag-native/Pressable'; | ||
|
||
import { HapticRoot, HapticRootProps } from './Haptic'; | ||
|
||
export type LocalHapticPressableProps = { | ||
hapticOptions?: { | ||
enableVibrateFallback?: HapticRootProps['enableVibrateFallback']; | ||
ignoreAndroidSystemSettings?: HapticRootProps['ignoreAndroidSystemSettings']; | ||
type?: HapticRootProps['type']; | ||
}; | ||
}; | ||
export type HapticPressableProps = PressableProps & LocalHapticPressableProps; | ||
|
||
export const HapticPressable = createComponent<HapticPressableProps>( | ||
(props) => { | ||
const { hapticOptions, ...restProps } = props; | ||
return ( | ||
<HapticRoot {...hapticOptions}> | ||
<Pressable {...restProps}>{props.children}</Pressable> | ||
</HapticRoot> | ||
); | ||
}, | ||
{ | ||
attach: { | ||
useProps: () => undefined, | ||
displayName: 'native.Haptic.Pressable', | ||
}, | ||
themeKey: 'native.Haptic.Pressable', | ||
} | ||
); |
32 changes: 32 additions & 0 deletions
32
packages/bumbag-native-haptic/src/Haptic/HapticTouchable.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,32 @@ | ||
import * as React from 'react'; | ||
import { createComponent } from 'bumbag/utils'; | ||
import { BoxTouchable, BoxTouchableProps } from 'bumbag-native/Box'; | ||
|
||
import { HapticRoot, HapticRootProps } from './Haptic'; | ||
|
||
export type LocalHapticTouchableProps = { | ||
hapticOptions?: { | ||
enableVibrateFallback?: HapticRootProps['enableVibrateFallback']; | ||
ignoreAndroidSystemSettings?: HapticRootProps['ignoreAndroidSystemSettings']; | ||
type?: HapticRootProps['type']; | ||
}; | ||
}; | ||
export type HapticTouchableProps = BoxTouchableProps & LocalHapticTouchableProps; | ||
|
||
export const HapticTouchable = createComponent<HapticTouchableProps>( | ||
(props) => { | ||
const { hapticOptions, ...restProps } = props; | ||
return ( | ||
<HapticRoot {...hapticOptions}> | ||
<BoxTouchable {...restProps}>{props.children}</BoxTouchable> | ||
</HapticRoot> | ||
); | ||
}, | ||
{ | ||
attach: { | ||
useProps: () => undefined, | ||
displayName: 'native.Haptic.Touchable', | ||
}, | ||
themeKey: 'native.Haptic.Touchable', | ||
} | ||
); |
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 |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import { Haptic as _Haptic, HapticNotification, HapticImpact, HapticRoot } from './Haptic'; | ||
import { HapticButton } from './HapticButton'; | ||
import { HapticPressable } from './HapticPressable'; | ||
import { HapticTouchable } from './HapticTouchable'; | ||
import { trigger, triggerImpact, triggerSelection, triggerNotification } from './utils'; | ||
|
||
export * from './Haptic'; | ||
export * from './HapticButton'; | ||
export * from './HapticPressable'; | ||
export * from './HapticTouchable'; | ||
export * from './utils'; | ||
export * from './types'; | ||
|
||
export const Haptic = Object.assign(_Haptic, { | ||
Root: Object.assign(HapticRoot, { trigger }), | ||
Notification: Object.assign(HapticNotification, { trigger: triggerNotification }), | ||
Impact: Object.assign(HapticImpact, { trigger: triggerImpact }), | ||
Button: HapticButton, | ||
Touchable: HapticTouchable, | ||
Pressable: HapticPressable, | ||
trigger: triggerSelection, | ||
}); |
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