Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons/faEllipsisV';
|
|
import { faInfo } from '@fortawesome/free-solid-svg-icons/faInfo';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import Stack from '@mui/material/Stack';
|
|
import Button from '@mui/material/Button';
|
|
import IconButton from '@mui/material/IconButton';
|
|
import SvgIcon from '@mui/material/SvgIcon';
|
|
|
|
const FontAwesomeSvgIcon = React.forwardRef((props, ref) => {
|
|
const { icon } = props;
|
|
|
|
const {
|
|
icon: [width, height, , , svgPathData],
|
|
} = icon;
|
|
|
|
return (
|
|
<SvgIcon ref={ref} viewBox={`0 0 ${width} ${height}`}>
|
|
{typeof svgPathData === 'string' ? (
|
|
<path d={svgPathData} />
|
|
) : (
|
|
/**
|
|
* A multi-path Font Awesome icon seems to imply a duotune icon. The 0th path seems to
|
|
* be the faded element (referred to as the "secondary" path in the Font Awesome docs)
|
|
* of a duotone icon. 40% is the default opacity.
|
|
*
|
|
* @see https://fontawesome.com/how-to-use/on-the-web/styling/duotone-icons#changing-opacity
|
|
*/
|
|
svgPathData.map((d, i) => (
|
|
<path style={{ opacity: i === 0 ? 0.4 : 1 }} d={d} />
|
|
))
|
|
)}
|
|
</SvgIcon>
|
|
);
|
|
});
|
|
|
|
FontAwesomeSvgIcon.propTypes = {
|
|
icon: PropTypes.any.isRequired,
|
|
};
|
|
|
|
export default function FontAwesomeSvgIconDemo() {
|
|
return (
|
|
<Stack direction="row" spacing={2}>
|
|
<IconButton aria-label="Example">
|
|
<FontAwesomeIcon icon={faEllipsisV} />
|
|
</IconButton>
|
|
<IconButton aria-label="Example">
|
|
<FontAwesomeSvgIcon icon={faEllipsisV} />
|
|
</IconButton>
|
|
<Button variant="contained" startIcon={<FontAwesomeIcon icon={faInfo} />}>
|
|
Example
|
|
</Button>
|
|
<Button variant="contained" startIcon={<FontAwesomeSvgIcon icon={faInfo} />}>
|
|
Example
|
|
</Button>
|
|
</Stack>
|
|
);
|
|
}
|