Skip to content

Commit f89111c

Browse files
authoredMar 20, 2024
fix(tasks): ui adjustments (#6086)
1 parent 0653134 commit f89111c

File tree

5 files changed

+43
-51
lines changed

5 files changed

+43
-51
lines changed
 

‎packages/sanity/src/tasks/plugin/TasksStudioNavbar.tsx

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {PanelRightIcon, TaskIcon} from '@sanity/icons'
2-
import {useCallback, useMemo} from 'react'
2+
import {useMemo} from 'react'
33
import {type NavbarProps, useTranslation} from 'sanity'
44

55
import {tasksLocaleNamespace} from '../i18n'
@@ -9,19 +9,10 @@ const EMPTY_ARRAY: [] = []
99

1010
function TasksStudioNavbarInner(props: NavbarProps) {
1111
const {
12-
handleCloseTasks,
1312
handleOpenTasks,
1413
state: {isOpen},
1514
} = useTasksNavigation()
1615

17-
const handleAction = useCallback(() => {
18-
if (isOpen) {
19-
handleCloseTasks()
20-
} else {
21-
handleOpenTasks()
22-
}
23-
}, [handleCloseTasks, handleOpenTasks, isOpen])
24-
2516
const {t} = useTranslation(tasksLocaleNamespace)
2617

2718
const actions = useMemo((): NavbarProps['__internal_actions'] => {
@@ -31,20 +22,20 @@ function TasksStudioNavbarInner(props: NavbarProps) {
3122
icon: PanelRightIcon,
3223
location: 'topbar',
3324
name: 'tasks-topbar',
34-
onAction: handleAction,
25+
onAction: handleOpenTasks,
3526
selected: isOpen,
3627
title: t('actions.open.text'),
3728
},
3829
{
3930
icon: TaskIcon,
4031
location: 'sidebar',
4132
name: 'tasks-sidebar',
42-
onAction: handleAction,
33+
onAction: handleOpenTasks,
4334
selected: isOpen,
4435
title: t('actions.open.text'),
4536
},
4637
]
47-
}, [handleAction, isOpen, props?.__internal_actions, t])
38+
}, [handleOpenTasks, isOpen, props?.__internal_actions, t])
4839

