Skip to content

Commit

Permalink
Merge pull request #10 from fosslife/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparkenstein authored Nov 22, 2024
2 parents f766d88 + 2a17385 commit 6107f37
Show file tree
Hide file tree
Showing 28 changed files with 1,123 additions and 471 deletions.
27 changes: 27 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
* text=auto eol=lf

# Denote all files that are truly binary and should not be modified
*.bin binary
*.exe binary
*.dll binary
*.so binary
*.dylib binary
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.ttf binary
*.woff binary
*.woff2 binary
*.eot binary
*.pdf binary
*.zip binary
*.tar.gz binary
*.rar binary
*.7z binary
*.iso binary
*.dmg binary

33 changes: 23 additions & 10 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@

#!/bin/sh
# Add debugging
set -e
echo "🚀 Starting pre-commit hook..."

# Get only staged files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(ts|tsx|js|jsx)$')
echo "📁 Getting staged files..."
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(ts|tsx|js|jsx)$' || true)
echo "Found files: $STAGED_FILES"

if [ -n "$STAGED_FILES" ]; then
echo "🔍 Checking staged files..."

# Run prettier on staged files
yarn prettier --write $STAGED_FILES
echo "Running Prettier..."
yarn prettier --write $STAGED_FILES || {
echo "❌ Prettier formatting failed"
exit 1
}

# Run eslint on staged files
yarn eslint $STAGED_FILES --fix
echo "Running ESLint..."
yarn eslint $STAGED_FILES --fix || {
echo "❌ ESLint check failed"
exit 1
}

# Add back the formatted/linted files to staging
echo "Adding formatted files back to staging..."
git add $STAGED_FILES
fi

# Run type checking
echo "🔍 Type checking..."
yarn tsc --noEmit

# Run tests (optional, as they might take long)
# echo "🧪 Running tests..."
# yarn test
echo "🔍 Running TypeScript check..."
yarn tsc --noEmit || {
echo "❌ TypeScript check failed"
exit 1
}

echo "✅ Pre-commit checks passed!"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@tauri-apps/plugin-shell": "^2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-resizable-panels": "^2.1.7",
"react-router-dom": "^6.28.0"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
printWidth: 120,
tabWidth: 2,
singleQuote: false,
trailingComma: "es5",
};
7 changes: 7 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = [] }
tauri = { version = "2", features = ["protocol-asset"] }
tauri-plugin-shell = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
4 changes: 3 additions & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"clipboard-manager:allow-read-image",
"clipboard-manager:allow-write-image",
"clipboard-manager:allow-read-text",
"clipboard-manager:allow-write-text"
"clipboard-manager:allow-write-text",
"core:window:default",
"core:window:allow-start-dragging"
]
}
33 changes: 32 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{os::windows::process::CommandExt, process::Command};

use trash;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
Expand All @@ -6,7 +8,7 @@ pub fn run() {
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![move_to_trash])
.invoke_handler(tauri::generate_handler![move_to_trash, open_file])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Expand All @@ -18,3 +20,32 @@ async fn move_to_trash(paths: Vec<String>) -> Result<(), String> {
}
Ok(())
}

#[tauri::command]
async fn open_file(path: String) -> Result<(), String> {
#[cfg(target_os = "windows")]
{
Command::new("cmd")
.raw_arg(format!("/C start \"\" \"{}\"", path))
.spawn()
.map_err(|e| e.to_string())?;
}

#[cfg(target_os = "macos")]
{
Command::new("open")
.arg(path)
.spawn()
.map_err(|e| e.to_string())?;
}

#[cfg(target_os = "linux")]
{
Command::new("xdg-open")
.arg(path)
.spawn()
.map_err(|e| e.to_string())?;
}

Ok(())
}
21 changes: 11 additions & 10 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
"windows": [
{
"title": "trafalgar",
"width": 800,
"height": 600
"width": 1000,
"height": 800
}
],
"security": {
"csp": null
"assetProtocol": {
"enable": true,
"scope": ["**/*"]
},
"csp": {
"default-src": ["'self'", "asset: http://asset.localhost"]
}
}
},

