Skip to content

refactor: layout and style#82

Merged
zmrlft merged 1 commit intomainfrom
pr-80
Mar 28, 2026
Merged

refactor: layout and style#82
zmrlft merged 1 commit intomainfrom
pr-80

Conversation

@zmrlft
Copy link
Copy Markdown
Owner

@zmrlft zmrlft commented Mar 28, 2026

Summary by cubic

Refactored the contribution editor and calendar into a cleaner, faster UI with a new useContributionEditor hook, streamlined layout/styles, and lighter global defaults. Updated docs and added date utilities; upgraded desktop runtime dependencies.

  • Refactors

    • Moved calendar/editor logic to useContributionEditor (drawing modes, pen intensity, buffer, import/export).
    • Simplified ContributionCalendar and SCSS; consistent grid sizing, smoother rendering, and disabled text selection.
    • Global CSS cleanup (fonts to Nunito, scrollbars, light color scheme, base resets).
    • Added utils/date.ts for ISO date parse/format helpers used by the editor.
    • App.tsx imports and helpers trimmed; naming and minor logic cleanups.
    • ImageImportCard effect deps fixed; removed an unused prop.
  • Dependencies

    • Upgraded github.com/wailsapp/wails/v2 to v2.11.0.
    • Upgraded github.com/wailsapp/go-webview2 to v1.0.22.

Written for commit 2be2764. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/src/components/ContributionCalendar.module.scss">

<violation number="1" location="frontend/src/components/ContributionCalendar.module.scss:44">
P2: The first weekday label loses its intended row alignment because `.week` no longer sets a base `grid-row`.</violation>
</file>

<file name="README_zh.md">

<violation number="1" location="README_zh.md:99">
P2: The documented Go version is outdated. The project’s `go.mod` requires Go 1.24.0, so `Go 1.23+` can mislead contributors into using an incompatible toolchain.</violation>
</file>

<file name="frontend/src/hooks/useContributionEditor.ts">

<violation number="1" location="frontend/src/hooks/useContributionEditor.ts:149">
P2: Mixing UTC-parsed dates (`new Date(dateStr)`) with local-time dates (`new Date(year, 0, 1)`) causes incorrect grid coordinates for users in non-UTC timezones. Use a consistent time basis — either parse both as UTC or both as local time. For example, split the date string and construct via `new Date(y, m-1, d)` to stay in local time consistently.</violation>

<violation number="2" location="frontend/src/hooks/useContributionEditor.ts:665">
P1: Drawing actions are not undoable because `pushSnapshot()` is never called before `applyDrawAction`. Every other mutation path in this hook snapshots the state first. Add a `pushSnapshot()` call in `handleTileMouseDown` when drawing begins so the pre-draw state is captured for undo.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

return;
}

setIsDrawing(true);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Drawing actions are not undoable because pushSnapshot() is never called before applyDrawAction. Every other mutation path in this hook snapshots the state first. Add a pushSnapshot() call in handleTileMouseDown when drawing begins so the pre-draw state is captured for undo.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/hooks/useContributionEditor.ts, line 665:

<comment>Drawing actions are not undoable because `pushSnapshot()` is never called before `applyDrawAction`. Every other mutation path in this hook snapshots the state first. Add a `pushSnapshot()` call in `handleTileMouseDown` when drawing begins so the pre-draw state is captured for undo.</comment>

<file context>
@@ -0,0 +1,903 @@
+        return;
+      }
+
+      setIsDrawing(true);
+      setLastHoveredDate(dateStr);
+      applyDrawAction(dateStr, drawMode);
</file context>
Fix with Cubic

Comment thread frontend/src/components/ContributionCalendar.module.scss
Comment thread README_zh.md Outdated
const getDateCoord = React.useCallback(
(dateStr: string) => {
const date = new Date(dateStr);
const yearStart = new Date(year, 0, 1);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Mixing UTC-parsed dates (new Date(dateStr)) with local-time dates (new Date(year, 0, 1)) causes incorrect grid coordinates for users in non-UTC timezones. Use a consistent time basis — either parse both as UTC or both as local time. For example, split the date string and construct via new Date(y, m-1, d) to stay in local time consistently.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/hooks/useContributionEditor.ts, line 149:

<comment>Mixing UTC-parsed dates (`new Date(dateStr)`) with local-time dates (`new Date(year, 0, 1)`) causes incorrect grid coordinates for users in non-UTC timezones. Use a consistent time basis — either parse both as UTC or both as local time. For example, split the date string and construct via `new Date(y, m-1, d)` to stay in local time consistently.</comment>

<file context>
@@ -0,0 +1,903 @@
+  const getDateCoord = React.useCallback(
+    (dateStr: string) => {
+      const date = new Date(dateStr);
+      const yearStart = new Date(year, 0, 1);
+      const firstDayOfWeek = yearStart.getDay();
+      const daysSinceYearStart = Math.floor(
</file context>
Fix with Cubic

@zmrlft zmrlft merged commit cf61e01 into main Mar 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant