diff --git a/index.html b/index.html
index e724a81..899a4e5 100644
--- a/index.html
+++ b/index.html
@@ -11,11 +11,14 @@
+
diff --git a/src/scenes/OverviewScene.ts b/src/scenes/OverviewScene.ts
index 80ef7ff..fea6373 100644
--- a/src/scenes/OverviewScene.ts
+++ b/src/scenes/OverviewScene.ts
@@ -35,12 +35,6 @@ export class OverviewScene {
store.setState({ currentScene: edge.scene });
}
});
-
- store.getState().addUserMessage({
- text: `Test Message ${Math.random()}`,
- inputWanted: false,
- timestamp: Date.now(),
- });
}
private drawLocations() {
diff --git a/src/scenes/scenes.ts b/src/scenes/scenes.ts
index 8aeef75..5083c73 100644
--- a/src/scenes/scenes.ts
+++ b/src/scenes/scenes.ts
@@ -1,4 +1,6 @@
export enum Scenes {
OVERVIEW = 'OVERVIEW',
LEGACY = 'LEGACY',
+ PACKAGES = 'PACKAGES',
+ CONTRIBUTORS = 'CONTRIBUTORS',
}
diff --git a/src/ui/companion.ts b/src/ui/companion.ts
index 0188e98..a58ca0b 100644
--- a/src/ui/companion.ts
+++ b/src/ui/companion.ts
@@ -34,6 +34,8 @@ export class Companion {
this.ref.addEventListener('mouseover', () => this.handleMouseEnter());
this.ref.addEventListener('mouseleave', () => this.handleMouseLeave());
+ this.messageButtonRef.addEventListener('click', () => this.confirmMessage());
+
this.pupilFollowCursor();
store.subscribe(
@@ -41,12 +43,16 @@ export class Companion {
if (companionState === CompanionState.ACTIVE) {
this.showActiveShape();
this.scaleUpCompanion();
+ this.stopAwaitAnimation();
+ this.showMessage(this.message);
} else if (companionState === CompanionState.IDLE) {
this.scaleDownCompanion();
this.showIdleShape();
+ this.stopAwaitAnimation();
} else if (companionState === CompanionState.AWAIT) {
this.playAwaitAnimation();
} else if (companionState === CompanionState.SUCCESS) {
+ this.stopAwaitAnimation();
this.playSuccessAnimation();
this.scaleDownCompanion();
this.showIdleShape();
@@ -59,7 +65,9 @@ export class Companion {
(messages: CompanionMessage[], prevMessages: CompanionMessage[]) => {
if (prevMessages.length !== messages.length) {
const newMessage = messages[messages.length - 1];
- this.showMessage(newMessage);
+ this.message = newMessage;
+
+ store.setState({ companionState: CompanionState.AWAIT });
}
},
(state) => state.userMessages
@@ -68,18 +76,28 @@ export class Companion {
showMessage(message: CompanionMessage) {
this.messageTextRef.innerText = message.text;
+ this.messageRef.style.display = 'flex';
if (message.inputWanted) {
this.messageInputRef.style.display = 'block';
-
- // TODO: Get text from textarea and log it on confirm, hide button after click on confirm as well
} else {
this.messageInputRef.style.display = 'none';
-
- // TODO: Hide message on confirm click, log time looked at message
}
}
+ confirmMessage() {
+ console.log(this.message);
+
+ if (this.message.inputWanted) {
+ // Get text from textarea
+ // Send via API
+ }
+
+ // Hide Message
+ store.setState({ companionState: CompanionState.IDLE });
+ this.messageRef.style.display = 'none';
+ }
+
showActiveShape() {
const mouth = document.getElementById('companion-mouth');
mouth.style.opacity = '100%';
@@ -130,7 +148,28 @@ export class Companion {
playSuccessAnimation() {}
- playAwaitAnimation() {}
+ playAwaitAnimation() {
+ document.getElementById('companion-await-indicator').style.display = 'inline';
+ anime({
+ targets: '#companion-await-indicator',
+ keyframes: [
+ { scale: 4, opacity: 0, rotate: '45deg', duration: 900 },
+ { scale: 5, duration: 200 },
+ ],
+ easing: 'easeOutQuad',
+ duration: 900,
+ loop: true,
+ });
+ }
+
+ stopAwaitAnimation() {
+ const indicator = document.getElementById('companion-await-indicator');
+ indicator.style.display = 'none';
+ indicator.style.opacity = '1';
+ indicator.style.transform = 'scale(1) rotate(0)';
+
+ anime.remove('#companion-await-indicator');
+ }
pupilFollowCursor() {
document.addEventListener('mousemove', (e) => {
diff --git a/styles.scss b/styles.scss
index 4e75290..0a41b0b 100644
--- a/styles.scss
+++ b/styles.scss
@@ -45,6 +45,13 @@ button {
width: 40px;
}
+ #companion-await-indicator {
+ height: 40px;
+ width: 40px;
+ position: absolute;
+ right: 0;
+ }
+
#companion-mouth {
position: absolute;
z-index: 2;
@@ -81,6 +88,7 @@ button {
}
#message {
+ display: none;
position: absolute;
right: 60px;
bottom: 50px;
@@ -89,7 +97,6 @@ button {
border-radius: 10px;
background-color: white;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
- display: flex;
flex-direction: column;
min-width: 70%;