| banksean | d52d39d | 2025-07-20 14:57:38 -0700 | [diff] [blame] | 1 | import { DemoModule } from "./demo-framework/types"; |
| 2 | import { demoUtils } from "./demo-fixtures/index"; |
| 3 | |
| 4 | const demo: DemoModule = { |
| 5 | title: "Mobile Chat Demo", |
| 6 | description: "Mobile chat interface with message display and scroll behavior", |
| 7 | imports: ["../mobile-chat.js"], |
| 8 | |
| 9 | customStyles: ` |
| 10 | body { |
| 11 | margin: 0; |
| 12 | padding: 0; |
| 13 | height: 100vh; |
| 14 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif; |
| 15 | } |
| 16 | `, |
| 17 | |
| 18 | setup: async (container: HTMLElement) => { |
| 19 | const section = demoUtils.createDemoSection( |
| 20 | "Mobile Chat Interface", |
| 21 | "Demonstrates mobile chat with multiple messages and scroll behavior", |
| 22 | ); |
| 23 | |
| 24 | // Create the mobile chat element |
| 25 | const chatElement = document.createElement("mobile-chat") as any; |
| 26 | chatElement.style.height = "60vh"; |
| 27 | chatElement.style.display = "block"; |
| 28 | chatElement.style.border = "1px solid #ccc"; |
| 29 | chatElement.style.borderRadius = "8px"; |
| 30 | |
| 31 | // Sample messages to test scroll behavior |
| 32 | const messages = [ |
| 33 | { |
| 34 | id: "1", |
| 35 | type: "user", |
| 36 | content: "Hello, I need help with setting up a project.", |
| 37 | timestamp: new Date().toISOString(), |
| 38 | }, |
| 39 | { |
| 40 | id: "2", |
| 41 | type: "agent", |
| 42 | content: |
| 43 | "Hello! I'd be happy to help you set up a project. What kind of project are you working on?", |
| 44 | timestamp: new Date().toISOString(), |
| 45 | }, |
| 46 | { |
| 47 | id: "3", |
| 48 | type: "user", |
| 49 | content: |
| 50 | "I'm trying to build a web application using React and TypeScript.", |
| 51 | timestamp: new Date().toISOString(), |
| 52 | }, |
| 53 | { |
| 54 | id: "4", |
| 55 | type: "agent", |
| 56 | content: |
| 57 | "Great choice! React with TypeScript is a powerful combination. Let me help you get started. First, we'll need to set up the project structure. Here are the steps:\n\n1. Create a new React app with TypeScript template\n2. Install additional dependencies\n3. Set up the folder structure\n4. Configure the development environment\n\nWould you like me to walk you through each step?", |
| 58 | timestamp: new Date().toISOString(), |
| 59 | }, |
| 60 | { |
| 61 | id: "5", |
| 62 | type: "user", |
| 63 | content: |
| 64 | "Yes, please walk me through each step. I want to make sure I understand everything.", |
| 65 | timestamp: new Date().toISOString(), |
| 66 | }, |
| 67 | { |
| 68 | id: "6", |
| 69 | type: "agent", |
| 70 | content: |
| 71 | "Perfect! Let's start with step 1:\n\n**Step 1: Create a new React app with TypeScript template**\n\nOpen your terminal and run:\n```bash\nnpx create-react-app my-app --template typescript\ncd my-app\n```\n\nThis will create a new React application with TypeScript already configured. The `--template typescript` flag tells Create React App to set up TypeScript for you automatically.", |
| 72 | timestamp: new Date().toISOString(), |
| 73 | }, |
| 74 | { |
| 75 | id: "7", |
| 76 | type: "user", |
| 77 | content: |
| 78 | "Okay, I ran that command and it created the project. What's next?", |
| 79 | timestamp: new Date().toISOString(), |
| 80 | }, |
| 81 | { |
| 82 | id: "8", |
| 83 | type: "agent", |
| 84 | content: |
| 85 | "Excellent! Now let's move to step 2:\n\n**Step 2: Install additional dependencies**\n\nYou might want to install some commonly used packages. Here are some recommendations:\n\n```bash\n# For routing\nnpm install react-router-dom\nnpm install @types/react-router-dom\n\n# For styling (choose one)\nnpm install styled-components # or\nnpm install @mui/material\n\n# For state management (if needed)\nnpm install redux @reduxjs/toolkit react-redux\n```\n\nWhich of these sound useful for your project?", |
| 86 | timestamp: new Date().toISOString(), |
| 87 | }, |
| 88 | { |
| 89 | id: "9", |
| 90 | type: "user", |
| 91 | content: |
| 92 | "I think I'll need routing and probably Material-UI for styling. Should I install both?", |
| 93 | timestamp: new Date().toISOString(), |
| 94 | }, |
| 95 | { |
| 96 | id: "10", |
| 97 | type: "agent", |
| 98 | content: |
| 99 | "Absolutely! React Router and Material-UI work great together. Run these commands:\n\n```bash\nnpm install react-router-dom @types/react-router-dom\nnpm install @mui/material @emotion/react @emotion/styled\nnpm install @mui/icons-material\n```\n\nMaterial-UI (now called MUI) requires @emotion packages for styling, and the icons package gives you access to thousands of Material Design icons.", |
| 100 | timestamp: new Date().toISOString(), |
| 101 | }, |
| 102 | ]; |
| 103 | |
| 104 | // Set messages after a brief delay to simulate loading |
| 105 | setTimeout(() => { |
| 106 | chatElement.messages = messages; |
| 107 | }, 100); |
| 108 | |
| 109 | section.appendChild(chatElement); |
| 110 | container.appendChild(section); |
| 111 | }, |
| 112 | }; |
| 113 | |
| 114 | export default demo; |