Skip to content

Commit bfa60e7

Browse files
echobtfactorydroid
andauthored
fix(gui): clean up unused imports and variables in UI components (#306)
AGENT 7 Analysis - UI & Extensions TypeScript Cleanup: - FileIcon.tsx: Remove unused 'Show' import - ExtensionCard.tsx: Remove unused 'formatNumber', 'StarRating' function, and 'For' import - ExtensionMarketplace.tsx: Remove unused 'ViewportMode' import - ExtensionsPanel.tsx: Remove unused 'setViewportMode' setter and 'hasUninstalledRecommendations' - ComponentPreview.tsx: Remove unused 'Theme' type and 'colors' variable, replace 'key' prop with 'data-reset-key' - MarkdownPreview.tsx: Remove unused 'batch' and 'JSX' imports, prefix unused '_ordered' param and '_exportToPdf' function Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 1d236e4 commit bfa60e7

6 files changed

Lines changed: 10 additions & 88 deletions

File tree

cortex-gui/src/components/dev/ComponentPreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
onMount,
1111
} from "solid-js";
1212
import { Icon } from "../ui/Icon";
13-
import { useTheme, Theme } from "@/context/ThemeContext";
13+
import { useTheme } from "@/context/ThemeContext";
1414

1515
// Component metadata type
1616
interface ComponentMeta {
@@ -533,7 +533,7 @@ function getCategories(): string[] {
533533

534534
// Component Preview Panel
535535
export function ComponentPreview() {
536-
const { theme, setTheme, isDark, colors } = useTheme();
536+
const { theme, setTheme, isDark } = useTheme();
537537
const [isOpen, setIsOpen] = createSignal(false);
538538
const [searchQuery, setSearchQuery] = createSignal("");
539539
const [selectedComponent, setSelectedComponent] = createSignal<ComponentMeta | null>(null);
@@ -1025,7 +1025,7 @@ export function ComponentPreview() {
10251025
style={{ "min-height": "inherit" }}
10261026
>
10271027
{/* Render component with current props */}
1028-
<div key={resetKey()}>
1028+
<div data-reset-key={resetKey()}>
10291029
{(() => {
10301030
const Component = comp().component;
10311031
return <Component {...componentProps()} />;

cortex-gui/src/components/extensions/ExtensionCard.tsx

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Show, createSignal, For } from "solid-js";
1+
import { Component, Show, createSignal } from "solid-js";
22
import { Extension, MarketplaceExtension, ExtensionUpdateInfo } from "../../context/ExtensionsContext";
33
import { Card, Text, Button, Badge } from "@/components/ui";
44
import { tokens } from "@/design-system/tokens";
@@ -109,82 +109,6 @@ export const ExtensionCard: Component<ExtensionCardProps> = (props) => {
109109
const hasUpdate = () => !!props.updateInfo;
110110
const isUpdating = () => !!props.isUpdating;
111111

112-
const formatNumber = (num: number): string => {
113-
if (num >= 1000000) {
114-
return (num / 1000000).toFixed(1) + "M";
115-
}
116-
if (num >= 1000) {
117-
return (num / 1000).toFixed(1) + "K";
118-
}
119-
return num.toString();
120-
};
121-
122-
// Star rating component - VS Code specifications
123-
// 3px margin-left between stars, 0.75 opacity for empty stars
124-
const StarRating = (rating: number) => {
125-
const fullStars = Math.floor(rating);
126-
const hasHalfStar = rating % 1 >= 0.5;
127-
const emptyStars = 5 - fullStars - (hasHalfStar ? 1 : 0);
128-
return (
129-
<div class="extension-ratings" style={{ display: "flex", "align-items": "center" }}>
130-
<For each={Array(fullStars).fill(0)}>
131-
{(_, index) => (
132-
<svg
133-
class="star star-full"
134-
width="12"
135-
height="12"
136-
viewBox="0 0 24 24"
137-
fill={tokens.colors.semantic.warning}
138-
stroke="none"
139-
style={{ "margin-left": index() > 0 ? "3px" : "0" }}
140-
>
141-
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
142-
</svg>
143-
)}
144-
</For>
145-
<Show when={hasHalfStar}>
146-
<svg
147-
class="star star-half"
148-
width="12"
149-
height="12"
150-
viewBox="0 0 24 24"
151-
style={{ "margin-left": fullStars > 0 ? "3px" : "0" }}
152-
>
153-
<defs>
154-
<linearGradient id="half-star-small">
155-
<stop offset="50%" stop-color={tokens.colors.semantic.warning} />
156-
<stop offset="50%" stop-color={tokens.colors.surface.canvas} />
157-
</linearGradient>
158-
</defs>
159-
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" fill="url(#half-star-small)" />
160-
</svg>
161-
</Show>
162-
<For each={Array(emptyStars).fill(0)}>
163-
{(_, index) => (
164-
<svg
165-
class="star star-empty"
166-
width="12"
167-
height="12"
168-
viewBox="0 0 24 24"
169-
fill={tokens.colors.surface.canvas}
170-
stroke={tokens.colors.text.muted}
171-
stroke-width="1"
172-
style={{
173-
"margin-left": "3px",
174-
opacity: 0.75 /* VS Code: empty stars at 0.75 opacity */
175-
}}
176-
>
177-
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
178-
</svg>
179-
)}
180-
</For>
181-
<span class="count" style={{ "font-size": "12px", color: tokens.colors.text.muted, "margin-left": "6px" }}>
182-
{rating.toFixed(1)}
183-
</span>
184-
</div>
185-
);
186-
};
187-
188112
// VS Code-style list view (60px height, compact)
189113
if (isListView()) {
190114
return (

cortex-gui/src/components/extensions/ExtensionMarketplace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, Show, For, createSignal, createMemo, onMount } from "solid-js";
22
import { useExtensions, Extension, MarketplaceExtension } from "../../context/ExtensionsContext";
3-
import { ExtensionCard, ViewMode, ViewportMode } from "./ExtensionCard";
3+
import { ExtensionCard, ViewMode } from "./ExtensionCard";
44
import { ExtensionDetail, ExtensionDetailData, MOCK_EXTENSION_DETAIL } from "./ExtensionDetail";
55
import { tokens } from "@/design-system/tokens";
66
import "../../styles/extensions.css";

cortex-gui/src/components/extensions/ExtensionsPanel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const ExtensionsPanel: Component<ExtensionsPanelProps> = (props) => {
3939
const {
4040
recommendations,
4141
uninstalledRecommendations,
42-
hasUninstalledRecommendations,
4342
loading: recommendationsLoading,
4443
installAllRecommendations,
4544
reloadRecommendations,
@@ -48,7 +47,7 @@ export const ExtensionsPanel: Component<ExtensionsPanelProps> = (props) => {
4847
const [searchQuery, setSearchQuery] = createSignal("");
4948
const [filter, setFilter] = createSignal<FilterType>("all");
5049
// VS Code responsive breakpoints: normal, narrow, mini
51-
const [viewportMode, setViewportMode] = createSignal<ViewportMode>("normal");
50+
const [viewportMode] = createSignal<ViewportMode>("normal");
5251
const [installingAll, setInstallingAll] = createSignal(false);
5352
const [updatingAll, setUpdatingAll] = createSignal(false);
5453

cortex-gui/src/components/ui/FileIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createMemo, Show } from "solid-js";
1+
import { createMemo } from "solid-js";
22
import { getFileIcon, getFolderIconExpanded } from "@/utils/fileIcons";
33

44
interface FileIconProps {

cortex-gui/src/components/viewers/MarkdownPreview.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
createMemo,
77
onMount,
88
onCleanup,
9-
batch,
10-
type JSX,
119
} from "solid-js";
1210
import { marked, type Token, type Tokens } from "marked";
1311
import { Icon } from "../ui/Icon";
@@ -382,7 +380,7 @@ class MarkdownRenderer {
382380
</div>`;
383381
}
384382

385-
private async renderListItem(item: Tokens.ListItem, ordered: boolean): Promise<string> {
383+
private async renderListItem(item: Tokens.ListItem, _ordered: boolean): Promise<string> {
386384
const checkbox = item.task
387385
? `<input type="checkbox" class="md-task-checkbox" ${item.checked ? "checked" : ""} disabled />`
388386
: "";
@@ -624,7 +622,8 @@ export function MarkdownPreview(props: MarkdownPreviewProps) {
624622
URL.revokeObjectURL(url);
625623
}
626624

627-
async function exportToPdf(): Promise<void> {
625+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
626+
async function _exportToPdf(): Promise<void> {
628627
const content = parsedContent();
629628
const printWindow = window.open("", "_blank");
630629
if (!printWindow) {

0 commit comments

Comments
 (0)