Skip to content

Commit 34b46be

Browse files
committed
fix(tutorial): create "new tutorial v1"
- HTML Tutorial is all information and videos for onboarding and feature presentations, - The launcher is html iframe to launch the integration user experience within WorkAdventure. This application will be set in our back office administration and available to WorkAdventure customers.
1 parent f7ebbc0 commit 34b46be

31 files changed

+8831
-5983
lines changed

.eslintignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
dist/
2-
jest.config.js
2+
jest.config.js
3+
tailwind.config.js
4+
tailwind.config.cjs
5+
postcss.config.js

.eslintrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"extends": "@rpidanny/eslint-config-typescript"
2+
"extends": "@rpidanny/eslint-config-typescript",
3+
"rules": {
4+
"no-unused-vars": "off",
5+
"simple-import-sort/imports": "off",
6+
"arrow-parens": "off",
7+
"camelcase": "off",
8+
"no-throw-literal": "error"
9+
}
310
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Features
2+
3+
* **tutorialv1:** create "new tutorial v1" ([6cf1e80](https://github.com/workadventure/scripting-api-extra/commit/6cf1e8053da44f2b8229fa6938c8c2da48ac74c8))
4+
15
## [1.3.3](https://github.com/workadventure/scripting-api-extra/compare/v1.3.2...v1.3.3) (2022-07-06)
26

37

package-lock.json

Lines changed: 8433 additions & 5961 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@workadventure/scripting-api-extra",
3-
"version": "1.3.3",
3+
"version": "1.4.0",
44
"description": "A set of utility functions / features to improve WorkAdventure maps",
55
"main": "dist/index.js",
66
"types": "dist/index.d.js",
@@ -47,20 +47,23 @@
4747
]
4848
},
4949
"devDependencies": {
50+
"@16bits/nes.css": "^2.3.2",
5051
"@commitlint/cli": "^13.1.0",
5152
"@commitlint/config-conventional": "^13.1.0",
5253
"@rpidanny/eslint-config-typescript": "^1.0.0",
5354
"@semantic-release/changelog": "^5.0.1",
5455
"@semantic-release/commit-analyzer": "^8.0.1",
5556
"@semantic-release/git": "^9.0.0",
5657
"@semantic-release/npm": "^7.1.0",
58+
"@tailwindcss/forms": "^0.5.3",
5759
"@tsconfig/svelte": "^2.0.1",
5860
"@types/copy-webpack-plugin": "^8.0.1",
5961
"@types/jest": "^27.0.1",
6062
"@types/mini-css-extract-plugin": "^2.2.0",
6163
"@types/mustache": "^4.1.2",
6264
"@types/webpack-dev-server": "^4.1.0",
6365
"@workadventure/iframe-api-typings": "^1.7.2",
66+
"autoprefixer": "^10.4.8",
6467
"copy-webpack-plugin": "^9.0.1",
6568
"cross-env": "^7.0.3",
6669
"css-loader": "^5.2.4",
@@ -73,6 +76,7 @@
7376
"mini-css-extract-plugin": "^2.2.2",
7477
"node-polyfill-webpack-plugin": "^1.1.2",
7578
"npm-run-all": "^4.1.5",
79+
"postcss": "^8.4.16",
7680
"prettier": "^2.0.5",
7781
"sass": "^1.32.12",
7882
"sass-loader": "^12.1.0",
@@ -81,6 +85,7 @@
8185
"svelte-check": "^2.1.0",
8286
"svelte-loader": "^3.1.1",
8387
"svelte-preprocess": "^4.7.3",
88+
"tailwindcss": "^3.1.8",
8489
"ts-jest": "^26.1.4",
8590
"ts-loader": "^9.2.5",
8691
"ts-node": "^10.1.0",
@@ -99,10 +104,12 @@
99104
},
100105
"unpkg": "dist/bundle.js",
101106
"dependencies": {
102-
"@fontsource/press-start-2p": "^4.5.0",
107+
"@fontsource/press-start-2p": "^4.5.10",
108+
"@workadventure-style/sweetsky": "^1.0.2",
103109
"@workadventure/tiled-map-type-guard": "^2.0.4",
104110
"mustache": "^4.2.0",
105111
"nes.css": "^2.3.0",
106-
"play-dtmf": "^0.1.1"
112+
"play-dtmf": "^0.1.1",
113+
"postcss-loader": "^7.0.1"
107114
}
108115
}

