page.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 'use client';
  2. import { useState } from 'react';
  3. import Link from 'next/link';
  4. // import { PreviewLayout } from "@/layouts/PreviewLayout"
  5. import clsx from 'clsx';
  6. import { uiDemoUrl, uiDownloadUrl } from '@/config/site';
  7. import Icon from '@/components/Icon';
  8. const devices = [
  9. { name: 'mobile', width: 375, icon: 'device-mobile' },
  10. { name: 'tablet', width: 960, icon: 'device-tablet' },
  11. { name: 'desktop', width: '100%', icon: 'device-desktop' },
  12. ];
  13. export default function PreviewPage() {
  14. const [currentDevice, setCurrentDevice] = useState('desktop');
  15. const [width, setWidth] = useState<string|number>('100%');
  16. return (
  17. <div className="preview">
  18. <iframe
  19. className="preview-iframe"
  20. src={uiDemoUrl}
  21. frameBorder="0"
  22. style={{ width }}
  23. />
  24. <div className="preview-navbar">
  25. <div className="mr-auto">
  26. <Link href="/" className="preview-navbar-link">
  27. <span className="logo logo-white logo-square" aria-label="Tabler" />
  28. </Link>
  29. </div>
  30. <div className="preview-navbar-devices">
  31. {devices.map((device) => (
  32. <button
  33. key={device.name}
  34. className={clsx('preview-navbar-link', {
  35. active: device.name === currentDevice,
  36. })}
  37. title={`Preview template on ${device.name}`}
  38. onClick={() => {
  39. setCurrentDevice(device.name);
  40. setWidth(device.width);
  41. }}
  42. >
  43. <Icon name={device.icon} />
  44. </button>
  45. ))}
  46. </div>
  47. <div className="ml-auto d-flex">
  48. <a href={uiDownloadUrl} className="btn btn-primary btn-responsive-sm lemonsqueezy-button">
  49. <Icon name="download" />
  50. <span className="btn-responsive-text">Download Tabler</span>
  51. </a>
  52. <a href={uiDemoUrl} className="preview-navbar-link ml-3">
  53. <Icon name="x" />
  54. </a>
  55. </div>
  56. </div>
  57. </div>
  58. );
  59. }
  60. // export async function getStaticProps() {
  61. // return {
  62. // props: {
  63. // meta: {
  64. // bodyClassName: "o-auto",
  65. // },
  66. // },
  67. // }
  68. // }