ImageAsset.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { FC } from 'react';
  2. export type ImageAssetProps = {
  3. name: string;
  4. src: string;
  5. };
  6. export const ImageAsset: FC<ImageAssetProps> = ({ name, src }) => {
  7. const containerStyle = {
  8. borderRadius: '20px',
  9. width: '12vw',
  10. height: '12vw',
  11. minWidth: '100px',
  12. minHeight: '100px',
  13. borderWidth: '1.5px',
  14. borderStyle: 'solid',
  15. borderColor: 'lightgray',
  16. overflow: 'hidden',
  17. margin: '0.3vw',
  18. };
  19. const colorDescriptionStyle = {
  20. textAlign: 'center' as 'center',
  21. color: 'gray',
  22. fontSize: '0.8em',
  23. };
  24. const imageStyle = {
  25. width: '100%',
  26. height: '80%',
  27. backgroundRepeat: 'no-repeat',
  28. backgroundSize: 'contain',
  29. backgroundPosition: 'center',
  30. marginTop: '5px',
  31. backgroundImage: `url(${src})`,
  32. };
  33. return (
  34. <figure style={containerStyle}>
  35. <a href={src} target="_blank" rel="noopener noreferrer">
  36. <div style={imageStyle} />
  37. <figcaption style={colorDescriptionStyle}>{name}</figcaption>
  38. </a>
  39. </figure>
  40. );
  41. };
  42. const rowStyle = {
  43. display: 'flex',
  44. flexDirection: 'row' as 'row',
  45. flexWrap: 'wrap' as 'wrap',
  46. // justifyContent: 'space-around',
  47. alignItems: 'center',
  48. };
  49. export const ImageRow = (props: ImageRowProps) => {
  50. const { images } = props;
  51. return (
  52. <div style={rowStyle}>
  53. {images.map(image => (
  54. <ImageAsset key={image.src} src={image.src} name={image.name} />
  55. ))}
  56. </div>
  57. );
  58. };
  59. interface ImageRowProps {
  60. images: ImageAssetProps[];
  61. }