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

Function Output

packages/dev/s2-docs/src/VisualExampleClient.tsx:206–263  ·  view source on GitHub ↗
({
  align = 'center',
  acceptOrientation
}: {
  align?: 'center' | 'start' | 'end';
  acceptOrientation?: boolean;
})

Source from the content-addressed store, hash-verified

204}
205
206export function Output({
207 align = 'center',
208 acceptOrientation
209}: {
210 align?: 'center' | 'start' | 'end';
211 acceptOrientation?: boolean;
212}) {
213 let {component, props, propsObject} = useContext(Context);
214
215 if (!isValidElement(component)) {
216 let children = props.children;
217 if (children?.icon || children?.avatar || children?.badge) {
218 let iconElement: ReactNode | null = null;
219 if (children.avatar) {
220 iconElement = <Avatar src="https://i.imgur.com/xIe7Wlb.png" />;
221 } else if (children.icon) {
222 iconElement = <LazyIcon icon={children.icon} />;
223 }
224
225 children = (
226 <>
227 {iconElement}
228 {children.text && <Text>{children.text}</Text>}
229 {children.badge && <NotificationBadge value={12} />}
230 </>
231 );
232 } else if (children?.text != null) {
233 children = children.text;
234 }
235
236 props = {...props, children};
237 }
238
239 if (props.contextualHelp) {
240 props = {
241 ...props,
242 contextualHelp: (
243 <ContextualHelp>
244 <Heading>Heading</Heading>
245 <Content>Content</Content>
246 </ContextualHelp>
247 )
248 };
249 }
250
251 if (propsObject) {
252 props = {[propsObject]: props};
253 }
254
255 return (
256 <ExampleOutput
257 component={component}
258 props={props}
259 align={align}
260 orientation={acceptOrientation ? props.orientation : undefined}
261 />
262 );
263}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected