Skip to content

Commit 0ffebda

Browse files
committed
Add labels to blog inputs
1 parent a7e8720 commit 0ffebda

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed

src/assets/state/roadmap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default [
6868
Alpha Version
6969
</Heading.H4>
7070
<p aria-labelledby="roadmap-alpha-version">
71-
If everything goes according to plan, our goal is to release a public alpha version of Commit Rocket by September.
71+
If everything goes according to plan, our goal is to release a public alpha version of Commit Rocket by the end of 2023.
7272
While it will be a challenging task, we are not afraid to take it on!
7373
Upon release of the first alpha version, we will also be open-sourcing the Git client!
7474
</p>

src/components/controls/Label.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { DetailedHTMLProps, ForwardedRef, LabelHTMLAttributes, forwardRef, useMemo } from "react";
2+
import { twMerge } from "tailwind-merge";
3+
4+
export interface LabelProps extends DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {
5+
htmlFor: string;
6+
}
7+
8+
const Label = forwardRef(({ className, ...props }: LabelProps, ref: ForwardedRef<HTMLLabelElement>) => {
9+
10+
const computedClassName = useMemo(
11+
() => twMerge("text-sm font-bold block", className),
12+
[className]
13+
);
14+
15+
return (
16+
<label
17+
className={computedClassName}
18+
{...props}
19+
/>
20+
);
21+
});
22+
23+
export default Label;

src/components/controls/Select.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const itemStyle = cva("px-4 py-2", {
3030
});
3131

3232
export type BaseProps<TOption extends any, TOptions extends readonly TOption[] = readonly TOption[]> = {
33+
id?: string;
3334
name?: string;
3435
className?: string;
3536
containerClassName?: string;
@@ -66,6 +67,7 @@ const optionsAnim = {
6667

6768
const Select = forwardRef(<TOption extends any>(
6869
{
70+
id,
6971
name,
7072
className,
7173
containerClassName,
@@ -100,6 +102,7 @@ const Select = forwardRef(<TOption extends any>(
100102

101103
<Listbox name={name} value={value} onChange={onChange}>
102104
<Listbox.Button
105+
id={id}
103106
ref={ref}
104107
onBlur={onBlur}
105108
className={computedClassName}

src/components/pages/about/Member.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const Member = ({ image, fullName, title, links }: IMember) => (
99
<div className="flex flex-col items-center max-w-full gap-2 sm:flex-row md:flex-col">
1010
<img
1111
className="object-cover w-40 h-40 rounded-full shadow-md aspect-auto md:w-60 md:h-60"
12-
aria-label=""
13-
alt=""
12+
aria-label={`A picture of ${fullName}`}
13+
alt={`A picture of ${fullName}`}
1414
src={image.src}
1515
width={image.width}
1616
height={image.height}

src/pages/blog/index.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { calculateReadtime } from "@/utils/readtime";
1919
import fadeAnim from "@/animations/fade";
2020
import Heading from "@/components/layout/Heading";
2121
import { makeOgMeta } from "@/utils/meta/opengraph";
22+
import Label from "@/components/controls/Label";
2223

2324
interface BlogPageProps {
2425
articles: IArticleBrief[];
@@ -94,21 +95,34 @@ const BlogPage: Page<BlogPageProps> = ({ articles, pathname }) => {
9495
<Heading.H1 id="blog" className="text-center text-secondary">
9596
Blog
9697
</Heading.H1>
97-
<div className="mx-0 sm:mx-16 md:mx-0 motion-safe:transition-[margin-inline] motion-safe:duration-500 flex gap-2">
98-
<Input
99-
type="text"
100-
color="secondary"
101-
variant="outlined"
102-
placeholder="Search..."
103-
{...register("search")}
104-
/>
105-
<ControlledSelect
106-
name="sort"
107-
color="secondary"
108-
control={control}
109-
options={SORT_OPTIONS}
110-
getDisplayName={(opt) => opt.name}
111-
/>
98+
<div className="mx-0 sm:mx-16 md:mx-0 motion-safe:transition-[margin-inline] motion-safe:duration-500 flex gap-2 items-end">
99+
<div>
100+
<Label htmlFor="search-input" className="text-secondary">
101+
Search:
102+
</Label>
103+
<Input
104+
id="search-input"
105+
type="text"
106+
color="secondary"
107+
variant="outlined"
108+
placeholder="Search..."
109+
{...register("search")}
110+
/>
111+
</div>
112+
<div>
113+
<Label htmlFor="sort-input" className="text-secondary">
114+
Sort:
115+
</Label>
116+
<ControlledSelect
117+
id="sort-input"
118+
name="sort"
119+
color="secondary"
120+
control={control}
121+
options={SORT_OPTIONS}
122+
getDisplayName={(opt) => opt.name}
123+
/>
124+
</div>
125+
112126
<AnimatePresence>
113127
{tags.length > 0 && <motion.div
114128
variants={fadeAnim}

0 commit comments

Comments
 (0)