Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/Examples/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Examples",
"position": 3,
"link": {
"type": "generated-index",
"description": "Demos and Implementation Examples for SpringRoll"
}
}
6 changes: 6 additions & 0 deletions docs/Examples/game.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import GameDemo from '../../src/components/GameDemo'

# Game Demo

<GameDemo />

9 changes: 9 additions & 0 deletions docs/Examples/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 1
sidebar_label: Introduction
sidebar_class_name: green
---

# Introduction

This is a collection of examples for the SpringRoll toolset. Each example is a standalone project that demonstrates specific features.
10 changes: 10 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ const config: Config = {
position: 'left',
label: 'SpringRoll Container',
},
{
type: 'docSidebar',
sidebarId: 'examplesSidebar',
position: 'left',
label: 'Examples',
},
{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/SpringRoll',
Expand All @@ -98,6 +104,10 @@ const config: Config = {
label: 'SpringRoll Container',
to: '/docs/springroll-container/getting-started',
},
{
label: 'Examples',
to: '/docs/Examples/introduction',
},
],
},
{
Expand Down
48 changes: 47 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"sass": "^1.77.6"
"sass": "^1.77.6",
"springroll-container": "^2.5.2"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.4.0",
Expand Down
3 changes: 2 additions & 1 deletion sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure
springrollSidebar: [{type: 'autogenerated', dirName: 'springroll'}],
containerSidebar: [{type: 'autogenerated', dirName: 'springroll-container'}]
containerSidebar: [{type: 'autogenerated', dirName: 'springroll-container'}],
examplesSidebar: [{type: 'autogenerated', dirName: 'Examples'}]

// But you can create a sidebar manually
/*
Expand Down
52 changes: 52 additions & 0 deletions src/components/GameDemo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useEffect, JSX } from 'react';
import clsx from 'clsx';
import styles from './styles.module.scss';
import { Container } from 'springroll-container';
import Heading from '@theme/Heading';

/**
* Game Demo Component - Creates a springroll container and loads the demo game into it. Referenced in docs/Examples/game.mdx
* @returns JSX.Element
*/
export default function GameDemo(): JSX.Element {
// Instantiate the container and load the demo game after the component mounts
useEffect(() => {
const container = new Container('#demo-game', {
plugins: []
});

container.openPath('http://springroll.io/springroll-io-demo-game/');
}, []);
return (
<section className={styles.gameDemoRoot}>
<iframe id="demo-game" className={styles.gameContainer}></iframe>

<div className={styles.gameEvents}>
<Heading as="h2" className={clsx('hero__subtitle', styles.gameHeader)}>
Game Options
</Heading>

<button type="button" className={clsx('button button--primary', styles.gameOptionButton)}>
<span>Pause</span>
</button>
<button type="button" className={clsx('button button--primary', styles.gameOptionButton)}>
<span>Mute</span>
</button>
<button type="button" className={clsx('button button--primary', styles.gameOptionButton)}>
<span>Hint</span>
</button>


<Heading as="h2" className={clsx('hero__subtitle', styles.gameHeader)}>
Game Events
</Heading>

<div className={clsx('button button--secondary', styles.gameOptionButton)}>Localiztion</div>
<div className={clsx('button button--secondary', styles.gameOptionButton)}>Speech Synch</div>
<div className={clsx('button button--secondary', styles.gameOptionButton)}>Pause</div>
<div className={clsx('button button--secondary', styles.gameOptionButton)}>Sound Mute</div>
<div className={clsx('button button--secondary', styles.gameOptionButton)}>Captions Start</div>
</div>
</section>
);
}
40 changes: 40 additions & 0 deletions src/components/GameDemo/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.gameDemoRoot {
display: flex;
flex-direction: row;
align-items: flex-start;
width: 100%;
height:60vh;
}

.gameContainer {
background-color: #FFF !important;
height: 100%;
width: 100%;
}

.gameHeader {
margin-top: 1rem;
margin-bottom: 0;
}

.gameOptionButton {
height: 2.4rem;
width: 15rem;
display: flex;
justify-content: center;
align-items: center;
text-transform: capitalize;
margin: .26rem;
transition: background-color .25s;
}

.gameEvents {
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
text-align: center;
padding: 0;
margin: 0;
}