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

Function Detail

packages/dev/s2-docs/pages/s2/home/ExampleApp.tsx:91–223  ·  view source on GitHub ↗
({detail, img, setDetail, showArrows}: any)

Source from the content-addressed store, hash-verified

89}
90
91function Detail({detail, img, setDetail, showArrows}: any) {
92 let [panel, setPanel] = useState('properties');
93 let [filters, setFilters] = useState({
94 brightness: 0,
95 contrast: 0,
96 saturation: 0
97 });
98
99 return (
100 <FilterContext value={{...filters, onChange: setFilters}}>
101 <ExampleApp2
102 panel={panel}
103 onPanelChange={setPanel}
104 onBack={() => {
105 if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
106 setDetail([]);
107 return;
108 }
109
110 document
111 .startViewTransition(async () => {
112 flushSync(() => setDetail([]));
113 img.style.viewTransitionName = 'photo';
114 })
115 .ready.then(() => {
116 img.style.viewTransitionName = '';
117 });
118 }}>
119 <div
120 className={style({
121 size: 'full',
122 display: 'flex',
123 alignItems: 'center',
124 justifyContent: 'center',
125 overflow: 'clip'
126 })}
127 style={
128 {
129 containerType: 'size'
130 } as any
131 }>
132 <Image
133 src={detail.urls.regular}
134 width={detail.width}
135 height={detail.height}
136 alt={detail.description || detail.alt_description}
137 UNSAFE_style={
138 {
139 viewTransitionName: 'photo',
140 '--scale': `min(100cqw / ${detail.width}, 100cqh / ${detail.height})`,
141 width: `calc(${detail.width} * var(--scale))`,
142 height: `calc(${detail.height} * var(--scale))`,
143 filter: `${filters.brightness ? `brightness(${filters.brightness + 100}%)` : ''} ${filters.contrast ? `contrast(${filters.contrast + 100}%)` : ''} ${filters.saturation ? `saturate(${filters.saturation + 100}%)` : ''}`
144 } as any
145 }
146 />
147 </div>
148 </ExampleApp2>

Callers

nothing calls this directly

Calls 1

startViewTransitionMethod · 0.80

Tested by

no test coverage detected