Skip to content

Commit

Permalink
Merge pull request #21 from h8moss/ver/1.2.1
Browse files Browse the repository at this point in the history
Ver/1.2.1
  • Loading branch information
h8moss authored Sep 17, 2024
2 parents 6dcab8e + 5da6fdf commit 7ac8981
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 182 deletions.
345 changes: 176 additions & 169 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "progress-tracker",
"private": true,
"version": "0.0.0",
"version": "1.2.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -11,7 +11,7 @@
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^1.4.0",
"@tauri-apps/api": "^1.6.0",
"natural-compare-lite": "^1.4.0",
"uuid": "^9.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion 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
@@ -1,6 +1,6 @@
[package]
name = "progress-tracker"
version = "0.0.0"
version = "1.2.1"
description = "A Tauri App"
authors = ["you"]
license = ""
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "progress tracker",
"version": "1.2.0"
"version": "1.2.1"
},
"tauri": {
"cli": {
Expand Down
28 changes: 24 additions & 4 deletions src/lib/components/NodeView/NodeView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
} from "../../types";
import { slide, scale } from "svelte/transition";
import ArrowRight from "./ArrowRight.svelte";
import { ContextMenuItems } from "../../util";
import { ContextMenuItems, interpretWeight } from "../../util";
import weightedProgressStore from "./weightedProgressStore";
import weightStore from "./weightStore";
import titleEditStore from "./titleEditStore";
Expand All @@ -44,6 +44,8 @@
export let isLast: () => boolean;
export let isFirst: () => boolean;
let oldProgressValue = 0;
type MoveDirections = "UP" | "DOWN" | "TOP" | "BOTTOM";
const dispatch = createEventDispatcher<{
Expand Down Expand Up @@ -83,8 +85,21 @@
...structuredClone(node ? node.configuration : {}),
} as Required<NodeConfiguration>;
$: progress = weightedProgressStore(configuration.weightInterpretation);
$: progress.set(getWeightedProgress(node));
$: progress = weightedProgressStore(
configuration.weightInterpretation,
oldProgressValue
);
$: {
if ($progress != undefined) {
console.log({ progress: $progress.progress });
oldProgressValue = $progress.progress;
}
// progress.set(getWeightedProgress(node));
}
$: {
progress.set(getWeightedProgress(node));
}
$: weight = weightStore(
node.weight || 0,
Expand Down Expand Up @@ -356,7 +371,12 @@
<button on:click={weight.onFinishEditing}>Ok</button>
</div>
{:else}
<p>{$weight.interpreted}</p>
<p>{
interpretWeight({
weight: getTotalWeight(node),
weightInterpretation: configuration.weightInterpretation
})
}</p>
{/if}
</div>
{#if node.children && (showChildren || headless)}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/NodeView/weightedProgressStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { cubicOut } from "svelte/easing";
import { tweened } from "svelte/motion";
import { derived, writable } from "svelte/store";

const weightedProgressStore = (weightInterpretation: WeightInterpretation) => {
const weightedProgress = writable(0);
const tweenedWeightedProgress = tweened(0, {
const weightedProgressStore = (weightInterpretation: WeightInterpretation, initialValue = 0) => {
const weightedProgress = writable(initialValue);
const tweenedWeightedProgress = tweened(initialValue, {
duration: 200,
easing: cubicOut,
});
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/ProgressIndicator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
position: sticky;
top: 0.5rem;
--bg: var(--bg-color, white);
z-index: 99;
}
div {
background: linear-gradient(
Expand Down
19 changes: 18 additions & 1 deletion src/lib/util/interpretWeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ const numberToUnit = ({
return num.toFixed(2) + baseUnit;
};

const fixedTrailingZeros = (n: number, trailing: number, decimals: number) => {
let [left, right] = n.toFixed(decimals || 1).split(".")

while (left.length < trailing) {
left = `0${left}`
}
if (decimals == 0) return left.toString();
return `${left}.${right}`
}

const weightToSeconds = (w: number) => {
let s = w;
let m = 0;
Expand All @@ -37,7 +47,14 @@ const weightToSeconds = (w: number) => {
}
}

return `${h}:${m}:${s.toFixed(2)}`;
// Seconds String
let ss = fixedTrailingZeros(s, 2, 2);
// Minutes String
let ms = fixedTrailingZeros(m, 2, 0);
// Hours String
let hs = fixedTrailingZeros(h, 2, 0);

return `${hs}:${ms}:${ss}`;
};

const weightToGrams = (weight: number) =>
Expand Down

0 comments on commit 7ac8981

Please sign in to comment.