Skip to content

Commit 1a5dadd

Browse files
Web/fixes (#1461)
* chore(web): add `main-footer` to docs and remove duplicate * chore(web): - reuse `fetchSafe` - omit `github-actions[bot]` from contributors list * fix datepicker tests * chore(web): open `main-footer` links in new tab * chore(web): navbar - add `rel` attribute to all `a` tags that have `target="_blank"` * chore(web): fix docs code preview light/dark style background image isolation
1 parent 83e5583 commit 1a5dadd

File tree

12 files changed

+67
-133
lines changed

12 files changed

+67
-133
lines changed

apps/web/app/docs/[[...slug]]/page.tsx

-98
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export default function DocPage({ params }: Props) {
6262
</ContentLayout>
6363
</main>
6464
<DocsPager doc={doc} />
65-
<DocFooter />
6665
<CarbonAds />
6766
</div>
6867
<ToC doc={doc} />
@@ -150,103 +149,6 @@ function DocsPager({ doc }: { doc: Doc }) {
150149
);
151150
}
152151

153-
function DocFooter() {
154-
return (
155-
<Footer className="rounded-none pt-16 shadow-none lg:px-0 dark:bg-gray-900">
156-
<div className="w-full">
157-
<div className="grid w-full justify-between md:grid-cols-2">
158-
<div className="mb-4 max-w-sm lg:mb-0">
159-
<Link href="/" className="flex items-center gap-3">
160-
<Image alt="" height="32" src="/favicon.svg" width="32" className="size-8" />
161-
<span className="text-xl font-semibold text-gray-900 dark:text-gray-100">Flowbite React</span>
162-
</Link>
163-
<p className="mb-3 mt-4 max-w-sm text-gray-600 dark:text-gray-400">
164-
Flowbite is an ecosystem built on top of Tailwind CSS including a component library, block sections, a
165-
Figma design system and other resources.
166-
</p>
167-
<p className="mb-3 mt-4 max-w-sm text-gray-600 dark:text-gray-400">
168-
Code licensed{" "}
169-
<a
170-
href="https://github.com/themesberg/flowbite-react/blob/main/LICENSE"
171-
className="text-cyan-600 hover:underline"
172-
>
173-
MIT
174-
</a>
175-
, docs{" "}
176-
<a
177-
href="https://creativecommons.org/licenses/by/3.0/"
178-
rel="nofollow noopener noreferrer"
179-
className="text-cyan-600 hover:underline"
180-
>
181-
CC BY 3.0
182-
</a>
183-
</p>
184-
</div>
185-
<div className="grid grid-cols-2 gap-8 sm:mt-4 sm:grid-cols-3 sm:gap-6">
186-
<div>
187-
<Footer.Title
188-
title="Resources"
189-
className="mb-6 text-sm font-semibold uppercase text-gray-900 dark:text-white"
190-
/>
191-
<Footer.LinkGroup col className="text-gray-600 dark:text-gray-400">
192-
<Footer.Link href="https://github.com/themesberg/flowbite-react" className="text-base">
193-
GitHub
194-
</Footer.Link>
195-
<Footer.Link href="https://flowbite.com/" className="text-base">
196-
Flowbite
197-
</Footer.Link>
198-
<Footer.Link href="https://tailwindcss.com/" className="text-base">
199-
Tailwind CSS
200-
</Footer.Link>
201-
<Footer.Link href="https://flowbite.com/figma/" className="text-base">
202-
Figma
203-
</Footer.Link>
204-
</Footer.LinkGroup>
205-
</div>
206-
<div>
207-
<Footer.Title
208-
title="Help & Support"
209-
className="mb-6 text-sm font-semibold uppercase text-gray-900 dark:text-white"
210-
/>
211-
<Footer.LinkGroup col className="text-gray-600 dark:text-gray-400">
212-
<Footer.Link href="https://discord.gg/4eeurUVvTy" className="text-base">
213-
Discord
214-
</Footer.Link>
215-
<Footer.Link href="https://github.com/themesberg/flowbite-react/discussions" className="text-base">
216-
Github Discussions
217-
</Footer.Link>
218-
</Footer.LinkGroup>
219-
</div>
220-
<div>
221-
<Footer.Title
222-
title="Legal"
223-
className="mb-6 text-sm font-semibold uppercase text-gray-900 dark:text-white"
224-
/>
225-
<Footer.LinkGroup col className="text-gray-600 dark:text-gray-400">
226-
<Footer.Link href="https://flowbite.com/license/" className="text-base">
227-
License
228-
</Footer.Link>
229-
<Footer.Link href="https://flowbite.com/brand/" className="text-base">
230-
Brand guideline
231-
</Footer.Link>
232-
</Footer.LinkGroup>
233-
</div>
234-
</div>
235-
</div>
236-
<Footer.Divider />
237-
<div className="w-full text-center sm:flex sm:items-center sm:justify-center">
238-
<Footer.Copyright
239-
by="All Rights Reserved. Flowbite™ is a registered trademark."
240-
href="/"
241-
year={new Date().getFullYear()}
242-
className="text-base"
243-
/>
244-
</div>
245-
</div>
246-
</Footer>
247-
);
248-
}
249-
250152
function ToC({ doc }: { doc: Doc }) {
251153
return (
252154
<div className="hidden w-64 flex-none px-8 xl:block xl:text-sm">

apps/web/app/docs/layout.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useEffect, useState } from "react";
99
import { HiMenuAlt1, HiX } from "react-icons/hi";
1010
import { twMerge } from "tailwind-merge";
1111
import { DocSearchInput } from "~/components/docsearch-input";
12+
import { MainFooter } from "~/components/main-footer";
1213
import { NavbarIcons, NavbarLinks } from "~/components/navbar";
1314
import { DOCS_SIDEBAR, type DocsSidebarItem } from "~/data/docs-sidebar";
1415

@@ -36,6 +37,7 @@ export default function DocsLayout({ children }: PropsWithChildren) {
3637
<DocsSidebar {...state} />
3738
<div className="w-full min-w-0">{children}</div>
3839
</div>
40+
<MainFooter />
3941
</div>
4042
</div>
4143
);

apps/web/app/page.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Banner } from "~/components/banner";
21
import {
32
ComponentsSection,
43
ContributorsSection,
@@ -7,11 +6,11 @@ import {
76
FigmaSection,
87
HeroSection,
98
HomeNavbar,
10-
MainFooter,
119
ReactSection,
1210
SocialProofSection,
1311
TailwindSection,
1412
} from "~/components/homepage";
13+
import { MainFooter } from "~/components/main-footer";
1514

1615
export default function HomePage() {
1716
return (

apps/web/components/code-demo.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,11 @@ function CodePreview({
244244
children,
245245
}: PropsWithChildren<{ view: View; isRTL: boolean; isDarkMode: boolean | null; iframe?: IFrameData }>) {
246246
return (
247-
<div
248-
{...(isRTL && { dir: "rtl" })}
249-
className={twMerge("code-preview-wrapper", isDarkMode !== null && (isDarkMode ? "dark" : "light"))}
250-
>
247+
<div {...(isRTL && { dir: "rtl" })} className="code-preview-wrapper">
251248
<div className="flex border-x border-gray-200 bg-white bg-gradient-to-r p-0 dark:border-gray-600 dark:bg-gray-900">
252-
<div className="code-responsive-wrapper w-full">
249+
<div
250+
className={twMerge("code-responsive-wrapper w-full", isDarkMode !== null && (isDarkMode ? "dark" : "light"))}
251+
>
253252
<div
254253
className={twMerge(
255254
"mx-auto w-full bg-white bg-gradient-to-r dark:bg-gray-900",

apps/web/components/homepage/contributors-section.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tooltip } from "flowbite-react";
22
import Image from "next/image";
33
import Link from "next/link";
4-
import { safeResJson } from "~/helpers/http";
4+
import { fetchSafe } from "~/helpers/http";
55

66
interface Contributor {
77
id: number;
@@ -12,9 +12,11 @@ interface Contributor {
1212

1313
async function fetchContributors(): Promise<Contributor[]> {
1414
try {
15-
const result = await fetch("https://api.github.com/repos/themesberg/flowbite-react/contributors?per_page=21");
15+
const result = await fetchSafe<Contributor[]>(
16+
"https://api.github.com/repos/themesberg/flowbite-react/contributors?per_page=21",
17+
);
1618

17-
return safeResJson(result);
19+
return result.filter((contributor) => contributor.login !== "github-actions[bot]");
1820
} catch (error) {
1921
return [];
2022
}

apps/web/components/homepage/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export { FeaturedSection } from "./featured-section";
55
export { FigmaSection } from "./figma-section";
66
export { HeroSection } from "./hero-section";
77
export { HomeNavbar } from "./home-navbar";
8-
export { MainFooter } from "./main-footer";
98
export { ReactSection } from "./react-section";
109
export { SocialProofSection } from "./social-proof-section";
1110
export { TailwindSection } from "./tailwind-section";

apps/web/components/homepage/social-proof-section.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Image from "next/image";
2-
import { safeResJson } from "~/helpers/http";
3-
4-
async function fetchSafe<T>(endpoint: string): Promise<T> {
5-
return safeResJson(await fetch(endpoint));
6-
}
2+
import { fetchSafe } from "~/helpers/http";
73

84
async function fetchStargazers(): Promise<string> {
95
try {

apps/web/components/homepage/main-footer.tsx renamed to apps/web/components/main-footer.tsx

+31-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export function MainFooter() {
2020
Code licensed{" "}
2121
<a
2222
href="https://github.com/themesberg/flowbite-react/blob/main/LICENSE"
23+
rel="nofollow noopener noreferrer"
24+
target="_blank"
2325
className="text-cyan-600 hover:underline"
2426
>
2527
MIT
@@ -28,6 +30,7 @@ export function MainFooter() {
2830
<a
2931
href="https://creativecommons.org/licenses/by/3.0/"
3032
rel="nofollow noopener noreferrer"
33+
target="_blank"
3134
className="text-cyan-600 hover:underline"
3235
>
3336
CC BY 3.0
@@ -41,16 +44,26 @@ export function MainFooter() {
4144
className="mb-6 text-sm font-semibold uppercase text-gray-900 dark:text-white"
4245
/>
4346
<Footer.LinkGroup col className="text-gray-600 dark:text-gray-400">
44-
<Footer.Link href="https://github.com/themesberg/flowbite-react" className="text-base">
47+
<Footer.Link
48+
href="https://github.com/themesberg/flowbite-react"
49+
rel="noopener"
50+
target="_blank"
51+
className="text-base"
52+
>
4553
GitHub
4654
</Footer.Link>
47-
<Footer.Link href="https://flowbite.com/" className="text-base">
55+
<Footer.Link href="https://flowbite.com/" rel="noopener" target="_blank" className="text-base">
4856
Flowbite
4957
</Footer.Link>
50-
<Footer.Link href="https://tailwindcss.com/" className="text-base">
58+
<Footer.Link
59+
href="https://tailwindcss.com/"
60+
rel="nofollow noopener noreferrer"
61+
target="_blank"
62+
className="text-base"
63+
>
5164
Tailwind CSS
5265
</Footer.Link>
53-
<Footer.Link href="https://flowbite.com/figma/" className="text-base">
66+
<Footer.Link href="https://flowbite.com/figma/" rel="noopener" target="_blank" className="text-base">
5467
Figma
5568
</Footer.Link>
5669
</Footer.LinkGroup>
@@ -61,10 +74,20 @@ export function MainFooter() {
6174
className="mb-6 text-sm font-semibold uppercase text-gray-900 dark:text-white"
6275
/>
6376
<Footer.LinkGroup col className="text-gray-600 dark:text-gray-400">
64-
<Footer.Link href="https://discord.gg/4eeurUVvTy" className="text-base">
77+
<Footer.Link
78+
href="https://discord.gg/4eeurUVvTy"
79+
rel="nofollow noopener noreferrer"
80+
target="_blank"
81+
className="text-base"
82+
>
6583
Discord
6684
</Footer.Link>
67-
<Footer.Link href="https://github.com/themesberg/flowbite-react/discussions" className="text-base">
85+
<Footer.Link
86+
href="https://github.com/themesberg/flowbite-react/discussions"
87+
rel="noopener"
88+
target="_blank"
89+
className="text-base"
90+
>
6891
Github Discussions
6992
</Footer.Link>
7093
</Footer.LinkGroup>
@@ -75,10 +98,10 @@ export function MainFooter() {
7598
className="mb-6 text-sm font-semibold uppercase text-gray-900 dark:text-white"
7699
/>
77100
<Footer.LinkGroup col className="text-gray-600 dark:text-gray-400">
78-
<Footer.Link href="https://flowbite.com/license/" className="text-base">
101+
<Footer.Link href="https://flowbite.com/license/" rel="noopener" target="_blank" className="text-base">
79102
License
80103
</Footer.Link>
81-
<Footer.Link href="https://flowbite.com/brand/" className="text-base">
104+
<Footer.Link href="https://flowbite.com/brand/" rel="noopener" target="_blank" className="text-base">
82105
Brand guideline
83106
</Footer.Link>
84107
</Footer.LinkGroup>

apps/web/components/navbar.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function NavbarIcons() {
4545
</div>
4646
<Tooltip animation={false} content="View Storybook">
4747
<a
48+
rel="noopener"
4849
target="_blank"
4950
href="https://storybook.flowbite-react.com/"
5051
className="hidden rounded-lg p-2.5 text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-4 focus:ring-gray-200 lg:block dark:text-gray-300 dark:hover:bg-gray-700 dark:focus:ring-gray-700"
@@ -54,6 +55,7 @@ export function NavbarIcons() {
5455
</Tooltip>
5556
<Tooltip animation={false} content="Join Discord Community">
5657
<a
58+
rel="nofollow noopener noreferrer"
5759
target="_blank"
5860
href="https://discord.gg/4eeurUVvTy"
5961
className="hidden rounded-lg p-2.5 text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-4 focus:ring-gray-200 lg:block dark:text-gray-300 dark:hover:bg-gray-700 dark:focus:ring-gray-700"
@@ -63,6 +65,7 @@ export function NavbarIcons() {
6365
</Tooltip>
6466
<Tooltip animation={false} content="View on GitHub">
6567
<a
68+
rel="noopener"
6669
target="_blank"
6770
href="https://github.com/themesberg/flowbite-react"
6871
className="hidden rounded-lg p-2.5 text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-4 focus:ring-gray-200 lg:block dark:text-gray-300 dark:hover:bg-gray-700 dark:focus:ring-gray-700"
@@ -73,7 +76,12 @@ export function NavbarIcons() {
7376
<Tooltip animation={false} content="Toggle dark mode">
7477
<DarkThemeToggle />
7578
</Tooltip>
76-
<a target="_blank" href="https://npmjs.com/package/flowbite-react" className="ml-2 hidden lg:block">
79+
<a
80+
rel="nofollow noopener noreferrer"
81+
target="_blank"
82+
href="https://npmjs.com/package/flowbite-react"
83+
className="ml-2 hidden lg:block"
84+
>
7785
<Badge className="bg-primary-50 px-2 text-sm font-medium text-primary-700 hover:bg-primary-600 hover:text-white sm:block lg:block dark:bg-gray-700 dark:text-primary-500 dark:hover:bg-primary-800 dark:hover:text-white">
7886
v{version}
7987
</Badge>

apps/web/helpers/http.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
export function safeResJson<T>(res: Response) {
2-
if (res.ok) return res.json() as Promise<T>;
1+
export async function fetchSafe<T>(endpoint: string): Promise<T> {
2+
const response = await fetch(endpoint);
33

4-
throw new Error("Internal server error!");
4+
if (!response.ok) {
5+
throw new Error("Internal server error!");
6+
}
7+
8+
return response.json();
59
}

apps/web/styles/docs.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ code.language-html .token.comment {
666666
@apply text-gray-500;
667667
}
668668

669-
:not(.light) & .code-responsive-wrapper {
669+
.code-responsive-wrapper {
670670
background-color: #111827;
671671
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fillRule='evenodd'%3E%3Cg fill='%236b7280' fill-opacity='0.4'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z'/%3E%3Cpath d='M6 5V0H5v5H0v1h5v94h1V6h94V5H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
672672
}

0 commit comments

Comments
 (0)