|
17 | 17 | */ |
18 | 18 |
|
19 | 19 | import React, { useEffect, useState } from "react"; |
20 | | -import { Button, Icon, LocationSelector, TextField, Typography } from "@wso2/ui-toolkit"; |
| 20 | +import { Button, Icon, LocationSelector, TextField, Typography,Codicon,Tooltip } from "@wso2/ui-toolkit"; |
21 | 21 | import styled from "@emotion/styled"; |
22 | 22 | import { useRpcContext } from "@wso2/ballerina-rpc-client"; |
23 | 23 | import { BodyText } from "../../styles"; |
@@ -47,6 +47,48 @@ const IconButton = styled.div` |
47 | 47 | } |
48 | 48 | `; |
49 | 49 |
|
| 50 | +const PreviewContainer = styled.div` |
| 51 | + border: 1px solid var(--vscode-input-border); |
| 52 | + border-radius: 4px; |
| 53 | + padding: 8px 12px; |
| 54 | + display: inline-flex; |
| 55 | + align-items: center; |
| 56 | + width: fit-content; |
| 57 | + height: 28px; |
| 58 | + gap: 8px; |
| 59 | + background-color: var(--vscode-editor-background); |
| 60 | + * { |
| 61 | + cursor: default !important; |
| 62 | + } |
| 63 | +`; |
| 64 | + |
| 65 | +const InputPreviewWrapper = styled.div` |
| 66 | + display: flex; |
| 67 | + flex-direction: column; |
| 68 | + gap: 3px; |
| 69 | + margin: 20px 0; |
| 70 | +`; |
| 71 | + |
| 72 | +const PreviewText = styled(Typography)` |
| 73 | + color: var(--vscode-sideBarTitle-foreground); |
| 74 | + opacity: 0.5; |
| 75 | + font-family: var(--vscode-editor-font-family, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace); |
| 76 | + word-break: break-all; |
| 77 | + min-width: 100px; |
| 78 | + display: flex; |
| 79 | + align-items: center; |
| 80 | + line-height: 1; |
| 81 | +`; |
| 82 | + |
| 83 | +const PreviewIcon = styled(Codicon)` |
| 84 | + display: flex; |
| 85 | + align-items: center; |
| 86 | +`; |
| 87 | + |
| 88 | +const sanitizeProjectName = (name: string): string => { |
| 89 | + return name.replace(/[^a-z0-9]/gi, '_').toLowerCase(); |
| 90 | +}; |
| 91 | + |
50 | 92 | export function ProjectForm() { |
51 | 93 | const { rpcClient } = useRpcContext(); |
52 | 94 | const [selectedModule, setSelectedModule] = useState("Main"); |
@@ -94,13 +136,23 @@ export function ProjectForm() { |
94 | 136 | <BodyText> |
95 | 137 | Name your integration and select a location to start building. |
96 | 138 | </BodyText> |
97 | | - <TextField |
98 | | - onTextChange={handleProjectName} |
99 | | - sx={{ marginTop: 20, marginBottom: 20 }} |
100 | | - value={name} |
101 | | - label="Integration Name" |
102 | | - placeholder="Enter a integration name" |
103 | | - /> |
| 139 | + <InputPreviewWrapper> |
| 140 | + <TextField |
| 141 | + onTextChange={handleProjectName} |
| 142 | + value={name} |
| 143 | + label="Integration Name" |
| 144 | + placeholder="Enter a integration name" |
| 145 | + autoFocus={true} |
| 146 | + /> |
| 147 | + <PreviewContainer> |
| 148 | + <PreviewIcon name="project" iconSx={{ fontSize: 14, color: "var(--vscode-descriptionForeground)" }} /> |
| 149 | + <Tooltip content="A unique identifier for your intergration"> |
| 150 | + <PreviewText variant="caption"> |
| 151 | + {name ? sanitizeProjectName(name) : "integration_id"} |
| 152 | + </PreviewText> |
| 153 | + </Tooltip> |
| 154 | + </PreviewContainer> |
| 155 | + </InputPreviewWrapper> |
104 | 156 | <LocationSelector |
105 | 157 | label="Select Integration Path" |
106 | 158 | selectedFile={path} |
|
0 commit comments