Skip to content

Commit

Permalink
Improvement(TimeAgo/Lanes UI): add full date timestamp tooltip + lane…
Browse files Browse the repository at this point in the history
… import menu fixes (#6984)
  • Loading branch information
luvkapur authored Feb 7, 2023
1 parent 78f1b1b commit 62e2c82
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 42 deletions.
9 changes: 9 additions & 0 deletions scopes/design/ui/time-ago/time-ago.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.dateTooltip,
.dateTooltipContent {
display: flex;
}

.dateTooltip {
max-width: unset !important; // Override inline css from Tippyjs
width: max-content;
}
15 changes: 7 additions & 8 deletions scopes/design/ui/time-ago/time-ago.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import testRenderer from 'react-test-renderer';
import { render } from '@testing-library/react';
import {
YearsAgoWithTimestamp,
Expand All @@ -13,7 +12,7 @@ import {

describe('Time Ago Component', () => {
it('renders correctly - years ago', () => {
testRenderer.create(<YearsAgoWithTimestamp />);
render(<YearsAgoWithTimestamp />);
});
it('should render - years ago', () => {
const { getByText } = render(<YearsAgoWithTimestamp />);
Expand All @@ -22,7 +21,7 @@ describe('Time Ago Component', () => {
expect(text).toBeInTheDocument();
});
it('renders correctly - month ago', () => {
testRenderer.create(<MonthTimeAgo />);
render(<MonthTimeAgo />);
});
it('should render - month ago', () => {
const { getByText } = render(<MonthTimeAgo />);
Expand All @@ -31,7 +30,7 @@ describe('Time Ago Component', () => {
expect(text).toBeInTheDocument();
});
it('renders correctly - months ago', () => {
testRenderer.create(<MonthsTimeAgo />);
render(<MonthsTimeAgo />);
});
it('should render - months ago', () => {
const { getByText } = render(<MonthsTimeAgo />);
Expand All @@ -40,7 +39,7 @@ describe('Time Ago Component', () => {
expect(text).toBeInTheDocument();
});
it('renders correctly - hour ago', () => {
testRenderer.create(<HourTimeAgo />);
render(<HourTimeAgo />);
});
it('should render - hour ago', () => {
const { getByText } = render(<HourTimeAgo />);
Expand All @@ -49,7 +48,7 @@ describe('Time Ago Component', () => {
expect(text).toBeInTheDocument();
});
it('renders correctly - hours ago', () => {
testRenderer.create(<HoursTimeAgo />);
render(<HoursTimeAgo />);
});
it('should render - hours ago', () => {
const { getByText } = render(<HoursTimeAgo />);
Expand All @@ -58,7 +57,7 @@ describe('Time Ago Component', () => {
expect(text).toBeInTheDocument();
});
it('renders correctly - just now', () => {
testRenderer.create(<CurrentTime />);
render(<CurrentTime />);
});
it('should render - just now', () => {
const { getByText } = render(<CurrentTime />);
Expand All @@ -67,7 +66,7 @@ describe('Time Ago Component', () => {
expect(text).toBeInTheDocument();
});
it('renders correctly - just now with ISO date', () => {
testRenderer.create(<CurrentTimeWithIsoDate />);
render(<CurrentTimeWithIsoDate />);
});
it('should render - just now', () => {
const { getByText } = render(<CurrentTimeWithIsoDate />);
Expand Down
14 changes: 11 additions & 3 deletions scopes/design/ui/time-ago/time-ago.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import timeAgo from '@teambit/base-ui.utils.time-ago';
import classNames from 'classnames';
import React, { useEffect, useMemo, useReducer } from 'react';
import { Tooltip } from '@teambit/design.ui.tooltip';
import styles from './time-ago.module.scss';

type TimeAgoProps = {
date: string | number;
Expand All @@ -21,8 +23,14 @@ export function TimeAgo(props: TimeAgoProps) {
}, [date, refreshIdx]);

return (
<span {...rest} className={classNames(className)}>
{formatted}
</span>
<Tooltip
className={styles.dateTooltip}
placement={'top'}
content={<div className={styles.dateTooltipContent}>{date}</div>}
>
<span {...rest} className={classNames(className)}>
{formatted}
</span>
</Tooltip>
);
}
10 changes: 9 additions & 1 deletion scopes/lanes/lanes/lanes.ui.runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,15 @@ export class LanesUI {
const { lanesModel } = useLanes();
if (!lanesModel?.viewedLane) return null;
const { viewedLane, currentLane } = lanesModel;
return <UseLaneMenu host={lanesUi.lanesHost} viewedLaneId={viewedLane.id} currentLaneId={currentLane?.id} />;
return (
<UseLaneMenu
actionName={'Import'}
actionIcon={'terminal'}
host={lanesUi.lanesHost}
viewedLaneId={viewedLane.id}
currentLaneId={currentLane?.id}
/>
);
});
lanesUi.registerLanesDropdown();
return lanesUi;
Expand Down
10 changes: 10 additions & 0 deletions scopes/lanes/ui/menus/use-lanes-menu/use-lanes-menu.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.top {
padding: 16px 24px;
color: var(--bit-text-color, #414141);
padding-left: 0px;
}

.title {
Expand Down Expand Up @@ -35,4 +36,13 @@
.lanesMenu {
background-color: var(--bit-bg-color, #ffffff);
border-bottom: 1px solid var(--bit-border-color-lightest, #ededed);
padding: 16px;
}

.moreInfo {
padding-left: 0px;

> a {
padding-left: 0px;
}
}
51 changes: 21 additions & 30 deletions scopes/lanes/ui/menus/use-lanes-menu/use-lanes-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { Icon } from '@teambit/evangelist.elements.icon';
import { CopyBox } from '@teambit/documenter.ui.copy-box';
import { ExpandableTabContent, TabContent } from '@teambit/ui-foundation.ui.use-box.tab-content';
import { Ellipsis } from '@teambit/design.ui.styles.ellipsis';
import { linkStyles } from '@teambit/ui-foundation.ui.use-box.bottom-link';
import { LanesHost } from '@teambit/lanes.ui.models.lanes-model';
Expand All @@ -20,10 +19,14 @@ export function UseLaneMenu({
host,
viewedLaneId,
currentLaneId,
actionName,
actionIcon,
}: {
host: LanesHost;
viewedLaneId: LaneId;
currentLaneId?: LaneId;
actionName?: string;
actionIcon?: string;
}) {
const switchedOutToCurrentLane = !!currentLaneId?.isEqual(currentLaneId);
const Menu = (
Expand All @@ -34,25 +37,30 @@ export function UseLaneMenu({
<Ellipsis className={styles.titleText}>{`Bulk import from ${viewedLaneId.name}`}</Ellipsis>
</div>
</div>
<ExpandableTabContent
content={
<LaneImportContent
host={host}
currentLaneId={viewedLaneId}
switchedOutToCurrentLane={switchedOutToCurrentLane}
/>
}
drawerTitle={<div className={styles.drawerTitle}>Learn more about Lanes</div>}
drawerContent={<LaneInfo />}
/>
<LaneImportContent host={host} currentLaneId={viewedLaneId} switchedOutToCurrentLane={switchedOutToCurrentLane} />
<div className={styles.moreInfo}>
<Link external href={'https://bit.dev/docs/lanes/lanes-overview'} className={linkStyles}>
<Icon of="information-sign" />
<div className={styles.drawerTitle}>Learn more about Lanes</div>
</Link>
</div>
</div>
);

return <UseBoxDropdown position="bottom-end" className={styles.useBox} Menu={Menu} />;
return (
<UseBoxDropdown
actionName={actionName}
actionIcon={actionIcon}
position="bottom-end"
className={styles.useBox}
Menu={Menu}
/>
);
}

function LaneImportContent({ host, currentLaneId, switchedOutToCurrentLane }: LaneImportContentProps) {
const laneId = host === 'workspace' ? currentLaneId.name : currentLaneId.toString();

if (switchedOutToCurrentLane) {
return (
<div className={styles.importContent}>
Expand All @@ -68,20 +76,3 @@ function LaneImportContent({ host, currentLaneId, switchedOutToCurrentLane }: La
</div>
);
}

type LaneInfoProps = {} & React.HTMLAttributes<HTMLDivElement>;

function LaneInfo({ ...rest }: LaneInfoProps) {
return (
<TabContent
{...rest}
className={styles.moreInfo}
bottom={
<Link external href={'https://bit.dev/docs/lanes/lanes-overview'} className={linkStyles}>
<Icon of="information-sign" />
<span>Getting Started with Lanes</span>
</Link>
}
></TabContent>
);
}

0 comments on commit 62e2c82

Please sign in to comment.