Browse Source

format and add ticker code as badge

Daniel Bohry 9 tháng trước cách đây
mục cha
commit
f3ad9b7267
1 tập tin đã thay đổi với 21 bổ sung1 xóa
  1. 21 1
      src/routes/portfolio/+page.svelte

+ 21 - 1
src/routes/portfolio/+page.svelte

@@ -208,6 +208,12 @@
 		fetchPortfolio();
 	}
 
+	function formatCode(input) {
+		return input.includes(':')
+			? input.split(':')[1]
+			: input;
+	}
+
 	function handleInputChange(event) {
 		const form = new FormData(event.target.closest('form'));
 		const code = form.get('code');
@@ -307,7 +313,9 @@
 			<tbody>
 			{#each result as stock}
 				<tr>
-					<td class="code">{stock.code}</td>
+					<td class="code">
+						<div class="col-code" title="{stock.code}">{formatCode(stock.code)}</div>
+					</td>
 					<td class="name">{stock.name}</td>
 					<td class="qty-edit">
 						<form id="updateQuantity" on:submit|preventDefault={updateStockQuantity}>
@@ -409,6 +417,18 @@
         color: #2c3e50;
     }
 
+    .col-code {
+        display: inline-block;
+        background-color: #e0f2ff;
+        color: #0369a1;
+        font-weight: 600;
+        font-family: monospace;
+        padding: 4px 10px;
+        border-radius: 9999px;
+        font-size: 0.875rem;
+				cursor: default;
+    }
+
     .name {
         color: #7f8c8d;
     }