Compare commits

...

3 commits

Author SHA1 Message Date
thislight
cecebda39b
Home: move to the top if the clicked tab is focus
All checks were successful
/ depoly (push) Successful in 1m4s
2024-08-17 19:01:05 +08:00
thislight
0f357a66e8
TootPreviewCard: balance padding 2024-08-17 18:58:25 +08:00
thislight
13ad3e4958
CompactToot: added preview cards 2024-08-17 18:09:55 +08:00
4 changed files with 20 additions and 4 deletions

View file

@ -1,12 +1,11 @@
import type { mastodon } from "masto";
import { type Component } from "solid-js";
import { Show, type Component } from "solid-js";
import tootStyle from "./toot.module.css";
import { formatRelative } from "date-fns";
import Img from "../material/Img";
import { Body2 } from "../material/typography";
import { css } from "solid-styled";
import { appliedCustomEmoji } from "../masto/toot";
import cardStyle from "../material/cards.module.css";
import { TootPreviewCard } from "./RegularToot";
type CompactTootProps = {
status: mastodon.v1.Status;
@ -48,6 +47,9 @@ const CompactToot: Component<CompactTootProps> = (props) => {
}}
class={[tootStyle.compactTootContent].join(" ")}
></div>
<Show when={toot().card}>
<TootPreviewCard src={toot().card!} alwaysCompact />
</Show>
</section>
);
};

View file

@ -282,6 +282,12 @@ const Home: ParentComponent = (props) => {
if (items.length > idx) {
items.item(idx).scrollIntoView({ block: "start", behavior: "smooth" });
}
if (isTabFocus(idx)) {
items.item(idx).scrollTo({
top: 0,
behavior: "smooth",
});
}
};
const openFullScreenToot = (

View file

@ -197,10 +197,17 @@ function TootAuthorGroup(props: { status: mastodon.v1.Status; now: Date }) {
);
}
function TootPreviewCard(props: { src: mastodon.v1.PreviewCard }) {
export function TootPreviewCard(props: {
src: mastodon.v1.PreviewCard;
alwaysCompact?: boolean;
}) {
let root: HTMLAnchorElement;
createEffect(() => {
if (props.alwaysCompact) {
root.classList.add(tootStyle.compact);
return;
}
if (!props.src.width) return;
const width = root.getBoundingClientRect().width;
if (width > props.src.width) {

View file

@ -147,6 +147,7 @@
grid-template-columns: minmax(10%, 30%) 1fr;
padding-left: 16px;
padding-right: 16px;
padding-top: 8px;
>img:first-child {
grid-row: 1 / 3;