Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PzYon/engraved into scrap-t…
Browse files Browse the repository at this point in the history
…oggle
  • Loading branch information
PzYon committed Jul 9, 2024
2 parents b87869d + 3f2089d commit 3fa902a
Show file tree
Hide file tree
Showing 14 changed files with 450 additions and 384 deletions.
555 changes: 282 additions & 273 deletions app/package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
"@dnd-kit/core": "6.1.0",
"@dnd-kit/sortable": "8.0.0",
"@emotion/styled": "11.11.5",
"@microsoft/applicationinsights-web": "3.2.2",
"@mui/icons-material": "5.15.21",
"@mui/material": "5.15.21",
"@microsoft/applicationinsights-web": "3.3.0",
"@mui/icons-material": "5.16.0",
"@mui/material": "5.16.0",
"@mui/styled-engine-sc": "5.14.12",
"@mui/x-date-pickers": "7.8.0",
"@tanstack/react-query": "5.49.0",
"@tanstack/react-query-devtools": "5.49.0",
"@mui/x-date-pickers": "7.9.0",
"@tanstack/react-query": "5.50.1",
"@tanstack/react-query-devtools": "5.50.1",
"@testing-library/jest-dom": "6.4.6",
"@testing-library/user-event": "14.5.2",
"@types/jest": "29.5.12",
"@types/node": "20.14.9",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@uiw/codemirror-extensions-langs": "4.22.2",
"@uiw/react-codemirror": "4.22.2",
"@uiw/codemirror-extensions-langs": "4.23.0",
"@uiw/react-codemirror": "4.23.0",
"@vitejs/plugin-react": "4.3.1",
"chart.js": "4.4.3",
"chartjs-adapter-date-fns": "3.0.0",
Expand All @@ -35,9 +35,9 @@
"react-dom": "18.3.1",
"react-hotkeys-hook": "4.5.0",
"react-onesignal": "3.0.1",
"react-router-dom": "6.24.0",
"typescript": "5.5.2",
"vite": "5.3.2"
"react-router-dom": "6.24.1",
"typescript": "5.5.3",
"vite": "5.3.3"
},
"scripts": {
"start": "vite",
Expand Down Expand Up @@ -70,23 +70,23 @@
]
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "5.49.0",
"@tanstack/eslint-plugin-query": "5.50.1",
"@types/jest": "29.5.12",
"@types/markdown-it": "14.1.1",
"@typescript-eslint/eslint-plugin": "7.14.1",
"@typescript-eslint/parser": "7.14.1",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"eslint": "8.57.0",
"eslint-plugin-react": "7.34.3",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "^0.4.5",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"prettier": "3.3.2",
"ts-jest": "29.1.5",
"ts-jest": "29.2.0",
"ts-node": "10.9.2",
"vite-plugin-checker": "0.6.4"
"vite-plugin-checker": "0.7.1"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.18.0"
"@rollup/rollup-linux-x64-gnu": "4.18.1"
}
}
16 changes: 12 additions & 4 deletions app/src/components/common/EmojiWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,32 @@ import { engravedEmojiStyle } from "./EngravedEmojiStyle";
export const EmojiWrapper: React.FC<{
emoji: string;
style: IconStyle;
}> = ({ emoji, style }) => {
isClickable?: boolean;
}> = ({ emoji, style, isClickable }) => {
const size = style === IconStyle.Large ? 26 : 22;
return (
<Host size={size} className="ngrvd-icon">
<Host
isClickable={isClickable}
size={size}
className={`ngrvd-icon${isClickable ? " clickable" : ""}`}
>
<Emoji unified={emoji} size={size} emojiStyle={engravedEmojiStyle} />
</Host>
);
};

