Skip to content

Commit 6f96c21

Browse files
committed
feat(trends): includes
1 parent 473d7f1 commit 6f96c21

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

client/src/pages/trends/components/ranking/header/index.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1+
import cn from "classnames"
12
import { useIntl } from "react-intl"
23
import useTrends from "../../../hooks/useTrends"
34
import useOptions from "../../../hooks/useOptions"
5+
import { useTrendsContext } from "../../../context"
6+
import { useState } from "react"
7+
import { TextInput } from "@dataesr/dsfr-plus"
48

59
export default function TrendsTableHeader() {
610
const intl = useIntl()
11+
const [openSearch, setOpenSearch] = useState(false)
12+
const { includes, setIncludes } = useTrendsContext()
713
const { trendsYears } = useTrends()
814
const { currentModel } = useOptions()
915

16+
const handleOpenSearchChange = () => {
17+
if (openSearch === true) setIncludes("") // reset includes if closing
18+
setOpenSearch(!openSearch)
19+
}
20+
1021
return (
1122
<thead>
1223
<tr>
13-
<th>Rank</th>
14-
<th>{intl.formatMessage({ id: `trends.ranking.header.domains` })}</th>
24+
<th className={cn("action", openSearch ? "open" : "")} onClick={handleOpenSearchChange}>
25+
{<span className="fr-icon-search-line" />}
26+
</th>
27+
<th>
28+
{openSearch ? (
29+
<TextInput value={includes} placeholder="Search topics" onChange={(event) => setIncludes(event.target.value)} />
30+
) : (
31+
intl.formatMessage({ id: `trends.ranking.header.domains` })
32+
)}
33+
</th>
1534
<th>{intl.formatMessage({ id: `trends.ranking.header.count` }, { max: trendsYears.max })}</th>
1635
<th title={`The variation between the volume in ${trendsYears.max} and the previous years average volume`}>
1736
{intl.formatMessage({ id: `trends.ranking.header.variation` })}

client/src/pages/trends/components/ranking/styles.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ th {
2020
color: var(--text-default-grey);
2121
cursor: default;
2222

23-
&.sort-button {
23+
&.action {
2424
cursor: pointer;
2525
&:hover {
2626
background-color: var(--active);
2727
}
2828
}
29+
&.open {
30+
background-color: var(--active);
31+
}
2932
}
3033

3134
// td {

0 commit comments

Comments
 (0)