Skip to content

Commit

Permalink
fix(GoalForm): button positions via priority
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jan 23, 2023
1 parent 2e19882 commit 607b6a8
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 35 deletions.
7 changes: 3 additions & 4 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@
"Goal's title must be longer than 10 symbols": "Goal's title must be longer than 10 symbols",
"Goal's description must be longer than 10 symbols": "Goal's description must be longer than 10 symbols",
"Goal's project or team are required": "Goal's project or team are required",
"Enter project or team title": "Enter project or team title",
"Enter owner name or email": "Enter owner name or email",
"Enter project or team title": "Team/Project",
"Goal's description is required": "Goal's description is required",
"Goal's description must be a string": "Goal's description must be a string",
"Something went wrong 😿": "Something went wrong 😿",
Expand All @@ -163,12 +162,12 @@
"Pro tip!": "Pro tip!",
"Press key to create the goal": "Press <key></key> to create the goal.",
"Assign": "Assign",
"Enter name or email": "Enter name or email",
"Enter name or email": "Name/Email",
"Schedule": "Schedule",
"Date input mask placeholder": "mm/dd/yyyy",
"Date input mask": "99/99/9999",
"State": "State",
"Enter tag title": "Enter tag title",
"Enter tag title": "Tag title",
"Priority": {
"Priority": "Priority",
"Highest": "Highest",
Expand Down
7 changes: 3 additions & 4 deletions i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,13 @@
"New goal": "Создать цель"
},
"new": {
"Create new goal": "Создание новой цели",
"Create new goal": "Новая цель",
"Goal's title is required": "Название цели обязательно",
"Goal's title must be a string": "Название цели должно быть строкой",
"Goal's title must be longer than 10 symbols": "Название цели должно быть длинее 10х символов",
"Goal's description must be longer than 10 symbols": "Описание цели должно быть длинее 10х символов",
"Goal's project or team are required": "Проект или команда обязательны",
"Enter project or team title": "Проект или команда",
"Enter owner name or email": "Имя или почта владельца",
"Enter project or team title": "Команда/Проект",
"Goal's description is required": "Описание цели обязательно",
"Goal's description must be a string": "Описание цели должно быть строкой",
"Something went wrong 😿": "Упс! Что-то пошло не так 😿",
Expand All @@ -163,7 +162,7 @@
"Pro tip!": "Держи совет!",
"Press key to create the goal": "Нажми <key></key> чтобы создать цель.",
"Assign": "Ответственный",
"Enter name or email": "Имя или почта",
"Enter name or email": "Имя/Почта",
"Schedule": "Срок",
"Date input mask placeholder": "dd.mm.yyyy",
"Date input mask": "99.99.9999",
Expand Down
1 change: 1 addition & 0 deletions src/components/EstimateComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export const EstimateComboBox = React.forwardRef<HTMLDivElement, EstimateComboBo
<StyledTriggerContainer>
{changed && <StyledCleanButton onClick={onCleanClick}>+</StyledCleanButton>}
<Button
ghost
ref={props.ref}
text={buttonText}
iconLeft={<Icon noWrap type="calendarTick" size="xs" />}
Expand Down
1 change: 1 addition & 0 deletions src/components/FlowComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const FlowComboBox = React.forwardRef<HTMLDivElement, FlowComboBoxProps>(
onChange={onChange}
renderTrigger={(props) => (
<Button
ghost
ref={props.ref}
text={props.text}
disabled={props.disabled}
Expand Down
61 changes: 38 additions & 23 deletions src/components/GoalForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useTranslations } from 'next-intl';
import { useForm, Controller } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
Expand Down Expand Up @@ -115,6 +115,10 @@ const StyledTagsContainer = styled.div`
padding-left: ${gapS};
`;

const StyledFormActions = styled(FormActions)`
padding-top: 50px;
`;

export const GoalForm: React.FC<GoalFormProps> = ({
formTitle,
title,
Expand All @@ -132,6 +136,15 @@ export const GoalForm: React.FC<GoalFormProps> = ({
const t = useTranslations(i18nKeyset);
const schema = schemaProvider(t);
const { locale } = usePageContext();
const [descriptionFocused, setDescriptionFocused] = useState(false);

const onDescriptionFocus = useCallback(() => {
setDescriptionFocused(true);
}, []);

const onDescriptionCancel = useCallback(() => {
setDescriptionFocused(false);
}, []);

const {
control,
Expand Down Expand Up @@ -198,6 +211,8 @@ export const GoalForm: React.FC<GoalFormProps> = ({
flat="both"
placeholder={t('And its description')}
error={errorsResolver(field.name)}
onFocus={onDescriptionFocus}
onCancel={onDescriptionCancel}
{...field}
/>
)}
Expand All @@ -209,21 +224,8 @@ export const GoalForm: React.FC<GoalFormProps> = ({
))}
</StyledTagsContainer>

<FormActions flat="top">
<StyledFormActions flat="top" focused={descriptionFocused}>
<FormAction left inline>
<Controller
name="owner"
control={control}
render={({ field }) => (
<UserComboBox
text={t('Assign')}
placeholder={t('Enter name or email')}
error={errorsResolver(field.name)}
{...field}
/>
)}
/>

<Controller
name="parent"
control={control}
Expand All @@ -238,24 +240,24 @@ export const GoalForm: React.FC<GoalFormProps> = ({
/>

<Controller
name="state"
name="priority"
control={control}
render={({ field }) => (
<StateDropdown
text={t('State')}
flowId={parentWatcher?.flowId}
<PriorityDropdown
text={t('Priority.Priority')}
error={errorsResolver(field.name)}
{...field}
/>
)}
/>

<Controller
name="priority"
name="owner"
control={control}
render={({ field }) => (
<PriorityDropdown
text={t('Priority.Priority')}
<UserComboBox
text={t('Assign')}
placeholder={t('Enter name or email')}
error={errorsResolver(field.name)}
{...field}
/>
Expand All @@ -277,6 +279,19 @@ export const GoalForm: React.FC<GoalFormProps> = ({
)}
/>

<Controller
name="state"
control={control}
render={({ field }) => (
<StateDropdown
text={t('State')}
flowId={parentWatcher?.flowId}
error={errorsResolver(field.name)}
{...field}
/>
)}
/>

<Controller
name="tags"
control={control}
Expand All @@ -294,7 +309,7 @@ export const GoalForm: React.FC<GoalFormProps> = ({
<FormAction right inline>
<Button view="primary" outline={!isValid} type="submit" text={t('Submit')} />
</FormAction>
</FormActions>
</StyledFormActions>
</Form>

{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoalParentComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const GoalParentComboBox = React.forwardRef<HTMLDivElement, GoalParentCom
disabled={disabled}
items={items}
onChange={onChange}
renderTrigger={(props) => <Button ref={props.ref} text={props.text} onClick={props.onClick} />}
renderTrigger={(props) => <Button ghost ref={props.ref} text={props.text} onClick={props.onClick} />}
renderInput={(props) => (
<StyledInput
autoFocus
Expand Down
2 changes: 1 addition & 1 deletion src/components/PriorityDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const PriorityDropdown = React.forwardRef<HTMLDivElement, PriorityDropdow
renderTrigger={(props) => (
<Button
ref={props.ref}
text={props.text}
ghost
onClick={props.onClick}
disabled={props.disabled}
iconLeft={
Expand Down
4 changes: 2 additions & 2 deletions src/components/StateDot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const StyledStateDot = styled.div<{
background-color: var(--bkg);
&:hover {
/* &:hover {
background-color: var(--bkg-hover);
}
} */
${({ onClick }) =>
onClick &&
Expand Down
1 change: 1 addition & 0 deletions src/components/StateDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const StateDropdown = React.forwardRef<HTMLDivElement, StateDropdownProps
disabled={!flowId || disabled}
renderTrigger={(props) => (
<Button
ghost
ref={props.ref}
text={props.text}
onClick={props.onClick}
Expand Down
1 change: 1 addition & 0 deletions src/components/TagComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const TagComboBox = React.forwardRef<HTMLDivElement, TagComboBoxProps>(
items={items}
renderTrigger={(props) => (
<Button
ghost
ref={props.ref}
text={props.text}
disabled={props.disabled}
Expand Down
1 change: 1 addition & 0 deletions src/components/UserComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const UserComboBox = React.forwardRef<HTMLDivElement, UserComboBoxProps>(
onChange={onChange}
renderTrigger={(props) => (
<Button
ghost
ref={props.ref}
text={props.text}
disabled={props.disabled}
Expand Down

0 comments on commit 607b6a8

Please sign in to comment.