-
Notifications
You must be signed in to change notification settings - Fork 509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: design system #2667
feat: design system #2667
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { CodeBlock, Pre } from "fumadocs-ui/components/codeblock"; | ||
import type { PropsWithChildren } from "react"; | ||
import reactElementToJSXString from "react-element-to-jsx-string"; | ||
|
||
export const RenderComponentWithSnippet: React.FC<PropsWithChildren> = (props) => { | ||
return ( | ||
<div> | ||
{props.children} | ||
<CodeBlock> | ||
<Pre> | ||
{reactElementToJSXString(props.children, { | ||
showFunctions: true, | ||
useBooleanShorthandSyntax: true, | ||
})} | ||
</Pre> | ||
</CodeBlock> | ||
</div> | ||
); | ||
}; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { PropsWithChildren } from "react"; | ||
|
||
export const Row: React.FC<PropsWithChildren> = (props) => { | ||
return <div className="flex w-full items-center justify-around gap-8">{props.children}</div>; | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||||||
"use client"; | ||||||||||||||
import { componentSource } from "@/app/source"; | ||||||||||||||
import defaultMdxComponents from "fumadocs-ui/mdx"; | ||||||||||||||
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from "fumadocs-ui/page"; | ||||||||||||||
//import { createTypeTable } from 'fumadocs-typescript/ui'; | ||||||||||||||
|
||||||||||||||
import { notFound } from "next/navigation"; | ||||||||||||||
export default async function Page(props: { | ||||||||||||||
params: Promise<{ slug?: string[] }>; | ||||||||||||||
}) { | ||||||||||||||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider simplifying the props type The Consider simplifying the type to: -export default async function Page(props: {
- params: Promise<{ slug?: string[] }>;
-}) {
+export default async function Page(props: {
+ params: { slug?: string[] };
+}) { 📝 Committable suggestion
Suggested change
|
||||||||||||||
const params = await props.params; | ||||||||||||||
|
||||||||||||||
const page = componentSource.getPage(params.slug); | ||||||||||||||
|
||||||||||||||
if (!page) { | ||||||||||||||
notFound(); | ||||||||||||||
} | ||||||||||||||
//const { AutoTypeTable } = createTypeTable(); | ||||||||||||||
|
||||||||||||||
const MDX = page.data.body; | ||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<DocsPage toc={page.data.toc} full={page.data.full}> | ||||||||||||||
<DocsTitle>{page.data.title}</DocsTitle> | ||||||||||||||
|
||||||||||||||
<DocsDescription>{page.data.description}</DocsDescription> | ||||||||||||||
|
||||||||||||||
<DocsBody> | ||||||||||||||
<MDX components={{ ...defaultMdxComponents }} /> | ||||||||||||||
</DocsBody> | ||||||||||||||
</DocsPage> | ||||||||||||||
); | ||||||||||||||
} | ||||||||||||||
/* | ||||||||||||||
export async function generateStaticParams() { | ||||||||||||||
return componentSource.generateParams(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export function generateMetadata({ params }: { params: { slug?: string[] } }) { | ||||||||||||||
const page = componentSource.getPage(params.slug); | ||||||||||||||
if (!page) { | ||||||||||||||
notFound(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
return { | ||||||||||||||
title: page.data.title, | ||||||||||||||
description: page.data.description, | ||||||||||||||
} satisfies Metadata; | ||||||||||||||
} | ||||||||||||||
*/ | ||||||||||||||
Comment on lines
+34
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the output, I can now provide a final response: Enable metadata and static generation functions The commented-out functions should be uncommented because:
Please uncomment these functions to ensure consistent behavior with other pages in the engineering app, particularly for:
🔗 Analysis chainEnable metadata and static generation functions The commented-out
Consider uncommenting and enabling these functions unless there's a specific reason for disabling them. Let's check if other pages implement these functions: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check for generateMetadata and generateStaticParams usage in other pages
rg "export (async )?function generate(Metadata|StaticParams)" --type tsx
Length of output: 102 Script: #!/bin/bash
# Check for generateMetadata and generateStaticParams usage in other pages with proper file extension
rg "export (async )?function generate(Metadata|StaticParams)" -t ts -t tsx
# Let's also check if there are any other page.tsx files
fd "page.tsx$"
# And specifically look at their content for metadata-related code
fd "page.tsx$" -x cat {} \;
Length of output: 114233 Script: #!/bin/bash
# Let's check if generateMetadata and generateStaticParams are used in other pages in the engineering app
fd "page.tsx$" apps/engineering/ -x cat {} \;
# Also check if there are any imports of Metadata type from next
rg "import.*Metadata.*from.*next" -t ts -t tsx apps/engineering/
Length of output: 5666 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { componentSource } from "@/app/source"; | ||
import "@unkey/ui/css"; | ||
import { DocsLayout } from "fumadocs-ui/layouts/notebook"; | ||
import type { ReactNode } from "react"; | ||
import { baseOptions } from "../layout.config"; | ||
export default function Layout({ children }: { children: ReactNode }) { | ||
return ( | ||
<DocsLayout tree={componentSource.pageTree} {...baseOptions}> | ||
{children} | ||
</DocsLayout> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
title: Colors | ||
description: Color scale and usage | ||
--- | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Unkey uses [Radix Colors](https://www.radix-ui.com/colors) and its scale. | ||
|
||
| Step | Use Case | | ||
|-------|-----------------------------------------| | ||
| 1 | App background | | ||
| 2 | Subtle background | | ||
| 3 | UI element background | | ||
| 4 | Hovered UI element background | | ||
| 5 | Active / Selected UI element background | | ||
| 6 | Subtle borders and separators | | ||
| 7 | UI element border and focus rings | | ||
| 8 | Hovered UI element border | | ||
| 9 | Solid backgrounds | | ||
| 10 | Hovered solid backgrounds | | ||
| 11 | Low-contrast text | | ||
| 12 | High-contrast text | | ||
|
||
[Read more](https://www.radix-ui.com/colors/docs/palette-composition/understanding-the-scale) | ||
|
||
|
||
## gray | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-gray-1"/> | ||
<div className="rounded-lg aspect-square bg-gray-2"/> | ||
<div className="rounded-lg aspect-square bg-gray-3"/> | ||
<div className="rounded-lg aspect-square bg-gray-4"/> | ||
<div className="rounded-lg aspect-square bg-gray-5"/> | ||
<div className="rounded-lg aspect-square bg-gray-6"/> | ||
<div className="rounded-lg aspect-square bg-gray-7"/> | ||
<div className="rounded-lg aspect-square bg-gray-8"/> | ||
<div className="rounded-lg aspect-square bg-gray-9"/> | ||
<div className="rounded-lg aspect-square bg-gray-10"/> | ||
<div className="rounded-lg aspect-square bg-gray-11"/> | ||
<div className="rounded-lg aspect-square bg-gray-12"/> | ||
</div> | ||
Comment on lines
+34
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance color grid accessibility and maintainability The color grids could benefit from several improvements:
Here's an example of how to improve one color grid: -<div className="grid grid-cols-12 gap-2">
- <div className="rounded-lg aspect-square bg-gray-1"/>
- <div className="rounded-lg aspect-square bg-gray-2"/>
+<div className="grid grid-cols-12 gap-2" role="group" aria-label="Gray color scale">
+ <div
+ className="rounded-lg aspect-square bg-gray-1 group relative"
+ aria-label="Gray shade 1"
+ >
+ <span className="opacity-0 group-hover:opacity-100 absolute bottom-0 left-0 right-0 text-xs p-1 bg-black/50 text-white text-center">
+ Gray 1
+ </span>
+ </div>
+ <div
+ className="rounded-lg aspect-square bg-gray-2 group relative"
+ aria-label="Gray shade 2"
+ >
+ <span className="opacity-0 group-hover:opacity-100 absolute bottom-0 left-0 right-0 text-xs p-1 bg-black/50 text-white text-center">
+ Gray 2
+ </span>
+ </div> Consider creating a reusable component to reduce repetition: type ColorSwatchProps = {
colorName: string;
shades: number[];
};
function ColorSwatchGrid({ colorName, shades }: ColorSwatchProps) {
return (
<div className="grid grid-cols-12 gap-2" role="group" aria-label={`${colorName} color scale`}>
{shades.map((shade) => (
<div
key={shade}
className={`rounded-lg aspect-square bg-${colorName}-${shade} group relative`}
aria-label={`${colorName} shade ${shade}`}
>
<span className="opacity-0 group-hover:opacity-100 absolute bottom-0 left-0 right-0 text-xs p-1 bg-black/50 text-white text-center">
{`${colorName} ${shade}`}
</span>
</div>
))}
</div>
);
} Also applies to: 49-62, 65-78, 96-110, 112-126, 128-142 |
||
|
||
## success | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-success-1"/> | ||
<div className="rounded-lg aspect-square bg-success-2"/> | ||
<div className="rounded-lg aspect-square bg-success-3"/> | ||
<div className="rounded-lg aspect-square bg-success-4"/> | ||
<div className="rounded-lg aspect-square bg-success-5"/> | ||
<div className="rounded-lg aspect-square bg-success-6"/> | ||
<div className="rounded-lg aspect-square bg-success-7"/> | ||
<div className="rounded-lg aspect-square bg-success-8"/> | ||
<div className="rounded-lg aspect-square bg-success-9"/> | ||
<div className="rounded-lg aspect-square bg-success-10"/> | ||
<div className="rounded-lg aspect-square bg-success-11"/> | ||
<div className="rounded-lg aspect-square bg-success-12"/> | ||
</div> | ||
|
||
## info | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-info-1"/> | ||
<div className="rounded-lg aspect-square bg-info-2"/> | ||
<div className="rounded-lg aspect-square bg-info-3"/> | ||
<div className="rounded-lg aspect-square bg-info-4"/> | ||
<div className="rounded-lg aspect-square bg-info-5"/> | ||
<div className="rounded-lg aspect-square bg-info-6"/> | ||
<div className="rounded-lg aspect-square bg-info-7"/> | ||
<div className="rounded-lg aspect-square bg-info-8"/> | ||
<div className="rounded-lg aspect-square bg-info-9"/> | ||
<div className="rounded-lg aspect-square bg-info-10"/> | ||
<div className="rounded-lg aspect-square bg-info-11"/> | ||
<div className="rounded-lg aspect-square bg-info-12"/> | ||
</div> | ||
|
||
## info | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-info-1"/> | ||
<div className="rounded-lg aspect-square bg-info-2"/> | ||
<div className="rounded-lg aspect-square bg-info-3"/> | ||
<div className="rounded-lg aspect-square bg-info-4"/> | ||
<div className="rounded-lg aspect-square bg-info-5"/> | ||
<div className="rounded-lg aspect-square bg-info-6"/> | ||
<div className="rounded-lg aspect-square bg-info-7"/> | ||
<div className="rounded-lg aspect-square bg-info-8"/> | ||
<div className="rounded-lg aspect-square bg-info-9"/> | ||
<div className="rounded-lg aspect-square bg-info-10"/> | ||
<div className="rounded-lg aspect-square bg-info-11"/> | ||
<div className="rounded-lg aspect-square bg-info-12"/> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove duplicate "info" section The "info" color grid is duplicated unnecessarily. Remove the second occurrence of the info section (lines 80-94). |
||
|
||
## warning | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-warning-1"/> | ||
<div className="rounded-lg aspect-square bg-warning-2"/> | ||
<div className="rounded-lg aspect-square bg-warning-3"/> | ||
<div className="rounded-lg aspect-square bg-warning-4"/> | ||
<div className="rounded-lg aspect-square bg-warning-5"/> | ||
<div className="rounded-lg aspect-square bg-warning-6"/> | ||
<div className="rounded-lg aspect-square bg-warning-7"/> | ||
<div className="rounded-lg aspect-square bg-warning-8"/> | ||
<div className="rounded-lg aspect-square bg-warning-9"/> | ||
<div className="rounded-lg aspect-square bg-warning-10"/> | ||
<div className="rounded-lg aspect-square bg-warning-11"/> | ||
<div className="rounded-lg aspect-square bg-warning-12"/> | ||
</div> | ||
|
||
## error | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-error-1"/> | ||
<div className="rounded-lg aspect-square bg-error-2"/> | ||
<div className="rounded-lg aspect-square bg-error-3"/> | ||
<div className="rounded-lg aspect-square bg-error-4"/> | ||
<div className="rounded-lg aspect-square bg-error-5"/> | ||
<div className="rounded-lg aspect-square bg-error-6"/> | ||
<div className="rounded-lg aspect-square bg-error-7"/> | ||
<div className="rounded-lg aspect-square bg-error-8"/> | ||
<div className="rounded-lg aspect-square bg-error-9"/> | ||
<div className="rounded-lg aspect-square bg-error-10"/> | ||
<div className="rounded-lg aspect-square bg-error-11"/> | ||
<div className="rounded-lg aspect-square bg-error-12"/> | ||
</div> | ||
|
||
## feature | ||
<div className="grid grid-cols-12 gap-2"> | ||
<div className="rounded-lg aspect-square bg-feature-1"/> | ||
<div className="rounded-lg aspect-square bg-feature-2"/> | ||
<div className="rounded-lg aspect-square bg-feature-3"/> | ||
<div className="rounded-lg aspect-square bg-feature-4"/> | ||
<div className="rounded-lg aspect-square bg-feature-5"/> | ||
<div className="rounded-lg aspect-square bg-feature-6"/> | ||
<div className="rounded-lg aspect-square bg-feature-7"/> | ||
<div className="rounded-lg aspect-square bg-feature-8"/> | ||
<div className="rounded-lg aspect-square bg-feature-9"/> | ||
<div className="rounded-lg aspect-square bg-feature-10"/> | ||
<div className="rounded-lg aspect-square bg-feature-11"/> | ||
<div className="rounded-lg aspect-square bg-feature-12"/> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling and improve type safety.
While the implementation is functional, consider these improvements for robustness:
Here's a suggested implementation:
📝 Committable suggestion