MCPcopy Index your code
hub / github.com/adobe/react-spectrum / ColorItem

Function ColorItem

packages/dev/s2-docs/src/ColorSearchView.tsx:327–436  ·  view source on GitHub ↗
({
  item,
  sectionId,
  isCopied = false,
  isBestMatch = false,
  isExactMatch = false
}: ColorItemProps)

Source from the content-addressed store, hash-verified

325}
326
327function ColorItem({
328 item,
329 sectionId,
330 isCopied = false,
331 isBestMatch = false,
332 isExactMatch = false
333}: ColorItemProps) {
334 let ref = useRef(null);
335
336 // Look up the pre-generated swatch class for this color
337 const swatchClass =
338 sectionId === 'text'
339 ? textSwatches[item.name]
340 : backgroundSwatches[item.name] || scaleSwatches[item.name] || '';
341
342 return (
343 <ListBoxItem
344 id={item.id}
345 textValue={item.name}
346 className={itemStyle}
347 ref={ref}
348 style={pressScale(ref)}>
349 <div
350 className={`${swatchClass || swatchStyle} ${style({position: 'relative'})}`}
351 style={
352 {
353 width: '48px',
354 height: '48px',
355 '--s2-container-bg': 'var(--v)'
356 } as React.CSSProperties
357 }>
358 <div
359 className={style({
360 position: 'absolute',
361 inset: 0,
362 display: 'flex',
363 alignItems: 'center',
364 justifyContent: 'center',
365 borderRadius: 'inherit',
366 color: 'auto',
367 '--iconPrimary': {
368 type: 'fill',
369 value: 'currentColor'
370 },
371 transition: 'default'
372 })}
373 style={{
374 opacity: isCopied ? 1 : 0,
375 transform: isCopied ? 'scale(1)' : 'scale(0.5)'
376 }}>
377 <CheckmarkCircle styles={iconStyle({size: 'XL'})} />
378 </div>
379 </div>
380 {isBestMatch && !isCopied ? (
381 <Badge
382 size="S"
383 variant={isExactMatch ? 'positive' : 'informative'}
384 UNSAFE_style={{width: 'max-content'}}>

Callers

nothing calls this directly

Calls 2

pressScaleFunction · 0.90
iconStyleFunction · 0.90

Tested by

no test coverage detected