"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/[email protected]", "icons/icon.icns", "icons/icon.ico"]
}
}
25 changes: 15 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { Outlet } from "react-router-dom";
import { AppShell } from "@mantine/core";
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
import { Sidebar } from "./components/Sidebar";
import { Box, Group } from "@mantine/core";

export function App() {
return (
<AppShell padding="md" navbar={{ width: 180, breakpoint: "sm" }}>
<AppShell.Navbar>
<Sidebar />
</AppShell.Navbar>

<AppShell.Main>
<Outlet />
</AppShell.Main>
</AppShell>
<Group align="stretch" h="100%" wrap="nowrap">
<PanelGroup direction="horizontal" autoSaveId="app-layout">
<Panel defaultSize={15} maxSize={25}>
<Sidebar />
</Panel>
<PanelResizeHandle style={{ backgroundColor: "gainsboro", width: 1 }} />
<Panel>
<Box h="100%" p="xs">
<Outlet />
</Box>
</Panel>
</PanelGroup>
</Group>
);
}
23 changes: 15 additions & 8 deletions src/components/FileExplorer/FileExplorer.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
.selected {
background-color: light-dark(
var(--mantine-color-blue-2),
var(--mantine-color-blue-9)
) !important;
background-color: light-dark(var(--mantine-color-blue-2), var(--mantine-color-blue-9)) !important;
}

.selected:hover {
background-color: light-dark(
var(--mantine-color-blue-1),
var(--mantine-color-blue-8)
);
background-color: light-dark(var(--mantine-color-blue-1), var(--mantine-color-blue-8));
}

.tableContainer {
position: relative;
overflow: auto;
padding-right: 2px;
height: 100%;
}

.table {
position: relative;
border-collapse: separate;
border-spacing: 0;
}
27 changes: 22 additions & 5 deletions src/components/FileExplorer/NavigationBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Group, ActionIcon, Breadcrumbs, Anchor } from "@mantine/core";
import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
import {
IconChevronLeft,
IconChevronRight,
IconLayoutGrid,
IconLayoutList,
} from "@tabler/icons-react";

interface NavigationBarProps {
path: string;
canGoBack: boolean;
canGoForward: boolean;
viewMode: "grid" | "list";
onViewModeChange: (mode: "grid" | "list") => void;
onBack: () => void;
onForward: () => void;
onPathChange: (newPath: string) => void;
Expand All @@ -14,6 +21,8 @@ export function NavigationBar({
path,
canGoBack,
canGoForward,
viewMode,
onViewModeChange,
onBack,
onForward,
onPathChange,
Expand Down Expand Up @@ -43,7 +52,6 @@ export function NavigationBar({
key={fullPath}
onClick={(event) => {
event.preventDefault();
console.log("Navigating to:", fullPath); // Debug log
onPathChange(fullPath);
}}
style={{ cursor: "pointer" }}
Expand All @@ -54,7 +62,7 @@ export function NavigationBar({
});

return (
<Group p="2" justify="flex-start" bg="gray.2">
<Group p="2" justify="space-between" bg="gray.2">
<Group gap="xs">
<ActionIcon
variant="subtle"
Expand All @@ -72,9 +80,18 @@ export function NavigationBar({
>
<IconChevronRight size={16} />
</ActionIcon>
<Breadcrumbs>{breadcrumbItems}</Breadcrumbs>
</Group>

<Breadcrumbs>{breadcrumbItems}</Breadcrumbs>
<ActionIcon
variant="light"
onClick={() => onViewModeChange(viewMode === "list" ? "grid" : "list")}
>
{viewMode === "list" ? (
<IconLayoutGrid size={16} />
) : (
<IconLayoutList size={16} />
)}
</ActionIcon>
</Group>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.cardButton {
width: 100%;
}

.card {
transition: all 0.2s ease;
cursor: pointer;
user-select: none;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}

.card:hover {
background-color: var(--mantine-color-gray-0);
}

.selected {
background-color: var(--mantine-color-blue-0);
border: 1px solid var(--mantine-color-blue-5);
}

.selected:hover {
background-color: var(--mantine-color-blue-0);
}
Loading

0 comments on commit 6107f37

Please sign in to comment.