Skip to content

Commit

Permalink
feat(PageTitle): show preset author
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jun 1, 2023
1 parent cbe298b commit 2f2ed41
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/components/GoalsPage/GoalsPage.i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"title": "Taskany — Goals — Dashboard",
"Dashboard": "Dashboard",
"This is your personal goals bundle": "This is your personal goals bundle. Created, owned, watching projects and goals are here.",
"Reset": "Reset"
"Reset": "Reset",
"created by": "created by"
}
3 changes: 2 additions & 1 deletion src/components/GoalsPage/GoalsPage.i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"title": "Taskany — Цели — Рабочий стол",
"Dashboard": "Рабочий стол",
"This is your personal goals bundle": "Здесь будут все созданные вами, назначенные на вас, а также цели и проекты, за которыми вы следите.",
"Reset": "Сбросить"
"Reset": "Сбросить",
"created by": "автор"
}
17 changes: 15 additions & 2 deletions src/components/GoalsPage/GoalsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,26 @@ export const GoalsPage = ({ user, ssrTime, locale }: ExternalPageProps) => {
);

const defaultTitle = <PageTitle title={tr('Dashboard')} />;
const presetTitle = <PageTitle title={tr('Dashboard')} subtitle={currentPreset?.title} />;
const presetInfo =
user.activityId === currentPreset?.activityId
? `${tr('created by')} ${currentPreset?.activity?.user?.name}`
: undefined;
const presetTitle = <PageTitle title={tr('Dashboard')} subtitle={currentPreset?.title} info={presetInfo} />;

const onShadowPresetTitleClick = useCallback(() => {
if (shadowPreset) setPreset(shadowPreset.id);
}, [setPreset, shadowPreset]);
const shadowPresetInfo =
user.activityId !== shadowPreset?.activityId
? `${tr('created by')} ${shadowPreset?.activity?.user?.name}`
: undefined;
const shadowPresetTitle = (
<PageTitle title={tr('Dashboard')} subtitle={shadowPreset?.title} onClick={onShadowPresetTitleClick} />
<PageTitle
title={tr('Dashboard')}
subtitle={shadowPreset?.title}
info={shadowPresetInfo}
onClick={onShadowPresetTitleClick}
/>
);
// eslint-disable-next-line no-nested-ternary
const title = currentPreset ? presetTitle : shadowPreset ? shadowPresetTitle : defaultTitle;
Expand Down
18 changes: 15 additions & 3 deletions src/components/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Text } from '@taskany/bricks';
import { gray4, gray7 } from '@taskany/colors';
import { gapS, gray4, gray6, gray7 } from '@taskany/colors';
import styled from 'styled-components';

interface PageTitleProps {
title?: string;
subtitle?: string;
info?: string;

onClick?: () => void;
}

const StyledText = styled(Text)`
padding-left: ${gapS};
transition: color 200ms ease-in-out;
${({ onClick }) =>
Expand All @@ -21,16 +25,24 @@ const StyledText = styled(Text)`
}
`}
`;
export const PageTitle: React.FC<PageTitleProps> = ({ title, subtitle, onClick }) => (

export const PageTitle: React.FC<PageTitleProps> = ({ title, subtitle, info, onClick }) => (
<>
{title}

{subtitle && (
<>
:{' '}
{':'}
<StyledText as="span" size="xxl" weight="bolder" color={onClick ? gray4 : gray7} onClick={onClick}>
{subtitle}
</StyledText>
</>
)}

{info && (
<StyledText as="span" size="s" weight="bold" color={gray6}>
{info}
</StyledText>
)}
</>
);
3 changes: 2 additions & 1 deletion src/components/ProjectPage/ProjectPage.i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"title": "Taskany — {project}",
"Reset": "Reset"
"Reset": "Reset",
"created by": "created by"
}
3 changes: 2 additions & 1 deletion src/components/ProjectPage/ProjectPage.i18n/ru.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"title": "Taskany — {project}",
"Reset": "Сбросить"
"Reset": "Сбросить",
"created by": "автор"
}
17 changes: 15 additions & 2 deletions src/components/ProjectPage/ProjectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,26 @@ export const ProjectPage = ({ user, locale, ssrTime, params: { id } }: ExternalP
.join('');

const defaultTitle = <PageTitle title={project.data?.title} />;
const presetTitle = <PageTitle title={project.data?.title} subtitle={currentPreset?.title} />;
const presetInfo =
user.activityId !== currentPreset?.activityId
? `${tr('created by')} ${currentPreset?.activity?.user?.name}`
: undefined;
const presetTitle = <PageTitle title={project.data?.title} subtitle={currentPreset?.title} info={presetInfo} />;

const onShadowPresetTitleClick = useCallback(() => {
if (shadowPreset) setPreset(shadowPreset.id);
}, [setPreset, shadowPreset]);
const shadowPresetInfo =
user.activityId !== shadowPreset?.activityId
? `${tr('created by')} ${shadowPreset?.activity?.user?.name}`
: undefined;
const shadowPresetTitle = (
<PageTitle title={project.data?.title} subtitle={shadowPreset?.title} onClick={onShadowPresetTitleClick} />
<PageTitle
title={project.data?.title}
subtitle={shadowPreset?.title}
info={shadowPresetInfo}
onClick={onShadowPresetTitleClick}
/>
);
// eslint-disable-next-line no-nested-ternary
const title = currentPreset ? presetTitle : shadowPreset ? shadowPresetTitle : defaultTitle;
Expand Down
14 changes: 14 additions & 0 deletions trpc/router/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export const filter = router({
},
include: {
stargizers: true,
activity: {
include: {
user: true,
ghost: true,
},
},
},
});

Expand Down Expand Up @@ -44,6 +50,14 @@ export const filter = router({
},
],
},
include: {
activity: {
include: {
user: true,
ghost: true,
},
},
},
});
}),
create: protectedProcedure.input(createFilterSchema).mutation(({ ctx, input }) => {
Expand Down

0 comments on commit 2f2ed41

Please sign in to comment.