Skip to content

Commit ec98280

Browse files
committed
TIDY-449 - design improvements
1 parent 957f7de commit ec98280

21 files changed

Lines changed: 323 additions & 173 deletions

client/components/calendar/birdView/Birdview.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
let {
2626
mode = TimeScaleUnit.DAY,
27-
birthdate = new Date(1995, 3, 10),
27+
birthdate = undefined,
2828
groupByBirthdate = true,
2929
yearPhases = []
3030
}: {

client/components/calendar/birdView/Roller.svelte

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@
7676
config: RollerConfig;
7777
items: any[];
7878
selectedItem?: string | number;
79-
handleWheelEvent: (
80-
e: WheelEvent | ProgrammedVerticalWheelEvent
81-
) => void;
79+
handleWheelEvent: (e: WheelEvent | ProgrammedVerticalWheelEvent) => void;
8280
container?: HTMLDivElement;
8381
onMount?: ((scrollToSelectedItem: () => void) => void) | undefined;
8482
} = $props();
@@ -154,10 +152,24 @@
154152
return year;
155153
}
156154
157-
function resolveYearSuffix(year: number) {
155+
function resolveYearDecadeAgePrefix(year: number) {
158156
if (!isGroupedByBirthdate() || !shouldRenderYearDivider(year))
159157
return undefined;
160-
return getAgeSuffix(year) || undefined;
158+
const ageText = getAgeSuffix(year);
159+
return ageText ? `${ageText}s` : undefined;
160+
}
161+
162+
function resolveYearPrefix(year: number) {
163+
const decadePrefix = resolveYearDecadeAgePrefix(year);
164+
if (decadePrefix) return decadePrefix;
165+
if (!isGroupedByBirthdate()) return undefined;
166+
const y = Number(year);
167+
const selectedYear = Number(selectedItem);
168+
const matchesHighlight =
169+
Number.isFinite(selectedYear) && y === selectedYear;
170+
if (!matchesHighlight) return undefined;
171+
const ageText = getAgeSuffix(year);
172+
return ageText || undefined;
161173
}
162174
163175
function resolveMonthLabel(year: number, month: string, index: number) {
@@ -166,13 +178,6 @@
166178
return label;
167179
}
168180
169-
function resolveMonthSuffix(year: number, index: number) {
170-
if (!isGroupedByBirthdate() || index != birthdateParts.monthIndex) {
171-
return undefined;
172-
}
173-
return getAgeSuffix(year) || undefined;
174-
}
175-
176181
function isBirthday(prefix: string, item: string) {
177182
if (!birthdateParts) return false;
178183
return (
@@ -211,9 +216,14 @@
211216
}
212217
213218
function getDayLabel(prefix: string, item: string) {
214-
return Number(item) == 1
215-
? `${prefix.slice(getFirstAlphabetPosition(prefix))} ${item}`
216-
: item;
219+
const n = Number(item);
220+
if (n == 1) {
221+
return `${prefix.slice(getFirstAlphabetPosition(prefix))} ${item}`;
222+
}
223+
if (Number.isFinite(n) && n >= 2 && n <= 9 && String(item).length == 1) {
224+
return `0${item}`;
225+
}
226+
return item;
217227
}
218228
219229
function getDayAdornment(prefix: string, item: string) {
@@ -503,16 +513,15 @@
503513
{config}
504514
item={month}
505515
label={resolveMonthLabel(item, month, index)}
506-
suffix={resolveMonthSuffix(item, index)}
507-
prefix={item}
516+
context={item}
508517
bind:selectedItem
509518
{handleClick}
510519
/>
511520
{/each}
512521
{:else}
513522
<RollerButton
514523
{config}
515-
prefix={config.itemType == Itemtype.YEAR
524+
context={config.itemType == Itemtype.YEAR
516525
? ""
517526
: item.slice(0, getLastAlphabetPosition(item) + 1)}
518527
label={config.itemType == Itemtype.DAY
@@ -523,8 +532,8 @@
523532
: config.itemType == Itemtype.YEAR
524533
? resolveYearLabel(item)
525534
: undefined}
526-
suffix={config.itemType == Itemtype.YEAR
527-
? resolveYearSuffix(item)
535+
prefix={config.itemType == Itemtype.YEAR
536+
? resolveYearPrefix(item)
528537
: undefined}
529538
adornment={config.itemType == Itemtype.DAY
530539
? getDayAdornment(

client/components/calendar/birdView/RollerButton.svelte

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
adornment,
1212
selectedItem = $bindable(),
1313
handleClick,
14-
prefix = ""
14+
prefix,
15+
context = ""
1516
}: {
1617
config: any;
1718
item: any;
@@ -21,6 +22,7 @@
2122
selectedItem?: any;
2223
handleClick: (value: any) => void;
2324
prefix?: string;
25+
context?: string;
2426
} = $props();
2527
2628
const currYear = new Date().getFullYear();
@@ -41,7 +43,7 @@
4143
];
4244
const currMonth = monthNames[currMonthIndex];
4345
const currDate = new Date().getDate();
44-
const isSelected = $derived(selectedItem == prefix + item);
46+
const isSelected = $derived(selectedItem == context + item);
4547
const state = $derived.by(() => {
4648
switch (config.itemType) {
4749
case Itemtype.YEAR:
@@ -51,25 +53,25 @@
5153
};
5254
case Itemtype.MONTH:
5355
return {
54-
isToday: currYear == Number(prefix) && currMonth == item,
56+
isToday: currYear == Number(context) && currMonth == item,
5557
isPast:
56-
currYear > Number(prefix) ||
57-
(currYear == Number(prefix) &&
58+
currYear > Number(context) ||
59+
(currYear == Number(context) &&
5860
currMonthIndex > monthNames.indexOf(item))
5961
};
6062
case Itemtype.DAY: {
61-
const firstAlphIndex = getFirstAlphabetPosition(prefix);
63+
const firstAlphIndex = getFirstAlphabetPosition(context);
6264
return {
6365
isToday:
64-
currYear == Number(prefix.slice(0, firstAlphIndex)) &&
65-
currMonth == prefix.slice(-3) &&
66+
currYear == Number(context.slice(0, firstAlphIndex)) &&
67+
currMonth == context.slice(-3) &&
6668
currDate == Number(item),
6769
isPast:
68-
currYear > Number(prefix.slice(0, firstAlphIndex)) ||
69-
(currYear == Number(prefix.slice(0, firstAlphIndex)) &&
70-
currMonthIndex > monthNames.indexOf(prefix.slice(-3))) ||
71-
(currYear == Number(prefix.slice(0, firstAlphIndex)) &&
72-
currMonthIndex == monthNames.indexOf(prefix.slice(-3)) &&
70+
currYear > Number(context.slice(0, firstAlphIndex)) ||
71+
(currYear == Number(context.slice(0, firstAlphIndex)) &&
72+
currMonthIndex > monthNames.indexOf(context.slice(-3))) ||
73+
(currYear == Number(context.slice(0, firstAlphIndex)) &&
74+
currMonthIndex == monthNames.indexOf(context.slice(-3)) &&
7375
currDate > Number(item))
7476
};
7577
}
@@ -90,24 +92,35 @@
9092
)}
9193
style="height:{config.itemHeight}px;"
9294
{...{
93-
[`data-${config.itemType}`]: `${prefix}${item}`
95+
[`data-${config.itemType}`]: `${context}${item}`
9496
}}
9597
onclick={() => {
96-
handleClick(prefix + item);
98+
handleClick(context + item);
9799
}}
98100
onkeydown={(event) => {
99101
if (event.key === "Enter") {
100-
handleClick(prefix + item);
102+
handleClick(context + item);
101103
}
102104
}}
103105
>
104106
<span class="flex w-full items-center justify-center">
105107
<span class="relative inline-flex items-center justify-center">
106-
<span>{label ?? item}</span>
108+
{#if prefix}
109+
<span
110+
class={cn(
111+
"absolute right-full mr-1 top-1/2 -translate-y-1/2 rounded-md px-1 py-0.5 text-b5 leading-none tabular-nums",
112+
{ "bg-aps3 text-aps1": isSelected },
113+
{ "bg-bgs3 text-fgs3": !isSelected }
114+
)}
115+
>
116+
{prefix}
117+
</span>
118+
{/if}
119+
<span class="tabular-nums">{label ?? item}</span>
107120
{#if suffix}
108121
<span
109122
class={cn(
110-
"absolute left-full ml-1 top-1/2 -translate-y-1/2 rounded-full px-1.5 py-0.5 text-b5 leading-none",
123+
"absolute left-full ml-1 top-1/2 -translate-y-1/2 rounded-md px-1 py-0.5 text-b5 leading-none tabular-nums",
111124
{ "bg-aps3 text-aps1": isSelected },
112125
{ "bg-bgs3 text-fgs3": !isSelected }
113126
)}

client/components/calendar/birdView/RollerPicker.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,9 @@
351351
itemHeight: rollerItemHeight,
352352
containerHeight: containerHeight
353353
};
354-
if (mode == TimeScaleUnit.PART)
355-
onSelectedDateChange?.(selectedDate);
356-
else if (mode == TimeScaleUnit.DAY)
357-
onSelectedMonthChange?.(selectedMonth);
358-
else if (mode == TimeScaleUnit.MONTH)
359-
onSelectedYearChange?.(selectedYear);
354+
if (mode == TimeScaleUnit.PART) onSelectedDateChange?.(selectedDate);
355+
else if (mode == TimeScaleUnit.DAY) onSelectedMonthChange?.(selectedMonth);
356+
else if (mode == TimeScaleUnit.MONTH) onSelectedYearChange?.(selectedYear);
360357
361358
onMount?.({
362359
handleDaysWheelEvent,
@@ -366,7 +363,10 @@
366363
});
367364
</script>
368365

369-
<div class="relative flex bg-bgs2" bind:clientHeight={containerHeight}>
366+
<div
367+
class="relative flex bg-bgs1 border-r border-brs2"
368+
bind:clientHeight={containerHeight}
369+
>
370370
<Roller
371371
handleWheelEvent={handleYearsWheelEvent}
372372
items={years}

client/components/combination/CreateCombination.svelte

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,35 @@
1616
import { CombinationType } from "@21n/components/combination/combination.type";
1717
1818
let label = "";
19-
let type: CombinationType = CombinationType.SIDENAV;
19+
let type: CombinationType = CombinationType.NOTEBOOK;
2020
let error: string | undefined = undefined;
2121
const typeOptions: ISelectItem[] = [
2222
{
23-
label: "Side nav",
23+
label: "Notebook",
2424
icon: "sidebar",
25-
value: CombinationType.SIDENAV
26-
},
27-
{
28-
label: "Wall",
29-
icon: "widget",
30-
value: CombinationType.WALL,
31-
isDisabled: true,
32-
badge: "planned"
25+
value: CombinationType.NOTEBOOK
3326
},
27+
// {
28+
// label: "Wall",
29+
// icon: "widget",
30+
// value: CombinationType.WALL,
31+
// isDisabled: true,
32+
// badge: "planned"
33+
// },
3434
{
3535
label: "Canvas",
3636
icon: "canvas",
37-
value: CombinationType.WHITEBOARD,
38-
isDisabled: true,
39-
badge: "planned"
40-
},
41-
{
42-
label: "Mind map",
43-
icon: "tree-view",
44-
value: CombinationType.MINDMAP,
37+
value: CombinationType.CANVAS,
4538
isDisabled: true,
4639
badge: "planned"
4740
}
41+
// {
42+
// label: "Mind map",
43+
// icon: "tree-view",
44+
// value: CombinationType.MINDMAP,
45+
// isDisabled: true,
46+
// badge: "planned"
47+
// }
4848
];
4949
5050
async function onSave() {
@@ -53,7 +53,7 @@
5353
error = "Name is required";
5454
return;
5555
}
56-
if (type !== CombinationType.SIDENAV) {
56+
if (type !== CombinationType.NOTEBOOK) {
5757
toasts.error("Only side nav combinations are supported currently");
5858
return;
5959
}
@@ -74,14 +74,17 @@
7474
<div class="flex flex-col gap-6 w-full h-full">
7575
<TextInput
7676
label={{
77-
label: "Name of the combination",
77+
label: "Name of the space",
7878
orientation: Orientation.Vertical
7979
}}
80-
placeholder="Some combination"
80+
placeholder="School, Project X, Work, etc."
8181
bind:value={label}
8282
/>
8383
<OptionSelector
84-
labelProps={{ label: "Type of combination" }}
84+
labelProps={{
85+
label: "Layout of the space",
86+
orientation: Orientation.Vertical
87+
}}
8588
style={OptionSelectorStyle.TRAIN}
8689
options={typeOptions}
8790
bind:selected={type}

client/components/combination/combination.type.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,36 @@ export interface IActiveCombination
5858
}
5959

6060
export enum CombinationType {
61+
/**
62+
* @deprecated - use {@link CombinationType.NOTEBOOK} instead.
63+
* Side nav is now a view type in notebook.
64+
*
65+
* A markdown page can be inserted as a sub side nav (TOC becomes the hierarchy).
66+
*/
6167
SIDENAV = "sidenav",
68+
/**
69+
* @deprecated - use {@link CombinationType.CANVAS} instead.
70+
*/
6271
WHITEBOARD = "whiteboard",
72+
/**
73+
* @deprecated - use {@link CombinationType.CANVAS} instead.
74+
*
75+
* A canvas can have option to insert a mind map.
76+
* A markdown page can be inserted as a mind map (TOC becomes the hierarchy).
77+
*/
6378
MINDMAP = "mindmap",
79+
/**
80+
* @deprecated - use {@link CombinationType.NOTEBOOK} instead. WALL is now a view type in notebook.
81+
*
82+
* Infinitely deep structured layout.
83+
* A markdown page can be inserted as sub wall (TOC becomes the hierarchy).
84+
*/
6485
WALL = "wall",
6586
/**
6687
* @deprecated - use horizontal stack and vertical stack when Calendar scope is activated in Calendar instead.
6788
* Previous - Pyramid, Funnel views merged into regular timeline view.
6889
*/
69-
TIMELINE = "timeline"
90+
TIMELINE = "timeline",
91+
NOTEBOOK = "notebook",
92+
CANVAS = "canvas"
7093
}

0 commit comments

Comments
 (0)