Sheet Modal - 图1

Sheet Modal React Component

Sheet Modal is a special overlay type which is similar to Picker/Calendar’s overlay. Such modal allows to create custom picker overlays with custom content.

Sheet Modal React component represents Sheet Modal component.

Sheet Modal Components

There are following components included:

  • **Sheet** / **F7Sheet** - sheet modal element

Sheet Modal Properties

PropTypeDescription
<Sheet> properties
backdropbooleanEnable to render additional sheet modal backdrop when required
openedbooleanAllows to open/close Sheet Modal and set its initial state
closeByBackdropClickbooleanWhen enabled, sheet will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClickbooleanWhen enabled, sheet will be closed on when click outside of it. By default inherits same app parameter value

Sheet Modal Methods

<Sheet> methods
.open(animate)Open sheet modal
.close(animate)Close sheet modal

Sheet Modal Events

EventDescription
<Sheet> events
sheetOpenEvent will be triggered when Sheet Modal starts its opening animation
sheetOpenedEvent will be triggered after Sheet Modal completes its opening animation
sheetCloseEvent will be triggered when Sheet Modal starts its closing animation
sheetClosedEvent will be triggered after Sheet Modal completes its closing animation

Open And Close Sheet Modal

You can control Sheet Modal state, open and closing it:

  • using its Sheet Modal API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant sheetOpen property (to open it) and sheetClose property to close it

Access To Sheet Modal Instance

You can access Sheet Modal initialized instance by accessing **.f7Sheet** component’s property.

Examples

  1. export default class extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. sheetOpened: false,
  6. };
  7. }
  8. render() {
  9. return (
  10. <Page onPageBeforeOut={this.onPageBeforeOut.bind(this)} onPageBeforeRemove={this.onPageBeforeRemove.bind(this)}>
  11. <Navbar title="Sheet Modal"></Navbar>
  12. <Block>
  13. <Row tag="p">
  14. <Button className="col" raised sheetOpen=".demo-sheet">Open Sheet</Button>
  15. <Button className="col" raised onClick={this.createSheet.bind(this)}>Create Dynamic Sheet</Button>
  16. </Row>
  17. <p>
  18. <Button className="col" raised onClick={() => {this.setState({sheetOpened: true})}}>Open Via Prop Change</Button>
  19. </p>
  20. </Block>
  21. <Sheet className="demo-sheet" opened={this.state.sheetOpened} onSheetClosed={() => {this.setState({sheetOpened: false})}}>
  22. <Toolbar>
  23. <div className="left"></div>
  24. <div className="right">
  25. <Link sheetClose>Close</Link>
  26. </div>
  27. </Toolbar>
  28. {/* Scrollable sheet content */}
  29. <PageContent>
  30. <Block>
  31. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae ducimus dolorum ipsa aliquid accusamus perferendis laboriosam delectus numquam minima animi, libero illo in tempora harum sequi corporis alias ex adipisci.</p>
  32. <p>Sunt magni enim saepe quasi aspernatur delectus consectetur fugiat necessitatibus qui sed, similique quis facere tempora, laudantium quae expedita ea, aperiam dolores. Aut deserunt soluta alias magnam. Consequatur, nisi, enim.</p>
  33. <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab. Quaerat quasi consectetur quidem libero? Repudiandae adipisci vel voluptatum, autem libero minus dignissimos repellat.</p>
  34. <p>Iusto, est corrupti! Totam minus voluptas natus esse possimus nobis, delectus veniam expedita sapiente ut cum reprehenderit aliquid odio amet praesentium vero temporibus obcaecati beatae aspernatur incidunt, perferendis voluptates doloribus?</p>
  35. <p>Illum id laborum tempore, doloribus culpa labore ex iusto odit. Quibusdam consequuntur totam nam obcaecati, enim cumque nobis, accusamus, quos voluptates, voluptatibus sapiente repellendus nesciunt praesentium velit ipsa illo iusto.</p>
  36. </Block>
  37. </PageContent>
  38. </Sheet>
  39. </Page>
  40. );
  41. }
  42. createSheet() {
  43. const self = this;
  44. const $ = self.$$;
  45. // Create sheet modal
  46. if (!self.sheet) {
  47. self.sheet = self.$f7.sheet.create({
  48. content: `
  49. <div class="sheet-modal">
  50. <div class="toolbar">
  51. <div class="toolbar-inner justify-content-flex-end">
  52. <a href="#" class="link sheet-close">Close</a>
  53. </div>
  54. </div>
  55. <div class="sheet-modal-inner">
  56. <div class="page-content">
  57. <div class="block">
  58. <p>This sheet modal was created dynamically</p>
  59. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non. Ut leo mauris, eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus, viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatis dignissim. Suspendisse non nisl semper tellus malesuada suscipit eu et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare consequat nunc viverra pellentesque. Aenean semper eu massa sit amet aliquam. Integer et neque sed libero mollis elementum at vitae ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibus lectus.</p>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. `.trim(),
  65. });
  66. }
  67. // Close inline sheet
  68. if ($('.demo-sheet.modal-in').length > 0) self.$f7.sheet.close('.demo-sheet');
  69. // Open it
  70. self.sheet.open();
  71. }
  72. onPageBeforeOut() {
  73. const self = this;
  74. // Close opened sheets on page out
  75. self.$f7.sheet.close();
  76. }
  77. onPageBeforeRemove() {
  78. const self = this;
  79. // Destroy sheet modal when page removed
  80. if (self.sheet) self.sheet.destroy();
  81. }
  82. };