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

Function IllustrationCards

packages/dev/s2-docs/src/IllustrationCards.tsx:63–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61});
62
63export function IllustrationCards() {
64 let [variant, setVariant] = useState<'linear' | 'gradient'>('gradient');
65 let [gradientStyle, setGradientStyle] = useState<'generic1' | 'generic2'>('generic1');
66
67 let {contains} = useFilter({sensitivity: 'base'});
68 let filter = useCallback(
69 (textValue: string, inputValue: string) => {
70 const trimmedInput = inputValue.trim();
71 // If input is empty after trimming, show all items
72 if (!trimmedInput) {
73 return true;
74 }
75 // Check if input matches an alias that maps to this illustration name
76 for (const alias of Object.keys(illustrationAliases)) {
77 if (contains(alias, trimmedInput) && illustrationAliases[alias].includes(textValue)) {
78 return true;
79 }
80 }
81 // Also compare for substrings in the illustration's actual name
82 return textValue != null && contains(textValue, trimmedInput);
83 },
84 [contains]
85 );
86
87 return (
88 <Autocomplete filter={filter}>
89 <div className={style({display: 'flex', flexDirection: 'column', gap: 8})}>
90 <div className={style({display: 'flex', justifyContent: 'center'})}>
91 <SegmentedControl
92 aria-label="Illustration type"
93 onSelectionChange={value => setVariant(value as 'linear' | 'gradient')}
94 selectedKey={variant}>
95 <SegmentedControlItem id="gradient">
96 <Gradient />
97 <Text>Gradient</Text>
98 </SegmentedControlItem>
99 <SegmentedControlItem id="linear">
100 <Polygon4 />
101 <Text>Linear</Text>
102 </SegmentedControlItem>
103 </SegmentedControl>
104 </div>
105 <SearchField
106 size="L"
107 aria-label="Search illustrations"
108 placeholder="Search illustrations"
109 />
110 {variant === 'gradient' && (
111 <RadioGroup
112 labelPosition="side"
113 orientation="horizontal"
114 value={gradientStyle}
115 onChange={value => setGradientStyle(value as 'generic1' | 'generic2')}
116 aria-label="Gradient Style"
117 UNSAFE_style={{display: 'flex', justifyContent: 'center'}}
118 styles={style({marginTop: 16})}>
119 <Radio value="generic1">Generic 1</Radio>
120 <Radio value="generic2">Generic 2</Radio>

Callers

nothing calls this directly

Calls 2

useFilterFunction · 0.85
containsFunction · 0.85

Tested by

no test coverage detected