|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
/** * 表格排序图标 * - default:上下三角均为未激活色 * - asc:上三角高亮(升序) * - desc:下三角高亮(降序) */ export type SortIconStatus = 'default' | 'asc' | 'desc' interface SortIconProps extends SVGProps<SVGSVGElement> { status?: SortIconStatus /** 未激活三角颜色 */ inactiveColor?: string /** 激活三角颜色 */ activeColor?: string } export const SortIcon = ({ status = 'default', inactiveColor = '#A3A3A3', activeColor = '#333333', className = '', 'aria-label': ariaLabel, ...props }: SortIconProps) => { const upColor = status === 'asc' ? activeColor : inactiveColor const downColor = status === 'desc' ? activeColor : inactiveColor return ( <svg {...props} aria-hidden={ariaLabel ? undefined : true} aria-label={ariaLabel} className={className} width="6" height="10" viewBox="0 0 6 10" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M3 0L6 4H0L3 0Z" fill={upColor} /> <path d="M3 10L0 6H6L3 10Z" fill={downColor} /> </svg> ) } |