Advertisement
Guest User

ClaudeAI - Mock Win Interface Version 1

a guest
Jul 8th, 2024
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. import React, { useState } from 'react';
  2. import { X, Minus, Square } from 'lucide-react';
  3.  
  4. const Windows95Interface = () => {
  5. const [windows, setWindows] = useState([
  6. { id: 1, title: 'My Computer', x: 20, y: 20, width: 300, height: 200, minimized: false },
  7. { id: 2, title: 'Notepad', x: 100, y: 100, width: 250, height: 180, minimized: false },
  8. ]);
  9.  
  10. const [activeWindow, setActiveWindow] = useState(null);
  11. const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
  12.  
  13. const handleMouseDown = (e, id) => {
  14. setActiveWindow(id);
  15. setDragStart({ x: e.clientX, y: e.clientY });
  16. };
  17.  
  18. const handleMouseMove = (e) => {
  19. if (activeWindow !== null) {
  20. const dx = e.clientX - dragStart.x;
  21. const dy = e.clientY - dragStart.y;
  22. setWindows(windows.map(w =>
  23. w.id === activeWindow
  24. ? { ...w, x: w.x + dx, y: w.y + dy }
  25. : w
  26. ));
  27. setDragStart({ x: e.clientX, y: e.clientY });
  28. }
  29. };
  30.  
  31. const handleMouseUp = () => {
  32. setActiveWindow(null);
  33. };
  34.  
  35. const minimizeWindow = (id) => {
  36. setWindows(windows.map(w =>
  37. w.id === id ? { ...w, minimized: !w.minimized } : w
  38. ));
  39. };
  40.  
  41. const closeWindow = (id) => {
  42. setWindows(windows.filter(w => w.id !== id));
  43. };
  44.  
  45. return (
  46. <div
  47. className="bg-teal-700 w-full h-screen relative overflow-hidden"
  48. onMouseMove={handleMouseMove}
  49. onMouseUp={handleMouseUp}
  50. >
  51. {windows.map(window => (
  52. <div
  53. key={window.id}
  54. className={`absolute bg-gray-200 border-2 border-gray-400 shadow-lg ${window.minimized ? 'hidden' : ''}`}
  55. style={{
  56. left: `${window.x}px`,
  57. top: `${window.y}px`,
  58. width: `${window.width}px`,
  59. height: `${window.height}px`,
  60. zIndex: activeWindow === window.id ? 10 : 1
  61. }}
  62. >
  63. <div
  64. className="bg-blue-900 text-white px-2 py-1 flex justify-between items-center cursor-move"
  65. onMouseDown={(e) => handleMouseDown(e, window.id)}
  66. >
  67. <span>{window.title}</span>
  68. <div className="flex space-x-1">
  69. <button onClick={() => minimizeWindow(window.id)} className="focus:outline-none">
  70. <Minus size={16} />
  71. </button>
  72. <button className="focus:outline-none">
  73. <Square size={16} />
  74. </button>
  75. <button onClick={() => closeWindow(window.id)} className="focus:outline-none">
  76. <X size={16} />
  77. </button>
  78. </div>
  79. </div>
  80. <div className="p-2">
  81. {window.title === 'My Computer' ? (
  82. <div className="flex flex-col items-center">
  83. <img src="/api/placeholder/64/64" alt="My Computer" className="mb-2" />
  84. <span>My Computer</span>
  85. </div>
  86. ) : (
  87. <textarea className="w-full h-32 p-2 border border-gray-400 resize-none" placeholder="Type here..."></textarea>
  88. )}
  89. </div>
  90. </div>
  91. ))}
  92. <div className="absolute bottom-0 left-0 right-0 bg-gray-300 h-10 flex items-center px-2">
  93. <button className="bg-green-600 text-white px-4 py-1 rounded">Start</button>
  94. </div>
  95. </div>
  96. );
  97. };
  98.  
  99. export default Windows95Interface;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement