Skip to content

Commit 03bdefa

Browse files
committed
Merge branch 'main' into feature/new-color-scheme
2 parents c83ab92 + a676ea4 commit 03bdefa

File tree

5 files changed

+49
-19
lines changed

5 files changed

+49
-19
lines changed

src/components/controls/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { RequiredKeys } from "@/types/utility";
77
export const style = cva("w-full rounded-full py-2 px-3 border-2", {
88
variants: {
99
color: {
10-
primary: "border-primary bg-white",
11-
secondary: "border-secondary bg-white"
10+
primary: "border-primary bg-transparent placeholder:text-primary/75",
11+
secondary: "border-secondary bg-transparent placeholder:text-secondary/75"
1212
},
1313
},
1414
defaultVariants: {

src/components/layout/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Header = () => {
2323
});
2424

2525
return (
26-
<header className="relative flex items-center w-full gap-4 p-4 transition-all md:px-8 md:gap-12">
26+
<header className="relative flex items-center w-full gap-4 p-4 transition-all md:px-8 md:gap-12 border-b border-black/5">
2727
<Link color="primary" className="flex items-center justify-center text-2xl font-bold transition-all lg:text-4xl" href="/">
2828
<img
2929
className="object-contain transition-all text-[0px] w-10 h-10 lg:w-12 lg:h-12"

src/components/pages/blog/ArticleBrief.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import IArticle from "@/assets/state/articles/article";
1212
import makeTagUrl from "./utils/makeTagUrl";
1313
import { readtimeFormatter } from "@/utils/readtime";
1414

15-
const listAnim = {
15+
const LIST_ANIM = {
1616
in: {
1717
opacity: 0,
1818
scale: 0.5,
@@ -21,14 +21,14 @@ const listAnim = {
2121
opacity: 1,
2222
scale: 1,
2323
transition: {
24-
duration: 0.35
24+
duration: 0.25
2525
}
2626
},
2727
exit: {
2828
opacity: 0,
2929
scale: 0.5,
3030
transition: {
31-
duration: 0.35
31+
duration: 0.25
3232
}
3333
}
3434
} as Variants;
@@ -51,7 +51,7 @@ const ArticleBrief = ({ title, thumbnail, thumbnailAlt, imgLoading, readtime, te
5151
return (
5252
<motion.li
5353
className="origin-center flex flex-col flex-1 gap-4 mx-0 rounded-lg motion-safe:transition-[margin-inline] motion-safe:duration-500 sm:mx-16 md:mx-0 bg-primary-300"
54-
variants={listAnim}
54+
variants={LIST_ANIM}
5555
initial="in"
5656
animate="anim"
5757
exit="exit"

src/pages/_app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default function App({ Component, pageProps, router }: AppProps) {
8484
<AnimatePresence mode="wait" onExitComplete={onAnimFinished}>
8585
<motion.div
8686
key={router.pathname}
87-
className="flex flex-col items-center flex-1 w-full px-8"
87+
className="flex flex-col items-center flex-1 w-full p-8 pb-0"
8888
initial="initial"
8989
animate="animate"
9090
exit="exit"

src/pages/blog/index.tsx

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { GetStaticProps } from "next";
33
import { useRouter } from "next/router";
44
import Head from "next/head";
55
import TagIcon from "@heroicons/react/24/solid/TagIcon";
6-
import { motion, AnimatePresence } from "framer-motion";
6+
import { motion, AnimatePresence, Variants } from "framer-motion";
77
import { useForm, useWatch } from "react-hook-form";
88
import { zodResolver } from "@hookform/resolvers/zod";
99
import { z } from "zod";
@@ -29,16 +29,16 @@ interface BlogPageProps {
2929

3030
const SORT_OPTIONS = [
3131
{
32-
"direction": "new",
33-
"name": "Newest",
34-
"func": (a: IArticleBrief, b: IArticleBrief) => {
32+
direction: 1,
33+
name: "Newest",
34+
func: (a: IArticleBrief, b: IArticleBrief) => {
3535
return new Date(b.date).getTime() - new Date(a.date).getTime();
3636
}
3737
},
3838
{
39-
"direction": "old",
40-
"name": "Oldest",
41-
"func": (a: IArticleBrief, b: IArticleBrief) => {
39+
direction: 2,
40+
name: "Oldest",
41+
func: (a: IArticleBrief, b: IArticleBrief) => {
4242
return new Date(a.date).getTime() - new Date(b.date).getTime();
4343
}
4444
}
@@ -47,12 +47,30 @@ const SORT_OPTIONS = [
4747
const filterSchema = z.object({
4848
search: z.string(),
4949
sort: z.object({
50-
direction: z.union([z.literal("new"), z.literal("old")]),
50+
direction: z.union([z.literal(1), z.literal(2)]),
5151
name: z.string(),
5252
func: z.function(z.tuple([z.object({}), z.object({})]), z.number())
5353
})
5454
});
5555

56+
const NO_RESULTS_ANIM = {
57+
in: {
58+
opacity: 0
59+
},
60+
anim: {
61+
opacity: 1,
62+
transition: {
63+
duration: 0.25
64+
}
65+
},
66+
exit: {
67+
opacity: 0,
68+
transition: {
69+
duration: 0.25
70+
}
71+
}
72+
} as Variants;
73+
5674
const filterSchemaResolver = zodResolver(filterSchema);
5775

5876
type FilterSchema = z.infer<typeof filterSchema>;
@@ -99,7 +117,7 @@ const BlogPage: Page<BlogPageProps> = ({ articles, pathname }) => {
99117
<Heading.H1 id="blog" className="text-center text-secondary">
100118
Blog
101119
</Heading.H1>
102-
{computedArticles.length > 0 && <>
120+
{articles.length > 0 && <>
103121
<div className="mx-0 sm:mx-16 md:mx-0 motion-safe:transition-[margin-inline] motion-safe:duration-500 flex gap-2 items-end">
104122
<div>
105123
<Label htmlFor="search-input" className="text-secondary">
@@ -149,13 +167,25 @@ const BlogPage: Page<BlogPageProps> = ({ articles, pathname }) => {
149167
</motion.div>}
150168
</AnimatePresence>
151169
</div>
152-
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3" aria-label="blog articles">
170+
<AnimatePresence>
171+
{computedArticles.length <= 0 && <motion.p
172+
role="note"
173+
className="w-full text-2xl font-semibold text-center"
174+
variants={NO_RESULTS_ANIM}
175+
initial="in"
176+
animate="anim"
177+
exit="exit"
178+
>
179+
There are no blog posts that fit this criteria
180+
</motion.p>}
181+
</AnimatePresence>
182+
<ul className="grid w-full grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3" aria-label="blog articles">
153183
<AnimatePresence>
154184
{computedArticles.map((brief, i) => <ArticleBrief key={brief.url} {...brief} imgLoading={i > 3 ? "lazy" : "eager"} />)}
155185
</AnimatePresence>
156186
</ul>
157187
</>}
158-
{computedArticles.length < 1 && <p role="note" className="text-3xl font-semibold text-center">
188+
{articles.length <= 0 && <p role="note" className="text-2xl font-semibold text-center">
159189
There are no blog posts yet! Stay tuned!
160190
</p>}
161191
</main>

0 commit comments

Comments
 (0)