mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-25 01:08:50 +01:00
Use useTruncated for notification items
This commit is contained in:
parent
f9b2ab3b94
commit
4acfb2a1cf
2 changed files with 38 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
import shortenNumber from '../utils/shorten-number';
|
import shortenNumber from '../utils/shorten-number';
|
||||||
import states from '../utils/states';
|
import states from '../utils/states';
|
||||||
import store from '../utils/store';
|
import store from '../utils/store';
|
||||||
|
import useTruncated from '../utils/useTruncated';
|
||||||
|
|
||||||
import Avatar from './avatar';
|
import Avatar from './avatar';
|
||||||
import FollowRequestButtons from './follow-request-buttons';
|
import FollowRequestButtons from './follow-request-buttons';
|
||||||
|
@ -266,20 +267,20 @@ function Notification({ notification, instance, reload, isStatic }) {
|
||||||
<ul class="notification-group-statuses">
|
<ul class="notification-group-statuses">
|
||||||
{_statuses.map((status) => (
|
{_statuses.map((status) => (
|
||||||
<li key={status.id}>
|
<li key={status.id}>
|
||||||
<Link
|
<TruncatedLink
|
||||||
class={`status-link status-type-${type}`}
|
class={`status-link status-type-${type}`}
|
||||||
to={
|
to={
|
||||||
instance ? `/${instance}/s/${status.id}` : `/s/${status.id}`
|
instance ? `/${instance}/s/${status.id}` : `/s/${status.id}`
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Status status={status} size="s" />
|
<Status status={status} size="s" />
|
||||||
</Link>
|
</TruncatedLink>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
{status && (!_statuses?.length || _statuses?.length <= 1) && (
|
{status && (!_statuses?.length || _statuses?.length <= 1) && (
|
||||||
<Link
|
<TruncatedLink
|
||||||
class={`status-link status-type-${type}`}
|
class={`status-link status-type-${type}`}
|
||||||
to={
|
to={
|
||||||
instance
|
instance
|
||||||
|
@ -306,11 +307,16 @@ function Notification({ notification, instance, reload, isStatic }) {
|
||||||
) : (
|
) : (
|
||||||
<Status statusID={actualStatusID} size="s" />
|
<Status statusID={actualStatusID} size="s" />
|
||||||
)}
|
)}
|
||||||
</Link>
|
</TruncatedLink>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TruncatedLink(props) {
|
||||||
|
const ref = useTruncated();
|
||||||
|
return <Link {...props} data-read-more="Read more →" ref={ref} />;
|
||||||
|
}
|
||||||
|
|
||||||
export default Notification;
|
export default Notification;
|
||||||
|
|
|
@ -98,8 +98,8 @@
|
||||||
}
|
}
|
||||||
.notification .status-link:not(.status-type-mention) > .status {
|
.notification .status-link:not(.status-type-mention) > .status {
|
||||||
font-size: calc(var(--text-size) * 0.9);
|
font-size: calc(var(--text-size) * 0.9);
|
||||||
max-height: 160px;
|
}
|
||||||
overflow: hidden;
|
.notification .status-link.truncated:not(.status-type-mention) > .status {
|
||||||
/* fade out mask gradient bottom */
|
/* fade out mask gradient bottom */
|
||||||
mask-image: linear-gradient(
|
mask-image: linear-gradient(
|
||||||
rgba(0, 0, 0, 1) 130px,
|
rgba(0, 0, 0, 1) 130px,
|
||||||
|
@ -107,6 +107,32 @@
|
||||||
transparent 159px
|
transparent 159px
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
.notification .status-link.truncated {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.notification .status-link.truncated:after {
|
||||||
|
content: attr(data-read-more);
|
||||||
|
line-height: 1;
|
||||||
|
display: inline-block;
|
||||||
|
position: absolute;
|
||||||
|
--inset-offset: 16px;
|
||||||
|
inset-block-end: var(--inset-offset);
|
||||||
|
inset-inline-end: var(--inset-offset);
|
||||||
|
color: var(--link-color);
|
||||||
|
background-color: var(--bg-faded-blur-color);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
border: 1px solid var(--outline-color);
|
||||||
|
padding: 0.5em 0.75em;
|
||||||
|
border-radius: 10em;
|
||||||
|
font-size: 90%;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition: all 0.2s ease-out;
|
||||||
|
}
|
||||||
|
.notification .status-link:is(:hover, :focus).truncated:after {
|
||||||
|
border-color: var(--link-color);
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
transform: translate(2px, 0);
|
||||||
|
}
|
||||||
.notification .status-link.status-type-mention {
|
.notification .status-link.status-type-mention {
|
||||||
max-height: 320px;
|
max-height: 320px;
|
||||||
filter: none;
|
filter: none;
|
||||||
|
|
Loading…
Reference in a new issue