Skip to content

Commit c21a572

Browse files
committed
added tooltip for track selection
1 parent 0a501e6 commit c21a572

File tree

7 files changed

+77
-43
lines changed

7 files changed

+77
-43
lines changed

apps/client/src/components/History/History.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function History() {
4343
<>
4444
<TitleCard
4545
title="Your history"
46+
info="You can select tracks by clicking them, ctrl-clicking them to add to the selection. You can also use shift-click to expand your selection"
4647
right={
4748
<CheckboxWithText
4849
checked={followInterval}

apps/client/src/components/TitleCard/TitleCard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import clsx from "clsx";
22
import Text from "../Text";
33
import s from "./index.module.css";
4+
import { ITooltip } from "../iTooltip/iTooltip";
45

56
interface TitleCardProps {
67
className?: string;
@@ -11,6 +12,7 @@ interface TitleCardProps {
1112
right?: React.ReactNode;
1213
noPadding?: boolean;
1314
noBorder?: boolean;
15+
info?: string;
1416
}
1517

1618
export default function TitleCard({
@@ -22,12 +24,16 @@ export default function TitleCard({
2224
right,
2325
noPadding,
2426
noBorder,
27+
info,
2528
}: TitleCardProps) {
2629
return (
2730
<div className={clsx(s.root, className, { [s.noborder]: noBorder })}>
2831
<div className={clsx(s.container, { [s.nopadding]: noPadding })}>
2932
<div className={s.title}>
30-
<Text element="h3" size='big'>{title}</Text>
33+
<div className={s.left}>
34+
<Text element="h3" size='big'>{title}</Text>
35+
<ITooltip content={info} />
36+
</div>
3137
<div>{right}</div>
3238
</div>
3339
<div className={clsx(s.content, { fade }, contentClassName)}>

apps/client/src/components/TitleCard/index.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@
3434
position: relative;
3535
flex-grow: 1;
3636
}
37+
38+
.left {
39+
display: flex;
40+
flex-direction: row;
41+
align-items: center;
42+
justify-content: flex-start;
43+
gap: 8px;
44+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { InfoOutline } from "@mui/icons-material";
2+
import { Tooltip } from "@mui/material";
3+
import s from './index.module.css'
4+
import { ReactNode } from "react";
5+
6+
interface ITooltipProps {
7+
content?: ReactNode;
8+
}
9+
10+
export function ITooltip({ content }: ITooltipProps) {
11+
if (!content) {
12+
return null;
13+
}
14+
15+
return (
16+
<Tooltip title={content}>
17+
<InfoOutline fontSize="small" className={s.icon} />
18+
</Tooltip>
19+
);
20+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.icon {
2+
color: var(--text-grey);
3+
}

apps/client/src/scenes/Collaborative/Affinity/Affinity.tsx

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Button, Checkbox, MenuItem, Select, Tooltip } from "@mui/material";
1+
import { Button, Checkbox, MenuItem, Select } from "@mui/material";
22
import { useState } from "react";
33
import { useSelector } from "react-redux";
4-
import { HelpOutline } from "@mui/icons-material";
54
import { AdminAccount } from "../../../services/redux/modules/admin/reducer";
65
import { selectAccounts } from "../../../services/redux/modules/admin/selector";
76
import { CollaborativeMode } from "../../../services/types";
@@ -17,6 +16,7 @@ import { useNavigateAndSearch } from "../../../services/hooks/hooks";
1716
import Header from "../../../components/Header";
1817
import { AFFINITY_PREFIX } from "./types";
1918
import s from "./index.module.css";
19+
import { ITooltip } from "../../../components/iTooltip/iTooltip";
2020

2121
export default function Affinity() {
2222
const navigate = useNavigateAndSearch();
@@ -30,14 +30,14 @@ export default function Affinity() {
3030
const accounts = useSelector(selectAccounts);
3131

3232
const add = (account: AdminAccount) => {
33-
const newSet = new Set(ids);
34-
if (newSet.has(account.id)) {
35-
newSet.delete(account.id);
36-
} else {
37-
newSet.add(account.id);
38-
}
39-
setIds(newSet);
40-
};
33+
const newSet = new Set(ids);
34+
if (newSet.has(account.id)) {
35+
newSet.delete(account.id);
36+
} else {
37+
newSet.add(account.id);
38+
}
39+
setIds(newSet);
40+
};
4141

4242
const compute = () => {
4343
navigate(`/collaborative/top/${statType}/${mode}`, {
@@ -46,44 +46,39 @@ export default function Affinity() {
4646
});
4747
};
4848

49-
const tooltip = (
50-
<Tooltip
51-
title={
52-
<div>
53-
<p>
54-
The affinity represents the probability the user like the same
55-
songs. The affinity feature comes with two <strong>modes</strong>:
56-
</p>
57-
<ul>
58-
<li>
59-
<strong>Average</strong>: bases the ranking on the average of the
60-
proportion each people listening to a specific element. If A
61-
listens to a song 50% of his time, B 25% and C 0%, the average
62-
will be 25%, thus ranking higher than A 12%, B 12% and C 12%.
63-
</li>
64-
<li>
65-
<strong>Minima</strong>: bases the ranking on the minimal
66-
proportion of each people listening to a specific element. If A
67-
listens to a song 50% of his time, B 25% and C 0%, the minima will
68-
be 0%, thus ranking lower than A 100% B 5% and C 1%.
69-
</li>
70-
</ul>
71-
<p>
72-
Average can mean that the top songs will satisfy a lot some people
73-
while minima means that the top songs will be known by everyone but
74-
not enjoyed as much for everyone.
75-
</p>
76-
</div>
77-
}>
78-
<HelpOutline className={s.question} />
79-
</Tooltip>
49+
const content = (
50+
<div>
51+
<p>
52+
The affinity represents the probability the user like the same
53+
songs. The affinity feature comes with two <strong>modes</strong>:
54+
</p>
55+
<ul>
56+
<li>
57+
<strong>Average</strong>: bases the ranking on the average of the
58+
proportion each people listening to a specific element. If A
59+
listens to a song 50% of his time, B 25% and C 0%, the average
60+
will be 25%, thus ranking higher than A 12%, B 12% and C 12%.
61+
</li>
62+
<li>
63+
<strong>Minima</strong>: bases the ranking on the minimal
64+
proportion of each people listening to a specific element. If A
65+
listens to a song 50% of his time, B 25% and C 0%, the minima will
66+
be 0%, thus ranking lower than A 100% B 5% and C 1%.
67+
</li>
68+
</ul>
69+
<p>
70+
Average can mean that the top songs will satisfy a lot some people
71+
while minima means that the top songs will be known by everyone but
72+
not enjoyed as much for everyone.
73+
</p>
74+
</div>
8075
);
8176

8277
return (
8378
<div className={s.root}>
8479
<Header
8580
hideInterval
86-
title={<div className={s.title}>Affinity {tooltip}</div>}
81+
title={<div className={s.title}>Affinity <ITooltip content={content} /></div>}
8782
subtitle="Compute the affinity you have with somebody using YourSpotify"
8883
/>
8984
<div className={s.content}>

apps/client/src/scenes/Collaborative/Affinity/index.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
display: flex;
2323
flex-direction: row;
2424
align-items: center;
25+
gap: 8px;
2526
}
2627

2728
.question {

0 commit comments

Comments
 (0)