Skip to content

Commit 04fd84b

Browse files
committed
Refactor: Card styles based on collection type
1 parent e8a87f9 commit 04fd84b

File tree

6 files changed

+29
-16
lines changed

6 files changed

+29
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
- [x] Visibility
7979
- [ ] Moving
8080
- [ ] Generate tags/slugs
81+
- [ ] Add custom field when uploading data
8182

8283
### Bugs
8384

src/components/notes/NoteCard.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,13 @@ const NoteCard = ({
5555
selected: !!isSelected,
5656
});
5757

58-
const titleClasses = classnames("title", {
59-
"post-title": type !== "DROP",
60-
});
61-
6258
const goToLink = () => window.open(url);
6359

6460
return (
65-
<StyledNoteCard size={settings?.cardSize}>
61+
<StyledNoteCard collectionType={settings?.collectionType}>
6662
<Card onClick={(e) => handleClick(e, _id)} className={cardClasses}>
6763
<h3
68-
className={titleClasses}
64+
className={"title"}
6965
dangerouslySetInnerHTML={{ __html: md.renderInline(title) }}
7066
/>
7167
{["DROP", "QUIZ"].includes(type) && content && (

src/components/notes/NoteMeta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const NoteMeta = ({ sourceInfo = {}, inPopup }) => {
2828
if (!entriesLength) return null;
2929

3030
return inPopup ? (
31-
<Popover content={SourceInfo} trigger="click">
32-
<Icon hover size={12} className="icon" type="circle" />
31+
<Popover content={SourceInfo} placement="bottomLeft">
32+
<Icon size={12} className="icon" type="circle" />
3333
</Popover>
3434
) : (
3535
SourceInfo

src/components/notes/UploadContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ const UploadCard = ({
572572
const onlyTitleAndURL = isExternalData;
573573
const goToLink = () => window.open(url);
574574
return (
575-
<StyledNoteCard size={onlyTitleAndURL ? "sm" : ""}>
575+
<StyledNoteCard collectionType={onlyTitleAndURL ? "LINK" : ""}>
576576
<Card className={cardClasses} onClick={() => editItem(item)}>
577577
<h3 className="title">{title}</h3>
578578
{!!content && (

src/components/notes/styled.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,29 @@ import styled from "styled-components";
22
import colors from "@codedrops/react-ui";
33
import { fadeInDownAnimation } from "../../lib/animations";
44

5+
const collectionType = ({ collectionType }) => {
6+
switch (collectionType) {
7+
case "LINK":
8+
return {
9+
height: "220px",
10+
fontSize: "1.2rem",
11+
};
12+
case "WORD":
13+
return {
14+
height: "180px",
15+
fontSize: "1.6rem",
16+
};
17+
default:
18+
return {
19+
height: "300px",
20+
fontSize: "1.2rem",
21+
};
22+
}
23+
};
24+
525
const StyledNoteCard = styled.div`
6-
height: ${(props) => (props.size === "sm" ? "180px" : "300px")};
7-
max-height: ${(props) => (props.size === "sm" ? "180px" : "300px")};
26+
height: ${(props) => collectionType(props).height};
27+
max-height: ${(props) => collectionType(props).height};
828
display: flex;
929
flex-direction: column;
1030
/* break-inside: avoid-column; */
@@ -36,12 +56,9 @@ const StyledNoteCard = styled.div`
3656
align-items: center;
3757
justify-content: center;
3858
.title {
39-
font-size: 1.2rem;
59+
font-size: ${(props) => collectionType(props).fontSize};
4060
text-align: center;
4161
}
42-
.post-title {
43-
font-size: 1.6rem;
44-
}
4562
.content {
4663
font-size: inherit;
4764
width: 100%;

src/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const DEFAULT_SETTING_STATE = {
103103
},
104104
],
105105
defaultDisplayType: "CARD",
106-
cardSize: "sm",
107106
defaultFilters: {
108107
limit: 50,
109108
status: ["QUICK_ADD", "DRAFT"],

0 commit comments

Comments
 (0)