Skip to content

Commit

Permalink
feat(CommentForm): form redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jun 9, 2023
1 parent 09289a0 commit 5bad2f0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 32 deletions.
9 changes: 1 addition & 8 deletions src/components/CommentCreateForm/CommentCreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,7 @@ const CommentCreateForm: React.FC<CommentCreateFormProps> = ({ goalId, states, o
/>
</StyledStateUpdate>
) : (
<Button
size="m"
view="primary"
disabled={busy}
outline={!isValid}
type="submit"
text={tr('Comment')}
/>
<Button size="m" view="primary" disabled={busy} outline type="submit" text={tr('Comment')} />
)
}
/>
Expand Down
3 changes: 1 addition & 2 deletions src/components/CommentForm/CommentForm.i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"Leave a comment": "Leave a comment...",
"Cancel": "Cancel",
"Markdown supported": "Styling with markdown is supported"
"Cancel": "Cancel"
}
3 changes: 1 addition & 2 deletions src/components/CommentForm/CommentForm.i18n/ru.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"Leave a comment": "Оставить комментарий...",
"Cancel": "Отменить",
"Markdown supported": "Текст можно стилизовать с помощью Markdown разметки"
"Cancel": "Отменить"
}
33 changes: 13 additions & 20 deletions src/components/CommentForm/CommentForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, { useCallback, useRef, useState } from 'react';
import styled from 'styled-components';
import { Controller, Control } from 'react-hook-form';
import { backgroundColor, gapS, gray4, gray6 } from '@taskany/colors';
import { backgroundColor, gapM, gray4, gray9 } from '@taskany/colors';
import {
Button,
Link,
Form,
FormCard,
FormAction,
FormActions,
MarkdownIcon,
QuestionIcon,
nullable,
useClickOutside,
Expand All @@ -18,7 +17,6 @@ import {
import { usePageContext } from '../../hooks/usePageContext';
import { routes } from '../../hooks/router';
import { FormEditor } from '../FormEditor/FormEditor';
import { Tip } from '../Tip';

import { tr } from './CommentForm.i18n';

Expand All @@ -42,7 +40,7 @@ const StyledFormBottom = styled.div`
align-items: center;
justify-content: space-between;
padding: ${gapS} ${gapS} 0 ${gapS};
padding-top: ${gapM};
`;

const StyledCommentForm = styled(FormCard)`
Expand All @@ -67,10 +65,6 @@ const StyledCommentForm = styled(FormCard)`
}
`;

const StyledTip = styled(Tip)`
padding: 0;
`;

export const CommentForm: React.FC<CommentFormProps> = ({
autoFocus,
control,
Expand Down Expand Up @@ -117,7 +111,7 @@ export const CommentForm: React.FC<CommentFormProps> = ({
{...field}
disabled={busy}
placeholder={tr('Leave a comment')}
height={commentFocused ? 120 : 60}
height={commentFocused ? 120 : 40}
onCancel={onCommentCancel}
onFocus={onCommentFocus}
autoFocus={autoFocus}
Expand All @@ -127,8 +121,16 @@ export const CommentForm: React.FC<CommentFormProps> = ({
/>

{nullable(commentFocused, () => (
<FormActions focused={commentFocused}>
<FormAction left inline />
<FormActions>
<FormAction left inline>
{nullable(commentFocused, () => (
<StyledFormBottom>
<Link href={routes.help(locale, 'comments')}>
<QuestionIcon size="s" color={gray9} />
</Link>
</StyledFormBottom>
))}
</FormAction>
<FormAction right inline>
{nullable(!busy, () => (
<Button size="m" outline text={tr('Cancel')} onClick={onCommentCancel} />
Expand All @@ -139,15 +141,6 @@ export const CommentForm: React.FC<CommentFormProps> = ({
</FormActions>
))}
</Form>

{nullable(commentFocused, () => (
<StyledFormBottom>
<StyledTip icon={<MarkdownIcon size="s" color={gray6} />}>{tr('Markdown supported')}</StyledTip>
<Link href={routes.help(locale, 'comments')}>
<QuestionIcon size="s" color={gray6} />
</Link>
</StyledFormBottom>
))}
</StyledCommentForm>
);
};

0 comments on commit 5bad2f0

Please sign in to comment.