Add quality survey at the end of the call (#1084)
Signed-off-by: Timo K <toger5@hotmail.de> Co-authored-by: Robin <robin@robin.town>
This commit is contained in:
parent
eff8847586
commit
2a6981c58d
12 changed files with 338 additions and 30 deletions
23
src/input/FeedbackInput.module.css
Normal file
23
src/input/FeedbackInput.module.css
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
Copyright 2023 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
.feedback textarea {
|
||||
height: 75px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.feedback {
|
||||
border-radius: 8px;
|
||||
}
|
||||
41
src/input/StarRatingInput.module.css
Normal file
41
src/input/StarRatingInput.module.css
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Copyright 2023 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
.starIcon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.starRating {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.inputContainer {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.hideElement {
|
||||
border: 0;
|
||||
clip-path: content-box;
|
||||
height: 0px;
|
||||
width: 0px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
width: 1px;
|
||||
display: inline-block;
|
||||
}
|
||||
85
src/input/StarRatingInput.tsx
Normal file
85
src/input/StarRatingInput.tsx
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
Copyright 2023 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import styles from "./StarRatingInput.module.css";
|
||||
import { ReactComponent as StarSelected } from "../icons/StarSelected.svg";
|
||||
import { ReactComponent as StarUnselected } from "../icons/StarUnselected.svg";
|
||||
|
||||
interface Props {
|
||||
starCount: number;
|
||||
onChange: (stars: number) => void;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
export function StarRatingInput({
|
||||
starCount,
|
||||
onChange,
|
||||
required,
|
||||
}: Props): JSX.Element {
|
||||
const [rating, setRating] = useState(0);
|
||||
const [hover, setHover] = useState(0);
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className={styles.starRating}>
|
||||
{[...Array(starCount)].map((_star, index) => {
|
||||
index += 1;
|
||||
return (
|
||||
<div
|
||||
className={styles.inputContainer}
|
||||
onMouseEnter={() => setHover(index)}
|
||||
onMouseLeave={() => setHover(rating)}
|
||||
key={index}
|
||||
>
|
||||
<input
|
||||
className={styles.hideElement}
|
||||
type="radio"
|
||||
id={"starInput" + String(index)}
|
||||
value={String(index) + "Star"}
|
||||
name="star rating"
|
||||
onChange={(_ev) => {
|
||||
setRating(index);
|
||||
onChange(index);
|
||||
}}
|
||||
required
|
||||
/>
|
||||
<label
|
||||
className={styles.hideElement}
|
||||
id={"starInvisibleLabel" + String(index)}
|
||||
htmlFor={String(index)}
|
||||
>
|
||||
{t("{{count}} stars", {
|
||||
count: index,
|
||||
})}
|
||||
</label>
|
||||
<label
|
||||
className={styles.starIcon}
|
||||
id={"starIcon" + String(index)}
|
||||
htmlFor={String(index)}
|
||||
>
|
||||
{index <= (hover || rating) ? (
|
||||
<StarSelected />
|
||||
) : (
|
||||
<StarUnselected />
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue