Initial commit from prod-batam
This commit is contained in:
13
platform/ui/src/components/Svg/Svg.tsx
Normal file
13
platform/ui/src/components/Svg/Svg.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import getSvg from './getSvg';
|
||||
|
||||
const Svg = ({ name, ...otherProps }) => {
|
||||
return <React.Fragment>{getSvg(name, { ...otherProps })}</React.Fragment>;
|
||||
};
|
||||
|
||||
Svg.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default Svg;
|
||||
22
platform/ui/src/components/Svg/getSvg.tsx
Normal file
22
platform/ui/src/components/Svg/getSvg.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import React from 'react';
|
||||
// Svgs
|
||||
import { ReactComponent as logoOhif } from './../../assets/svgs/ohif-logo.svg';
|
||||
|
||||
const SVGS = {
|
||||
'logo-ohif': logoOhif,
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the matching SVG as a React Component.
|
||||
* Results in an inlined SVG Element. If there's no match,
|
||||
* return `null`
|
||||
*/
|
||||
export default function getSvg(key, props) {
|
||||
if (!key || !SVGS[key]) {
|
||||
return React.createElement('div', null, 'Missing SVG');
|
||||
}
|
||||
|
||||
return React.createElement(SVGS[key], props);
|
||||
}
|
||||
|
||||
export { SVGS };
|
||||
2
platform/ui/src/components/Svg/index.js
Normal file
2
platform/ui/src/components/Svg/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import Svg from './Svg';
|
||||
export default Svg;
|
||||
Reference in New Issue
Block a user