组件 · 数据展示
SiteDomain
A site's domain where the app says which site a page is on, cut at its start when it doesn't fit, so its end, whose site it is, always shows.
import { SiteDomain } from "@botiverse/raft-ui/wip";SiteDomain draws a site's domain where the app says which site a page is on: a built-in browser's address bar, the head over a page on another site, a web page's panel title. When the domain is longer than its room it loses its start, never its end. The end of a domain says whose site it is: accounts.google.com.sign-in.evil-example.net with its end cut off would read as Google.
When to use
Anatomy
SiteDomain: aspanthat cuts its text at the start, holding the domain in a left-to-rightbdi. Itshostis the domain. Required.
It draws the domain and nothing else. The Not secure badge, the path, the tooltip with the full address and any icon are the caller's, beside it.
Behavior
- A domain that fits starts at the inline start, as every head and address does.
- One that doesn't fit is cut at its start with an ellipsis: the box is laid right to left so the browser's
text-overflow: ellipsisfalls at the start, and thebdikeeps the domain itself, and text selected or copied from it, left to right. Find in page, copy and screen readers get the whole domain. - It shrinks in a flex row (
min-w-0). Put it after whatever should give up its room first, and give thatshrink.
Address rows
Only where the design shows a page's path as well, today the row of a web page opened beside a conversation, the domain comes first, in full and bold, and the path, query and fragment follow it, muted and cut at their end. The path gives up its room first (shrink-9999); the domain is cut, at its start, only once the path has gone. A built-in browser's address bar shows the domain alone, with no path (Navigation, rule 4). Never pass a whole address to SiteDomain: cut at its start, an address loses its domain first.
Content
- Pass the domain as
URL.hostgives it: ASCII (punycode,xn--…) for an internationalized domain, so a look-alike Unicode domain can't pass for another, and with its port when it has one. Don't dropwww.or any other subdomain: a subdomain can belong to someone else. - On an
http:page, show Not secure before the domain: a Badge withappearance="soft"andvariant="warning", which doesn't shrink. - Put the full address in the row's
title(or a Tooltip), so a cut domain can still be read in full.
Accessibility
- It is text, with no role of its own. A screen reader reads the whole domain, left to right, whatever is cut.
- A head or a panel that names its page by the domain uses it inside its heading element.
Rules
- Cut a domain at its start, never its end: the end says whose site it is.
- Draw only a domain with it. The path goes beside it, cut at its end.
- Show the domain in ASCII form, as the browser's address does: a Unicode look-alike of another site's domain would read as that site.
API
SiteDomain
Also takes the attributes of its element.