Skip to content

Commit

Permalink
added expand button
Browse files Browse the repository at this point in the history
  • Loading branch information
vwh committed Jul 28, 2024
1 parent 0fd0ff3 commit b8ee71a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Dialog from "./components/dialog";
import Footer from "./components/footer";

function App() {
const { db, tables, isLoading, loadDatabase } = useSQLiteStore();
const { db, tables, isLoading, loadDatabase, expandPage } = useSQLiteStore();
const [fetchError, setFetchError] = useState<string | null>(null);
const [showDialog, setShowDialog] = useState(false);
const [urlToFetch, setUrlToFetch] = useState<string | null>(null);
Expand Down Expand Up @@ -87,7 +87,9 @@ function App() {
};

return (
<>
<main
className={`mx-auto flex h-screen flex-col gap-3 p-4 ${expandPage ? "w-full" : "container"}`}
>
{!db && <Logo />}
<UploadFile />
{renderContent()}
Expand All @@ -97,7 +99,7 @@ function App() {
fn={handleRetryWithProxy}
/>
{!db && <Footer />}
</>
</main>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/export-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function ExportButtons() {
)}
{renderExportButton(
() => exportCustomQueryAsCSV(db, customQuery),
"Export custom query"
"Export custom query as CSV"
)}
</div>
),
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function Settings() {
</div>
<div>
<p className="mb-1 text-sm text-muted-foreground">
Query History
Query History ({queryHestory.length})
</p>
<ScrollArea className="h-48 rounded-md border">
<div className="p-4">
Expand Down
14 changes: 12 additions & 2 deletions src/components/table-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import {
} from "./ui/select";
import { Badge } from "./ui/badge";
import ExportButtons from "./export-buttons";
import { Button } from "./ui/button";

import { ExpandIcon } from "lucide-react";

export default function TableSelect() {
const { tables, selectedTable, setSelectedTable } = useSQLiteStore();
const { tables, selectedTable, setSelectedTable, expandPage, setExpandPage } =
useSQLiteStore();

const selectedTableCount = useMemo(() => {
const index = parseInt(selectedTable);
Expand All @@ -32,7 +36,7 @@ export default function TableSelect() {
);

return (
<section className="flex items-center justify-center gap-2">
<section className="flex items-center justify-center gap-1">
<Select value={selectedTable} onValueChange={setSelectedTable}>
<SelectTrigger className="grow">
<SelectValue placeholder="Select a table" />
Expand All @@ -51,6 +55,12 @@ export default function TableSelect() {
>
<span className="w-full text-center">{selectedTableCount}</span>
</Badge>
<Button
className="hidden md:block"
onClick={() => setExpandPage(!expandPage)}
>
<ExpandIcon className="h-5 w-5" />
</Button>
<ExportButtons />
</section>
);
Expand Down
4 changes: 1 addition & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import "./index.css";

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<main className="container mx-auto flex h-screen flex-col gap-3 p-4">
<App />
</main>
<App />
<Toaster />
</React.StrictMode>
);
7 changes: 6 additions & 1 deletion src/store/useSQLiteStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface SQLiteState {
queryHestory: string[];
setQueryHestory: (value: string[]) => void;
appendToQueryHestory: (value: string) => void;
expandPage: boolean;
setExpandPage: (value: boolean) => void;
}

const initializeStore = create<SQLiteState>((set, get) => ({
Expand Down Expand Up @@ -96,7 +98,10 @@ const initializeStore = create<SQLiteState>((set, get) => ({
queryHestory: [],
setQueryHestory: (value: string[]) => set({ queryHestory: value }),
appendToQueryHestory: (value: string) =>
set((state) => ({ queryHestory: [...state.queryHestory, value] }))
set((state) => ({ queryHestory: [...state.queryHestory, value] })),

expandPage: false,
setExpandPage: (value: boolean) => set({ expandPage: value })
}));

export default initializeStore;

0 comments on commit b8ee71a

Please sign in to comment.