CLASSROOMIO-T-27: Remove unused variable Merge branch 'CLASSROOMIO-T-27' of https://gitlab.com/thenextgreat/classroomio into CLASSROOMIO-T-27 CLASSROOMIO-T-27: Complete reviews functionality CLASSROOMIO-T-27: Review Render Update CLASSROOMIO-T-27: - Resolved Feedbacks CLASSROOMIO-T-27: Fixed Ratings Data CLASSROOMIO-T-27: - Added Ratings Svg - Fixed avatar_url feedback CLASSROOMIO-T-27: Import Adjustment CLASSROOMIO-T-27: Code Review CLASSROOM-T-27: Added Add Review Functionality CLASSROOMIO-T-27: - Unresolved Review - Enhance Code Redability CLASSROOMIO-T-27: Completed the delete functionality CLASSROOMIO-T-27: Hide/Show functionality CLASSROOMIO-T-27: Double Quotation Update CLASSROOMIO-T-27: Testing toggle functinality CLASSROOMIO-T-27: Added the icons CLASSROOMIO-T-27: Completion of the hide/show functionality CLASSROOMIO-T-27: Display the store data on the review page for styling CLASSROOMIO-T-27: Styling of the review component & connecting it's data CLASSROOMIO-T-27: - Add ReviewsForm - Completion of the Reviews Form Structure/Styling CLASSROOMIO-T-27: Added a reviews modal CLASSROOMIO-T-27: Logic update for review section CLASSROOMIO-T-50: Logic for overlapping reviews CLASSROOMIO-T-27: - Completion of the structure & styling with mock data. - Addition of custom ratings assets CLASSROOMIO-T-27: - Review Section Code Structure - Import Profile Picture Assets Co-authored-by: Rotimi Best <[email protected]> Co-authored-by: Tunji Adeyemi <[email protected]> Co-authored-by: tunny17 <[email protected]> Merge-request: CLASSROOMIO-MR-26 Merged-by: Best Admin <[email protected]>
111 lines
2.5 KiB
Svelte
111 lines
2.5 KiB
Svelte
<script>
|
|
import { onMount } from 'svelte';
|
|
import IconButton from '../IconButton/index.svelte';
|
|
import PasswordEye from '../Icons/PasswordEye.svelte';
|
|
|
|
export let label = '';
|
|
export let placeholder = '';
|
|
export let value = '';
|
|
export let name = '';
|
|
export let onKeyDown = () => {};
|
|
export let className = '';
|
|
export let inputClassName = '';
|
|
export let labelClassName = '';
|
|
export let bgColor = 'bg-gray-200';
|
|
export let type = 'text';
|
|
export let isPassword = false;
|
|
export let autoFocus = false;
|
|
export let isRequired = false;
|
|
export let isDisabled = false;
|
|
export let min = undefined;
|
|
export let max = undefined;
|
|
export let errorMessage = '';
|
|
export let helperMessage = '';
|
|
export let autoComplete = true;
|
|
export let onChange = () => {}; // This is to know if element is 'dirty'
|
|
export let onInputChange = (e) => {};
|
|
|
|
let ref;
|
|
let fieldNode;
|
|
|
|
function typeAction(node) {
|
|
node.type = type;
|
|
|
|
if (isRequired) {
|
|
node.required = '';
|
|
}
|
|
|
|
fieldNode = node;
|
|
}
|
|
|
|
function handlePasswordEye() {
|
|
type = type === 'password' ? 'text' : 'password';
|
|
typeAction(fieldNode);
|
|
}
|
|
|
|
onMount(() => {
|
|
if (autoFocus) {
|
|
ref.focus();
|
|
}
|
|
|
|
if (type === 'password') {
|
|
isPassword = true;
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<label class="block relative {className}">
|
|
{#if label}
|
|
<label
|
|
for="text-field"
|
|
class="dark:text-white m-0 font-light {labelClassName}"
|
|
>
|
|
{label}
|
|
|
|
{#if isRequired}
|
|
<span class="text-red-700">*</span>
|
|
{/if}
|
|
</label>
|
|
{/if}
|
|
<input
|
|
use:typeAction
|
|
class="form-input {inputClassName} dark:text-black p-3 mt-1 block w-full border-none {bgColor} {errorMessage
|
|
? 'border-red-500'
|
|
: ''}"
|
|
on:keydown={onKeyDown}
|
|
on:change={onInputChange}
|
|
{placeholder}
|
|
bind:value
|
|
bind:this={ref}
|
|
required={isRequired}
|
|
disabled={isDisabled}
|
|
autocomplete={autoComplete ? 'on' : 'off'}
|
|
on:blur={onChange}
|
|
{name}
|
|
{min}
|
|
{max}
|
|
/>
|
|
{#if isPassword}
|
|
<span class="password-eye">
|
|
<IconButton value="write-code" onClick={handlePasswordEye}>
|
|
<PasswordEye isClosed={type === 'password' ? true : false} />
|
|
</IconButton>
|
|
</span>
|
|
{/if}
|
|
{#if errorMessage}
|
|
<p class="text-sm text-red-500">{errorMessage}</p>
|
|
{:else if helperMessage}
|
|
<p class="dark:text-white text-sm">
|
|
{helperMessage}
|
|
</p>
|
|
{/if}
|
|
</label>
|
|
|
|
<style>
|
|
.password-eye {
|
|
position: absolute;
|
|
top: 23px;
|
|
right: 6px;
|
|
}
|
|
</style>
|