@primer/react
Version:
An implementation of GitHub's Primer Design System using React
116 lines (113 loc) • 2.79 kB
JavaScript
import { c } from 'react-compiler-runtime';
import { AlertFillIcon, CheckCircleFillIcon, AlertIcon, CheckCircleIcon } from '@primer/octicons-react';
import { clsx } from 'clsx';
import classes from './InlineMessage.module.css.js';
import { BoxWithFallback } from '../internal/components/BoxWithFallback.js';
import { jsxs, jsx } from 'react/jsx-runtime';
const variantToIcon = variant => {
const icons = {
warning: /*#__PURE__*/jsx(AlertIcon, {
className: classes.InlineMessageIcon
}),
critical: /*#__PURE__*/jsx(AlertIcon, {
className: classes.InlineMessageIcon
}),
success: /*#__PURE__*/jsx(CheckCircleIcon, {
className: classes.InlineMessageIcon
}),
unavailable: /*#__PURE__*/jsx(AlertIcon, {
className: classes.InlineMessageIcon
})
};
return icons[variant];
};
const variantToSmallIcon = variant => {
const icons = {
warning: /*#__PURE__*/jsx(AlertFillIcon, {
className: classes.InlineMessageIcon,
size: 12
}),
critical: /*#__PURE__*/jsx(AlertFillIcon, {
className: classes.InlineMessageIcon,
size: 12
}),
success: /*#__PURE__*/jsx(CheckCircleFillIcon, {
className: classes.InlineMessageIcon,
size: 12
}),
unavailable: /*#__PURE__*/jsx(AlertFillIcon, {
className: classes.InlineMessageIcon,
size: 12
})
};
return icons[variant];
};
function InlineMessage(t0) {
const $ = c(18);
let children;
let className;
let rest;
let t1;
let variant;
if ($[0] !== t0) {
({
children,
className,
size: t1,
variant,
...rest
} = t0);
$[0] = t0;
$[1] = children;
$[2] = className;
$[3] = rest;
$[4] = t1;
$[5] = variant;
} else {
children = $[1];
className = $[2];
rest = $[3];
t1 = $[4];
variant = $[5];
}
const size = t1 === undefined ? "medium" : t1;
let t2;
if ($[6] !== size || $[7] !== variant) {
t2 = size === "small" ? variantToSmallIcon(variant) : variantToIcon(variant);
$[6] = size;
$[7] = variant;
$[8] = t2;
} else {
t2 = $[8];
}
const icon = t2;
let t3;
if ($[9] !== className) {
t3 = clsx(className, classes.InlineMessage);
$[9] = className;
$[10] = t3;
} else {
t3 = $[10];
}
let t4;
if ($[11] !== children || $[12] !== icon || $[13] !== rest || $[14] !== size || $[15] !== t3 || $[16] !== variant) {
t4 = /*#__PURE__*/jsxs(BoxWithFallback, {
className: t3,
...rest,
"data-size": size,
"data-variant": variant,
children: [icon, children]
});
$[11] = children;
$[12] = icon;
$[13] = rest;
$[14] = size;
$[15] = t3;
$[16] = variant;
$[17] = t4;
} else {
t4 = $[17];
}
return t4;
}
export { InlineMessage };