feat: new-card-design (#196)

* card option 1

* UI updates for item card

* fix test error

* fix pagination issues on backend

* add integer support

* remove date from cards

* implement pagination for search page

* resolve search state problems

* other fixes

* fix broken datetime

* attempt to fix scroll behavior
This commit is contained in:
Hayden 2023-01-01 13:50:48 -08:00 committed by GitHub
parent 58d6f9a28c
commit 891d41b75f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 393 additions and 142 deletions

View file

@ -5,72 +5,21 @@
<script setup lang="ts">
type DateTimeFormat = "relative" | "long" | "short" | "human";
function ordinalIndicator(num: number) {
if (num > 3 && num < 21) return "th";
switch (num % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
}
type Props = {
date?: Date | string;
format?: DateTimeFormat;
};
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
const props = withDefaults(defineProps<Props>(), {
date: undefined,
format: "relative",
});
const value = computed(() => {
if (!props.date) {
if (!props.date || !validDate(props.date)) {
return "";
}
const dt = typeof props.date === "string" ? new Date(props.date) : props.date;
if (!dt) {
return "";
}
if (!validDate(dt)) {
return "";
}
switch (props.format) {
case "relative":
return useTimeAgo(dt).value + useDateFormat(dt, " (MM-DD-YYYY)").value;
case "long":
return useDateFormat(dt, "MM-DD-YYYY (dddd)").value;
case "short":
return useDateFormat(dt, "MM-DD-YYYY").value;
case "human":
// January 1st, 2021
return `${months[dt.getMonth()]} ${dt.getDate()}${ordinalIndicator(dt.getDate())}, ${dt.getFullYear()}`;
default:
return "";
}
});
const props = defineProps({
date: {
type: [Date, String],
required: true,
},
format: {
type: String as () => DateTimeFormat,
default: "relative",
},
return fmtDate(props.date, props.format);
});
</script>