/** @jsx withSlots */ import * as React from 'react'; import { Button, IButtonComponent, IButtonProps, IButtonStyles, IButtonTokens } from '@uifabric/experiments'; import { withSlots } from '@uifabric/foundation'; // Temporary import file to experiment with next version of foundation. import { composed } from '@uifabric/foundation/lib/next/composed'; import { buttonProperties, getNativeProps } from '@uifabric/utilities'; import { Spinner, Stack, IStackProps } from 'office-ui-fabric-react'; const stackProps: IStackProps = { tokens: { childrenGap: 16 }, padding: 8, maxWidth: 400 }; const SpinnerButton: React.FunctionComponent = composed( Button, { slots: { icon: Spinner }, }, ); const IconAtEndButtonView: IButtonComponent['view'] = (props, slots) => { const { icon, content, children, disabled, onClick, allowDisabledFocus, ariaLabel, keytipProps, buttonRef, ...rest } = props; const buttonProps = getNativeProps>(rest, buttonProperties); const _onClick = (ev: React.MouseEvent) => { if (!disabled && onClick) { onClick(ev); if (ev.defaultPrevented) { return; } } }; return ( {content && } {children} {icon && } ); }; const IconAtEndButton: React.FunctionComponent = composed(Button, { view: IconAtEndButtonView, }); const SpinnerAtEndButton: React.FunctionComponent = composed( IconAtEndButton, { slots: { icon: Spinner }, }, ); export class SlotsRecompositionExample extends React.Component<{}, {}> { public render(): JSX.Element { return ( {/* TODO: Can we change the typing of the slots on recomposition? */} ); } }