Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusef Almamari committed Aug 3, 2024
1 parent 39936b0 commit 6e88e3f
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 6 deletions.
45 changes: 45 additions & 0 deletions src/assets/icons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
"book_2",
"terminal",
"person",
"group",
"public",
"rocket_launch",
"workspace_premium",
"psychology",
"emoji_objects",
"pets",
"health_and_safety",
"recycling",
"vaccines",
"potted_plant",
"skull",
"dentistry",
"radiology",
"neurology",
"labs",
"nutrition",
"stethoscope",
"clinical_notes",
"prescriptions",
"cardiology",
"microbiology",
"pulmonology",
"pediatrics",
"oncology",
"syringe",
"gynecology",
"hematology",
"endocrinology",
"gastroenterology",
"immunology",
"verified",
"biotech",
"rheumatology",
"nephrology",
"ophthalmology",
"urology",
"science",
"genetics",
"calculate"
]
2 changes: 1 addition & 1 deletion src/components/ui/MaterialComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function Checkbox({ className, onChange, checked = false, indeterminate =

export function Icon({ name, className, ...rest }) {
return (
<md-icon slot="icon" {...rest} class={`align-middle text-xl ${className}`}>
<md-icon slot="icon" {...rest} class={`align-middle ${className}`}>
{name}
</md-icon>
);
Expand Down
1 change: 1 addition & 0 deletions src/data/store/slices/bibsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const bibsSlice = createSlice({
dateCreated: new Date().toString(),
dateModified: new Date().toString(),
id: uid(10),
icon: "book_2",
citations: [],
tags: [],
};
Expand Down
17 changes: 16 additions & 1 deletion src/pages/bibliography/Bibliography.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CitationStylesMenu,
TagsDialog,
IdAndPasswordDialogVisible,
IconsMenu,
} from "./BibliographyTools";
import {
addNewBibAndMoveSelectedCitations,
Expand Down Expand Up @@ -59,6 +60,7 @@ export default function Bibliography() {
const [citationStyleMenuVisible, setCitationStyleMenuVisible] = useState(false);
const [tagsDialogVisible, setTagsDialogVisible] = useState(false);
const [searchByIdentifiersInput, setSearchByIdentifiersInput] = useState("");
const [iconsMenuVisible, setIconsMenuVisible] = useState(false);

const keyMap = {
// "ctrl+a": selectAll,
Expand Down Expand Up @@ -364,17 +366,19 @@ export default function Bibliography() {
["Tags", () => setTagsDialogVisible(true)],
["Change style", () => setCitationStyleMenuVisible(true)],
["Rename bibliography", () => setRenameWindowVisible(true)],
["Change icon", () => setIconsMenuVisible(true)],
].concat(getConditionalOptionsWhenNothingSelected());

return (
<div className="mx-auto max-w-[50rem]">
<HotKeys keyMap={keyMap}>
<TopBar
icon={bibliography?.icon}
headline={bibliography?.title}
description={
<>
<>
{bibliography?.collab?.open ? <Icon name="group" /> : ""}
{bibliography?.collab?.open ? <Icon name="group" className="text-xl" /> : ""}
{`${bibliography?.collab?.open ? ` ${bibliography?.collab?.id} • ` : ""}${bibliography?.style.name.long}`}
</>

Expand Down Expand Up @@ -473,6 +477,17 @@ export default function Bibliography() {
/>
)}

{iconsMenuVisible && (
<IconsMenu
setIsVisible={setIconsMenuVisible}
onSubmit={(chosenIcon) =>
dispatch(
updateBibField({ bibliographyId: bibliography.id, key: "icon", value: chosenIcon })
)
}
/>
)}

<Fab
label="Add citation"
icon="add"
Expand Down
31 changes: 28 additions & 3 deletions src/pages/bibliography/BibliographyTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import Tag from "../../components/ui/Tag";
import citationStyles from "../../assets/styles.json";
import mostPopularStyles from "../../assets/mostPopularStyles.json";
import { uid } from "../../utils/utils.ts";
import { Checkbox, List, OutlinedButton } from "../../components/ui/MaterialComponents";
import { Checkbox, Icon, List, OutlinedButton, TextButton } from "../../components/ui/MaterialComponents";
import icons from "../../assets/icons.json";

// Source types
import ArticleJournal from "../../components/sourceTypes/ArticleJournal";
Expand Down Expand Up @@ -167,7 +168,7 @@ export function ReferenceEntries(props) {
className="font-cambo"
onClick={() => openCitationForm(citation?.content.type, false, citation?.id)}
style={
/^(apa|modern-language-association|chicago)$/i.test(bibliography?.style.code)
/^(apa|modern-language-association|chicago)/.test(bibliography?.style.code)
? hangingIndentationStyle
: {}
}
Expand All @@ -177,7 +178,6 @@ export function ReferenceEntries(props) {
),
style: {
backgroundColor: citation?.isChecked ? "var(--md-sys-color-tertiary-container)" : "",
color: citation?.isChecked ? "var(--md-sys-color-on-tertiary-container)" : "",
},
draggable: true, // FIXME: Only works when dragged from the edge of the list item
onDragStart: handleDrag,
Expand Down Expand Up @@ -689,6 +689,31 @@ export function SmartGeneratorDialog(props) {
);
}

export function IconsMenu({ onSubmit, setIsVisible }) {
return (
<div>
<button type="button" onClick={() => setIsVisible(false)}>
X
</button>
<h3>Icons Menu</h3>
<div>
{icons.map((icon) => {
return (
<TextButton
onClick={() => {
onSubmit(icon);
setIsVisible(false);
}}
>
<Icon name={icon} />
</TextButton>
);
})}
</div>
</div>
);
}

export function TagsDialog(props) {
const { setTagsDialogVisible: setIsVisible, onTagAdded, onTagRemoved } = props;
const bibliography = useFindBib();
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ export default function Home() {
}

return {
start: <Icon name={bib?.icon} />,
title: bib?.collab?.open ? (
<>
<Icon name="group" /> {bib.title}
<Icon name="group" className="text-xl" /> {bib.title}
</>
) : (
bib.title
Expand Down

0 comments on commit 6e88e3f

Please sign in to comment.