postcss.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const postcssConfig = require("@workadventure-style/sweetsky/postcss.config");
2+
module.exports = postcssConfig;
2.98 MB
Loading
1.86 MB
Loading
2.45 MB
Loading
2.98 MB
Loading
2.81 MB
Loading
937 KB
Loading

src/Features/configuration.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Properties } from "../Properties";
2-
import type { ITiledMap } from "@workadventure/tiled-map-type-guard/dist";
2+
import type { ITiledMap, ITiledMapLayer } from "@workadventure/tiled-map-type-guard/dist";
33
import { defaultAssetsUrl } from "./default_assets_url";
44
import { getLayersMap } from "../LayersFlattener";
55
import { openConfig } from "../VariablesExtra";
6-
import type { ITiledMapLayer } from "@workadventure/tiled-map-type-guard/dist";
76
import type { ActionMessage } from "@workadventure/iframe-api-typings/Api/iframe/Ui/ActionMessage";
87

98
let layersMap!: Map<string, ITiledMapLayer>;
@@ -12,7 +11,7 @@ let layersMap!: Map<string, ITiledMapLayer>;
1211
* Initialize the configuration button in the menu
1312
*/
1413
export async function initConfiguration(assetsUrl?: string | undefined): Promise<void> {
15-
const map: ITiledMap = await WA.room.getTiledMap();
14+
const map: ITiledMap = (await WA.room.getTiledMap()) as ITiledMap;
1615
assetsUrl = assetsUrl ?? defaultAssetsUrl;
1716
layersMap = await getLayersMap();
1817
const configurationLayer = map.layers.find((layer) => layer.name === "configuration");

src/Features/tutorial.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { WasCameraUpdatedEvent } from "@workadventure/iframe-api-typings/Api/Events/WasCameraUpdatedEvent";
22
import { desktopConfig, mobileConfig } from "../Iframes/Tutorial/config/config";
3-
import type { ITiledMapProperty } from "@workadventure/tiled-map-type-guard/dist";
43
import type { Position } from "@workadventure/iframe-api-typings/Api/iframe/player";
54
import type { CreateEmbeddedWebsiteEvent } from "@workadventure/iframe-api-typings/Api/Events/EmbeddedWebsiteEvent";
65
import { defaultAssetsUrl } from "./default_assets_url";
@@ -9,9 +8,7 @@ export async function initTutorial(): Promise<void> {
98
const tutorialDone = WA.player.state.tutorialDone;
109
const isForMobile = /Mobi|Android/i.test(navigator.userAgent);
1110
const map = await WA.room.getTiledMap();
12-
const tutorialProperty = await map.properties?.find(
13-
(property: ITiledMapProperty) => property.name === "tutorial",
14-
);
11+
const tutorialProperty = await map.properties?.find((property) => property.name === "tutorial");
1512
const isTutorialEnabled = tutorialProperty && tutorialProperty.value;
1613

1714
if (!tutorialDone && isTutorialEnabled) {

src/Iframes/Configuration/Components/Section.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
{#if $currentPage !== 'configuration' }
1515
<div class="left mb-20">
16-
<button class="nes-btn" on:click={() => { $currentPage = $currentPage.substr(0, $currentPage.indexOf('/')) }}>&lt; Back</button>
16+
<button class="nes-btn" on:click={() => { $currentPage = $currentPage.substring(0, $currentPage.indexOf('/')) }}>&lt; Back</button>
1717
</div>
1818
{/if}
1919

src/Iframes/Configuration/Components/Sections.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div>
1818

1919
{#if $currentPage !== 'configuration' }
20-
<button class="nes-btn" on:click={() => { $currentPage = $currentPage.substr(0, $currentPage.indexOf('/')) }}>Back</button>
20+
<button class="nes-btn" on:click={() => { $currentPage = $currentPage.substring(0, $currentPage.indexOf('/')) }}>Back</button>
2121
{/if}
2222

2323
<style lang="scss">

src/Iframes/Configuration/Stores/LayersStore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { derived, Readable } from "svelte/store";
2-
import type { ITiledMap, ITiledMapLayer } from "@workadventure/tiled-map-type-guard/dist";
2+
import type { ITiledMapLayer } from "@workadventure/tiled-map-type-guard/dist";
33
import { currentPage } from "./NavigationStore";
44

55
// TODO: add a store for all layers flattened
@@ -10,9 +10,9 @@ export const configurationLayerStore = derived<Readable<string>, ITiledMapLayer
1010
($currentPage, set) => {
1111
WA.room
1212
.getTiledMap()
13-
.then((tiledMap: ITiledMap) => {
13+
.then((tiledMap) => {
1414
const configurationLayer = tiledMap.layers.find(
15-
(layer: ITiledMapLayer) => layer.name === "configuration",
15+
(layer) => layer.name === "configuration",
1616
);
1717

1818
if (configurationLayer === undefined) {
@@ -21,7 +21,7 @@ export const configurationLayerStore = derived<Readable<string>, ITiledMapLayer
2121
);
2222
}
2323

24-
set(findLayer($currentPage, configurationLayer));
24+
set(findLayer($currentPage, configurationLayer as ITiledMapLayer));
2525
})
2626
.catch((e) => console.error(e));
2727
},
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defaultAssetsUrl } from "../../../Features/default_assets_url";
2+
3+
console.info("Onboarding script initialized!");
4+
document.addEventListener("DOMContentLoaded", () => {
5+
const tutoUrl = `${
6+
defaultAssetsUrl !== "" ? defaultAssetsUrl : "http://extra.workadventure.localhost"
7+
}/tutorialv1.html`;
8+
console.info("Start onboarding application!", tutoUrl);
9+
10+
if (WA.player.state.tutorialDone) return;
11+
12+
//TODO delete @ts-ignore when new scripting release is up
13+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
14+
// @ts-ignore
15+
WA.ui.modal.openModal({
16+
src: tutoUrl,
17+
allow: "fullscreen; clipboard-read; clipboard-write",
18+
allowApi: true,
19+
});
20+
});
21+
22+
export {};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Tutotrial</title>
5+
<script src="<%= workadventure_url %>/iframe_api.js" ></script>
6+
</head>
7+
<body class="tw-bg-dark-purple/95">
8+
Tutu v1 script launcher
9+
</body>
10+
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script lang="ts">
2+
import { currentStepStore, steps } from "../Store/StepStore";
3+
import Step from "./Step.svelte";
4+
import Steps from "./Steps.svelte";
5+
6+
function close(){
7+
WA.player.state.tutorialDone = true;
8+
//TODO delete @ts-ignore when new scripting release is up
9+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
10+
// @ts-ignore
11+
WA.ui.modal.closeModal();
12+
}
13+
</script>
14+
15+
<div class="tuto tw-h-full tw-text-center tw-bg-dark-purple/95">
16+
<Steps
17+
on:close={close}
18+
on:skip={close}
19+
>
20+
{#each steps as step, index}
21+
{#if $currentStepStore === (index+1)}
22+
<Step
23+
title={step.title}
24+
videoUrl={step.videoUrl}
25+
videoPoster={step.videoPoster}
26+
description={step.description}
27+
shortTiltle={step.shortTiltle}
28+
/>
29+
{/if}
30+
{/each}
31+
</Steps>
32+
</div>
33+
<style>
34+
.tuto{
35+
min-width: 500px;
36+
}
37+
</style>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script lang="ts">
2+
export let title: string;
3+
export let shortTiltle: string;
4+
export let videoUrl: string;
5+
export let videoPoster: string;
6+
export let description: string;
7+
</script>
8+
<div class="ste tw-px-16 tw-py-5 tw-overflow-y-scroll">
9+
<div class="title tw-text-white">
10+
<h1 class="tw-p-3">{title}</h1>
11+
<p class="tw-p-3">{shortTiltle}</p>
12+
</div>
13+
<div class="video">
14+
<video class="tw-w-full tw-rounded-lg"
15+
poster={videoPoster}
16+
controls
17+
autoplay
18+
muted
19+
>
20+
<track kind="captions">
21+
<source src={videoUrl} type="video/mp4">
22+
Video not available in your navigator
23+
</video>
24+
</div>
25+
<div class="description tw-p-3 tw-mb-16 tw-text-left tw-text-white tw-pb-20">
26+
{@html description}
27+
</div>
28+
</div>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<script lang="ts">
2+
import { createEventDispatcher } from "svelte";
3+
import { currentStepStore, steps } from "../Store/StepStore";
4+
5+
const dispatch = createEventDispatcher();
6+
7+
function next(){
8+
if($currentStepStore === steps.length)return;
9+
currentStepStore.set($currentStepStore + 1);
10+
}
11+
function previous(){
12+
if($currentStepStore === 1)return;
13+
currentStepStore.set($currentStepStore - 1);
14+
}
15+
function close(){
16+
dispatch('close');
17+
}
18+
function skip(){
19+
dispatch('skip');
20+
}
21+
</script>
22+
<div class="body">
23+
<slot></slot>
24+
25+
<div class="progress-bar">
26+
</div>
27+
</div>
28+
<div class="footer tw-p-3 tw-bg-medium-purple tw-flex tw-justify-around tw-fixed tw-bottom-0 tw-w-full tw-overflow-y-hidden tw-overflow-x-auto tw-flex-wrap tw-overflow-visible">
29+
<div class="elispes tw-bg-medium-purple/60 tw-absolute tw-w-full -tw-top-10 tw-flex tw-flex-row tw-justify-center tw-align-middle">
30+
{#each steps as _, i}
31+
<span class="elispe {(i+1) === $currentStepStore ? 'tw-bg-light-blue' : 'tw-bg-lighter-purple'}"></span>
32+
{/each}
33+
</div>
34+
<button class="btn {$currentStepStore === 1 ? 'disabled' : 'light outline'} tw-w-1/3 tw-justify-center tw-mx-6 tw-relative tw-cursor-pointer" on:click|stopPropagation={previous}>
35+
<span class="tw-px-4 tw-absolute tw-left-4">&lt;</span> Previous
36+
</button>
37+
{#if $currentStepStore === steps.length}
38+
<button class="btn light tw-w-1/3 tw-justify-center tw-mx-6 tw-relative tw-cursor-pointer" on:click|stopPropagation={close}>
39+
Finish
40+
</button>
41+
{:else}
42+
<button class="btn light tw-w-1/3 tw-justify-center tw-mx-6 tw-relative tw-cursor-pointer" on:click|stopPropagation={next}>
43+
Next
44+
<span class="tw-px-4 tw-absolute tw-right-4">></span>
45+
</button>
46+
{/if}
47+
<button class="btn blue-title tw-underline tw-decoration-light-blue tw-cursor-pointer" on:click|stopPropagation={skip}>
48+
Skip all
49+
</button>
50+
</div>
51+
<style lang="scss">
52+
.footer{
53+
overflow: visible;
54+
button{
55+
max-height: 40px;
56+
&:nth-child(1){
57+
min-width: 160px;
58+
max-width: 180px;
59+
}
60+
&:nth-child(2){
61+
min-width: 150px;
62+
max-width: 170px;
63+
}
64+
}
65+
}
66+
.elispes{
67+
height: 40px;
68+
.elispe{
69+
width: 15px;
70+
height: 15px;
71+
border-radius: 99%;
72+
margin: 6px;
73+
}
74+
}
75+
</style>

0 commit comments

Comments
 (0)