MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ColorItem

Function ColorItem

packages/dev/s2-docs/src/ColorSearchView.tsx:327–438  ·  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 // oxlint-disable react/react-compiler
343 return (
344 <ListBoxItem
345 id={item.id}
346 textValue={item.name}
347 className={itemStyle}
348 ref={ref}
349 style={pressScale(ref)}>
350 <div
351 className={`${swatchClass || swatchStyle} ${style({position: 'relative'})}`}
352 style={
353 {
354 width: '48px',
355 height: '48px',
356 '--s2-container-bg': 'var(--v)'
357 } as React.CSSProperties
358 }>
359 <div
360 className={style({
361 position: 'absolute',
362 inset: 0,
363 display: 'flex',
364 alignItems: 'center',
365 justifyContent: 'center',
366 borderRadius: 'inherit',
367 color: 'auto',
368 '--iconPrimary': {
369 type: 'fill',
370 value: 'currentColor'
371 },
372 transition: 'default'
373 })}
374 style={{
375 opacity: isCopied ? 1 : 0,
376 transform: isCopied ? 'scale(1)' : 'scale(0.5)'
377 }}>
378 <CheckmarkCircle styles={iconStyle({size: 'XL'})} />
379 </div>
380 </div>
381 {isBestMatch && !isCopied ? (
382 <Badge
383 size="S"
384 variant={isExactMatch ? 'positive' : 'informative'}

Callers

nothing calls this directly

Calls 2

pressScaleFunction · 0.90
iconStyleFunction · 0.90

Tested by

no test coverage detected