4940
return props.renderDefault({
5041
...props,

‎packages/sanity/src/tasks/src/tasks/components/activity/TasksActivityCommentInput.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function TasksActivityCommentInput(props: TasksCommentActivityInputProps)
6464

6565
return (
6666
<ActivityItem userId={currentUser.id}>
67-
<Card tone="transparent" radius={3} paddingY={1} paddingX={2}>
67+
<Card tone="transparent" radius={3} padding={2}>
6868
<CommentInput
6969
withAvatar={false}
7070
currentUser={currentUser}

‎packages/sanity/src/tasks/src/tasks/components/activity/TasksSubscribers.tsx

+29-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {AvatarStack, Flex} from '@sanity/ui'
22
import {AnimatePresence, motion} from 'framer-motion'
3-
import {useCallback} from 'react'
3+
import {useCallback, useMemo} from 'react'
44
import {type FormPatch, type PatchEvent, type Path, set} from 'sanity'
55

66
import {Button} from '../../../../../ui-components'
@@ -47,28 +47,38 @@ export function TasksSubscribers(props: TasksSubscriberProps) {
4747
)
4848
}
4949

50-
export function TasksSubscriberAvatars(props: {subscriberIds?: string[]}) {
51-
const {subscriberIds} = props
50+
const EMPTY_ARRAY: [] = []
51+
52+
interface TasksSubscriberAvatarsProps {
53+
subscriberIds?: string[]
54+
}
55+
56+
export function TasksSubscriberAvatars(props: TasksSubscriberAvatarsProps) {
57+
const {subscriberIds: subscriberIdsProp} = props
58+
59+
const subscriberIds = useMemo(() => {
60+
// Make sure we have valid subscriber IDs
61+
return subscriberIdsProp?.filter(Boolean) || EMPTY_ARRAY
62+
}, [subscriberIdsProp])
5263

5364
return (
5465
<AnimatePresence initial={false}>
5566
<AvatarStack maxLength={3} size={0}>
56-
{subscriberIds &&
57-
subscriberIds.map((subscriberId) => (
58-
<motion.div
59-
key={subscriberId}
60-
exit={{opacity: 0, translateX: '2px', scale: 0.9}}
61-
animate={{
62-
opacity: 1,
63-
translateX: 0,
64-
scale: 1,
65-
transition: {type: 'just', duration: 0.2},
66-
}}
67-
initial={{opacity: 0, translateX: '2px', scale: 0.9}}
68-
>
69-
<TasksUserAvatar user={{id: subscriberId}} size={0} />
70-
</motion.div>
71-
))}
67+
{subscriberIds.map((subscriberId) => (
68+
<motion.div
69+
key={subscriberId}
70+
exit={{opacity: 0, translateX: '2px', scale: 0.9}}
71+
animate={{
72+
opacity: 1,
73+
translateX: 0,
74+
scale: 1,
75+
transition: {type: 'just', duration: 0.2},
76+
}}
77+
initial={{opacity: 0, translateX: '2px', scale: 0.9}}
78+
>
79+
<TasksUserAvatar user={{id: subscriberId}} size={0} />
80+
</motion.div>
81+
))}
7282
</AvatarStack>
7383
</AnimatePresence>
7484
)

‎packages/sanity/src/tasks/src/tasks/components/form/fields/assignee/AssigneeEditFormField.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ const StyledButton = styled(Button)`
2020
padding: 3px 6px;
2121
`
2222

23-
export function AssigneeEditFormField(props: {
23+
interface AssigneeEditFormFieldProps {
2424
value: string | undefined
2525
path: Path
2626
onChange: (patch: FormPatch | PatchEvent | FormPatch[]) => void
27-
}) {
27+
}
28+
29+
export function AssigneeEditFormField(props: AssigneeEditFormFieldProps) {
2830
const {value, onChange, path} = props
2931
const subscribers = useFormValue(['subscribers']) as string[] | undefined
3032
const {mentionOptions} = useMentionUser()
@@ -33,10 +35,11 @@ export function AssigneeEditFormField(props: {
3335
[mentionOptions.data, value],
3436
)
3537
const {t} = useTranslation(tasksLocaleNamespace)
38+
3639
const onSelect = useCallback(
3740
(userId: string) => {
3841
onChange(set(userId, path))
39-
if (subscribers && !subscribers.includes(userId)) {
42+
if (subscribers && !subscribers.includes(userId) && userId) {
4043
onChange(set([...subscribers, userId], ['subscribers']))
4144
}
4245
},

‎packages/sanity/src/tasks/src/tasks/components/list/TasksListItem.tsx

+3-15
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ interface TasksListItemProps
2727
const TitleButton = styled(UIButton)`
2828
width: 100%;
2929
max-width: 100%;
30-
31-
&:hover {
32-
text-decoration: underline;
33-
background-color: transparent;
34-
}
3530
`
3631

3732
const TaskDetailsRoot = styled(Flex)`
@@ -83,15 +78,8 @@ function TaskDueDate({dueBy}: {dueBy: string}) {
8378
)
8479
}
8580

86-
export function TasksListItem({
87-
assignedTo,
88-
title,
89-
dueBy,
90-
target,
91-
onSelect,
92-
documentId,
93-
status,
94-
}: TasksListItemProps) {
81+
export function TasksListItem(props: TasksListItemProps) {
82+
const {assignedTo, title, dueBy, target, onSelect, documentId, status} = props
9583
const targetDocument = useMemo(() => getTargetDocumentMeta(target), [target])
9684

9785
return (
@@ -103,7 +91,7 @@ export function TasksListItem({
10391

10492
<Flex flex={1}>
10593
<TitleButton onClick={onSelect} mode="bleed" padding={2}>
106-
<Text size={1} weight="semibold" textOverflow="ellipsis">
94+
<Text size={1} textOverflow="ellipsis" weight="semibold">
10795
{title || 'Untitled'}
10896
</Text>
10997
</TitleButton>

0 commit comments

Comments
 (0)
Please sign in to comment.