Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

8.0 KB
Raw Blame
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';

import { voiceSendButtonMarker } from '../markers.stylex';

const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
const SEND_CIRCLE_COLLAPSED = 'circle(14px at calc(100% - 16px) 50%)';
const SEND_CIRCLE_EXPANDED = 'circle(150% at calc(100% - 16px) 50%)';

const voiceMessageEnter = stylex.keyframes({
  from: { transform: 'translateX(8px)', opacity: 0 },
  to: { transform: 'translateX(0)', opacity: 1 },
});

const voiceMessageBusyDot = stylex.keyframes({
  '0%, 60%, 100%': { transform: 'scale(0.72)', opacity: 0.38 },
  '30%': { transform: 'scale(1)', opacity: 1 },
});

export const styles = stylex.create({
  bar: {
    width: '4px',
    minHeight: '4px',
    borderRadius: '9999px',
    backgroundColor: cssVar.colorPrimary,
    backgroundImage: 'none',
    transition: { default: 'height 80ms linear', [REDUCED_MOTION]: 'none' },
  },
  cancelButton: {
    'cursor': 'default',
    'position': 'relative',
    'display': 'inline-flex',
    'flex': 'none',
    'alignItems': 'center',
    'justifyContent': 'center',
    'width': '32px',
    'height': '32px',
    'padding': '0',
    'borderStyle': 'none',
    'borderRadius': '9999px',
    'color': { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
    'backgroundColor': { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFill },
    'backgroundImage': { 'default': 'none', ':hover': 'none' },
    'transition': {
      'default': 'color 120ms ease,\n    background 120ms ease,\n    transform 120ms ease',
      '@media (prefers-reduced-motion: reduce)': 'none',
    },
    'outlineWidth': { 'default': null, ':focus-visible': '2px' },
    'outlineStyle': { 'default': null, ':focus-visible': 'solid' },
    'outlineColor': { 'default': null, ':focus-visible': cssVar.colorPrimary },
    'outlineOffset': { 'default': null, ':focus-visible': '2px' },
    'transform': { 'default': null, ':active': 'scale(0.96)' },
    '::after': {
      content: { 'default': null, '@media (width <= 600px)': "''" },
      position: { 'default': null, '@media (width <= 600px)': 'absolute' },
      inset: { 'default': null, '@media (width <= 600px)': '-6px' },
    },
  },
  container: {
    display: 'flex',
    flex: 'none',
    gap: '6px',
    alignItems: 'center',
    width: 'min(300px, calc(100vw - 112px))',
    minWidth: 'min(220px, calc(100vw - 112px))',
    height: '32px',
    paddingInline: '2px',
    animationName: { default: voiceMessageEnter, [REDUCED_MOTION]: 'none' },
    animationDuration: { default: '160ms', [REDUCED_MOTION]: '0s' },
    animationTimingFunction: { default: 'ease-out', [REDUCED_MOTION]: 'ease' },
  },
  error: {
    position: 'absolute',
    zIndex: 1,
    insetBlockStart: '50%',
    insetInlineStart: '12px',
    insetInlineEnd: '44px',
    transform: 'translateY(-50%)',
    overflow: 'hidden',
    fontSize: cssVar.fontSizeSM,
    lineHeight: 1.3,
    color: cssVar.colorError,
    textAlign: 'center',
    textOverflow: 'ellipsis',
    whiteSpace: 'nowrap',
  },
  pill: {
    position: 'relative',
    overflow: 'hidden',
    flex: '1',
    minWidth: '0',
    height: '100%',
    borderRadius: '9999px',
    backgroundColor: cssVar.colorFillSecondary,
    backgroundImage: 'none',
  },
  progress: {
    position: 'absolute',
    zIndex: 3,
    insetBlockEnd: '0',
    insetInline: '6px',
    overflow: 'hidden',
    height: '2px',
    borderRadius: '1px',
    backgroundColor: cssVar.colorFillSecondary,
    backgroundImage: 'none',
  },
  progressValue: {
    height: '100%',
    borderRadius: 'inherit',
    opacity: 0.72,
    backgroundColor: cssVar.colorBgContainer,
    backgroundImage: 'none',
    transition: { default: 'width 120ms linear', [REDUCED_MOTION]: 'none' },
  },
  sendArrow: {
    position: 'absolute',
    zIndex: 2,
    insetBlockStart: '50%',
    insetInlineEnd: '2px',
    transform: {
      default: 'translateY(-50%)',
      [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]:
        'translateY(-50%) translateX(6px)',
    },
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center',
    width: '28px',
    height: '28px',
    opacity: { default: 1, [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]: 0 },
    transition: { default: 'opacity 100ms ease, transform 160ms ease', [REDUCED_MOTION]: 'none' },
  },
  sendArrowHidden: {
    transform: 'translateY(-50%) translateX(6px)',
    opacity: 0,
  },
  sendButton: {
    'cursor': { 'default': 'default', ':disabled': 'not-allowed' },
    'position': 'absolute',
    'zIndex': 2,
    'inset': '0',
    'overflow': 'hidden',
    'width': '100%',
    'padding': '0',
    'borderWidth': '0',
    'borderStyle': 'none',
    'borderRadius': 'inherit',
    'color': cssVar.colorBgContainer,
    'backgroundColor': 'transparent',
    'backgroundImage': 'none',
    'outlineWidth': { 'default': null, ':focus-visible': '2px' },
    'outlineStyle': { 'default': null, ':focus-visible': 'solid' },
    'outlineColor': { 'default': null, ':focus-visible': cssVar.colorPrimary },
    'outlineOffset': { 'default': null, ':focus-visible': '-3px' },
    '::before': {
      content: "''",
      position: 'absolute',
      zIndex: 0,
      inset: '0',
      borderRadius: 'inherit',
      opacity: { 'default': null, ':disabled': 0.45 },
      backgroundColor: cssVar.colorPrimary,
      backgroundImage: 'none',
      clipPath: { 'default': SEND_CIRCLE_COLLAPSED, ':focus-visible': SEND_CIRCLE_EXPANDED },
      transition: {
        default: 'clip-path 160ms cubic-bezier(0.2, 0.8, 0.2, 1)',
        [REDUCED_MOTION]: 'none',
      },
    },
  },
  sendButtonError: {
    '::before': { backgroundColor: cssVar.colorError },
  },
  sendButtonExpanded: {
    'cursor': 'wait',
    'color': cssVar.colorTextSecondary,
    'backgroundColor': cssVar.colorBgContainer,
    '::before': {
      opacity: 1,
      backgroundColor: cssVar.colorFill,
      clipPath: SEND_CIRCLE_EXPANDED,
    },
  },
  sendButtonHoverExpanded: {
    '::before': { clipPath: SEND_CIRCLE_EXPANDED },
  },
  sendDot: {
    width: '3px',
    height: '3px',
    borderRadius: '9999px',
    backgroundColor: 'currentcolor',
    backgroundImage: 'none',
  },
  sendDotBusy: {
    animationName: { default: voiceMessageBusyDot, [REDUCED_MOTION]: 'none' },
    animationDuration: { default: '900ms', [REDUCED_MOTION]: '0s' },
    animationTimingFunction: { default: 'ease-in-out', [REDUCED_MOTION]: 'ease' },
    animationIterationCount: { default: 'infinite', [REDUCED_MOTION]: 1 },
  },
  sendDotBusySecond: { animationDelay: '120ms' },
  sendDotBusyThird: { animationDelay: '240ms' },
  sendDots: { display: 'inline-flex', gap: '3px', alignItems: 'center' },
  sendLabel: {
    position: 'absolute',
    zIndex: 2,
    inset: '0',
    transform: {
      default: 'translateY(4px)',
      [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]: 'translateY(0)',
    },
    display: 'flex',
    gap: '8px',
    alignItems: 'center',
    justifyContent: 'center',
    minWidth: '0',
    paddingInline: '10px',
    fontSize: cssVar.fontSize,
    fontWeight: cssVar.fontWeightStrong,
    whiteSpace: 'nowrap',
    opacity: { default: 0, [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]: 1 },
    transition: { default: 'opacity 100ms ease, transform 160ms ease', [REDUCED_MOTION]: 'none' },
  },
  sendLabelExpanded: {
    gap: '8px',
    paddingInline: '14px',
    fontSize: cssVar.fontSizeSM,
    fontWeight: 'normal',
  },
  sendLabelOpen: { transform: 'translateY(0)', opacity: 1 },
  sendText: { overflow: 'hidden', minWidth: '0', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
  hidden: { display: 'none' },
  visuallyHidden: {
    position: 'absolute',
    overflow: 'hidden',
    width: '1px',
    height: '1px',
    margin: '-1px',
    padding: '0',
    borderWidth: '0',
    borderStyle: 'none',
    whiteSpace: 'nowrap',
    clip: 'rect(0, 0, 0, 0)',
    clipPath: 'inset(50%)',
  },
  waveform: {
    pointerEvents: 'none',
    position: 'absolute',
    zIndex: 1,
    inset: '0',
    display: 'flex',
    gap: '4px',
    alignItems: 'center',
    justifyContent: 'center',
  },
});