Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Gallery/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedAt": "2026-11-12T17:07:53.501Z",
"generatedAt": "2026-11-16T16:22:21.698Z",
"items": [
{
"author": "ScriptWidget Community",
Expand Down Expand Up @@ -184,9 +184,9 @@
"url": "https://raw.githubusercontent.com/everettjf/scriptwidget/main/Gallery/widgets/habit-heatmap/lib/records.js"
},
{
"bytes": 7716,
"bytes": 8155,
"path": "main.jsx",
"sha256": "72898fbb7bb7fd80f2def57fb226156bab8de376e66d7adb156a5c1582749e4f",
"sha256": "d5c8d8d5224bdcaf059a5719b1e076e9cba790bbc32fd89f0939150112baba4c",
"url": "https://raw.githubusercontent.com/everettjf/scriptwidget/main/Gallery/widgets/habit-heatmap/main.jsx"
},
{
Expand All @@ -204,7 +204,7 @@
{
"bytes": 1487,
"path": "widget.json",
"sha256": "a8e22985d811dd1623081a16e5622a775f8819e9c8205da2320786c5916217f1",
"sha256": "854007a790145f2d4316829645093b9c88c3ad31cc2a23918a5d83d764a45a0b",
"url": "https://raw.githubusercontent.com/everettjf/scriptwidget/main/Gallery/widgets/habit-heatmap/widget.json"
}
],
Expand All @@ -219,7 +219,7 @@
"tags": [
"productivity"
],
"version": "1.2.0"
"version": "1.3.0"
},
{
"author": "ScriptWidget",
Expand Down
12 changes: 8 additions & 4 deletions Gallery/widgets/habit-heatmap/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ const CheckIn = ({ habit }) => (
</button>
);

// The flame counts consecutive days and returns to 0 after a missed day; this
// count is every recorded check-in and never goes down.
const Total = ({ habit }) => <text font="caption" color="#8B949E">{`${daysFor(habit).length} total`}</text>;

// App Intent calls the named function after evaluating this source.
if (size === "action") {
// Do not render a widget while handling a tap.
Expand All @@ -129,15 +133,15 @@ if (size === "action") {
<vstack alignment="leading" spacing="4" padding="12" background="#0D1117">
<Header habit={habits[0]} font="headline" />
<Grid log={logs[0]} colors={habits[0].color} weeks={8} cell={9} gap={2} />
<CheckIn habit={habits[0]} />
<hstack><CheckIn habit={habits[0]} /><spacer /><Total habit={habits[0]} /></hstack>
</vstack>
);
} else if (size === "medium") {
$render(
<vstack alignment="leading" spacing="4" padding="12" background="#0D1117">
<Header habit={habits[0]} font="headline" />
<Grid log={logs[0]} colors={habits[0].color} weeks={22} cell={10} gap={2} />
<CheckIn habit={habits[0]} />
<hstack><CheckIn habit={habits[0]} /><spacer /><Total habit={habits[0]} /></hstack>
</vstack>
);
} else if (size === "extraLarge") {
Expand All @@ -147,7 +151,7 @@ if (size === "action") {
<vstack alignment="leading" spacing="10" frame="max">
<Header habit={habit} font="headline" />
<Grid log={logs[index]} colors={habit.color} weeks={11} cell={12} gap={3} />
<CheckIn habit={habit} />
<hstack><CheckIn habit={habit} /><spacer /><Total habit={habit} /></hstack>
</vstack>
))}
</hstack>
Expand All @@ -157,7 +161,7 @@ if (size === "action") {
<vstack alignment="leading" spacing="12" padding="16" background="#0D1117">
{habits.map((habit, index) => (
<vstack alignment="leading" spacing="5">
<hstack><Header habit={habit} font="subheadline" /><CheckIn habit={habit} /></hstack>
<hstack spacing="8"><Header habit={habit} font="subheadline" /><Total habit={habit} /><CheckIn habit={habit} /></hstack>
<Grid log={logs[index]} colors={habit.color} weeks={26} cell={7} gap={3} />
</vstack>
))}
Expand Down
2 changes: 1 addition & 1 deletion Gallery/widgets/habit-heatmap/widget.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"formatVersion": 2,
"id": "app.scriptwidget.template.habit-heatmap",
"name": "Habit Heatmap",
"version": "1.2.0",
"version": "1.3.0",
"runtimeVersion": "1.0",
"minimumRuntimeVersion": "1.3",
"entry": "main.jsx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ const CheckIn = ({ habit }) => (
</button>
);

