Compare commits

...

3 commits

Author SHA1 Message Date
thislight
d2df08f140
RegularToot: supports bot mark
All checks were successful
/ depoly (push) Successful in 1m19s
2024-11-05 16:20:13 +08:00
thislight
bda41f0923
Profile: supports bot mark 2024-11-05 16:19:55 +08:00
thislight
456cfdfbb0
typography: remove module css 2024-11-05 16:07:10 +08:00
8 changed files with 64 additions and 37 deletions

View file

@ -1,5 +1,6 @@
import { Component, JSX, splitProps } from "solid-js"; import { Component, JSX, splitProps } from "solid-js";
import materialStyles from "./material.module.css"; import materialStyles from "./material.module.css";
import "./typography.css";
/** /**
* Material-styled button. * Material-styled button.
@ -10,12 +11,15 @@ const Button: Component<JSX.ButtonHTMLAttributes<HTMLButtonElement>> = (
props, props,
) => { ) => {
const [managed, passthough] = splitProps(props, ["class", "type"]); const [managed, passthough] = splitProps(props, ["class", "type"]);
const classes = () =>
managed.class
? [materialStyles.button, managed.class].join(" ")
: materialStyles.button;
const type = () => managed.type ?? "button"; const type = () => managed.type ?? "button";
return <button type={type()} class={classes()} {...passthough}></button>;
return (
<button
type={type()}
class={`${materialStyles.button} buttonText ${managed.class || ""}`}
{...passthough}
></button>
);
}; };
export default Button; export default Button;

View file

@ -10,7 +10,6 @@
} }
.button { .button {
composes: buttonText from "./typography.module.css";
composes: touchTarget; composes: touchTarget;
border: none; border: none;

View file

@ -29,12 +29,11 @@
font-size: var(--subheading-size); font-size: var(--subheading-size);
} }
.body1 { .body1, .body2 {
font-size: var(--body-size); font-size: var(--body-size);
} }
.body2 { .body2 {
composes: body1;
font-weight: var(--body2-weight); font-weight: var(--body2-weight);
} }

View file

@ -1,7 +1,6 @@
import { JSX, ParentComponent, splitProps, type Ref } from "solid-js"; import { JSX, ParentComponent, splitProps, type Ref } from "solid-js";
import { Dynamic } from "solid-js/web"; import { Dynamic } from "solid-js/web";
import typography from "./typography.module.css"; import "./typography.css";
import { mergeClass } from "../utils";
type AnyElement = keyof JSX.IntrinsicElements | ParentComponent<any>; type AnyElement = keyof JSX.IntrinsicElements | ParentComponent<any>;
@ -40,13 +39,11 @@ export function Typography<T extends AnyElement>(
"class", "class",
"typography", "typography",
]); ]);
const classes = () =>
mergeClass(managed.class, typography[managed.typography]);
return ( return (
<Dynamic <Dynamic
ref={managed.ref} ref={managed.ref}
component={managed.component ?? "span"} component={managed.component ?? "span"}
class={classes()} class={`${managed.class} ${managed.typography}`}
{...passthough} {...passthough}
></Dynamic> ></Dynamic>
); );

View file

@ -38,6 +38,16 @@
flex-flow: column nowrap; flex-flow: column nowrap;
} }
.bot-mark {
font-size: 1.2em;
}
.display-name {
display: flex;
align-items: center;
gap: 4px;
}
table.acct-fields { table.acct-fields {
word-break: break-all; word-break: break-all;

View file

@ -38,10 +38,12 @@ import {
PlaylistAdd, PlaylistAdd,
Send, Send,
Share, Share,
SmartToy,
SmartToySharp,
Translate, Translate,
Verified, Verified,
} from "@suid/icons-material"; } from "@suid/icons-material";
import { Title } from "../material/typography"; import { Body2, Title } from "../material/typography";
import { useNavigate, useParams } from "@solidjs/router"; import { useNavigate, useParams } from "@solidjs/router";
import { useSessionForAcctStr } from "../masto/clients"; import { useSessionForAcctStr } from "../masto/clients";
import { resolveCustomEmoji } from "../masto/toot"; import { resolveCustomEmoji } from "../masto/toot";
@ -400,15 +402,21 @@ const Profile: Component = () => {
}} }}
></Avatar> ></Avatar>
<div class="name-grp"> <div class="name-grp">
<span <div class="display-name">
ref={(e) => <Show when={profile()?.bot}>
createRenderEffect(() => (e.innerHTML = displayName())) <SmartToySharp class="bot-mark" aria-label="Bot" />
} </Show>
aria-label="Display name" <Body2
></span> component="span"
ref={(e: HTMLElement) =>
createRenderEffect(() => (e.innerHTML = displayName()))
}
aria-label="Display name"
></Body2>
</div>
<span aria-label="Complete username">{fullUsername()}</span> <span aria-label="Complete username">{fullUsername()}</span>
</div> </div>
<div> <div role="presentation">
<Switch> <Switch>
<Match <Match
when={ when={

View file

@ -20,6 +20,7 @@ import {
StarOutline, StarOutline,
Bookmark, Bookmark,
Share, Share,
SmartToySharp,
} from "@suid/icons-material"; } from "@suid/icons-material";
import { useTimeSource } from "../platform/timesrc.js"; import { useTimeSource } from "../platform/timesrc.js";
import { resolveCustomEmoji } from "../masto/toot.js"; import { resolveCustomEmoji } from "../masto/toot.js";
@ -151,17 +152,22 @@ function TootAuthorGroup(
<div class={tootStyle.tootAuthorGrp} {...rest}> <div class={tootStyle.tootAuthorGrp} {...rest}>
<Img src={toot().account.avatar} class={tootStyle.tootAvatar} /> <Img src={toot().account.avatar} class={tootStyle.tootAvatar} />
<div class={tootStyle.tootAuthorNameGrp}> <div class={tootStyle.tootAuthorNameGrp}>
<Body2 <div class={tootStyle.tootAuthorNamePrimary}>
class={tootStyle.tootAuthorNamePrimary} <Show when={toot().account.bot}>
ref={(e: { innerHTML: string }) => { <SmartToySharp class="bot-mark" aria-label="Bot" />
createRenderEffect(() => { </Show>
e.innerHTML = resolveCustomEmoji( <Body2
toot().account.displayName, component="span"
toot().account.emojis, ref={(e: { innerHTML: string }) => {
); createRenderEffect(() => {
}); e.innerHTML = resolveCustomEmoji(
}} toot().account.displayName,
/> toot().account.emojis,
);
});
}}
/>
</div>
<time datetime={toot().createdAt}> <time datetime={toot().createdAt}>
{formatRelative(toot().createdAt, managed.now, { {formatRelative(toot().createdAt, managed.now, {
locale: dateFnLocale(), locale: dateFnLocale(),

View file

@ -49,10 +49,7 @@
.tootAuthorNameGrp { .tootAuthorNameGrp {
display: grid; display: grid;
grid-template-columns: 1fr auto; grid-template-columns: 1fr auto;
color: var(--tutu-color-secondary-text-on-surface);
>* {
color: var(--tutu-color-secondary-text-on-surface);
}
> :last-child { > :last-child {
grid-column: 1 /3; grid-column: 1 /3;
@ -70,7 +67,14 @@
} }
.tootAuthorNamePrimary { .tootAuthorNamePrimary {
color: revert; color: var(--tutu-color-on-surface);
display: flex;
align-items: center;
gap: 4px;
> :global(.bot-mark) {
font-size: 1.2em;
}
} }
.tootAvatar { .tootAvatar {