const Host = styled("span")<{ size: number }>`
const Host = styled("span")<{
size: number;
isClickable?: boolean;
}>`
width: ${(p) => p.size + 8}px;
height: ${(p) => p.size + 5}px;
display: block;
margin-left: -2px;
cursor: ${(p) => (p.isClickable ? "pointer" : "default")};
& > span,
& > img {
cursor: pointer;
display: block !important;
line-height: ${(p) => p.size}px;
font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI",
Expand Down
24 changes: 18 additions & 6 deletions app/src/components/common/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,30 @@ import { IconStyle } from "./IconStyle";
export const Icon: React.FC<{
children: React.ReactNode;
style: IconStyle;
}> = ({ children, style }) => {
isClickable?: boolean;
}> = ({ children, style, isClickable }) => {
const Host = style === IconStyle.Small ? SmallHost : LargeHost;

return <Host className="ngrvd-icon">{children}</Host>;
return (
<Host className={`ngrvd-icon${isClickable ? " clickable" : ""}`}>
{children}
</Host>
);
};

const LargeHost = styled("span")`
const BaseHost = styled("span")`
&.clickable {
cursor: pointer !important;
}
svg {
border-radius: 100%;
color: ${(p) => p.theme.palette.primary.main};
}
`;

const LargeHost = styled(BaseHost)`
svg {
background-color: ${(p) => p.theme.palette.background.default} !important;
border: 2px solid ${(p) => p.theme.palette.primary.main};
margin-top: 9px;
Expand All @@ -24,10 +38,8 @@ const LargeHost = styled("span")`
}
`;

const SmallHost = styled("span")`
const SmallHost = styled(BaseHost)`
svg {
border-radius: 100%;
color: ${(p) => p.theme.palette.primary.main};
border: 1px solid ${(p) => p.theme.palette.primary.main};
padding: ${(p) => p.theme.spacing(0.5)};
width: 0.6em;
Expand Down
7 changes: 5 additions & 2 deletions app/src/components/common/JournalTypeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { IconStyle } from "./IconStyle";
export const JournalTypeIcon: React.FC<{
type: JournalType;
style: IconStyle;
}> = ({ type, style }) => (
<Icon style={style}>{JournalTypeFactory.create(type).getIcon()}</Icon>
isClickable?: boolean;
}> = ({ type, style, isClickable }) => (
<Icon style={style} isClickable={isClickable}>
{JournalTypeFactory.create(type).getIcon()}
</Icon>
);
8 changes: 7 additions & 1 deletion app/src/components/details/JournalPageTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export const JournalPageTitle: React.FC<{

setEmoji(e);
}}
opener={<JournalIcon journal={journal} iconStyle={IconStyle.Large} />}
opener={
<JournalIcon
journal={journal}
iconStyle={IconStyle.Large}
isClickable={true}
/>
}
/>
}
title={journal?.name}
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/details/scraps/markdown/LazyCodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const LazyCodeMirror: React.FC<ICodeMirrorProps> = ({
color: theme.palette.text.primary,
backgroundColor: theme.palette.common.white,
padding: theme.spacing(2),
outline: `1px solid ${theme.palette.background.default}`,
borderRadius: "3px",
},
".cm-layer.cm-selectionLayer .cm-selectionBackground": {
backgroundColor: theme.palette.primary.main,
Expand Down
11 changes: 8 additions & 3 deletions app/src/components/overview/journals/JournalIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import { EmojiWrapper } from "../../common/EmojiWrapper";
export const JournalIcon: React.FC<{
journal: IJournal;
iconStyle: IconStyle;
}> = ({ journal, iconStyle }) => {
isClickable?: boolean;
}> = ({ journal, iconStyle, isClickable }) => {
const emoji = getUiSettings(journal).emoji?.unified;

return emoji ? (
<EmojiWrapper emoji={emoji} style={iconStyle} />
<EmojiWrapper emoji={emoji} style={iconStyle} isClickable={isClickable} />
) : (
<JournalTypeIcon type={journal.type} style={iconStyle} />
<JournalTypeIcon
type={journal.type}
style={iconStyle}
isClickable={isClickable}
/>
);
};
6 changes: 3 additions & 3 deletions app/src/components/overview/scheduled/Scheduled.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Entities } from "../search/Entities";

export const Scheduled: React.FC = () => {
return <Entities isSchedule={true}></Entities>;
};
export const Scheduled: React.FC = () => (
<Entities isSchedule={true} executeWithoutConditions={true}></Entities>
);
9 changes: 6 additions & 3 deletions app/src/components/overview/search/Entities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ import { getScheduleForUser } from "../scheduled/scheduleUtils";
import { useAppContext } from "../../../AppContext";
import { addDays, isBefore } from "date-fns";

export const Entities: React.FC<{ isSchedule?: boolean }> = ({
isSchedule,
}) => {
export const Entities: React.FC<{
isSchedule?: boolean;
executeWithoutConditions?: boolean;
}> = ({ isSchedule, executeWithoutConditions }) => {
const { user } = useAppContext();
const { searchText } = usePageContext();

const queryResult: ISearchEntitiesResult = useSearchEntitiesQuery(
searchText,
isSchedule,
executeWithoutConditions,
);

if (!queryResult) {
Expand Down
12 changes: 10 additions & 2 deletions app/src/serverApi/reactQuery/queries/useSearchEntitiesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ import { ISearchEntitiesResult } from "../../ISearchEntitiesResult";
export const useSearchEntitiesQuery = (
searchText?: string,
scheduledOnly?: boolean,
executeWithoutConditions?: boolean,
) => {
const { data: result } = useQuery<ISearchEntitiesResult>({
queryKey: queryKeysFactory.entities(searchText, scheduledOnly),
queryKey: queryKeysFactory.entities(
searchText,
scheduledOnly,
executeWithoutConditions,
),

queryFn: () => ServerApi.getSearchEntities(searchText, scheduledOnly),
queryFn: () =>
executeWithoutConditions || searchText
? ServerApi.getSearchEntities(searchText, scheduledOnly)
: Promise.resolve({ entities: [], journals: [] }),
});

return result;
Expand Down
14 changes: 12 additions & 2 deletions app/src/serverApi/reactQuery/queryKeysFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,18 @@ export const queryKeysFactory = {
return [journals, "entries", searchText ?? "", journalTypes?.join() ?? ""];
},

entities(searchText?: string, scheduledOnly: boolean = false) {
return ["search", "entities", searchText ?? "", scheduledOnly];
entities(
searchText?: string,
scheduledOnly = false,
executeWithoutConditions = false,
) {
return [
"search",
"entities",
searchText ?? "",
scheduledOnly,
executeWithoutConditions,
];
},

systemInfo() {
Expand Down
Loading

0 comments on commit 3fa902a

Please sign in to comment.