Giter VIP home page Giter VIP logo

a-slides's Introduction

a-slides

Customisable slideshow scaffolding using Jekyll and Generators

Design philosphy

  • Minimalist to encourage running own Javascript inside generators to control slides
  • Extensible via plugins
  • provides minimal styling so addtional styling can be provided by slide author

How to use

As a github pages site:

An example site is in https://github.com/AdaRoseEdwards/a-slides/tree/master/jekyll-template it has two methods of creating slide content:

on it's own

  • include build/a-slides.js and build/a-slides.css in your page.
  • when the script is done it converts appropriate DOM into slides.
<div class="a-slides_slide-container">
	<div class="a-slides_slide active" data-slide-id="slide-id-for-deep-linking">
		<div class="dark a-slides_slide-content">
			Slide 1 Content goes here
		</div>
		<div class="a-slides_notes">
			Slide 1 Notes goes here
		</div>
	</div>
	<div class="a-slides_slide active" data-slide-id="slide-the-second-slide">
		<div class="dark a-slides_slide-content">
			Slide 2 Content goes here
		</div>
		<div class="a-slides_notes">
			Slide 2 Notes goes here
		</div>
	</div>
</div>

API:

Initialising

	const slideData = {'slide-id': {
		setup() {},
		action: function *() {
			this.appendChild(window.MAKE.markdown('# Hello'));
			yield;
			this.appendChild(window.MAKE.markdown('# World'));
		},
		teardown: {
			this.innerHTML = '';
		}
	}};

	new ASlides(slideData, {
		slideContainer: document.querySelector('.a-slides_slide-container'),
		plugins: [
			ASlides.prototype.plugins.markdownTransform, // needs to be run first
			ASlides.prototype.plugins.slideController, // needs to be run before buttons are added to it.
			ASlides.prototype.plugins.deepLinking,
			ASlides.prototype.plugins.interactionKeyboard,
			ASlides.prototype.plugins.interactionTouch({ // has configuration
				use: ['swipe-back']
			}),
			ASlides.prototype.plugins.bridgeServiceWorker,
			ASlides.prototype.plugins.bridgeWebRTC({ // PeerJS plugin so one slide controls the rest
				peerSettings: {
					host: 'example-peerjs-server.com',
					secure: true,
					port: 9000,
					debug: 2,
					path:"/peerjs"
				}
			})
		]
	});

	if (location.search === '?presentation') {
		slideContainer.classList.add('presentation');
	}

	if (location.search === '?notes') {
		slideContainer.classList.add('hide-presentation');
	}

Inbuilt Plugins

  • markdownTransform: .* Converts the content of any dom element with a class of '.marked' into html using markdown syntax.

  • slideController: .* Adds some buttons to the top of the screen for going in and out of presentation mode

  • deepLinking: .* If the url contains a hash which matches a slide-id that slide gets displayed on load

  • interactionKeyboard: .* Adds key controls for progressing to the next slide or going back to the previous

  • interactionTouch: .* So one can swipe forward or back to previous slides.

  • bridgeServiceWorker: .* Allows one open tab to control another so you can have notes on one display and the presentation on another. .* Requires a service worker set to echo some events, example:

	// Send a signal to all connected windows.
	// Used for service worker bridge in a-slides
	function reply(data) {
		return self.clients.matchAll({type: 'window'})
		.then(function (windows) {
			windows.forEach(function (w) {
				w.postMessage(data);
			});
		});
	}

	// Echo messages back to every window
	self.addEventListener('message', function(event) {
		reply(event.data);
	});
  • bridgeWebRTC: .* Uses the peer.js library to connect to and control another client via WebRTC. Requires an existing peer.js signaling server.

Animating slides

Slide animations are defined as such:

{'slide-id': {
	setup() {},
	action: function *() {
		this.appendChild(window.MAKE.markdown('# Hello'));
		yield;
		this.appendChild(window.MAKE.markdown('# World'));
	},
	teardown: {
		this.innerHTML = '';
	}
}}

Events

  • a-slides_slide-setup
  • a-slides_slide-show
  • a-slides_slide-teardown
  • a-slides_refresh-slide (fireable)
  • a-slides_next-slide (fireable)
  • a-slides_previous-slide (fireable)
  • a-slides_goto-slide (fireable)
// goto a slide by id or by dom element
slideContainer.fire('a-slides_goto-slide', {slide: 0});
slideContainer.fire('a-slides_goto-slide', {slide: document.querySelector('.a-slide')});

Writing plugins

Todo

Styling

Example SCSS file: jekyll-template/styles/slides.scss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.