Implementation
Được sử dụng để hiển thị thông tin bổ sung hoặc để người dùng thực hiện một số hành động phụ liên quan đến nội dung chính trên màn hình, tiếp tục sử dụng tiếp một tính năng của ứng dụng
Properties
Sheet
Name | Type | Default | Description | Minimum Version |
---|---|---|---|---|
mask | boolean | Hiển thị mask khi show sheet | ||
afterClose | function | Function gọi sai khi close sheet | ||
onClose | function | Function gọi khi close sheet | ||
maskClosable | boolean | Đóng sheet khi click bào mask | ||
visible | boolean | Hiển thị sheet modal | ||
unmountOnClose | boolean | false | Unmount sau khi đóng sheet modal | 1.6.0 |
title | string | Title của sheet modal | ||
modalStyle | React.CSSProperties | Style modal | ||
maskStyle | React.CSSProperties | Style mask | ||
modalClassName | string | Modal class name | ||
maskClassName | string | Mask class name | ||
width | string | number | Sheet width | ||
height | string | number | Sheet height | ||
description | string | Sheet description | ||
children | React.ReactNode | Nội dung sheet | ||
zIndex | number | Giá trị z-index của modal | ||
handler | boolean | Sheet handler | ||
autoHeight | boolean | false | Chiều cao của sheet ôm theo content | |
swipeToClose | boolean | Vuốt xuống để đóng sheet modal | ||
snapPoints | number[] | ({sheetModalHeight}) => number[] | Các snap points là vị trí của action sheet tính theo thuộc tính bottom css
| ||
defaultSnapPoint | number | Index của snapPoints mặc định khi mở sheet modal | ||
onSnap | (snapPoint: number) => void | callback function khi expand/collapse đến một snap point mới | ||
ref | SheetRef | Sheet modal ref |
Type
SheetRef
Name | Type | Default | Description |
---|---|---|---|
sheet | HTMLDivElement | Sheet modal element | |
snapTo | (index: number)=> void | Expand/collapse Sheet modal đến snap point cụ thể trong snapPoints đã khai báo |
Sheet.Action
Name | Type | Default | Description |
---|---|---|---|
divider | boolean | Có divider giữa các action | |
actions | ActionButton[] | Danh sách các action | |
groupDivider | boolean | Có divider giữa các group action |
ActionButton
Name | Type | Default | Description |
---|---|---|---|
highLight | boolean | Nếu giá trị là true action sẽ có kiểu highlight | |
danger | boolean | Nếu giá trị là true action sẽ có kiểu danger | |
onClick | function | Function sẽ được gọi khi click action | |
close | boolean | Action sau khi click sẽ close modal | |
disabled | boolean | Disable action |
Example
import React, { useRef, useState } from "react"; import { Button, Sheet, Text, Box, Page } from "zmp-ui"; export default function Demo() { const [sheetVisible, setSheetVisible] = useState(false); const [actionSheetVisible, setActionSheetVisible] = useState(false); return ( <Page className='section-container'> <Text.Title size='small'>Bottom Sheet</Text.Title> <Box mt={4}> <Button variant='secondary' fullWidth onClick={() => { setActionSheetVisible(true); }} > Bottom Action Sheet </Button> </Box> <Box mt={4}> <Button variant='secondary' fullWidth onClick={() => { setSheetVisible(true); }} > Custom Bottom Sheet </Button> </Box> <Sheet visible={sheetVisible} onClose={() => setSheetVisible(false)} autoHeight mask handler swipeToClose > <Box p={4} className='custom-bottom-sheet' flex flexDirection='column'> <Box className='bottom-sheet-cover'> <img alt='Bottom Sheet' src={""} /> </Box> <Box my={4}> <Text.Title> Cho phép Starbucks Coffee xác định vị trí của bạn </Text.Title> </Box> <Box className='bottom-sheet-body' style={{ overflowY: "auto" }}> <Text> Starbucks Coffee sẽ sử dụng vị trí của bạn để hỗ trợ giao nhận hàng, tìm kiếm dịch vụ, bạn bè quanh bạn, hoặc các dịch vụ liên quan đến địa điểm khác. </Text> </Box> <Box flex flexDirection='row' mt={1}> <Box style={{ flex: 1 }} pr={1}> <Button fullWidth variant='secondary' onClick={() => { setSheetVisible(false); }} > Để sau </Button> </Box> <Box style={{ flex: 1 }} pl={1}> <Button fullWidth onClick={() => { setSheetVisible(false); }} > Cho phép </Button> </Box> </Box> </Box> </Sheet> <Sheet.Actions mask visible={actionSheetVisible} title='This is title, it can be one line or two line' onClose={() => setActionSheetVisible(false)} swipeToClose actions={[ [ { text: "Sample Menu", close: true }, { text: "Sample Menu", close: true }, { text: "Negative Menu", danger: true, close: true } ], [{ text: "Cancel", close: true }] ]} /> </Page> ); }