Skip to content

Commit

Permalink
update styling
Browse files Browse the repository at this point in the history
  • Loading branch information
osamasayed committed Feb 28, 2024
1 parent 52b87ee commit f6806e0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@use "src/styles/breakpoints";

.bodyInput {
border: none !important;
border-radius: 0 !important;
padding-inline: 0 !important;
& > div {
border: none;
margin-block-start: var(--spacing-large);
}

textarea {
font-size: var(--font-size-large);
font-weight: var(--font-weight-medium);

@include breakpoints.smallerThanTablet {
min-height: 30vh;
}
}
}

.submitButton {
margin-block-start: var(--spacing-small);
display: flex;
align-items: center;
flex-direction: row-reverse;
}

.ratingContainer {
display: flex;
align-items: center;
flex-direction: column;
}
27 changes: 22 additions & 5 deletions src/components/Course/CourseFeedback/CourseFeedbackForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import React, { useState } from 'react';

import useTranslation from 'next-translate/useTranslation';

import styles from './CourseFeedbackForm.module.scss';

import {
mutateCachedCourseAfterFeedback,
mutateCachedLessonsAfterFeedback,
} from '@/components/Course/utils/mutations';
import buildFormBuilderFormField from '@/components/FormBuilder/buildFormBuilderFormField';
import buildTranslatedErrorMessageByErrorId from '@/components/FormBuilder/buildTranslatedErrorMessageByErrorId';
import FormBuilder from '@/components/FormBuilder/FormBuilder';
import styles from '@/components/Notes/NoteModal/NoteModal.module.scss';
import Button from '@/dls/Button/Button';
import { ToastStatus, useToast } from '@/dls/Toast/Toast';
import useMutateMultipleKeys from '@/hooks/useMutateMultipleKeys';
Expand Down Expand Up @@ -78,7 +79,21 @@ const CourseFeedbackForm: React.FC<Props> = ({ course, onSuccess }) => {
{
field: 'rating',
type: FormFieldType.StarRating,
defaultValue: 5,
// user must pick a rating
defaultValue: null,
containerClassName: styles.ratingContainer,
rules: [
{
type: RuleType.Required,
value: true,
errorId: ErrorMessageId.RequiredField,
errorMessage: buildTranslatedErrorMessageByErrorId(
ErrorMessageId.RequiredField,
'rating',
t,
),
},
],
},
{
field: 'body',
Expand Down Expand Up @@ -110,9 +125,11 @@ const CourseFeedbackForm: React.FC<Props> = ({ course, onSuccess }) => {
isSubmitting={isLoading}
renderAction={({ isLoading: isSubmitting }) => {
return (
<Button htmlType="submit" isLoading={isSubmitting} isDisabled={isSubmitting}>
{t('common:submit')}
</Button>
<div className={styles.submitButton}>
<Button htmlType="submit" isLoading={isSubmitting} isDisabled={isSubmitting}>
{t('common:submit')}
</Button>
</div>
);
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormBuilder/buildFormBuilderFormField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const buildFormBuilderFormField = (formField: FormField, t: Translate): FormBuil
rules: formField.rules.map((rule) => ({
type: rule.type,
value: rule.value,
errorMessage: t(`validation.${rule.errorId}`, {
errorMessage: t(`common:validation.${rule.errorId}`, {
field: capitalize(formField.field),
...rule.errorExtraParams,
}),
Expand Down

0 comments on commit f6806e0

Please sign in to comment.