mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Show hashtag usage total counts
This commit is contained in:
parent
146e5d1a7e
commit
3092a8bba1
5 changed files with 65 additions and 16 deletions
15
src/app.css
15
src/app.css
|
@ -1992,6 +1992,21 @@ ul.link-list li a {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
|
.count {
|
||||||
|
font-size: 80%;
|
||||||
|
display: inline-block;
|
||||||
|
color: var(--text-insignificant-color);
|
||||||
|
min-width: 16px;
|
||||||
|
min-height: 16px;
|
||||||
|
padding: 4px;
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
@media (min-width: 40em) {
|
||||||
|
background-color: var(--bg-faded-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ul.link-list li:first-child a {
|
ul.link-list li:first-child a {
|
||||||
border-top-left-radius: var(--radius);
|
border-top-left-radius: var(--radius);
|
||||||
|
|
|
@ -269,6 +269,15 @@
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
|
|
||||||
|
.grow {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.count {
|
||||||
|
font-size: 80%;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#compose-container .text-expander-menu li b img {
|
#compose-container .text-expander-menu li b img {
|
||||||
/* The shortcode emojis */
|
/* The shortcode emojis */
|
||||||
|
|
|
@ -17,6 +17,7 @@ import db from '../utils/db';
|
||||||
import emojifyText from '../utils/emojify-text';
|
import emojifyText from '../utils/emojify-text';
|
||||||
import localeMatch from '../utils/locale-match';
|
import localeMatch from '../utils/locale-match';
|
||||||
import openCompose from '../utils/open-compose';
|
import openCompose from '../utils/open-compose';
|
||||||
|
import shortenNumber from '../utils/shorten-number';
|
||||||
import states, { saveStatus } from '../utils/states';
|
import states, { saveStatus } from '../utils/states';
|
||||||
import store from '../utils/store';
|
import store from '../utils/store';
|
||||||
import {
|
import {
|
||||||
|
@ -1306,6 +1307,7 @@ const Textarea = forwardRef((props, ref) => {
|
||||||
username,
|
username,
|
||||||
acct,
|
acct,
|
||||||
emojis,
|
emojis,
|
||||||
|
history,
|
||||||
} = result;
|
} = result;
|
||||||
const displayNameWithEmoji = emojifyText(displayName, emojis);
|
const displayNameWithEmoji = emojifyText(displayName, emojis);
|
||||||
// const item = menuItem.cloneNode();
|
// const item = menuItem.cloneNode();
|
||||||
|
@ -1324,9 +1326,18 @@ const Textarea = forwardRef((props, ref) => {
|
||||||
</li>
|
</li>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
|
const total = history?.reduce?.(
|
||||||
|
(acc, cur) => acc + +cur.uses,
|
||||||
|
0,
|
||||||
|
);
|
||||||
html += `
|
html += `
|
||||||
<li role="option" data-value="${encodeHTML(name)}">
|
<li role="option" data-value="${encodeHTML(name)}">
|
||||||
<span>#<b>${encodeHTML(name)}</b></span>
|
<span class="grow">#<b>${encodeHTML(name)}</b></span>
|
||||||
|
${
|
||||||
|
total
|
||||||
|
? `<span class="count">${shortenNumber(total)}</span>`
|
||||||
|
: ''
|
||||||
|
}
|
||||||
</li>
|
</li>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import NavMenu from '../components/nav-menu';
|
||||||
import SearchForm from '../components/search-form';
|
import SearchForm from '../components/search-form';
|
||||||
import Status from '../components/status';
|
import Status from '../components/status';
|
||||||
import { api } from '../utils/api';
|
import { api } from '../utils/api';
|
||||||
|
import shortenNumber from '../utils/shorten-number';
|
||||||
import useTitle from '../utils/useTitle';
|
import useTitle from '../utils/useTitle';
|
||||||
|
|
||||||
const SHORT_LIMIT = 5;
|
const SHORT_LIMIT = 5;
|
||||||
|
@ -244,20 +245,32 @@ function Search(props) {
|
||||||
{hashtagResults.length > 0 ? (
|
{hashtagResults.length > 0 ? (
|
||||||
<>
|
<>
|
||||||
<ul class="link-list hashtag-list">
|
<ul class="link-list hashtag-list">
|
||||||
{hashtagResults.map((hashtag) => (
|
{hashtagResults.map((hashtag) => {
|
||||||
<li key={hashtag.name}>
|
const { name, history } = hashtag;
|
||||||
<Link
|
const total = history.reduce(
|
||||||
to={
|
(acc, cur) => acc + +cur.uses,
|
||||||
instance
|
0,
|
||||||
? `/${instance}/t/${hashtag.name}`
|
);
|
||||||
: `/t/${hashtag.name}`
|
return (
|
||||||
}
|
<li key={hashtag.name}>
|
||||||
>
|
<Link
|
||||||
<Icon icon="hashtag" />
|
to={
|
||||||
<span>{hashtag.name}</span>
|
instance
|
||||||
</Link>
|
? `/${instance}/t/${hashtag.name}`
|
||||||
</li>
|
: `/t/${hashtag.name}`
|
||||||
))}
|
}
|
||||||
|
>
|
||||||
|
<Icon icon="hashtag" />
|
||||||
|
<span>{hashtag.name}</span>
|
||||||
|
{!!total && (
|
||||||
|
<span class="count">
|
||||||
|
{shortenNumber(total)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
{type !== 'hashtags' && (
|
{type !== 'hashtags' && (
|
||||||
<div class="ui-state">
|
<div class="ui-state">
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { api } from '../utils/api';
|
||||||
import { oklab2rgb, rgb2oklab } from '../utils/color-utils';
|
import { oklab2rgb, rgb2oklab } from '../utils/color-utils';
|
||||||
import { filteredItems } from '../utils/filters';
|
import { filteredItems } from '../utils/filters';
|
||||||
import pmem from '../utils/pmem';
|
import pmem from '../utils/pmem';
|
||||||
|
import shortenNumber from '../utils/shorten-number';
|
||||||
import states from '../utils/states';
|
import states from '../utils/states';
|
||||||
import { saveStatus } from '../utils/states';
|
import { saveStatus } from '../utils/states';
|
||||||
import useTitle from '../utils/useTitle';
|
import useTitle from '../utils/useTitle';
|
||||||
|
@ -131,7 +132,7 @@ function Trending({ columnMode, ...props }) {
|
||||||
<span class="more-insignificant">#</span>
|
<span class="more-insignificant">#</span>
|
||||||
{name}
|
{name}
|
||||||
</span>
|
</span>
|
||||||
<span class="filter-count">{total.toLocaleString()}</span>
|
<span class="filter-count">{shortenNumber(total)}</span>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
Loading…
Reference in a new issue