|
| 1 | +import { Component } from "solid-js"; |
| 2 | + |
| 3 | +export type ConnectionState = "connecting" | "connected" | "disconnected"; |
| 4 | + |
| 5 | +export interface SettingsProps { |
| 6 | + port: number | null; |
| 7 | + connectionState: ConnectionState; |
| 8 | +} |
| 9 | + |
| 10 | +const Settings: Component<SettingsProps> = (props) => { |
| 11 | + const getStatusColor = () => { |
| 12 | + switch (props.connectionState) { |
| 13 | + case "connected": |
| 14 | + return "var(--vscode-testing-iconPassed, #89d185)"; |
| 15 | + case "connecting": |
| 16 | + return "var(--vscode-testing-iconQueued, #cca700)"; |
| 17 | + case "disconnected": |
| 18 | + return "var(--vscode-testing-iconFailed, #f14c4c)"; |
| 19 | + } |
| 20 | + }; |
| 21 | + |
| 22 | + const getStatusText = () => { |
| 23 | + switch (props.connectionState) { |
| 24 | + case "connected": |
| 25 | + return "Connected"; |
| 26 | + case "connecting": |
| 27 | + return "Connecting..."; |
| 28 | + case "disconnected": |
| 29 | + return "Disconnected"; |
| 30 | + } |
| 31 | + }; |
| 32 | + |
| 33 | + return ( |
| 34 | + <div style={{ |
| 35 | + padding: "16px", |
| 36 | + color: "var(--vscode-foreground)", |
| 37 | + "font-family": "var(--vscode-font-family)", |
| 38 | + }}> |
| 39 | + <h2 style={{ |
| 40 | + "font-size": "16px", |
| 41 | + "font-weight": "600", |
| 42 | + "margin-bottom": "20px", |
| 43 | + color: "var(--vscode-foreground)", |
| 44 | + }}> |
| 45 | + Settings |
| 46 | + </h2> |
| 47 | + |
| 48 | + <div style={{ |
| 49 | + background: "var(--vscode-editor-background)", |
| 50 | + border: "1px solid var(--vscode-panel-border)", |
| 51 | + "border-radius": "4px", |
| 52 | + padding: "16px", |
| 53 | + }}> |
| 54 | + <h3 style={{ |
| 55 | + "font-size": "13px", |
| 56 | + "font-weight": "600", |
| 57 | + "margin-bottom": "12px", |
| 58 | + color: "var(--vscode-foreground)", |
| 59 | + }}> |
| 60 | + CLI Server |
| 61 | + </h3> |
| 62 | + |
| 63 | + {/* Connection Status */} |
| 64 | + <div style={{ |
| 65 | + display: "flex", |
| 66 | + "align-items": "center", |
| 67 | + "margin-bottom": "12px", |
| 68 | + }}> |
| 69 | + <span style={{ |
| 70 | + "font-size": "12px", |
| 71 | + color: "var(--vscode-descriptionForeground)", |
| 72 | + width: "100px", |
| 73 | + }}> |
| 74 | + Status: |
| 75 | + </span> |
| 76 | + <div style={{ |
| 77 | + display: "flex", |
| 78 | + "align-items": "center", |
| 79 | + gap: "8px", |
| 80 | + }}> |
| 81 | + <span style={{ |
| 82 | + width: "8px", |
| 83 | + height: "8px", |
| 84 | + "border-radius": "50%", |
| 85 | + background: getStatusColor(), |
| 86 | + display: "inline-block", |
| 87 | + }} /> |
| 88 | + <span style={{ |
| 89 | + "font-size": "12px", |
| 90 | + color: "var(--vscode-foreground)", |
| 91 | + }}> |
| 92 | + {getStatusText()} |
| 93 | + </span> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + |
| 97 | + {/* Port Number */} |
| 98 | + <div style={{ |
| 99 | + display: "flex", |
| 100 | + "align-items": "center", |
| 101 | + }}> |
| 102 | + <span style={{ |
| 103 | + "font-size": "12px", |
| 104 | + color: "var(--vscode-descriptionForeground)", |
| 105 | + width: "100px", |
| 106 | + }}> |
| 107 | + Port: |
| 108 | + </span> |
| 109 | + <span style={{ |
| 110 | + "font-size": "12px", |
| 111 | + color: "var(--vscode-foreground)", |
| 112 | + "font-family": "var(--vscode-editor-font-family, monospace)", |
| 113 | + }}> |
| 114 | + {props.port !== null ? props.port : "—"} |
| 115 | + </span> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | + </div> |
| 119 | + ); |
| 120 | +}; |
| 121 | + |
| 122 | +export default Settings; |
0 commit comments