Skip to content

Commit 2869df1

Browse files
committed
feat: add star github button
1 parent a5a6039 commit 2869df1

16 files changed

+76
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UX Patterns for Devs
22

3-
UX Patterns for Developers is a free collection of UX patterns towards developers who want to understand how to build effective UI components accessible and usable.
3+
UX Patterns for Developers was created by [David Dias](https://thedaviddias.com). It is a free collection of UX patterns towards developers who want to understand how to build effective UI components accessible and usable.
44

55
![Screenshot of the homepage ofUX Patterns for Devs](./public/img/ux-patterns-developers.webp)
66

app/_components/stars.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use client'
2+
3+
import { PROJECT_URL } from '@/app/_constants/project';
4+
import * as Sentry from "@sentry/nextjs";
5+
import { StarIcon } from 'lucide-react';
6+
import { GitHubIcon } from 'nextra/icons';
7+
import { useEffect, useState } from 'react';
8+
9+
export function Stars() {
10+
const [stars, setStars] = useState<number | null>(null)
11+
12+
useEffect(() => {
13+
fetch('https://api.github.com/repos/thedaviddias/ux-patterns-for-developers')
14+
.then(res => res.json())
15+
.then(data => setStars(data.stargazers_count))
16+
.catch(err => Sentry.captureException(err))
17+
}, [])
18+
19+
if (stars === null) return <div className="flex items-center justify-center gap-2">
20+
<span className="inline-flex items-center gap-2 px-4 py-2 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 text-sm font-medium text-gray-900 dark:text-gray-100 rounded-lg border border-gray-200 dark:border-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-200 dark:focus:ring-gray-700">Loading...</span>
21+
</div>
22+
23+
return (
24+
<div className="flex items-center justify-center gap-2">
25+
<a
26+
href={PROJECT_URL}
27+
target="_blank"
28+
rel="noopener noreferrer"
29+
className="plausible-event-name=Star+Github inline-flex items-center gap-2 px-4 py-2 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 text-sm font-medium text-gray-900 dark:text-gray-100 rounded-lg border border-gray-200 dark:border-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-200 dark:focus:ring-gray-700"
30+
>
31+
<GitHubIcon className="w-4 h-4" />
32+
<span className="hidden lg:inline">Star on GitHub</span>
33+
<span className="inline-flex items-center px-2 py-0.5 rounded bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-gray-100">
34+
<StarIcon className="w-4 h-4 mr-1" />
35+
{stars}
36+
</span>
37+
</a>
38+
</div>
39+
)
40+
}

app/_components/subscribe.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,18 @@ export const SubscribeForm = () => {
6767
</h2>
6868
<form onSubmit={handleSubmit} className="space-y-4">
6969
<div className="space-y-2">
70-
<div className="inline-flex gap-2">
70+
<div className="flex gap-2">
7171
<Input
72-
id="subscribe-form"
73-
placeholder="Your email"
72+
placeholder="[email protected]"
7473
type="email"
74+
className="md:w-2/5"
7575
value={formState.email}
7676
onChange={(e) => setFormState((prev) => ({ ...prev, email: e.target.value }))}
7777
disabled={isLoading}
7878
required
7979
/>
8080
<Button
8181
type="submit"
82-
// className="group relative"
8382
disabled={isLoading}
8483
data-loading={isLoading}
8584
variant="outline"
@@ -102,7 +101,7 @@ export const SubscribeForm = () => {
102101
{formState.message && (
103102
<p
104103
className={cn(
105-
"mt-2 text-xs",
104+
"mt-2 text-sm",
106105
formState.status === "error" ? "text-destructive" : "text-muted-foreground",
107106
)}
108107
role="alert"

app/api/email/route.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function POST(req: NextRequest) {
1414
);
1515
}
1616

17-
const response = await fetch(
17+
await fetch(
1818
"https://connect.mailerlite.com/api/subscribers",
1919
{
2020
method: "POST",
@@ -27,10 +27,6 @@ export async function POST(req: NextRequest) {
2727
}
2828
);
2929

30-
const json = await response.json();
31-
32-
console.info("mailerlite response:", json);
33-
3430
return NextResponse.json(
3531
{ success: true, message: "signed up" },
3632
{ status: 201 }

content/en/_meta.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ export default {
1111
title: 'Documentation'
1212
},
1313
about: {
14-
type: 'menu',
14+
type: 'page',
1515
title: 'About',
16-
items: {
17-
about: 'Project',
18-
contributors: {
19-
href: 'https://github.com/thedaviddias/ux-patterns-for-developers/graphs/contributors'
20-
}
16+
theme: {
17+
sidebar: false,
18+
typesetting: 'article',
2119
}
2220
},
2321
}

content/en/about/about.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
**UX Patterns for Developers** is a free collection of UX patterns towards developers who want to understand how to build effective UI components accessible and usable.
44

5+
It was created by [David Dias](https://thedaviddias.com).
6+
57
## History
68

79
For the past few years, as a frontend developer, I have been studying and creating UI components for multiple different projects and applications. From simple personal projects, to large-scale enterprise applications, I have always been interested in UX patterns and how they can be applied to UI design.
@@ -21,10 +23,16 @@ We welcome contributions from the community! Whether you want to:
2123

2224
Visit our [GitHub repository](https://github.com/thedaviddias/ux-patterns-for-developers/blob/main/.github/CONTRIBUTING.md) to learn how to contribute.
2325

26+
You can also check the [list of contributors](https://github.com/thedaviddias/ux-patterns-for-developers/graphs/contributors) on Github.
27+
2428
## Need Help?
2529

2630
If you need assistance or want to report an issue:
2731

2832
- Open a [GitHub issue](https://github.com/thedaviddias/ux-patterns-for-developers/issues/new/choose)
2933
- Join our [Discord community](https://ddias.link/discord)
3034
- Check the pattern's documentation for specific implementation details
35+
36+
## License
37+
38+
This project is licensed under the MIT license.

content/en/index.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ description: "UX Patterns for Developers is a collection of UX patterns for ever
44
searchable: false
55
---
66

7-
import { Hero } from '@app/_components/sections/hero'
8-
import { SubscribeForm } from '@app/_components/subscribe'
9-
import { OverviewGrid } from '@app/_components/sections/overview-grid'
10-
import { Callout, Tabs } from 'nextra/components'
7+
import { Hero } from "@app/_components/sections/hero";
8+
import { OverviewGrid } from "@app/_components/sections/overview-grid";
9+
import { Stars } from "@app/_components/stars";
10+
import { SubscribeForm } from "@app/_components/subscribe";
11+
import { Callout, Tabs } from "nextra/components";
1112

1213
# UX Patterns for Devs
1314

14-
<Hero lang={props.params.lang} title={metadata.title} description={metadata.description} />
15+
<Hero
16+
lang={props.params.lang}
17+
title={metadata.title}
18+
description={metadata.description}
19+
/>
20+
21+
<Stars />
1522

1623
<OverviewGrid lang={props.params.lang} />
1724

1825
<SubscribeForm />
19-

next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const nextConfig = withBundleAnalyzer(
2929
destination: '/docs/getting-started',
3030
statusCode: 302
3131
},
32+
{
33+
source: '/about',
34+
destination: '/about/index',
35+
statusCode: 302
36+
},
3237
]
3338
})
3439
)
4.06 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)