import * as React from "react"; import * as Constants from "~/common/constants"; import * as System from "~/components/system"; import CodeBlock from "~/components/system/CodeBlock"; import Group from "~/components/system/Group"; import SystemPage from "~/components/system/SystemPage"; import ViewSourceLink from "~/components/system/ViewSourceLink"; export default class SystemPageCarousel extends React.Component { componentDidMount() { const style = { maxHeight: "80%", maxWidth: "80%", display: "block" }; System.dispatchCustomEvent({ name: "slate-global-create-carousel", detail: { slides: [ { component: ( ), }, { component: ( ), }, ], }, }); } _handleOpen = (detail) => { System.dispatchCustomEvent({ name: "slate-global-open-carousel", detail: detail, }); }; _handleClose = () => { System.dispatchCustomEvent({ name: "slate-global-close-carousel", detail: {}, }); }; render() { return ( Carousel

The carousel component is used to display multiple images.


Imports

Import React and the Carousel Component, as well as the dispatchCustomEvent function.
{`import * as React from "react"; import { GlobalCarousel, dispatchCustomEvent } from "slate-react-system";`}


Usage

Declare the component at the root level of your document (e.g. in index.js or App.js) so it is accessible throughout and will not get buried in the DOM tree.
Optionally, use style to style the background.
{`class App extends React.Component { render() { return ( {this.props.children} ); } }`}


Carousel

Open carousel
{`class ExampleOne extends React.Component { componentDidMount() { // NOTE(jim): // The global carousel component takes an array of JSX elements // You can style them however you like. const style = { maxHeight: "80%", maxWidth: "80%", display: "block" }; const slides = [ {component: }, {component: } ]; System.dispatchCustomEvent({ name: "slate-global-create-carousel", detail: { slides }, }); } _handleOpen = () => { dispatchCustomEvent({ name: "slate-global-open-carousel" detail: { index: 0 } }); }; _handleClose = () => { dispatchCustomEvent({ name: "slate-global-close-carousel" }); }; render() { return ( Open Carousel ); } }`}


Accepted React Properties




Accepted Create Carousel Properties

Note that these properties are passed through a custom event rather than as react properties.
slides ), b: ["Component[]", "Component"], c: "null", d: "Components to be rendered inside the carousel", }, { id: 2, a: ( index ), b: ["number"], c: 0, d: "Index of the initial slide", }, ], }} />
); } }