Skip to content

Commit

Permalink
Merge branch 'release/1.1.0' into feature/issue-1807
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Kolpakov authored Nov 1, 2024
2 parents c41e8e5 + d7888ce commit 0c37593
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 29 deletions.
24 changes: 14 additions & 10 deletions src/app/common/components/Editor/QEditor.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,30 @@ interface EditorProps {
}

const Editor: React.FC<EditorProps> = ({
qRef, value, onChange, maxChars, initialVal, selectionChange, onCharacterCountChange = () => {}, readOnly = false
qRef, value, onChange, maxChars, initialVal, selectionChange, onCharacterCountChange = () => { }, readOnly = false
}) => {
const [isReadOnly, setIsReadOnly] = useState(readOnly);
const indentedValue = refactorIndentsHtml(value || '');
const [val, setVal] = useState(indentedValue);
const [rawText, setRawText] = useState(removeHtmlTags(value) ?? '');
const [characterCount, setCharacterCount] = useState(rawText.length ?? 0);
const [rawText, setRawText] = useState('');
const [characterCount, setCharacterCount] = useState(0);
const [validateDescription, setValidateDescription] = useState<boolean>(false);
const quillRef = useRef<ReactQuill | null>(null);
const availableButtons = new Set(['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight',
'ArrowUp', 'ArrowDown', 'Home', 'End']);

const countCharacters = (content: string) => {
const textWithoutTags = removeHtmlTags(content);
setRawText(textWithoutTags);
const count = textWithoutTags.length;
setCharacterCount(count);
};

useEffect(() => {
if (value?.includes('\n')) {
const preservedIndents = refactorIndentsHtml(value || '');
setVal(preservedIndents);
}
const valueWithoutHtml = removeHtmlTags(value);
setRawText(valueWithoutHtml);
const count = valueWithoutHtml.length;
setCharacterCount(count);
}, [value]);

useEffect(() => {
Expand All @@ -55,19 +54,24 @@ const Editor: React.FC<EditorProps> = ({
setValidateDescription(false);
}
}, [characterCount, maxChars]);

useEffect(() => {
setIsReadOnly(readOnly);
setIsReadOnly(readOnly);
}, [readOnly]);

useEffect(() => {
onCharacterCountChange(characterCount);
}, [characterCount, onCharacterCountChange]);

const handleOnChange = (html: string) => {
if (!isReadOnly) {
if (!isReadOnly) {
onChange(html);
setVal(html);
countCharacters(html);
const valueWithoutHtml = removeHtmlTags(html);
setCharacterCount(valueWithoutHtml.length);
}
};

const handleSelectionChange = (range: ReactQuill.Range | null, source: Sources, editor: UnprivilegedEditor) => {
if (range && range.index != null && range.length != null) {
const selectedText = editor.getText(range.index, range.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ const NewStreetcode = () => {
<TextBlock
parseId={parseId}
inputInfo={inputInfo}
form={form}
setInputInfo={setInputInfo}
video={video}
setVideo={setVideo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ $articlesImg: "@assets/images/sources/Articles.webp";

h4{
font-weight: 300;
}

.adminContainer-red-h4{
font-weight: 300;
color: c.$accented-red-color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const StreetcodeArtsBlock = React.memo(() => (
<h2>Арт-галерея</h2>
<h3>Завантажити арти</h3>
<DownloadBlock />
<h4>* Зауважте, не використані арти видаляються</h4>
<h4 className='adminContainer-red-h4'>* Зауважте, не використані арти видаляються</h4>
</div>
));
export default StreetcodeArtsBlock;
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/* eslint-disable no-restricted-imports */
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import TextsApi from '@api/streetcode/text-content/texts.api';
import { useAsync } from '@hooks/stateful/useAsync.hook';

import { FormInstance } from 'antd';

import Video from '@/models/media/video.model';
import { Text } from '@/models/streetcode/text-contents.model';

import TextForm from './TextForm/TextForm.component';

interface Props {
inputInfo: Partial<Text> | undefined;
form: FormInstance<unknown>,
setInputInfo: React.Dispatch<React.SetStateAction<Partial<Text> | undefined>>;
video: Video | undefined;
setVideo: React.Dispatch<Video | undefined>;
Expand All @@ -18,7 +21,7 @@ interface Props {
}

const TextBlock = React.memo(({
inputInfo, setInputInfo, video, setVideo, onChange, parseId,
inputInfo, form, setInputInfo, video, setVideo, onChange, parseId,
}: Props) => {
const [inputInfoAsync, setInputInfoAsync] = useState<Partial<Text>| undefined>();
const [canLoad, setCanLoad] = useState<boolean>(parseId === null);
Expand All @@ -34,6 +37,7 @@ const TextBlock = React.memo(({
return (
canLoad ? (
<TextForm
form={form}
inputInfo={inputInfo}
setInputInfo={setInputInfo}
video={video}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const LinkEditor = ({
</Button>
{inputInfo?.link && showPreview && (
<div>
<h4>Попередній перегляд</h4>
<h4 className='adminContainer-red-h4'>Попередній перегляд</h4>
<Youtube opts={opts} videoId={youtubeId} />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import './TextForm.styles.scss';

import { Form, Input } from 'antd';
import { useEffect } from 'react';

import { Form, FormInstance, Input } from 'antd';

import QUILL_TEXTS_LENGTH from
'@/features/AdminPage/NewStreetcode/TextBlock/TextLengthConstants/textMaxLength.constant';
Expand All @@ -14,17 +16,18 @@ import TextPreview from './TextPreview/TextPreview.component';

const isQuillEmpty = (text: string | undefined) => {
return !text || text.replace(/<(.|\n)*?>/g, '').trim().length === 0;
}
};

interface Props {
form: FormInstance<unknown>,
inputInfo: Partial<Text> | undefined;
setInputInfo: React.Dispatch<React.SetStateAction<Partial<Text> | undefined>>;
video: Video | undefined;
setVideo: React.Dispatch<Video | undefined>;
onChange: (fieldName: string, value: any) => void;
}
const TextForm = ({
inputInfo, setInputInfo, video, setVideo, onChange,
form, inputInfo, setInputInfo, video, setVideo, onChange,
}: Props) => {
const maxTitleLength = 50;
const handleChangeTitle = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand All @@ -35,6 +38,13 @@ const TextForm = ({
}));
onChange('title', value);
};

useEffect(() => {
form.setFieldsValue({
title: inputInfo?.title,
});
}, [inputInfo, form]);

return (
<Form.Item className="textForm">
<Form.Item
Expand All @@ -50,7 +60,6 @@ const TextForm = ({
},
},
]}
initialValue={inputInfo?.title}
>
<Input
showCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ const TeamPositionsMainPage: React.FC = observer(() => {
</div>
);
},
sorter: (a, b) => a.position.localeCompare(b.position),
sortDirections: ['ascend', 'descend', 'ascend'],
defaultSortOrder: 'ascend',
},
{
title: 'Дії',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $timelineSquareImg: "@assets/images/timeline/Square.webp";
}

.slick-list {
margin:f.pxToRem(0) !important;
margin: f.pxToRem(0) !important;
}

.slick-track {
Expand All @@ -53,13 +53,13 @@ $timelineSquareImg: "@assets/images/timeline/Square.webp";

.slick-slide {
border-radius: 40px;
border-width:f.pxToRem(15px) f.pxToRem(15px);
border-width: f.pxToRem(15px) f.pxToRem(15px);
border-style: solid ;
border-color: c.$timeline-reel-color;
@include mut.bg-image($timelineSquareImg);


background-size:f.pxToRem(605px) f.pxToRem(365px);
background-size: f.pxToRem(605px) f.pxToRem(365px);
background-position: center;

&:nth-child(2n + 1) {
Expand All @@ -72,7 +72,7 @@ $timelineSquareImg: "@assets/images/timeline/Square.webp";

.slick-current {
border-radius: 40px;
box-shadow: inset 0px 0px 0px 6px c.$pure-white-color;
box-shadow: inset 0 0 0 6px c.$pure-white-color;
}
}
}
Expand Down Expand Up @@ -107,12 +107,12 @@ $timelineSquareImg: "@assets/images/timeline/Square.webp";
}
.slick-slide {
border-radius: 20px;
border-width:f.pxToRem(7px) f.pxToRem(7px);
background-size:f.pxToRem(295px) f.pxToRem(185px);
border-width: f.pxToRem(7px) f.pxToRem(7px);
background-size: f.pxToRem(295px) f.pxToRem(211px);
background-position: center;
}
.slick-current {
box-shadow: inset 0px 0px 0px 3px c.$pure-white-color;
box-shadow: inset 0 0 0 3px c.$pure-white-color;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

@media screen and (max-width: 1024px) {
.timelineItem{
@include mut.sized(299px, 190px);
@include mut.sized(299px, 208px);
border-radius: 15px;
.timelineItemContent{
padding: f.pxToRem(13px);
Expand Down

0 comments on commit 0c37593

Please sign in to comment.