diff --git a/src/components/feedbackWidget/feedbackWdget.tsx b/src/components/feedbackWidget/feedbackWdget.tsx index 2bc5607..1aeea92 100644 --- a/src/components/feedbackWidget/feedbackWdget.tsx +++ b/src/components/feedbackWidget/feedbackWdget.tsx @@ -10,11 +10,6 @@ import { Component, h, getAssetPath, State, Prop, Element } from '@stencil/core' export class FeedbackWidget { @Element() el; - @State() angryEmoji = "emojiAngry.png"; - @State() emojiHeartEyes = "emojiHeartEyes.png"; - @State() emojiNeutral = "emojiNeutral.png"; - @State() emojiSad = "emojiSad.png"; - @State() emojiSmile = "emojiSmile.png"; @Prop() appName = "Product" @State() quetionsArray = []; @State() feedBackData = []; @@ -24,6 +19,7 @@ export class FeedbackWidget { @State() phaseEnd: boolean = false; @State() textAreaIsActive: boolean = false; @State() textAreaData: string = "" + @State() isCompact: boolean = true; private questionOne = `How satisfied are you with the ${this.appName}'s value for money?` private questionTwo = `How satisfied are you with ${this.appName}'s ease of use?` @@ -33,6 +29,7 @@ export class FeedbackWidget { componentWillLoad() { this.quetionsArray.push(this.questionOne, this.questionTwo, this.questionThree, this.questionFour) + this.checkCookie() } handleProgressBar() { @@ -56,10 +53,9 @@ export class FeedbackWidget { this.phaseTwo = true; this.phaseOne = false; } - + this.handleProgressBar() this.feedBackData.push({question: this.quetionsArray[this.qIndex], rate: e.target.alt}) } - this.handleProgressBar() } userInputText(e) { @@ -96,62 +92,123 @@ export class FeedbackWidget { } handleClosure() { - this.el.remove() + //this.el.remove() + this.isCompact = true; + } + + handleSameUser() { + + } + + handleCompactContainer() { + this.isCompact = false; + } + + setCookie(cname, cvalue, exdays) { + const d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + let expires = "expires="+d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; + } + + getCookie(cname) { + let name = cname + "="; + let ca = document.cookie.split(';'); + for(let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) == ' ') { + c = c.substring(1); + } + if (c.indexOf(name) == 0) { + return c.substring(name.length, c.length); + } + } + return ""; + } + + checkCookie() { + let user = this.getCookie("username"); + if (user != "") { + console.log('welcome back', user) + this.handleSameUser() + } else { + for(let i = 0; i < 19; ++i) user += Math.floor(Math.random() * 10); + if (user != "" && user != null) { + this.setCookie("username", user, 365); + } + } } + + render() { - const angryEmoji = getAssetPath(`../../assets/${this.angryEmoji}`); - const emojiHeartEyes = getAssetPath(`../../assets/${this.emojiHeartEyes}`); - const emojiNeutral = getAssetPath(`../../assets/${this.emojiNeutral}`); - const emojiSad = getAssetPath(`../../assets/${this.emojiSad}`); - const emojiSmile = getAssetPath(`../../assets/${this.emojiSmile}`); + const angryEmoji = getAssetPath(`../../assets/emojiAngry.png`); + const emojiHeartEyes = getAssetPath(`../../assets/emojiHeartEyes.png`); + const emojiNeutral = getAssetPath(`../../assets/emojiNeutral.png`); + const emojiSad = getAssetPath(`../../assets/emojiSad.png`); + const emojiSmile = getAssetPath(`../../assets/emojiSmile.png`); return ( -
-
- {/*
Your feedback matters!
*/} -
-
+ this.isCompact + ?
this.handleCompactContainer()}> +
+

Feedback

+
+
-
this.handleClosure()}> - +
+
+ :
+
+ {/*
Your feedback matters!
*/} +
+
+
+
this.handleClosure()}> + +
+
+
+
+
+ {this.quetionsArray[this.qIndex]} +
+
this.handleQuestionChange(e)}> + angry + sad + neutral + smile + happy +
+
+
Poor
+
Excellent
-
-
-
- {this.quetionsArray[this.qIndex]} -
-
this.handleQuestionChange(e)}> - angry - sad - neutral - smile - happy -
-
-
Poor
-
Excellent
-
+
+
+ {this.questionFive}
-
-
- {this.questionFive} -
-
-

Answer required

- -
-
- -
+
+

Answer required

+
-
- Thank you for taking part in our survey +
+
+
+ Thank you for taking part in our survey +
+
); } + + static insertWidget() { + const widget = document.createElement('ifx-feedback-widget'); + document.body.appendChild(widget); + } + } \ No newline at end of file diff --git a/src/components/feedbackWidget/feedbackWidget.css b/src/components/feedbackWidget/feedbackWidget.css index 8f25a15..0243a9e 100644 --- a/src/components/feedbackWidget/feedbackWidget.css +++ b/src/components/feedbackWidget/feedbackWidget.css @@ -1,9 +1,49 @@ :host { display: inline-block; + /* position: fixed; */ + /* bottom: 50%; */ + /* right: 0px; */ + z-index: 9999999999999; } +.compact__container { + position: fixed; + bottom: 50%; + right: 0px; + + display: flex; + justify-content: center; + align-items: center; + box-shadow: 0 0 10px 5px rgba(41,41,42,.07); + width: 40px; + height: auto; + border-radius: 3px; + font-family: "Source Sans 3"; + cursor: pointer; + + &:hover { + width: 45px; + } + + + & .compact__wrapper { + display: flex; + flex-direction: column; + gap: 10px; + padding: 12px 14px 12px 12px; + & p { + font-size: 13px; + margin: 0; + padding: 0; + writing-mode: vertical-rl; + transform: rotate(180deg); + } + } + +} .container { + margin-right: 10px; font-family: "Source Sans 3"; border-radius: 10px; box-shadow: 0 0 10px 5px rgba(41,41,42,.07); @@ -15,6 +55,7 @@ padding: 16px; width: unset; gap: 10px; + background-color: #FFF; & .top__wrapper { display: flex; diff --git a/src/index.html b/src/index.html index 7d7851f..ea6fe94 100644 --- a/src/index.html +++ b/src/index.html @@ -12,5 +12,6 @@
fsfsfsf
gdgdgdg
+
lorem900