Skip to content

Commit

Permalink
feat(NewGoalCriteria): preview in goal lists
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Feb 26, 2024
1 parent 9892306 commit 578a4c9
Show file tree
Hide file tree
Showing 12 changed files with 1,345 additions and 1,123 deletions.
1,946 changes: 975 additions & 971 deletions cypress/fixtures/langs.json

Large diffs are not rendered by default.

120 changes: 0 additions & 120 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/GoalBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Badge } from './Badge';
import { NextLink } from './NextLink';
import { StateDot } from './StateDot';

interface GoalBadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'> {
title: string;
interface GoalBadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'title'> {
title: React.ReactNode;
href?: string;
color?: number;
children?: React.ReactNode;
Expand Down
56 changes: 31 additions & 25 deletions src/components/GoalTableList/GoalTableList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Badge, CircleProgressBar, State, Table, Tag, Text, User, UserGroup } from '@taskany/bricks/harmony';
import { Badge, State, Table, Tag, Text, User, UserGroup } from '@taskany/bricks/harmony';
import { MouseEventHandler, useMemo } from 'react';
import { Link, ListViewItem, nullable } from '@taskany/bricks';
import { IconMessageTextOutline } from '@taskany/icons';
Expand All @@ -14,6 +14,7 @@ import { NextLink } from '../NextLink';
import { routes } from '../../hooks/router';
import { TagsList } from '../TagsList';
import { RelativeTime } from '../RelativeTime/RelativeTime';
import { GoalCriteriaPreview } from '../NewGoalCriteria/NewGoalCriteria';

import s from './GoalTableList.module.css';

Expand Down Expand Up @@ -41,7 +42,14 @@ export const GoalTableList = <T extends Partial<NonNullable<GoalByIdReturnType>>
{
content: (
<>
<Text>{goal.title}</Text>
<Link
as={NextLink}
href={routes.goal(goal?._shortId as string)}
inline
onClick={onGoalPreviewShow(goal)}
>
<Text>{goal.title}</Text>
</Link>
{nullable(goal.tags, (tags) => (
<TagsList>
{tags.map((tag) => (
Expand Down Expand Up @@ -120,38 +128,36 @@ export const GoalTableList = <T extends Partial<NonNullable<GoalByIdReturnType>>
width: 90,
},
{
content: nullable(goal._achivedCriteriaWeight, (weight) => (
<CircleProgressBar value={weight} />
)),
content: goal._achivedCriteriaWeight != null && goal.id != null && (
<GoalCriteriaPreview achievedWeight={goal._achivedCriteriaWeight} goalId={goal.id} />
),
width: 24,
},
],
})),
[goals, locale, onTagClick],
[goals, locale, onGoalPreviewShow, onTagClick],
);

return (
<Table {...attrs}>
{data.map((row) => (
<Link key={row.goal.id} as={NextLink} href={routes.goal(row.goal?._shortId as string)} inline>
<ListViewItem
value={row.goal}
renderItem={({ active, hovered: _, ...props }) => (
<TableListItem
onClick={onGoalPreviewShow(row.goal)}
selected={selectedGoalResolver?.(row.goal?.id as string)}
hovered={active}
{...props}
>
{row.list.map(({ content, width, className }, index) => (
<TableListItemElement key={index} width={width} className={className}>
{content}
</TableListItemElement>
))}
</TableListItem>
)}
/>
</Link>
<ListViewItem
key={row.goal.id}
value={row.goal}
renderItem={({ active, hovered: _, ...props }) => (
<TableListItem
selected={selectedGoalResolver?.(row.goal?.id as string)}
hovered={active}
{...props}
>
{row.list.map(({ content, width, className }, index) => (
<TableListItemElement key={index} width={width} className={className}>
{content}
</TableListItemElement>
))}
</TableListItem>
)}
/>
))}
</Table>
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/NewGoalCriteria/NewGoalCriteria.i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Achievement criteria": "Achievement criteria",
"Loading ...": "Loading ..."
}
17 changes: 17 additions & 0 deletions src/components/NewGoalCriteria/NewGoalCriteria.i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable */
// Do not edit, use generator to update
import { i18n, fmt, I18nLangSet } from 'easy-typed-intl';
import getLang from '../../../utils/getLang';

import ru from './ru.json';
import en from './en.json';

export type I18nKey = keyof typeof ru & keyof typeof en;
type I18nLang = 'ru' | 'en';

const keyset: I18nLangSet<I18nKey> = {};

keyset['ru'] = ru;
keyset['en'] = en;

export const tr = i18n<I18nLang, I18nKey>(keyset, fmt, getLang);
4 changes: 4 additions & 0 deletions src/components/NewGoalCriteria/NewGoalCriteria.i18n/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Achievement criteria": "Критерии достижимости",
"Loading ...": "Загрузка ..."
}
58 changes: 58 additions & 0 deletions src/components/NewGoalCriteria/NewGoalCriteria.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.NewGoalCriteria {
/* for non-interactive popups allow inner events */
pointer-events: all;
width: 400px;
}

.NewGoalCriteriaTitle {
color: var(--text-secondary);
padding-bottom: var(--gap-xs);
border-bottom: 1px solid var(--gray-900);
}

.NewGoalCriteriaTable {
margin-top: var(--gap-sm);
}

.NewGoalCriteriaItemTitle {
line-height: 24px;
}

.NewGoalCriteriaItemTitleStrike,
.NewGoalCriteriaItemWeight {
color: var(--text-secondary);
}

.NewGoalCriteriaWeightColumn {
text-align: right;
}

.NewGoalCriteriaTableRow {
align-items: baseline;
}

.NewGoalCriteriaGoalBadge {
padding: 0;
align-items: baseline;
}

.NewGoalCriteriaTrigger {
cursor: pointer;
}
.NewGoalCriteriaLoader {
display: flex;
justify-content: center;
}

.NewGoalCriteriaItemCheckbox {
align-items: baseline;
/* FIXME: https://github.com/taskany-inc/bricks/issues/868 */
cursor: default;
pointer-events: none;
}

/* FIXME: https://github.com/taskany-inc/bricks/issues/863 */
.NewGoalCriteriaGoalBadgeState,
.NewGoalCriteriaItemCheckbox input[type="checkbox"] {
transform: translateY(3px);
}
Loading

0 comments on commit 578a4c9

Please sign in to comment.