// The flame counts consecutive days and returns to 0 after a missed day; this
// count is every recorded check-in and never goes down.
const Total = ({ habit }) => <text font="caption" color="#8B949E">{`${daysFor(habit).length} total`}</text>;

// App Intent calls the named function after evaluating this source.
if (size === "action") {
// Do not render a widget while handling a tap.
Expand All @@ -129,15 +133,15 @@ if (size === "action") {
<vstack alignment="leading" spacing="4" padding="12" background="#0D1117">
<Header habit={habits[0]} font="headline" />
<Grid log={logs[0]} colors={habits[0].color} weeks={8} cell={9} gap={2} />
<CheckIn habit={habits[0]} />
<hstack><CheckIn habit={habits[0]} /><spacer /><Total habit={habits[0]} /></hstack>
</vstack>
);
} else if (size === "medium") {
$render(
<vstack alignment="leading" spacing="4" padding="12" background="#0D1117">
<Header habit={habits[0]} font="headline" />
<Grid log={logs[0]} colors={habits[0].color} weeks={22} cell={10} gap={2} />
<CheckIn habit={habits[0]} />
<hstack><CheckIn habit={habits[0]} /><spacer /><Total habit={habits[0]} /></hstack>
</vstack>
);
} else if (size === "extraLarge") {
Expand All @@ -147,7 +151,7 @@ if (size === "action") {
<vstack alignment="leading" spacing="10" frame="max">
<Header habit={habit} font="headline" />
<Grid log={logs[index]} colors={habit.color} weeks={11} cell={12} gap={3} />
<CheckIn habit={habit} />
<hstack><CheckIn habit={habit} /><spacer /><Total habit={habit} /></hstack>
</vstack>
))}
</hstack>
Expand All @@ -157,7 +161,7 @@ if (size === "action") {
<vstack alignment="leading" spacing="12" padding="16" background="#0D1117">
{habits.map((habit, index) => (
<vstack alignment="leading" spacing="5">
<hstack><Header habit={habit} font="subheadline" /><CheckIn habit={habit} /></hstack>
<hstack spacing="8"><Header habit={habit} font="subheadline" /><Total habit={habit} /><CheckIn habit={habit} /></hstack>
<Grid log={logs[index]} colors={habit.color} weeks={26} cell={7} gap={3} />
</vstack>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"formatVersion": 2,
"id": "app.scriptwidget.template.habit-heatmap",
"name": "Habit Heatmap",
"version": "1.2.0",
"version": "1.3.0",
"runtimeVersion": "1.0",
"minimumRuntimeVersion": "1.3",
"entry": "main.jsx",
Expand Down
4 changes: 4 additions & 0 deletions Tests/ScriptWidgetRuntimeTests/RuntimeExecutionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ final class RuntimeExecutionTests: XCTestCase {
}
XCTAssertTrue(try text(7).contains("0 days"))
XCTAssertTrue(try text(7).contains("Check in"))
XCTAssertTrue(try text(7).contains("0 total"))
try tap(7)
try tap(7)
XCTAssertTrue(try text(7).contains("1 day"))
Expand All @@ -192,7 +193,10 @@ final class RuntimeExecutionTests: XCTestCase {
XCTAssertTrue(try text(8).contains("Check in"))
try tap(8)
XCTAssertTrue(try text(8).contains("2 days"))
XCTAssertTrue(try text(8).contains("2 total"))
// A missed day ends the streak but never lowers the total.
XCTAssertTrue(try text(10).contains("0 days"))
XCTAssertTrue(try text(10).contains("2 total"))
try tap(10)
try tap(10, "checkInRun")
let stored = habitRuntime(package).executeJSXSyncForWidget("""
Expand Down
Loading
Loading