diff --git a/src/components/Card.jsx b/src/components/Card.jsx
index 533052c..358d625 100644
--- a/src/components/Card.jsx
+++ b/src/components/Card.jsx
@@ -1,7 +1,18 @@
import "./Card.css";
export default function Card(props) {
- const { href, title, body, tag } = props;
+ const { href, title, body, tag, dateAdded } = props;
+
+ const isNew = () => {
+ if (!dateAdded) return false;
+
+ const addedDate = new Date(dateAdded);
+ const today = new Date();
+ const differenceInTime = today.getTime() - addedDate.getTime();
+ const differenceInDays = differenceInTime / (1000 * 3600 * 24);
+
+ return differenceInDays <= 30;
+ };
return (
@@ -9,6 +20,7 @@ export default function Card(props) {
{title}
{body}
+ {isNew() && New}
{tag}
diff --git a/src/components/CardsContainer.jsx b/src/components/CardsContainer.jsx
index 3afbb76..814dff1 100644
--- a/src/components/CardsContainer.jsx
+++ b/src/components/CardsContainer.jsx
@@ -14,13 +14,14 @@ export default function CardsContainer({ filter }) {
return (
- {filteredCards.map(({ url, title, body, tag }, i) => (
+ {filteredCards.map(({ url, title, body, tag, "date-added": dateAdded }, i) => (
))}
diff --git a/src/components/CategoryNav.css b/src/components/CategoryNav.css
index 4f0b960..9f05413 100644
--- a/src/components/CategoryNav.css
+++ b/src/components/CategoryNav.css
@@ -3,6 +3,8 @@
box-shadow: inset 0px -1px 0px var(--border-muted);
white-space: nowrap;
overflow-x: scroll;
+ /* scrollbar-width: none; /* Firefox */
+ /* -ms-overflow-style: none; /* Internet Explorer and Edge */
position: sticky;
top: 0;
background-color: var(--background);
@@ -13,12 +15,7 @@
z-index: 999999;
}
-/* hide scrollbar
-.category-nav {
- scrollbar-width: none;
- -ms-overflow-style: none;
-}
-.category-nav::-webkit-scrollbar{
+/* Hide scrollbar for Chrome, Safari and Opera */
+/* .category-nav::-webkit-scrollbar {
display: none;
-}
-*/
+} */