feat(habits): add opt-in partial count carryover with daily reset defaults
This commit is contained in:
@@ -31,7 +31,7 @@ export function scheduled(rule: Schedule, date: string): boolean {
|
||||
export function shade(ratio: number | null, steps: number, settings: CalendarSettings, exactSteps: boolean) {
|
||||
if (ratio === null) return { level: null, color: settings.notDueColor };
|
||||
if (ratio <= 0) return { level: 0, color: settings.emptyColor };
|
||||
const total = exactSteps ? steps : settings.shadeCount;
|
||||
const total = steps;
|
||||
const level = exactSteps ? Math.min(total, Math.round(ratio * total)) : ratio >= 1 ? total : Math.min(total - (total > 1 ? 1 : 0), Math.max(1, Math.floor(ratio * total)));
|
||||
const intensity = total <= 1 ? 1 : 0.2 + 0.8 * (level - 1) / (total - 1);
|
||||
const color = '#' + [1, 3, 5].map(i => Math.round(255 * (1 - intensity) + parseInt(settings.mainColor.slice(i, i + 2), 16) * intensity).toString(16).padStart(2, '0')).join('');
|
||||
|
||||
Reference in New Issue
Block a user