Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Oct 1, 2024
1 parent 17e81d0 commit 39792f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import {Menu, usePortal} from '@sanity/ui'
import {type MouseEvent, useCallback} from 'react'
import {ContextMenuButton, useTranslation} from 'sanity'

import {MenuButton, MenuItem} from '../../../../ui-components'
import {Button, MenuButton, MenuItem} from '../../../../ui-components'
import {structureLocaleNamespace} from '../../../i18n'
import {TIMELINE_LIST_WRAPPER_ID} from './timeline'
import {TIMELINE_MENU_PORTAL} from './timelineMenu'
import {ChevronDownIcon, LaunchIcon, LinkIcon} from '@sanity/icons'

/**
* This is a hack to force the scrollbar to not appear when the list is expanding,
Expand Down Expand Up @@ -56,33 +57,9 @@ export function ExpandableTimelineItemMenu({
)

return (
<MenuButton
id={`timeline-item-menu-button-${chunkId}`}
button={
<ContextMenuButton
aria-label={t('timeline-item.menu-button.aria-label')}
size="large"
tooltipProps={{content: t('timeline-item.menu-button.tooltip')}}
/>
}
menu={
<Menu padding={1}>
<MenuItem
text={t(
isExpanded
? 'timeline-item.menu.action-collapse'
: 'timeline-item.menu.action-expand',
)}
onClick={handleExpandClick}
/>
</Menu>
}
popover={{
// when used inside the timeline menu we want to keep the element inside the popover, to avoid closing the popover when clicking expand.
portal: portalContext.elements?.[TIMELINE_MENU_PORTAL] ? TIMELINE_MENU_PORTAL : true,
placement: 'bottom-end',
fallbackPlacements: ['left', 'left-end', 'left-start'],
}}
/>
<>
<Button icon={ChevronDownIcon} mode="bleed" />
<Button icon={LaunchIcon} mode="bleed" />
</>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Card, Flex, Stack, Text} from '@sanity/ui'
import {Badge, Box, Card, Flex, Stack, Text} from '@sanity/ui'
// eslint-disable-next-line camelcase
import {getTheme_v2, type ThemeColorAvatarColorKey} from '@sanity/ui/theme'
import {createElement, type MouseEvent, useCallback, useMemo} from 'react'
Expand Down Expand Up @@ -59,6 +59,13 @@ const RELATIVE_TIME_OPTIONS: RelativeTimeOptions = {
useTemporalPhrase: true,
}

const TextBadge = styled.span`
border-radius: 0.0625rem;
--card-bg-color: var(--card-badge-caution-bg-color);
--card-fg-color: var(--card-badge-caution-fg-color);
background-color: var(--card-bg-color);
cursor: default;
`
export function TimelineItem({
chunk,
isSelected,
Expand Down Expand Up @@ -116,9 +123,13 @@ export function TimelineItem({
</IconBox>
</div>
<Stack space={2}>
<Text size={1} weight="medium">
{t(TIMELINE_ITEM_I18N_KEY_MAPPING[type]) || <code>{type}</code>}
</Text>
<Box as="p">
<Text size={1} weight="medium">
{t(TIMELINE_ITEM_I18N_KEY_MAPPING[type]) || <code>{type}</code>}{' '}
<TextBadge>Summer drop</TextBadge>
</Text>
{/* <Badge mode="outline" tone={'caution'} radius={1}></Badge> */}
</Box>

<Text as="time" size={1} muted dateTime={timestamp} title={formattedTimestamp}>
{updatedTimeAgo}
Expand Down

0 comments on commit 39792f5

Please sign in to comment.