page.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use client';
  2. import { useState } from 'react';
  3. import { useClipboard } from '@/hooks';
  4. import clsx from 'clsx';
  5. // import glob from 'glob';
  6. const importFiles = (type) => {
  7. return [];
  8. //return glob.sync(`./public/samples/${type}/*.{jpg,png}`).map((file) => file.replace('./public', ''))
  9. };
  10. export default function SamplesPage() {
  11. const clipboard = useClipboard();
  12. const types = [
  13. {
  14. title: 'Avatars',
  15. list: importFiles('avatars'),
  16. },
  17. {
  18. title: 'Photos',
  19. list: importFiles('photos'),
  20. },
  21. {
  22. title: 'Products',
  23. list: importFiles('products'),
  24. },
  25. {
  26. title: 'Tracks',
  27. list: importFiles('tracks'),
  28. },
  29. ];
  30. let [clicked, setClicked] = useState([]);
  31. return (
  32. <>
  33. {types.map((type, i) => (
  34. <section className={clsx('section', i % 2 === 0 ? '' : 'section-light')} key={type.title}>
  35. <div className="container">
  36. <div>
  37. <h3 className="mb-4">{type.title}</h3>
  38. <div className="row">
  39. {type.list.map((item) => (
  40. <div className="col-auto" key={item}>
  41. <img
  42. src={`${item}`}
  43. alt=""
  44. style={{ width: '80px', opacity: clicked.indexOf(item) >= 0 ? 0.2 : 1 }}
  45. onClick={() => {
  46. clipboard.copy(item);
  47. setClicked([item, ...clicked]);
  48. }}
  49. />
  50. </div>
  51. ))}
  52. </div>
  53. </div>
  54. </div>
  55. </section>
  56. ))}
  57. </>
  58. );
  59. }