Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

3.6 KB
Raw Blame
.tooltip {
  user-select: none; // 同步悬浮需要点击链接,因此不能使用  pointer-events: none;
  position: fixed;
  z-index: 1000000;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: normal;
  color: var(--b3-tooltips-color);
  word-wrap: break-word;
  background-color: var(--b3-tooltips-background);
  border-radius: var(--b3-border-radius);
  line-height: 17px;
  width: max-content;
  max-width: 320px;
  animation-name: zoomIn;
  animation-duration: 150ms;
  animation-delay: 300ms;
  animation-fill-mode: both;
  max-height: 90vh;
  overflow: auto;
  box-sizing: border-box;
  white-space: break-spaces;

  a {
    color: var(--b3-theme-secondary);

    &:hover {
      text-decoration: underline;
    }
  }

  &--error {
    background: var(--b3-theme-error);
  }

  .ft__on-surface {
    color: var(--b3-tooltips-second-color);
  }
}

.drag-tip {
  max-width: min(216px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);

  &__title,
  &__target {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__action {
    color: var(--b3-tooltips-second-color);
    font-size: 12px;

    &--target {
      display: grid;
      grid-template-columns: minmax(0, max-content) minmax(0, 1fr) minmax(0, max-content);
    }
  }

  &__label {
    color: var(--b3-tooltips-color);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }
}

.b3-tooltips {
  position: relative;
  cursor: pointer;
  overflow: hidden;

  &::after {
    z-index: 1000000;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: normal;
    color: var(--b3-tooltips-color);
    word-wrap: break-word;
    white-space: pre;
    content: attr(aria-label);
    background-color: var(--b3-tooltips-background);
    border-radius: var(--b3-border-radius);
    line-height: 17px;
    transform: scale(.9);
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    box-shadow: var(--b3-tooltips-shadow);
    font-family: var(--b3-font-family);
  }

  &::after {
    pointer-events: none;
    position: absolute;
    opacity: 0;
    transition: opacity 150ms 300ms cubic-bezier(0, 0, .2, 1), transform 150ms 300ms cubic-bezier(0, 0, .2, 1);
  }

  &:hover,
  &:focus-within {
    overflow: initial;
  }

  &:hover::after,
  &:focus-within::after {
    display: inline-block;
    opacity: 1;
    transform: scale(1);
  }

  &__s::after,
  &__se::after,
  &__sw::after {
    top: 100%;
    right: 50%;
    margin-top: 5px
  }

  &__se::after {
    right: auto;
    left: 50%;
    margin-left: -15px
  }

  &__sw::after {
    margin-right: -15px
  }

  &__n::after,
  &__ne::after,
  &__nw::after {
    right: 50%;
    bottom: 100%;
    margin-bottom: 5px
  }

  &__ne::after {
    right: auto;
    left: 50%;
    margin-left: -15px
  }

  &__nw::after {
    margin-right: -15px
  }

  &__s::after,
  &__n::after {
    transform: translateX(50%) scale(.8);
  }

  &__s:hover::after,
  &__n:hover::after,
  &__s:focus-within::after,
  &__n:focus-within::after {
    transform: translateX(50%) scale(1);
  }

  &__w::after {
    right: 100%;
    bottom: 50%;
    margin-right: 5px;
    transform: translateY(50%) scale(.8);
  }

  &__e::after {
    bottom: 50%;
    left: 100%;
    margin-left: 5px;
    transform: translateY(50%) scale(.8);
  }

  &__e:hover::after,
  &__w:hover::after,
  &__e:focus-within::after,
  &__w:focus-within::after {
    transform: translateY(50%) scale(1);
  }
}

.body--touch-input {
  .tooltip--hover {
    display: none;
  }

  .b3-tooltips::after {
    content: none;
  }
}

@media screen and (max-width: 520px) {
  .b3-tooltips::after {
    content: none;
  }
}