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 { _handleCreate = (detail) => { System.dispatchCustomEvent({ name: "create-carousel", detail: detail }); }; _handleDelete = () => { System.dispatchCustomEvent({ name: "delete-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

this._handleCreate({ slides: [ { src: "https://images.unsplash.com/photo-1428765048792-aa4bdde46fea?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1489&q=80", alt: "photo of grey and black ferris wheel during daytime", }, { src: "https://images.unsplash.com/photo-1503914068268-5413b35b45ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80", alt: "pink road bike", }, ].map((props) => ( )), }) } > Open carousel
While the Carousel component is always present, a carousel will only appear once you trigger it by creating a custom event with the title{" "} "create-carousel". It can be removed with a custom event entitled{" "} "delete-carousel".
{`class ExampleOne extends React.Component { _handleCreate = (detail) => { dispatchCustomEvent({ name: "create-carousel", detail: detail }); }; _handleDelete = () => { dispatchCustomEvent({ name: "delete-carousel", detail: {} }); }; render() { let carouselContent = [ { src: "https://images.unsplash.com/photo-1428765048792-aa4bdde46fea?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1489&q=80", alt: "photo of grey and black ferris wheel during daytime", }, { src: "https://images.unsplash.com/photo-1503914068268-5413b35b45ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80", alt: "pink road bike", }, ].map((props) => ); return ( this._handleCreate({ slides: carouselContent })} > 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: ( currentSlide ), b: ["number"], c: 0, d: "Index of the initial slide", }, ], }} />
); } }