Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EN-6414] fix(cv): fix cv bugs and design #148

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ export const StyledRightColumn = styled.div`
flex: 1;
`;

export const StyledTitleAccordion = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
> h2 {
margin-bottom: 0;
}
`;

export const StyledCVPageContentInformations = styled.div`
background-color: #ffffffe5;
padding: 30px;
Expand Down Expand Up @@ -427,7 +436,6 @@ export const StyledCVPageContentFooter = styled.div`
`;

export const StyledChevronIcon = styled(Icon)`
position: absolute;
top: 30px;
right: 30px;
svg {
Expand Down
27 changes: 13 additions & 14 deletions src/components/partials/CV/PageCvContent/PageCVContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
StyledCVExperienceDate,
StyledCVExperienceDescription,
StyledCVExperienceDateMobile,
StyledTitleAccordion,
} from 'src/components/partials/CV/PageCvContent/PageCVContent.styles';
import { Button, Icon } from 'src/components/utils';
import { CarouselSwiper } from 'src/components/utils/CarouselSwiper';
Expand Down Expand Up @@ -231,11 +232,10 @@ export const PageCVContent = ({
!isDesktop ? 'mobile' : ''
}`}
>
{!isDesktop && <StyledChevronIcon name="chevron-down" />}
{isDesktop ? (
<H4 title="Informations" color={CV_COLORS.titleGray} />
) : (
<span
<StyledTitleAccordion
onClick={() => {
setOpenedPanel({
...openedPanel,
Expand All @@ -244,7 +244,8 @@ export const PageCVContent = ({
}}
>
<H2 title="Informations" color={CV_COLORS.titleGray} />
</span>
<StyledChevronIcon name="chevron-down" />
</StyledTitleAccordion>
)}
<ul>
{cv.contracts && cv.contracts.length > 0 && (
Expand Down Expand Up @@ -338,10 +339,7 @@ export const PageCVContent = ({
!isDesktop ? 'mobile' : ''
}`}
>
{!isDesktop && <StyledChevronIcon name="chevron-down" />}

{/* {isDesktop ?<H2 title="Expériences" color={CV_COLORS.titleGray} />: */}
<span
<StyledTitleAccordion
onClick={() => {
setOpenedPanel({
...openedPanel,
Expand All @@ -350,7 +348,8 @@ export const PageCVContent = ({
}}
>
<H2 title="Expériences" color={CV_COLORS.titleGray} />
</span>
<StyledChevronIcon name="chevron-down" />
</StyledTitleAccordion>
<ul>
{cv.experiences?.map((experience) => {
return (
Expand Down Expand Up @@ -423,8 +422,7 @@ export const PageCVContent = ({
!isDesktop ? 'mobile' : ''
}`}
>
{!isDesktop && <StyledChevronIcon name="chevron-down" />}
<span
<StyledTitleAccordion
onClick={() => {
setOpenedPanel({
...openedPanel,
Expand All @@ -433,7 +431,8 @@ export const PageCVContent = ({
}}
>
<H2 title="Formation" color={CV_COLORS.titleGray} />
</span>
<StyledChevronIcon name="chevron-down" />
</StyledTitleAccordion>
<ul>
{cv.formations.map((formation) => {
return (
Expand Down Expand Up @@ -507,11 +506,10 @@ export const PageCVContent = ({
!isDesktop ? 'mobile' : ''
}`}
>
{!isDesktop && <StyledChevronIcon name="chevron-down" />}
{isDesktop ? (
<H4 title="Mes Passions" color={CV_COLORS.titleGray} />
) : (
<span
<StyledTitleAccordion
onClick={() => {
setOpenedPanel({
...openedPanel,
Expand All @@ -520,7 +518,8 @@ export const PageCVContent = ({
}}
>
<H2 title="Mes Passions" color={CV_COLORS.titleGray} />
</span>
<StyledChevronIcon name="chevron-down" />
</StyledTitleAccordion>
)}
<ul>
{cv?.passions?.map(({ name }) => {
Expand Down
9 changes: 8 additions & 1 deletion src/components/utils/Inputs/Inputs.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@ export const StyledAnnotationsErrorMessage = styled(FieldErrorMessage)`
bottom: 0 !important;
`;

export const StyledLimitContainer = styled.div`
display: flex;
> :first-child {
margin-right: 5px;
}
`;

export const StyledLimit = styled.div`
color: ${({ warning }) => {
return warning ? COLORS.noRed : COLORS.darkGray;
return warning ? COLORS.darkOrange : COLORS.darkGray;
}};
font-size: 12px;
line-height: 12px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
StyledAnnotationsErrorMessage,
StyledInputLabel,
StyledLimit,
StyledLimitContainer,
} from '../../Inputs.styles';
import { CommonInputProps } from '../../Inputs.types';
import {
Expand Down Expand Up @@ -109,26 +110,29 @@ export function SelectCreatable<T extends FilterConstant | FilterConstant[]>({
max={maxItems}
maxLength={maxChar}
isValidNewOption={(inputValue) => {
return maxChar ? inputValue.length < maxChar : true;
const isEmpty = inputValue.trim().length === 0;
return maxChar ? inputValue.length < maxChar && !isEmpty : !isEmpty;
}}
/>
</StyledSelect>
<StyledAnnotations>
<div>
<StyledAnnotationsErrorMessage error={error} />
</div>
{maxChar && (
<StyledLimit>
<span>
Chaque élément ne doit pas dépasser {maxChar} caractères.
</span>
</StyledLimit>
)}
{maxItems && (
<StyledLimit warning={remainingItems <= 0}>
<span>{remainingItems} élément(s) restant(s)</span>
</StyledLimit>
)}
<StyledLimitContainer>
{maxChar && (
<StyledLimit>
<span>
Chaque élément ne doit pas dépasser {maxChar} caractères.
</span>
</StyledLimit>
)}
{maxItems && (
<StyledLimit warning={remainingItems <= 0}>
<span>{remainingItems} élément(s) restant(s)</span>
</StyledLimit>
)}
</StyledLimitContainer>
</StyledAnnotations>
</StyledSelectContainer>
);
Expand Down
10 changes: 3 additions & 7 deletions src/components/utils/Inputs/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@ export function TextArea({
}: TextAreaProps) {
const isMobile = useIsMobile();

const { textAreaRef, remainingLines, textAreaWidth } = useLineLimit(
value,
name,
onChange,
maxLines?.lines
);
const { textAreaRef, remainingLines, maxLinesReached, textAreaWidth } =
useLineLimit(value, name, onChange, maxLines?.lines);

useEffect(() => {
if (!maxLines) return null;
if (remainingLines <= 0) {
if (maxLinesReached) {
setIsMaxLinesReached(true);
} else {
setIsMaxLinesReached(false);
Expand Down
7 changes: 4 additions & 3 deletions src/components/utils/Inputs/TextArea/useLineLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ export function useLineLimit(
}
}, []);

const remainingLines =
maxLines - numberOfLines < 0 ? 0 : maxLines - numberOfLines;
const maxLinesReached = maxLines - numberOfLines < 0;

const remainingLines = maxLinesReached ? 0 : maxLines - numberOfLines;

useEffect(() => {
if (maxLines && ref && ref.current && value !== prevValue) {
Expand Down Expand Up @@ -118,5 +119,5 @@ export function useLineLimit(
}
}, [windowWidth]);

return { remainingLines, textAreaRef: ref, textAreaWidth };
return { remainingLines, maxLinesReached, textAreaRef: ref, textAreaWidth };
}