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 package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/svelte": "^5.1.0",
"@testing-library/user-event": "^14.6.1",
"@thwbh/veilchen": "^0.2.2",
"@thwbh/veilchen": "^0.2.3",
"@tsconfig/svelte": "^5.0.4",
"@types/date-fns": "^2.6.0",
"@types/node": "^22.10.1",
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/src/service/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct Dashboard {
pub weight_month_list: Vec<WeightTracker>,
pub food_categories: Vec<FoodCategory>,
pub current_day: i32,
pub days_total: i32,
}

// ============================================================================
Expand Down Expand Up @@ -88,6 +89,10 @@ impl Dashboard {
.num_days() as i32;
let current_day: i32 = day_count + 1; // Day count will be zero at the first day

let days_total: i32 = intake_target_end_date
.signed_duration_since(intake_target_start_date)
.num_days() as i32;

Ok(Self {
user_data,
intake_target,
Expand All @@ -98,6 +103,7 @@ impl Dashboard {
weight_month_list,
food_categories,
current_day,
days_total,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/service/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fn process_intake(
.into_iter()
.map(|(category, (sum, count))| {
FoodCategory::find_by_key(conn, category)
.map(|cat| (cat.longvalue, math_f32::floor_f32(sum / count as f32, 0)))
.map(|cat| (cat.shortvalue, math_f32::floor_f32(sum / count as f32, 0)))
.map_err(|e| format!("Failed to get food category: {}", e))
})
.collect::<Result<BTreeMap<String, f32>, String>>()?;
Expand Down
16 changes: 7 additions & 9 deletions src/lib/activity.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { Barbell, OfficeChair, PersonSimpleRun, PersonSimpleTaiChi, Trophy } from 'phosphor-svelte';
import type { Component } from 'svelte';
import { BadgeColor, type OptionCardBadge } from '@thwbh/veilchen';

export interface ActivityLevelInfo {
level: number;
label: string;
icon: Component;
badge: {
text: string;
color: 'success' | 'error' | 'warning' | 'info' | 'primary' | 'secondary' | 'accent';
};
badge: OptionCardBadge;
description: string;
}

Expand All @@ -17,39 +15,39 @@ export const activityLevels: ActivityLevelInfo[] = [
level: 1,
label: 'Mostly Sedentary',
icon: OfficeChair,
badge: { text: 'Level 1', color: 'secondary' },
badge: { text: 'Level 1', color: BadgeColor.Secondary },
description:
'You likely have an office job and try your best reaching your daily step goal. Apart from that, you do not work out regularly and spend most of your day stationary.'
},
{
level: 1.25,
label: 'Light Activity',
icon: PersonSimpleTaiChi,
badge: { text: 'Level 2', color: 'secondary' },
badge: { text: 'Level 2', color: BadgeColor.Secondary },
description:
'You either have a job that requires you to move around frequently or you hit the gym 2x - 3x times a week. In either way, you are regularly lifting weight and training your cardiovascular system.'
},
{
level: 1.5,
label: 'Moderate Activity',
icon: PersonSimpleRun,
badge: { text: 'Level 3', color: 'secondary' },
badge: { text: 'Level 3', color: BadgeColor.Secondary },
description:
'You consistently train your body 3x - 4x times a week. Your training plan became more sophisticated over the years and include cardiovascular HIIT sessions. You realized how important nutrition is and want to improve your sportive results.'
},
{
level: 1.75,
label: 'Highly Active',
icon: Barbell,
badge: { text: 'Level 4', color: 'accent' },
badge: { text: 'Level 4', color: BadgeColor.Warning },
description:
'Fitness is your top priority in life. You dedicate large parts of your week to train your body, maybe even regularly visit sportive events. You work out almost every day and certainly know what you are doing.'
},
{
level: 2,
label: 'Athlete',
icon: Trophy,
badge: { text: 'Level 5', color: 'warning' },
badge: { text: 'Level 5', color: BadgeColor.Accent },
description:
"Your fitness level reaches into the (semi-) professional realm. Calculators like this won't fulfill your needs and you are curious how far off the results will be."
}
Expand Down
29 changes: 16 additions & 13 deletions src/lib/api/category.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import type { FoodCategory } from '$lib/api/gen';
import { BowlFood, Coffee, Cookie, ForkKnife, IceCream, PintGlass } from 'phosphor-svelte';
import type { Component } from 'svelte';

const categoryIcons: Record<string, Component> = {
b: Coffee,
l: BowlFood,
d: ForkKnife,
s: Cookie,
t: IceCream,
u: PintGlass
};

const categoryColors = new Map([
['b', 'bg-warning'], // Breakfast → #f5b474 (warm orange)
['l', 'bg-success'], // Lunch → #63ca7b (fresh green)
['d', 'bg-primary'], // Dinner → oklch(52% 0.105 223) (cool blue)
['s', 'bg-secondary'], // Snack → oklch(70% 0.183 293) (purple)
['t', 'bg-accent'] // Treat → oklch(82% 0.119 306) (pink/lavender)
]);
export const getFoodCategoryLongvalue = (
foodCategories: Array<FoodCategory>,
shortvalue: string
foodCategories: Array<FoodCategory>,
shortvalue: string
): string => {
return foodCategories.filter((fc) => fc.shortvalue === shortvalue)[0].longvalue;
return foodCategories.filter((fc) => fc.shortvalue === shortvalue)[0].longvalue;
};

export const getFoodCategoryColor = (shortvalue: string): string => {
return categoryColors.get(shortvalue)!;
}
export const getFoodCategoryIcon = (shortvalue: string): Component => {
return categoryIcons[shortvalue];
};
1 change: 0 additions & 1 deletion src/lib/assets/icons/alert-circle-filled.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/arrow-right.svg

This file was deleted.

51 changes: 51 additions & 0 deletions src/lib/assets/icons/book-bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions src/lib/assets/icons/bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/lib/assets/icons/chart-line.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/chart-pie-4.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/check.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/circle-check.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/circle-x.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/dashboard.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/file-type-csv.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/file-upload.svg

This file was deleted.

73 changes: 73 additions & 0 deletions src/lib/assets/icons/fit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/lib/assets/icons/food-off.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/food.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/github.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/hamburger-plus.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/assets/icons/history.svg

This file was deleted.

Loading
Loading