UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

33 lines (32 loc) 1.2 kB
import { __assign, __rest } from "tslib"; import clsx from 'clsx'; import * as React from 'react'; import Icon from '../icon'; import Spinner from '../spinner'; import styles from './styles.css.js'; function getIconAlign(props) { var standalone = props.variant === 'icon'; return standalone ? 'left' : props.iconAlign; } function IconWrapper(_a) { var iconName = _a.iconName, iconUrl = _a.iconUrl, iconAlt = _a.iconAlt, props = __rest(_a, ["iconName", "iconUrl", "iconAlt"]); if (!iconName && !iconUrl) { return null; } return (React.createElement(Icon, { className: clsx(styles.icon, styles["icon-" + getIconAlign(props)], props.iconClass), name: iconName, url: iconUrl, alt: iconAlt })); } export function LeftIcon(props) { if (props.loading) { return React.createElement(Spinner, { className: clsx(styles.icon, styles['icon-left']) }); } else if (getIconAlign(props) === 'left') { return React.createElement(IconWrapper, __assign({}, props)); } return null; } export function RightIcon(props) { if (getIconAlign(props) === 'right') { return React.createElement(IconWrapper, __assign({}, props)); } return null; }