Skip to content

Commit

Permalink
Merge pull request #10 from toggle-corp/feature/journal-improvements
Browse files Browse the repository at this point in the history
Add improvements to Journal View
  • Loading branch information
frozenhelium authored Oct 23, 2024
2 parents 24b5bb1 + 3f0f481 commit 94c3556
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 69 deletions.
34 changes: 32 additions & 2 deletions src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,40 @@ function App() {
},
});

const handleStorageStateUpdate: typeof setStorageState = useCallback(
(val) => {
setStorageState((prevValue) => {
const newValue = typeof val === 'function'
? val(prevValue)
: val;

if (
prevValue['timur-config'].value?.dailyJournalGrouping !== newValue['timur-config'].value?.dailyJournalGrouping
|| prevValue['timur-config'].value?.dailyJournalAttributeOrder !== newValue['timur-config'].value?.dailyJournalAttributeOrder
) {
const overriddenValue: typeof newValue = {
...newValue,
'timur-config': {
...newValue['timur-config'],
value: {
...(newValue['timur-config'].value ?? defaultConfigValue),
collapsedGroups: [],
},
},
};
return overriddenValue;
}

return newValue;
});
},
[],
);

const storageContextValue = useMemo<LocalStorageContextProps>(() => ({
storageState,
setStorageState,
}), [storageState]);
setStorageState: handleStorageStateUpdate,
}), [storageState, handleStorageStateUpdate]);

// Device Size

Expand Down
1 change: 1 addition & 0 deletions src/components/SelectInputContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ function SelectInputContainer<
style={(searchText || !valueDisplay) ? undefined : {
backgroundColor: valueBgColor ?? colorscheme[0][1],
color: valueFgColor ?? colorscheme[0][0],
border: 'var(--width-separator-sm) solid var(--color-foreground)',
}}
id={inputId}
name={name}
Expand Down
28 changes: 14 additions & 14 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

--base-font-size: 1rem;

--font-size-2xs: calc(var(--base-font-size) * 0.625);
--font-size-xs: calc(var(--base-font-size) * 0.75);
--font-size-sm: calc(var(--base-font-size) * 0.875);
--font-size-md: var(--base-font-size);
--font-size-lg: calc(var(--base-font-size) * 1.25);
--font-size-xl: calc(var(--base-font-size) * 1.44);
--font-size-2xl: calc(var(--base-font-size) * 1.8);
--font-size-3xl: calc(var(--base-font-size) * 2.5);
--font-size-4xl: calc(var(--base-font-size) * 3.6);
--font-size-2xs: calc(var(--base-font-size) * 0.625); /* -1 */
--font-size-xs: calc(var(--base-font-size) * 0.75); /* -0.5 */
--font-size-sm: calc(var(--base-font-size) * 0.875); /* -0.25 */
--font-size-md: var(--base-font-size); /* 0 */
--font-size-lg: calc(var(--base-font-size) * 1.25); /* 0.5 */
--font-size-xl: calc(var(--base-font-size) * 1.44); /* 1 */
--font-size-2xl: calc(var(--base-font-size) * 1.8); /* 1.5 */
--font-size-3xl: calc(var(--base-font-size) * 2.5); /* 2 */
--font-size-4xl: calc(var(--base-font-size) * 3.6); /* 2.5 */

@media screen and (max-width: 40rem) {
--base-font-size: 0.875rem;
Expand Down Expand Up @@ -165,23 +165,23 @@ h1, h2, h3, h4, h5, h6 {
}

h1 {
font-size: var(--font-size-2xl);
font-size: var(--font-size-3xl);
}

h2 {
font-size: var(--font-size-xl);
font-size: var(--font-size-2xl);
}

h3 {
font-size: var(--font-size-lg);
font-size: var(--font-size-xl);
}

h4 {
font-size: var(--font-size-md);
font-size: var(--font-size-lg);
}

h5 {
font-size: var(--font-size-sm);
font-size: var(--font-size-md);
}

p {
Expand Down
24 changes: 15 additions & 9 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ type GroupedItem<LIST_ITEM, ATTRIBUTE> = {
attribute: ATTRIBUTE;
level: number;
} | {
itemKey: string;
type: 'list-item';
value: LIST_ITEM;
level: number;
Expand All @@ -273,18 +274,21 @@ export function groupListByAttributes<LIST_ITEM, ATTRIBUTE>(

const groupedItems = list.flatMap((listItem, listIndex) => {
if (listIndex === 0) {
const groupKey = getGroupKey(listItem, attributes);
const headings = attributes.map((attribute, i) => ({
type: 'heading' as const,
value: listItem,
attribute,
level: i,
groupKey,
}));
const headings = attributes.map((attribute, i) => {
const groupKey = getGroupKey(listItem, attributes.slice(0, i + 1));
return {
type: 'heading' as const,
value: listItem,
attribute,
level: i,
groupKey,
};
});

return [
...headings,
{
itemKey: getGroupKey(listItem, attributes),
type: 'list-item' as const,
value: listItem,
level: attributes.length,
Expand All @@ -306,19 +310,20 @@ export function groupListByAttributes<LIST_ITEM, ATTRIBUTE>(
if (attributeMismatchIndex === -1) {
return [
{
itemKey: getGroupKey(listItem, attributes),
type: 'list-item' as const,
value: listItem,
level: attributes.length,
},
];
}

const groupKey = getGroupKey(listItem, attributes);
const headings = attributes.map((attribute, i) => {
if (i < attributeMismatchIndex) {
return undefined;
}

const groupKey = getGroupKey(listItem, attributes.slice(0, i + 1));
return {
type: 'heading' as const,
value: listItem,
Expand All @@ -331,6 +336,7 @@ export function groupListByAttributes<LIST_ITEM, ATTRIBUTE>(
return [
...headings,
{
itemKey: getGroupKey(listItem, attributes),
type: 'list-item' as const,
value: listItem,
level: attributes.length,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const defaultConfigValue: ConfigStorage = {
indent: true,
compactTextArea: false,
checkboxForStatus: false,
enableCollapsibleGroups: false,
startSidebarShown: window.innerWidth >= 900,
endSidebarShown: false,
dailyJournalGrouping: {
Expand All @@ -22,6 +23,7 @@ export const defaultConfigValue: ConfigStorage = {
{ key: 'task', sortDirection: 1 },
{ key: 'status', sortDirection: 1 },
],
collapsedGroups: [],
};

export const colorscheme: [string, string][] = [
Expand Down
2 changes: 2 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export type ConfigStorage = {
checkboxForStatus: boolean,
compactTextArea: boolean,
indent: boolean,
enableCollapsibleGroups: boolean,

dailyJournalAttributeOrder: DailyJournalAttribute[];
dailyJournalGrouping: DailyJournalGrouping;

collapsedGroups: string[],
startSidebarShown: boolean,
endSidebarShown: boolean,
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/DailyJournal/AddWorkItemDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function AddWorkItemDialog(props: Props) {
<Dialog
open={showAddWorkItemDialog}
onClose={handleModalClose}
heading="Add new entry"
heading="Add entry"
contentClassName={styles.modalContent}
className={styles.addWorkItemDialog}
focusElementRef={titleInputRef}
Expand Down
Loading

0 comments on commit 94c3556

Please sign in to comment.