导航

v2.1.0
排版

提及

句子中被点名的个人、团队或事物。

本页内容

提及用于在句中点出某个人、团队或事物,例如 @Ada、#design 或工单编号。它沿用句子的字体和墨色,采用控件的字重,并以同一墨色的浅色调作为底色。它没有轮廓,因此能与行内代码区分开来。

提及

<div class="flex flex-col max-w(440) mx-auto">  <div class="message">    <div class="message-bubble">      <a class="mention" href="#">@Ada Lovelace</a> the build for <a class="mention" href="#">#412</a> is green. Can <a class="mention mention-self" href="#">@you</a> review it before <span class="mention">Friday</span>?    </div>  </div>  <div class="message message-sent">    <div class="message-bubble">      On it. I will loop in <a class="mention" href="#">@design</a> for the corners.    </div>  </div></div>
<div className="flex flex-col max-w(440) mx-auto">  <div className="message">    <div className="message-bubble">      <a className="mention" href="#">@Ada Lovelace</a> the build for <a className="mention" href="#">#412</a> is green. Can <a className="mention mention-self" href="#">@you</a> review it before <span className="mention">Friday</span>?    </div>  </div>  <div className="message message-sent">    <div className="message-bubble">      On it. I will loop in <a className="mention" href="#">@design</a> for the corners.    </div>  </div></div>
<div class="flex flex-col max-w(440) mx-auto">  <div class="message">    <div class="message-bubble">      <a class="mention" href="#">@Ada Lovelace</a> the build for <a class="mention" href="#">#412</a> is green. Can <a class="mention mention-self" href="#">@you</a> review it before <span class="mention">Friday</span>?    </div>  </div>  <div class="message message-sent">    <div class="message-bubble">      On it. I will loop in <a class="mention" href="#">@design</a> for the corners.    </div>  </div></div>
<template>  <div class="flex flex-col max-w(440) mx-auto">    <div class="message">      <div class="message-bubble">        <a class="mention" href="#">@Ada Lovelace</a> the build for <a class="mention" href="#">#412</a> is green. Can <a class="mention mention-self" href="#">@you</a> review it before <span class="mention">Friday</span>?      </div>    </div>    <div class="message message-sent">      <div class="message-bubble">        On it. I will loop in <a class="mention" href="#">@design</a> for the corners.      </div>    </div>  </div></template>

用在 <a> 上时,提及会链接到个人资料或工单等目标,指针悬停时底色会加深。用在 <span> 上时,它只突出显示一个名称,例如解析器识别出的日期。样式表通过 :any-link 区分这两种用法,让只有能跳转的提及看起来像链接。

#读者自己的名字

mention-self 用于标记当前读者。稍深的底色和一圈细边框让读者在长讨论串中一眼找到自己的名字。它沿用其他提及的墨色,色调差异也有意做得很轻微,因此请在正文中写出“你”或读者的名字。

#在正文中使用

提及不会跨行断开。它的底色和细边框颜色由当前文字颜色混合而成,因此在句子出现的任何地方都清晰可读。例如,在采用墨色背景的已发送消息中,提及沿用消息气泡自身的浅色文字,并配以浅色底色。

#无障碍

  • 标记符号是文本的一部分。请在元素内写入 @ 或 #,让提及在复制和朗读时保留相同的内容。
  • 打开个人资料的提及本身就是链接,无需额外指定角色。

#类名

类名说明
mention名称沿用所在句子的字体和文字颜色,采用控件字重,并以该文字颜色的浅色调作为底色。名称内部不换行,用作链接时,指针悬停会加深底色。
mention-self读者自己的名称使用更明显的底色和细线。与 mention 一同使用

#源码

@master/ui/components/mention.css
/* * Mention: a person, a team or a thing named inside a sentence: @Ada, #design, an issue's number. * It is the sentence's own type and its own ink at the control weight, on a faint tint of that ink, with no * contour, which tells it apart from inline code. Because the tint and the hairline are mixed from the * current color, a mention reads on any surface: a page, a card, the ink of a sent message. * As a link it deepens under the pointer. mention-self marks the reader's own name with a firmer tint and a * hairline, so it is found at a glance in a long thread. */@layer components.ui {  .mention {    --mention-tint: 7%;    padding: .0625em .3125em;    border-radius: calc((var(--radius-chip) - 2px) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: color-mix(in oklab, currentColor var(--mention-tint), transparent);    color: inherit;    font-weight: var(--font-weight-control);    text-decoration: none;    white-space: nowrap;    -webkit-box-decoration-break: clone;    box-decoration-break: clone;    @media (hover: hover) {      &:any-link:hover {        --mention-tint: 13%;      }    }    /* Pressed: the same deeper tint, so a tap on a touch screen is answered too. */    &:any-link:active {      --mention-tint: 13%;    }    &:focus-visible {      outline: 2px solid var(--color-focus);      outline-offset: 2px;    }    &.mention-self {      --mention-tint: 12%;      box-shadow: inset 0 0 0 .5px color-mix(in oklab, currentColor 28%, transparent);      /* Its own tint is already firmer, so as a link it deepens from there. */      @media (hover: hover) {        &:any-link:hover {          --mention-tint: 18%;        }      }      &:any-link:active {        --mention-tint: 18%;      }    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;    }  }}