-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat(Sheet): new component #840
Conversation
Size stats
|
Deploy preview for mistica-web ready! ✅ Preview Built with commit 355ae57. |
Accessibility report ℹ️ You can run this locally by executing |
doc/bottomSheet.md
Outdated
<> | ||
<ButtonPrimary onPress={() => setShowSheet(true)}>show bottom sheet</ButtonPrimary> | ||
{showSheet && ( | ||
<BottomSheet onClose={() => setShowSheet(false)}> |
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.
note that onClose
is called when the closing animation finishes, so the idea is not unmounting the component until the transition finishes, that's why I set showSheet to false in onClose handler instead of ButtonPrimary onPress handler
doc/bottomSheet.md
Outdated
Mística predefines some common bottom sheet patterns for you to use: `RadioListBottomSheet`, | ||
`ActionsListBottomSheet`, `InfoBottomSheet` and `ActionsBottomSheet`. You can see examples in the storybook. | ||
|
||
## `showBottomSheet` imperative api |
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 equivalent to the confirm()
, alert()
methods we have for dialogs
doc/bottomSheet.md
Outdated
export const App = () => { | ||
return ( | ||
<> | ||
<BottomSheetRoot /> |
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've decided to not include this automatically inside ThemeContextProvider
to allow webs using mistica to optin to use this. The advantage is that we don't bloat webs with all sheet components JS code if they are not going to use it. Also, it isn't needed to use BottomSheetRoot
if you don't wan't to use the imperative api
doc/bottomSheet.md
Outdated
import {BottomSheetRoot} from '@telefonica/mistica'; | ||
import * as webviewBridge from '@tef-novum/webview-bridge'; | ||
|
||
const nativeImplementation = createNativeSheetImplementationFromWebviewBridge(webviewBridge); |
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.
with this approach, mistica doesn't need to depend on webview bridge lib, because the native implementation is injected, not imported. I think we could follow a similar approach for alert()
confirm()
or other components using the bridge. That would allow us to remove the "@tef-novum/webview-bridge"
dependency from mistica package.json
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.
Ideally we should be able to inject the bridge function "as is" to the Root component.
Something like:
import {openBottomSheet} from '@tef-novum/webview-bridge`;
<BottomSheetRoot nativeImplementation={openBottomSheet} />
and the nativeImplementation
prop would be typed as typeof openBottomSheet
;
This way everything is tied, types are verified at compile time and we won't need a createNativeSheetImplementationFromWebviewBridge
.
Perhaps the bridge dependency could be listed as optionalDependency
. I think it would be a problem to fully decouple both implementations.
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.
hmmm... I see your point, but that would mean I'd need to re-implement the specific sheet methods in mistica (bottomSheetSingleSelector
, bottomSheetActionSelector
, bottomSheetInfo
, bottomSheetActions
)
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.
ok, I've moved these specific sheet methods from the bridge lib to mistica and removed them from webview-bridge (Telefonica/webview-bridge#115)
src/bottom-sheet-root.tsx
Outdated
type SheetPropsByType = { | ||
RADIO_LIST: SheetProps<{ | ||
selectedId?: string; | ||
items: Array<{ | ||
id: string; | ||
title?: string; | ||
description?: string; | ||
icon?: { | ||
size?: 'small' | 'large'; | ||
url: string; | ||
urlDark?: string; | ||
}; | ||
}>; | ||
}>; | ||
ACTIONS_LIST: SheetProps<{ | ||
items: Array<{ | ||
id: string; | ||
title: string; | ||
style?: 'normal' | 'destructive'; | ||
icon?: { | ||
url: string; | ||
urlDark?: string; | ||
}; | ||
}>; | ||
}>; | ||
INFO: SheetProps<{ | ||
items: Array<{ | ||
id: string; | ||
title: string; | ||
description?: string; | ||
icon: InfoIcon; | ||
}>; | ||
}>; | ||
ACTIONS: SheetProps<{ | ||
button: { | ||
text: string; | ||
}; | ||
secondaryButton?: { | ||
text: string; | ||
}; | ||
link?: { | ||
text: string; | ||
withChevron?: boolean; | ||
}; | ||
}>; |
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.
all this could be imported from the bridge, which should be the source of truth for this kind of components
> | ||
{React.Children.map(children, (child) => ( | ||
<div>{child}</div> | ||
<div role={role === 'list' ? 'listitem' : undefined}>{child}</div> |
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.
👍
transform: 'scale(1)', | ||
transform: 'none', |
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.
what motivated this change?
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.
scale(1) creates a new stacking context, that was affecting zindex inside sheet
src/bottom-sheet.tsx
Outdated
|
||
isDraggingRef.current = false; | ||
setDragDistance(0); | ||
if (dragDistance > 50 && (currentYRef.current > window.innerHeight * 0.75 || dragSpeed > 0.5)) { |
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.
Maybe 0.50 would be a better threshold (to close it you must drag a distance >= half the height)
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've been playing and I think the current values feel more natural, give it a try
I don't think so. It's already managed by |
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.
Using chrome iOS, it looks like when I scroll the sheet's content, it assumes I'm scrolling the sheet itself, but just for a few milliseconds. After that, it starts scrolling the content.
This happens only sometimes, seems unstable. I used this snippet in Playroom.
I couldn't reproduce this issue in desktop/android devices.
IMG_5784.MP4
hmmm... it's dificult to reproduce, maybe you tapped the grab zone with your finger? |
not really, If I take the Marcos's example and use sheetbody inside without title prop, the content do not respect the top padding Maybe we can solved this case using the same title padding for children when no props is added in SheetBody (?) |
What happens with scroll in those cases? |
I would solve it exactly the same way as in the dialogs (Is the Divider between title and extra defined in specs? I can't see it in specs) |
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.
🤩
# [14.21.0](v14.20.1...v14.21.0) (2023-08-24) ### Bug Fixes * **Cards:** remove min width from all the cards ([#858](#858)) ([029a6ea](029a6ea)) * **Tabs:** remove extra margin in safari ([#857](#857)) ([be8c2f2](be8c2f2)) ### Features * **FeedbackScreens:** updates in icons, paddings and styling ([#852](#852)) ([4b231e6](4b231e6)) * **Sheet:** new component ([#840](#840)) ([f03ca7c](f03ca7c)) * **utilities:** Remove lodash dependency and replace it with custom functions ([#856](#856)) ([dcaf691](dcaf691))
🎉 This PR is included in version 14.21.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
WEB-1492
Figma: https://www.figma.com/file/nxToAYk7FGC86TS0mY61TU/%F0%9F%94%B8-Sheet-specs?type=design&node-id=3346-16622&mode=design&t=AfsHntMnROCmNvcD-0
Webview bridge spec: https://confluence.tid.es/display/CTO/%5BAPPS%5D+Shared+Spec%3A+Bottom+Sheet+opened+from+Webview-Bridge