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.

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

import { densityTokens, sidebarRow } from '@/styles/density.stylex';

// StyleX can only fold constants declared in this module (or in a `.stylex.ts` file), so
// these mirror ./constants — keep the two in sync.
const SKILL_ICON_GAP = 14;
const SKILL_TRAILING_CONTROL_SIZE = 20;

// Shared by the policy menu rows; kept in one place so hover/disabled stay in sync.
export const styles = stylex.create({
  addSkillLabel: { flex: '1', textAlign: 'start' },
  addSkillRow: {
    display: 'flex',
    gap: `${SKILL_ICON_GAP}px`,
    alignItems: 'center',
    width: 'calc(100% + 24px)',
    minHeight: sidebarRow.controlHeight,
    // The footer adds 8px block padding; cancel it on the last action row so the
    // bottom row sits flush against the popup edge instead of leaving a gap.
    marginBlockEnd: { 'default': null, ':last-child': '-8px' },
    marginInline: '-12px',
    paddingInline: densityTokens['--lobe-density-content-gap'],
    borderStyle: 'none',
    borderRadius: sidebarRow.radius,
    fontSize: sidebarRow.textFontSize,
    color: cssVar.colorText,
    backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
    backgroundImage: { 'default': 'none', ':hover': 'none' },
    transition: `background 150ms ${cssVar.motionEaseOut}`,
  },
  deleteButton: {
    cursor: { 'default': 'pointer', ':disabled': 'not-allowed' },
    display: 'flex',
    gap: '10px',
    alignItems: 'center',
    width: '100%',
    minHeight: sidebarRow.controlHeight,
    paddingBlock: '4px',
    paddingInline: '10px',
    borderStyle: 'none',
    borderRadius: sidebarRow.radius,
    fontSize: sidebarRow.textFontSize,
    lineHeight: '20px',
    color: cssVar.colorError,
    opacity: { 'default': null, ':disabled': 0.45 },
    // `:disabled` has to win over `:hover`, so it is nested under it.
    backgroundColor: {
      'default': 'transparent',
      ':hover': { 'default': cssVar.colorErrorBg, ':disabled': 'transparent' },
    },
    backgroundImage: { 'default': 'none', ':hover': 'none' },
    transition: `background 150ms ${cssVar.motionEaseOut}`,
  },
  deleteDivider: {
    height: '1px',
    marginBlock: '2px',
    marginInline: '4px',
    backgroundColor: cssVar.colorBorderSecondary,
    backgroundImage: 'none',
  },
  deleteIcon: { color: cssVar.colorError },
  iconAuto: { color: cssVar.colorInfo },
  iconDefault: { color: cssVar.colorTextTertiary },
  iconDisabled: { color: cssVar.colorError },
  policyButton: {
    cursor: { 'default': 'pointer', ':disabled': 'not-allowed' },
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center',
    // Connector rows hand this button to the menu's extra slot, a plain block
    // wrapper — without vertical-align its strut adds descender space below the
    // button and pushes those rows taller than the rest.
    width: `${SKILL_TRAILING_CONTROL_SIZE}px`,
    height: `${SKILL_TRAILING_CONTROL_SIZE}px`,
    padding: '0',
    borderStyle: 'none',
    borderRadius: '6px',
    color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorTextSecondary },
    opacity: { 'default': null, ':disabled': 0.45 },
    verticalAlign: 'top',
    // `:disabled` has to win over `:hover`, so it is nested under it.
    backgroundColor: {
      'default': 'transparent',
      ':hover': { 'default': cssVar.colorFillTertiary, ':disabled': 'transparent' },
    },
    backgroundImage: { 'default': 'none', ':hover': 'none' },
    transition: 'color 0.2s, background 0.2s',
  },
  policyCheck: {
    display: 'flex',
    flex: 'none',
    alignItems: 'center',
    justifyContent: 'center',
    width: '16px',
    height: '16px',
    color: cssVar.colorInfo,
  },
  policyItem: {
    cursor: { 'default': 'pointer', ':disabled': 'not-allowed' },
    display: 'flex',
    gap: '10px',
    alignItems: 'center',
    width: '100%',
    minHeight: sidebarRow.controlHeight,
    paddingBlock: '4px',
    paddingInline: '10px',
    borderStyle: 'none',
    borderRadius: sidebarRow.radius,
    fontSize: sidebarRow.textFontSize,
    lineHeight: '20px',
    color: cssVar.colorText,
    opacity: { 'default': null, ':disabled': 0.45 },
    // `:disabled` has to win over `:hover`, so it is nested under it.
    backgroundColor: {
      'default': 'transparent',
      ':hover': { 'default': cssVar.colorFillTertiary, ':disabled': 'transparent' },
    },
    backgroundImage: { 'default': 'none', ':hover': 'none' },
    transition: `background 150ms ${cssVar.motionEaseOut}`,
  },
  policyItemIcon: {
    display: 'flex',
    flex: 'none',
    alignItems: 'center',
    justifyContent: 'center',
    width: '16px',
    height: '16px',
  },
  policyPanel: {
    minWidth: '132px',
    padding: '4px',
    borderRadius: cssVar.borderRadius,
    backgroundColor: cssVar.colorBgElevated,
    backgroundImage: 'none',
    boxShadow: '0 0 15px 0 #00000008, 0 2px 30px 0 #00000014',
  },
  // Capability rows (memory / web search) host their own settings under the
  // activation policy, so the panel takes the width those settings had as
  // standalone popovers instead of the compact 132px policy list.
  policyPanelWide: { width: '320px' },
  policyText: { flex: '1', textAlign: 'start' },
  toolLabel: {
    display: 'flex',
    flex: '1',
    gap: `${SKILL_ICON_GAP}px`,
    alignItems: 'center',
    minWidth: '0',
  },
  toolLabelBody: {
    overflow: 'hidden',
    display: 'flex',
    flexGrow: '0',
    flexShrink: '1',
    flexBasis: 'auto',
    gap: '6px',
    alignItems: 'center',
    minWidth: '0',
  },
  toolLabelText: {
    overflow: 'hidden',
    flexGrow: '0',
    flexShrink: '1',
    flexBasis: 'auto',
    minWidth: '0',
    lineHeight: 1.4,
    textOverflow: 'ellipsis',
    whiteSpace: 'nowrap',
  },
  // Hover / focus-within on the row (the default marker) reveals the trailing controls.
  toolRow: {
    display: 'flex',
    gap: densityTokens['--lobe-density-section-gap'],
    alignItems: 'center',
    justifyContent: 'space-between',
    width: '100%',
    minWidth: '0',
  },
  toolTrailing: {
    pointerEvents: {
      'default': 'none',
      '@media (hover: none)': 'auto',
      [stylex.when.ancestor(':hover')]: 'auto',
      [stylex.when.ancestor(':focus-within')]: 'auto',
    },
    display: 'inline-flex',
    flex: 'none',
    gap: '8px',
    alignItems: 'center',
    opacity: {
      'default': 0,
      '@media (hover: none)': 1,
      [stylex.when.ancestor(':hover')]: 1,
      [stylex.when.ancestor(':focus-within')]: 1,
    },
    transition: `opacity 150ms ${cssVar.motionEaseOut}`,
  },
  toolTrailingVisible: { pointerEvents: 'auto', opacity: 1 },
  typeTag: {
    display: 'inline-flex',
    flex: 'none',
    alignItems: 'center',
    paddingBlock: '1px',
    paddingInline: '4px',
    borderWidth: '1px',
    borderStyle: 'solid',
    borderColor: cssVar.colorBorderSecondary,
    borderRadius: '4px',
    color: cssVar.colorTextTertiary,
    backgroundColor: cssVar.colorFillQuaternary,
    backgroundImage: 'none',
  },
});