text
stringlengths 21
253k
| id
stringlengths 25
123
| metadata
dict | __index_level_0__
int64 0
181
|
---|---|---|---|
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5" />
<path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" />
<path d="M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2" />
<path d="M20 22v.01" />
</svg>
| lucide-icons/lucide/icons/mail-question.svg | {
"file_path": "lucide-icons/lucide/icons/mail-question.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 258
} | 64 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728" />
<circle cx="12" cy="10" r="3" />
<path d="m16 18 2 2 4-4" />
</svg>
| lucide-icons/lucide/icons/map-pin-check.svg | {
"file_path": "lucide-icons/lucide/icons/map-pin-check.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 211
} | 65 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M9.26 9.26 3 11v3l14.14 3.14" />
<path d="M21 15.34V6l-7.31 2.03" />
<path d="M11.6 16.8a3 3 0 1 1-5.8-1.6" />
<line x1="2" x2="22" y1="2" y2="22" />
</svg>
| lucide-icons/lucide/icons/megaphone-off.svg | {
"file_path": "lucide-icons/lucide/icons/megaphone-off.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 194
} | 66 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z" />
<path d="M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7" />
</svg>
| lucide-icons/lucide/icons/message-circle-heart.svg | {
"file_path": "lucide-icons/lucide/icons/message-circle-heart.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 209
} | 67 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15V5a2 2 0 0 0-2-2H9" />
<path d="m2 2 20 20" />
<path d="M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10" />
</svg>
| lucide-icons/lucide/icons/message-square-off.svg | {
"file_path": "lucide-icons/lucide/icons/message-square-off.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 166
} | 68 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z" />
<path d="m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18" />
<path d="m2.3 2.3 7.286 7.286" />
<circle cx="11" cy="11" r="2" />
</svg>
| lucide-icons/lucide/icons/pen-tool.svg | {
"file_path": "lucide-icons/lucide/icons/pen-tool.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 284
} | 69 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M2 22h20" />
<path d="M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z" />
</svg>
| lucide-icons/lucide/icons/plane-landing.svg | {
"file_path": "lucide-icons/lucide/icons/plane-landing.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 285
} | 70 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2" />
<path d="M18 6h.01" />
<path d="M6 18h.01" />
<path d="M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z" />
<path d="M18 11.66V22a4 4 0 0 0 4-4V6" />
</svg>
| lucide-icons/lucide/icons/pocket-knife.svg | {
"file_path": "lucide-icons/lucide/icons/pocket-knife.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 231
} | 71 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="8" cy="21" r="1" />
<circle cx="19" cy="21" r="1" />
<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12" />
</svg>
| lucide-icons/lucide/icons/shopping-cart.svg | {
"file_path": "lucide-icons/lucide/icons/shopping-cart.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 188
} | 72 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polygon points="19 20 9 12 19 4 19 20" />
<line x1="5" x2="5" y1="19" y2="5" />
</svg>
| lucide-icons/lucide/icons/skip-back.svg | {
"file_path": "lucide-icons/lucide/icons/skip-back.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 133
} | 73 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z" />
<path d="M7 21h10" />
<path d="M19.5 12 22 6" />
<path d="M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62" />
<path d="M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62" />
<path d="M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62" />
</svg>
| lucide-icons/lucide/icons/soup.svg | {
"file_path": "lucide-icons/lucide/icons/soup.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 315
} | 74 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3" />
<path d="M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3" />
<line x1="12" x2="12" y1="4" y2="20" />
</svg>
| lucide-icons/lucide/icons/square-split-horizontal.svg | {
"file_path": "lucide-icons/lucide/icons/square-split-horizontal.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 189
} | 75 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2" />
<path d="M8.5 2h7" />
<path d="M14.5 16h-5" />
</svg>
| lucide-icons/lucide/icons/test-tube.svg | {
"file_path": "lucide-icons/lucide/icons/test-tube.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 182
} | 76 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M2 10s3-3 3-8" />
<path d="M22 10s-3-3-3-8" />
<path d="M10 2c0 4.4-3.6 8-8 8" />
<path d="M14 2c0 4.4 3.6 8 8 8" />
<path d="M2 10s2 2 2 5" />
<path d="M22 10s-2 2-2 5" />
<path d="M8 15h8" />
<path d="M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1" />
<path d="M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1" />
</svg>
| lucide-icons/lucide/icons/theater.svg | {
"file_path": "lucide-icons/lucide/icons/theater.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 292
} | 77 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 6h18" />
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
<line x1="10" x2="10" y1="11" y2="17" />
<line x1="14" x2="14" y1="11" y2="17" />
</svg>
| lucide-icons/lucide/icons/trash-2.svg | {
"file_path": "lucide-icons/lucide/icons/trash-2.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 226
} | 78 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="10" r="1" />
<path d="M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2" />
<path d="M6 17v.01" />
<path d="M6 13v.01" />
<path d="M18 17v.01" />
<path d="M18 13v.01" />
<path d="M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5" />
</svg>
| lucide-icons/lucide/icons/university.svg | {
"file_path": "lucide-icons/lucide/icons/university.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 246
} | 79 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8" />
<path d="M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7" />
<path d="m2.1 21.8 6.4-6.3" />
<path d="m19 5-7 7" />
</svg>
| lucide-icons/lucide/icons/utensils-crossed.svg | {
"file_path": "lucide-icons/lucide/icons/utensils-crossed.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 232
} | 80 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m2 8 2 2-2 2 2 2-2 2" />
<path d="m22 8-2 2 2 2-2 2 2 2" />
<rect width="8" height="14" x="8" y="5" rx="1" />
</svg>
| lucide-icons/lucide/icons/vibrate.svg | {
"file_path": "lucide-icons/lucide/icons/vibrate.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 159
} | 81 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72" />
<path d="m14 7 3 3" />
<path d="M5 6v4" />
<path d="M19 14v4" />
<path d="M10 2v2" />
<path d="M7 8H3" />
<path d="M21 16h-4" />
<path d="M11 3H9" />
</svg>
| lucide-icons/lucide/icons/wand-sparkles.svg | {
"file_path": "lucide-icons/lucide/icons/wand-sparkles.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 285
} | 82 |
import { Injectable } from '@angular/core';
import defaultAttributes from '../icons/constants/default-attributes';
/**
* A configuration service for Lucide icon components.
*
* You can inject this service, typically in AppComponent, and customize its property values in
* order to provide default values for all the icons used in the application.
*/
@Injectable({ providedIn: 'root' })
export class LucideIconConfig {
color: string = defaultAttributes.stroke;
size: number = defaultAttributes.width;
strokeWidth: number = defaultAttributes['stroke-width'];
absoluteStrokeWidth = false;
}
| lucide-icons/lucide/packages/lucide-angular/src/lib/lucide-icon.config.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-angular/src/lib/lucide-icon.config.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 154
} | 83 |
import plugins from '@lucide/rollup-plugins';
import dts from 'rollup-plugin-dts';
import pkg from './package.json' assert { type: 'json' };
const packageName = 'LucideReact';
const outputFileName = 'lucide-react-native';
const outputDir = 'dist';
const inputs = ['src/lucide-react-native.ts'];
const bundles = [
{
format: 'cjs',
inputs,
outputDir,
preserveModules: true,
},
{
format: 'esm',
inputs,
outputDir,
preserveModules: true,
},
];
const configs = bundles
.map(({ inputs, outputDir, format, minify, preserveModules }) =>
inputs.map((input) => ({
input,
plugins: plugins({ pkg, minify }),
external: ['react', 'react-native-svg'],
output: {
name: packageName,
...(preserveModules
? {
dir: `${outputDir}/${format}`,
exports: 'auto',
}
: {
file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
}),
format,
preserveModules,
sourcemap: true,
globals: {
react: 'react',
'react-native-svg': 'react-native-svg',
},
},
})),
)
.flat();
export default [
{
input: inputs[0],
output: [
{
file: `dist/${outputFileName}.d.ts`,
format: 'es',
},
],
plugins: [dts()],
},
...configs,
];
| lucide-icons/lucide/packages/lucide-react-native/rollup.config.mjs | {
"file_path": "lucide-icons/lucide/packages/lucide-react-native/rollup.config.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 664
} | 84 |
import { describe, it, expect } from 'vitest';
import { createLucideIcon } from '../src/lucide-react';
import { airVent } from './testIconNodes';
import { render } from '@testing-library/react';
describe('Using createLucideIcon', () => {
it('should create a component from an iconNode', () => {
const AirVent = createLucideIcon('AirVent', airVent);
const { container } = render(<AirVent />);
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toBeDefined();
});
});
| lucide-icons/lucide/packages/lucide-react/tests/createLucideIcon.spec.tsx | {
"file_path": "lucide-icons/lucide/packages/lucide-react/tests/createLucideIcon.spec.tsx",
"repo_id": "lucide-icons/lucide",
"token_count": 169
} | 85 |
import { writeFile } from '@lucide/helpers';
export default function generateIconNodes(parsedSvgs, packageDir) {
const iconNodes = parsedSvgs.reduce((acc, { name, parsedSvg }) => {
acc[name] = parsedSvg.children.map(({ name, attributes }) => [name, attributes]);
return acc;
}, {});
const iconNodesStringified = JSON.stringify(iconNodes, null, 2);
writeFile(iconNodesStringified, 'icon-nodes.json', packageDir);
}
| lucide-icons/lucide/packages/lucide-static/scripts/generateIconNodes.mjs | {
"file_path": "lucide-icons/lucide/packages/lucide-static/scripts/generateIconNodes.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 149
} | 86 |
type Booleanish = boolean | 'true' | 'false';
interface AriaAttributes {
'aria-activedescendant'?: string | undefined;
'aria-atomic'?: Booleanish | undefined;
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both' | undefined;
'aria-busy'?: Booleanish | undefined;
'aria-checked'?: boolean | 'false' | 'mixed' | 'true' | undefined;
'aria-colcount'?: number | undefined;
'aria-colindex'?: number | undefined;
'aria-colspan'?: number | undefined;
'aria-controls'?: string | undefined;
'aria-current'?:
| boolean
| 'false'
| 'true'
| 'page'
| 'step'
| 'location'
| 'date'
| 'time'
| undefined;
'aria-describedby'?: string | undefined;
'aria-details'?: string | undefined;
'aria-disabled'?: Booleanish | undefined;
'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined;
'aria-errormessage'?: string | undefined;
'aria-expanded'?: Booleanish | undefined;
'aria-flowto'?: string | undefined;
'aria-grabbed'?: Booleanish | undefined;
'aria-haspopup'?:
| boolean
| 'false'
| 'true'
| 'menu'
| 'listbox'
| 'tree'
| 'grid'
| 'dialog'
| undefined;
'aria-hidden'?: Booleanish | undefined;
'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling' | undefined;
'aria-keyshortcuts'?: string | undefined;
'aria-label'?: string | undefined;
'aria-labelledby'?: string | undefined;
'aria-level'?: number | undefined;
'aria-live'?: 'off' | 'assertive' | 'polite' | undefined;
'aria-modal'?: Booleanish | undefined;
'aria-multiline'?: Booleanish | undefined;
'aria-multiselectable'?: Booleanish | undefined;
'aria-orientation'?: 'horizontal' | 'vertical' | undefined;
'aria-owns'?: string | undefined;
'aria-placeholder'?: string | undefined;
'aria-posinset'?: number | undefined;
'aria-pressed'?: boolean | 'false' | 'mixed' | 'true' | undefined;
'aria-readonly'?: Booleanish | undefined;
'aria-relevant'?:
| 'additions'
| 'additions removals'
| 'additions text'
| 'all'
| 'removals'
| 'removals additions'
| 'removals text'
| 'text'
| 'text additions'
| 'text removals'
| undefined;
'aria-required'?: Booleanish | undefined;
'aria-roledescription'?: string | undefined;
'aria-rowcount'?: number | undefined;
'aria-rowindex'?: number | undefined;
'aria-rowspan'?: number | undefined;
'aria-selected'?: Booleanish | undefined;
'aria-setsize'?: number | undefined;
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other' | undefined;
'aria-valuemax'?: number | undefined;
'aria-valuemin'?: number | undefined;
'aria-valuenow'?: number | undefined;
}
| lucide-icons/lucide/packages/lucide/src/attributeTypes.ts | {
"file_path": "lucide-icons/lucide/packages/lucide/src/attributeTypes.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 1016
} | 87 |
import path from 'path';
import { writeFile, getCurrentDirPath, readAllMetadata } from '../tools/build-helpers/helpers.mjs';
const currentDir = getCurrentDirPath(import.meta.url);
const ICONS_DIR = path.resolve(currentDir, '../icons');
const icons = readAllMetadata(ICONS_DIR);
const newCategories = {};
Object.keys(icons).forEach((iconName) => {
icons[iconName].categories.forEach((categoryName) => {
newCategories[categoryName] = newCategories[categoryName] || [];
newCategories[categoryName].push(iconName);
});
});
const ordered = Object.keys(newCategories)
.sort()
.reduce((obj, key) => {
obj[key] = newCategories[key];
return obj;
}, {});
const categoriesContent = JSON.stringify(ordered, null, 2);
writeFile(categoriesContent, 'categories.json', path.resolve(currentDir, '..'));
| lucide-icons/lucide/scripts/migrateIconsToCategories.mjs | {
"file_path": "lucide-icons/lucide/scripts/migrateIconsToCategories.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 275
} | 88 |
/* eslint-disable import/prefer-default-export */
import fs from 'fs';
import path from 'path';
/**
* append content to a file
*
* @param {string} content
* @param {string} fileName
* @param {string} outputDirectory
*/
export const appendFile = (content, fileName, outputDirectory) =>
fs.appendFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
| lucide-icons/lucide/tools/build-helpers/src/appendFile.mjs | {
"file_path": "lucide-icons/lucide/tools/build-helpers/src/appendFile.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 111
} | 89 |
/* eslint-disable import/prefer-default-export */
import { toCamelCase } from './toCamelCase.mjs';
/**
* Converts string to PascalCase
*
* @param {string} string
* @returns {string} A pascalized string
*/
export const toPascalCase = (string) => {
const camelCase = toCamelCase(string);
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
};
| lucide-icons/lucide/tools/build-helpers/src/toPascalCase.mjs | {
"file_path": "lucide-icons/lucide/tools/build-helpers/src/toPascalCase.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 123
} | 90 |
import path from 'path';
import { readSvgDirectory } from '@lucide/helpers';
async function getAliases(iconDirectory) {
const iconJsons = readSvgDirectory(iconDirectory, '.json');
const aliasesEntries = await Promise.all(
iconJsons.map(async (jsonFile) => {
const file = await import(path.join(iconDirectory, jsonFile), { assert: { type: 'json' } });
return [path.basename(jsonFile, '.json'), file.default];
}),
);
return Object.fromEntries(aliasesEntries);
}
export default getAliases;
| lucide-icons/lucide/tools/build-icons/utils/getAliases.mjs | {
"file_path": "lucide-icons/lucide/tools/build-icons/utils/getAliases.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 175
} | 91 |
import {
Body,
Button,
Column,
Container,
Head,
Html,
Img,
Preview,
Row,
Section,
Tailwind,
Text,
} from "@react-email/components";
const siteUrl =
process.env.NEXT_PUBLIC_URL ?? "https://chadnext.moinulmoin.com";
interface VerificationTemplateProps {
userName: string;
code: string;
}
const VerificationTemp: React.FC<Readonly<VerificationTemplateProps>> = ({
userName,
code,
}) => (
<Html>
<Head />
<Preview>Verify your email</Preview>
<Tailwind>
<Body className="bg-white">
<Container className="mx-auto py-20">
<Section className="mx-auto text-center">
<Row>
<Column align="right">
<Img
src={`${siteUrl}/chad-next.png`}
height="50"
alt="ChadNext logo"
className="inline-block "
/>
</Column>
<Column align="left">
<Text className="ml-2 text-lg font-bold">ChadNext</Text>
</Column>
</Row>
</Section>
<Text className="my-4 text-lg">Hi, {userName.split(" ")[0]}</Text>
<Text className="text-center text-base font-semibold ">
Click the link below to login to your account.
</Text>
<Section className="mt-8 text-center">
<div
className="bg-bg-white inline-block rounded-md bg-slate-900 tracking-wider px-6 py-3 text-base text-gray-100"
>
{code}
</div>
<Text className="mt-2.5 text-sm ">
This link expires in 10 minutes and can only be used once.
</Text>
</Section>
<Text className="mt-8 ">
Best,
<br />
ChadNext team
</Text>
</Container>
</Body>
</Tailwind>
</Html>
);
export default VerificationTemp;
| moinulmoin/chadnext/emails/verification.tsx | {
"file_path": "moinulmoin/chadnext/emails/verification.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 990
} | 92 |
"use server";
import { freePlan, proPlan } from "~/config/subscription";
import prisma from "~/lib/prisma";
import { type UserSubscriptionPlan } from "~/types";
export async function getUserSubscriptionPlan(
userId: string
): Promise<UserSubscriptionPlan> {
const user = await prisma.user.findFirst({
where: {
id: userId,
},
select: {
stripeSubscriptionId: true,
stripeCurrentPeriodEnd: true,
stripeCustomerId: true,
stripePriceId: true,
},
});
if (!user) {
throw new Error("User not found");
}
// Check if user is on a pro plan.
const isPro = Boolean(
user.stripePriceId &&
user.stripeCurrentPeriodEnd?.getTime()! + 86_400_000 > Date.now()
);
const plan = isPro ? proPlan : freePlan;
return {
...plan,
...user,
stripeCurrentPeriodEnd: user.stripeCurrentPeriodEnd?.getTime()!,
isPro,
stripePriceId: user.stripePriceId || "",
};
}
| moinulmoin/chadnext/src/actions/subscription.ts | {
"file_path": "moinulmoin/chadnext/src/actions/subscription.ts",
"repo_id": "moinulmoin/chadnext",
"token_count": 354
} | 93 |
import { Skeleton } from "~/components/ui/skeleton";
export default function Loading() {
return (
<div className="grid gap-4 md:grid-cols-3 lg:grid-cols-4">
<Skeleton className="h-36 rounded-lg" />
<Skeleton className="h-36 rounded-lg" />
<Skeleton className="h-36 rounded-lg" />
<Skeleton className="h-36 rounded-lg" />
</div>
);
}
| moinulmoin/chadnext/src/app/[locale]/dashboard/projects/loading.tsx | {
"file_path": "moinulmoin/chadnext/src/app/[locale]/dashboard/projects/loading.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 157
} | 94 |
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";
import { validateRequest } from "~/actions/auth";
const f = createUploadthing();
// FileRouter for your app, can contain multiple FileRoutes
export const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } })
// Set permissions and file types for this FileRoute
.middleware(async () => {
// This code runs on your server before upload
const { user, session } = await validateRequest();
// If you throw, the user will not be able to upload
if (!session) throw new UploadThingError("Unauthorized!");
// Whatever is returned here is accessible in onUploadComplete as `metadata`
return { userId: user.id };
})
.onUploadComplete(({ file }) => {
return { url: file.url };
}),
} satisfies FileRouter;
export type OurFileRouter = typeof ourFileRouter;
| moinulmoin/chadnext/src/app/api/uploadthing/core.ts | {
"file_path": "moinulmoin/chadnext/src/app/api/uploadthing/core.ts",
"repo_id": "moinulmoin/chadnext",
"token_count": 330
} | 95 |
"use client";
import React from "react";
import Icons from "./shared/icons";
import { Button } from "./ui/button";
import { toast } from "./ui/use-toast";
export default function CopyButton({ content }: { content: string }) {
const copyToClipboard = (content: string) => {
if (!navigator.clipboard) {
toast({
title: "Error copying!",
description: "Please try again.",
variant: "destructive",
});
}
navigator.clipboard.writeText(content);
toast({
title: "Project ID copied!",
});
};
return (
<Button
type="button"
className="absolute right-0 top-0 h-full "
size="icon"
variant="ghost"
onClick={() => copyToClipboard(content)}
>
<span className="sr-only">Copy</span>
<Icons.copy className="h-3 w-3" />
</Button>
);
}
| moinulmoin/chadnext/src/components/copy-button.tsx | {
"file_path": "moinulmoin/chadnext/src/components/copy-button.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 339
} | 96 |
"use client";
import { CheckIcon, LanguagesIcon } from "lucide-react";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuShortcut,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu";
import { useChangeLocale, useCurrentLocale } from "~/locales/client";
import { Button } from "../ui/button";
const locales = [
{
name: "English",
value: "en",
},
{
name: "French",
value: "fr",
},
];
export default function LocaleToggler() {
const changeLocale = useChangeLocale({ preserveSearchParams: true });
const currentLocale = useCurrentLocale();
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="w-9 px-0">
<LanguagesIcon className=" h-5 w-5 " />
<span className="sr-only">Change Locale</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{locales.map((locale) => (
<DropdownMenuItem
key={locale.value}
onClick={() => changeLocale(locale.value as typeof currentLocale)}
disabled={locale.value === currentLocale}
>
<span>{locale.name}</span>
{locale.value === currentLocale ? (
<DropdownMenuShortcut>
<CheckIcon className="h-4 w-4" />
</DropdownMenuShortcut>
) : null}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
);
}
| moinulmoin/chadnext/src/components/shared/locale-toggler.tsx | {
"file_path": "moinulmoin/chadnext/src/components/shared/locale-toggler.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 660
} | 97 |
import { createI18nServer } from "next-international/server";
export const { getI18n, getScopedI18n, getStaticParams, getCurrentLocale } =
createI18nServer({
en: () => import("./en"),
fr: () => import("./fr"),
});
| moinulmoin/chadnext/src/locales/server.ts | {
"file_path": "moinulmoin/chadnext/src/locales/server.ts",
"repo_id": "moinulmoin/chadnext",
"token_count": 84
} | 98 |
"use client";
import {
Card,
CardContent,
CardFooter,
CardHeader,
} from "@/components/ui/card";
import { Building2, Clock, Mail, Phone } from "lucide-react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
const formSchema = z.object({
firstName: z.string().min(2).max(255),
lastName: z.string().min(2).max(255),
email: z.string().email(),
subject: z.string().min(2).max(255),
message: z.string(),
});
export const ContactSection = () => {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
firstName: "",
lastName: "",
email: "",
subject: "Web Development",
message: "",
},
});
function onSubmit(values: z.infer<typeof formSchema>) {
const { firstName, lastName, email, subject, message } = values;
console.log(values);
const mailToLink = `mailto:[email protected]?subject=${subject}&body=Hello I am ${firstName} ${lastName}, my Email is ${email}. %0D%0A${message}`;
window.location.href = mailToLink;
}
return (
<section id="contact" className="container py-24 sm:py-32">
<section className="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<div className="mb-4">
<h2 className="text-lg text-primary mb-2 tracking-wider">
Contact
</h2>
<h2 className="text-3xl md:text-4xl font-bold">Connect With Us</h2>
</div>
<p className="mb-8 text-muted-foreground lg:w-5/6">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatum
ipsam sint enim exercitationem ex autem corrupti quas tenetur
</p>
<div className="flex flex-col gap-4">
<div>
<div className="flex gap-2 mb-1">
<Building2 />
<div className="font-bold">Find us</div>
</div>
<div>742 Evergreen Terrace, Springfield, IL 62704</div>
</div>
<div>
<div className="flex gap-2 mb-1">
<Phone />
<div className="font-bold">Call us</div>
</div>
<div>+1 (619) 123-4567</div>
</div>
<div>
<div className="flex gap-2 mb-1">
<Mail />
<div className="font-bold">Mail US</div>
</div>
<div>[email protected]</div>
</div>
<div>
<div className="flex gap-2">
<Clock />
<div className="font-bold">Visit us</div>
</div>
<div>
<div>Monday - Friday</div>
<div>8AM - 4PM</div>
</div>
</div>
</div>
</div>
<Card className="bg-muted/60 dark:bg-card">
<CardHeader className="text-primary text-2xl"> </CardHeader>
<CardContent>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="grid w-full gap-4"
>
<div className="flex flex-col md:!flex-row gap-8">
<FormField
control={form.control}
name="firstName"
render={({ field }) => (
<FormItem className="w-full">
<FormLabel>First Name</FormLabel>
<FormControl>
<Input placeholder="Leopoldo" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="lastName"
render={({ field }) => (
<FormItem className="w-full">
<FormLabel>Last Name</FormLabel>
<FormControl>
<Input placeholder="Miranda" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex flex-col gap-1.5">
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input
type="email"
placeholder="[email protected]"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex flex-col gap-1.5">
<FormField
control={form.control}
name="subject"
render={({ field }) => (
<FormItem>
<FormLabel>Subject</FormLabel>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select a subject" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="Web Development">
Web Development
</SelectItem>
<SelectItem value="Mobile Development">
Mobile Development
</SelectItem>
<SelectItem value="Figma Design">
Figma Design
</SelectItem>
<SelectItem value="REST API">REST API</SelectItem>
<SelectItem value="FullStack Project">
FullStack Project
</SelectItem>
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex flex-col gap-1.5">
<FormField
control={form.control}
name="message"
render={({ field }) => (
<FormItem>
<FormLabel>Message</FormLabel>
<FormControl>
<Textarea
rows={5}
placeholder="Your message..."
className="resize-none"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<Button className="mt-4">Send message</Button>
</form>
</Form>
</CardContent>
<CardFooter></CardFooter>
</Card>
</section>
</section>
);
};
| nobruf/shadcn-landing-page/components/layout/sections/contact.tsx | {
"file_path": "nobruf/shadcn-landing-page/components/layout/sections/contact.tsx",
"repo_id": "nobruf/shadcn-landing-page",
"token_count": 4846
} | 99 |
import { redirect } from "next/navigation"
import { authOptions } from "@/lib/auth"
import { getCurrentUser } from "@/lib/session"
import { stripe } from "@/lib/stripe"
import { getUserSubscriptionPlan } from "@/lib/subscription"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { BillingForm } from "@/components/billing-form"
import { DashboardHeader } from "@/components/header"
import { Icons } from "@/components/icons"
import { DashboardShell } from "@/components/shell"
export const metadata = {
title: "Billing",
description: "Manage billing and your subscription plan.",
}
export default async function BillingPage() {
const user = await getCurrentUser()
if (!user) {
redirect(authOptions?.pages?.signIn || "/login")
}
const subscriptionPlan = await getUserSubscriptionPlan(user.id)
// If user has a pro plan, check cancel status on Stripe.
let isCanceled = false
if (subscriptionPlan.isPro && subscriptionPlan.stripeSubscriptionId) {
const stripePlan = await stripe.subscriptions.retrieve(
subscriptionPlan.stripeSubscriptionId
)
isCanceled = stripePlan.cancel_at_period_end
}
return (
<DashboardShell>
<DashboardHeader
heading="Billing"
text="Manage billing and your subscription plan."
/>
<div className="grid gap-8">
<Alert className="!pl-14">
<Icons.warning />
<AlertTitle>This is a demo app.</AlertTitle>
<AlertDescription>
Taxonomy app is a demo app using a Stripe test environment. You can
find a list of test card numbers on the{" "}
<a
href="https://stripe.com/docs/testing#cards"
target="_blank"
rel="noreferrer"
className="font-medium underline underline-offset-8"
>
Stripe docs
</a>
.
</AlertDescription>
</Alert>
<BillingForm
subscriptionPlan={{
...subscriptionPlan,
isCanceled,
}}
/>
</div>
</DashboardShell>
)
}
| shadcn-ui/taxonomy/app/(dashboard)/dashboard/billing/page.tsx | {
"file_path": "shadcn-ui/taxonomy/app/(dashboard)/dashboard/billing/page.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 894
} | 100 |
import { notFound } from "next/navigation"
import { allPages } from "contentlayer/generated"
import { Mdx } from "@/components/mdx-components"
import "@/styles/mdx.css"
import { Metadata } from "next"
import { env } from "@/env.mjs"
import { siteConfig } from "@/config/site"
import { absoluteUrl } from "@/lib/utils"
interface PageProps {
params: {
slug: string[]
}
}
async function getPageFromParams(params) {
const slug = params?.slug?.join("/")
const page = allPages.find((page) => page.slugAsParams === slug)
if (!page) {
null
}
return page
}
export async function generateMetadata({
params,
}: PageProps): Promise<Metadata> {
const page = await getPageFromParams(params)
if (!page) {
return {}
}
const url = env.NEXT_PUBLIC_APP_URL
const ogUrl = new URL(`${url}/api/og`)
ogUrl.searchParams.set("heading", page.title)
ogUrl.searchParams.set("type", siteConfig.name)
ogUrl.searchParams.set("mode", "light")
return {
title: page.title,
description: page.description,
openGraph: {
title: page.title,
description: page.description,
type: "article",
url: absoluteUrl(page.slug),
images: [
{
url: ogUrl.toString(),
width: 1200,
height: 630,
alt: page.title,
},
],
},
twitter: {
card: "summary_large_image",
title: page.title,
description: page.description,
images: [ogUrl.toString()],
},
}
}
export async function generateStaticParams(): Promise<PageProps["params"][]> {
return allPages.map((page) => ({
slug: page.slugAsParams.split("/"),
}))
}
export default async function PagePage({ params }: PageProps) {
const page = await getPageFromParams(params)
if (!page) {
notFound()
}
return (
<article className="container max-w-3xl py-6 lg:py-12">
<div className="space-y-4">
<h1 className="inline-block font-heading text-4xl lg:text-5xl">
{page.title}
</h1>
{page.description && (
<p className="text-xl text-muted-foreground">{page.description}</p>
)}
</div>
<hr className="my-4" />
<Mdx code={page.body.code} />
</article>
)
}
| shadcn-ui/taxonomy/app/(marketing)/[...slug]/page.tsx | {
"file_path": "shadcn-ui/taxonomy/app/(marketing)/[...slug]/page.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 937
} | 101 |
import * as React from "react"
import Link from "next/link"
import { MainNavItem } from "types"
import { siteConfig } from "@/config/site"
import { cn } from "@/lib/utils"
import { useLockBody } from "@/hooks/use-lock-body"
import { Icons } from "@/components/icons"
interface MobileNavProps {
items: MainNavItem[]
children?: React.ReactNode
}
export function MobileNav({ items, children }: MobileNavProps) {
useLockBody()
return (
<div
className={cn(
"fixed inset-0 top-16 z-50 grid h-[calc(100vh-4rem)] grid-flow-row auto-rows-max overflow-auto p-6 pb-32 shadow-md animate-in slide-in-from-bottom-80 md:hidden"
)}
>
<div className="relative z-20 grid gap-6 rounded-md bg-popover p-4 text-popover-foreground shadow-md">
<Link href="/" className="flex items-center space-x-2">
<Icons.logo />
<span className="font-bold">{siteConfig.name}</span>
</Link>
<nav className="grid grid-flow-row auto-rows-max text-sm">
{items.map((item, index) => (
<Link
key={index}
href={item.disabled ? "#" : item.href}
className={cn(
"flex w-full items-center rounded-md p-2 text-sm font-medium hover:underline",
item.disabled && "cursor-not-allowed opacity-60"
)}
>
{item.title}
</Link>
))}
</nav>
{children}
</div>
</div>
)
}
| shadcn-ui/taxonomy/components/mobile-nav.tsx | {
"file_path": "shadcn-ui/taxonomy/components/mobile-nav.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 686
} | 102 |
"use client"
import * as React from "react"
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
const AlertDialog = AlertDialogPrimitive.Root
const AlertDialogTrigger = AlertDialogPrimitive.Trigger
const AlertDialogPortal = ({
className,
children,
...props
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
{children}
</div>
</AlertDialogPrimitive.Portal>
)
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName
const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
>(({ className, children, ...props }, ref) => (
<AlertDialogPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in",
className
)}
{...props}
ref={ref}
/>
))
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className, ...props }, ref) => (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
"fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full",
className
)}
{...props}
/>
</AlertDialogPortal>
))
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
const AlertDialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
className
)}
{...props}
/>
)
AlertDialogHeader.displayName = "AlertDialogHeader"
const AlertDialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
)
AlertDialogFooter.displayName = "AlertDialogFooter"
const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title
ref={ref}
className={cn("text-lg font-semibold", className)}
{...props}
/>
))
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName
const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Action
ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>
))
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(
buttonVariants({ variant: "outline" }),
"mt-2 sm:mt-0",
className
)}
{...props}
/>
))
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
export {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
}
| shadcn-ui/taxonomy/components/ui/alert-dialog.tsx | {
"file_path": "shadcn-ui/taxonomy/components/ui/alert-dialog.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 1530
} | 103 |
"use client"
import {
Toast,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport,
} from "@/components/ui/toast"
import { useToast } from "@/components/ui/use-toast"
export function Toaster() {
const { toasts } = useToast()
return (
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} {...props}>
<div className="grid gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
{description && (
<ToastDescription>{description}</ToastDescription>
)}
</div>
{action}
<ToastClose />
</Toast>
)
})}
<ToastViewport />
</ToastProvider>
)
}
| shadcn-ui/taxonomy/components/ui/toaster.tsx | {
"file_path": "shadcn-ui/taxonomy/components/ui/toaster.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 385
} | 104 |
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { NextAuthOptions } from "next-auth"
import EmailProvider from "next-auth/providers/email"
import GitHubProvider from "next-auth/providers/github"
import { Client } from "postmark"
import { env } from "@/env.mjs"
import { siteConfig } from "@/config/site"
import { db } from "@/lib/db"
const postmarkClient = new Client(env.POSTMARK_API_TOKEN)
export const authOptions: NextAuthOptions = {
// huh any! I know.
// This is a temporary fix for prisma client.
// @see https://github.com/prisma/prisma/issues/16117
adapter: PrismaAdapter(db as any),
session: {
strategy: "jwt",
},
pages: {
signIn: "/login",
},
providers: [
GitHubProvider({
clientId: env.GITHUB_CLIENT_ID,
clientSecret: env.GITHUB_CLIENT_SECRET,
}),
EmailProvider({
from: env.SMTP_FROM,
sendVerificationRequest: async ({ identifier, url, provider }) => {
const user = await db.user.findUnique({
where: {
email: identifier,
},
select: {
emailVerified: true,
},
})
const templateId = user?.emailVerified
? env.POSTMARK_SIGN_IN_TEMPLATE
: env.POSTMARK_ACTIVATION_TEMPLATE
if (!templateId) {
throw new Error("Missing template id")
}
const result = await postmarkClient.sendEmailWithTemplate({
TemplateId: parseInt(templateId),
To: identifier,
From: provider.from as string,
TemplateModel: {
action_url: url,
product_name: siteConfig.name,
},
Headers: [
{
// Set this to prevent Gmail from threading emails.
// See https://stackoverflow.com/questions/23434110/force-emails-not-to-be-grouped-into-conversations/25435722.
Name: "X-Entity-Ref-ID",
Value: new Date().getTime() + "",
},
],
})
if (result.ErrorCode) {
throw new Error(result.Message)
}
},
}),
],
callbacks: {
async session({ token, session }) {
if (token) {
session.user.id = token.id
session.user.name = token.name
session.user.email = token.email
session.user.image = token.picture
}
return session
},
async jwt({ token, user }) {
const dbUser = await db.user.findFirst({
where: {
email: token.email,
},
})
if (!dbUser) {
if (user) {
token.id = user?.id
}
return token
}
return {
id: dbUser.id,
name: dbUser.name,
email: dbUser.email,
picture: dbUser.image,
}
},
},
}
| shadcn-ui/taxonomy/lib/auth.ts | {
"file_path": "shadcn-ui/taxonomy/lib/auth.ts",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 1287
} | 105 |
import { Metadata } from "next"
import Image from "next/image"
import Link from "next/link"
import { cn } from "@/lib/utils"
import { buttonVariants } from "@/registry/new-york/ui/button"
import { UserAuthForm } from "@/app/(app)/examples/authentication/components/user-auth-form"
export const metadata: Metadata = {
title: "Authentication",
description: "Authentication forms built using the components.",
}
export default function AuthenticationPage() {
return (
<>
<div className="md:hidden">
<Image
src="/examples/authentication-light.png"
width={1280}
height={843}
alt="Authentication"
className="block dark:hidden"
/>
<Image
src="/examples/authentication-dark.png"
width={1280}
height={843}
alt="Authentication"
className="hidden dark:block"
/>
</div>
<div className="container relative hidden h-[800px] flex-col items-center justify-center md:grid lg:max-w-none lg:grid-cols-2 lg:px-0">
<Link
href="/examples/authentication"
className={cn(
buttonVariants({ variant: "ghost" }),
"absolute right-4 top-4 md:right-8 md:top-8"
)}
>
Login
</Link>
<div className="relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex">
<div className="absolute inset-0 bg-zinc-900" />
<div className="relative z-20 flex items-center text-lg font-medium">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="mr-2 h-6 w-6"
>
<path d="M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3" />
</svg>
Acme Inc
</div>
<div className="relative z-20 mt-auto">
<blockquote className="space-y-2">
<p className="text-lg">
“This library has saved me countless hours of work and
helped me deliver stunning designs to my clients faster than
ever before.”
</p>
<footer className="text-sm">Sofia Davis</footer>
</blockquote>
</div>
</div>
<div className="lg:p-8">
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">
<div className="flex flex-col space-y-2 text-center">
<h1 className="text-2xl font-semibold tracking-tight">
Create an account
</h1>
<p className="text-sm text-muted-foreground">
Enter your email below to create your account
</p>
</div>
<UserAuthForm />
<p className="px-8 text-center text-sm text-muted-foreground">
By clicking continue, you agree to our{" "}
<Link
href="/terms"
className="underline underline-offset-4 hover:text-primary"
>
Terms of Service
</Link>{" "}
and{" "}
<Link
href="/privacy"
className="underline underline-offset-4 hover:text-primary"
>
Privacy Policy
</Link>
.
</p>
</div>
</div>
</div>
</>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/authentication/page.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/authentication/page.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1889
} | 106 |
"use client"
import * as React from "react"
import {
CaretSortIcon,
CheckIcon,
PlusCircledIcon,
} from "@radix-ui/react-icons"
import { cn } from "@/lib/utils"
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/registry/new-york/ui/avatar"
import { Button } from "@/registry/new-york/ui/button"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
} from "@/registry/new-york/ui/command"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/registry/new-york/ui/dialog"
import { Input } from "@/registry/new-york/ui/input"
import { Label } from "@/registry/new-york/ui/label"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/registry/new-york/ui/popover"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/registry/new-york/ui/select"
const groups = [
{
label: "Personal Account",
teams: [
{
label: "Alicia Koch",
value: "personal",
},
],
},
{
label: "Teams",
teams: [
{
label: "Acme Inc.",
value: "acme-inc",
},
{
label: "Monsters Inc.",
value: "monsters",
},
],
},
]
type Team = (typeof groups)[number]["teams"][number]
type PopoverTriggerProps = React.ComponentPropsWithoutRef<typeof PopoverTrigger>
interface TeamSwitcherProps extends PopoverTriggerProps {}
export default function TeamSwitcher({ className }: TeamSwitcherProps) {
const [open, setOpen] = React.useState(false)
const [showNewTeamDialog, setShowNewTeamDialog] = React.useState(false)
const [selectedTeam, setSelectedTeam] = React.useState<Team>(
groups[0].teams[0]
)
return (
<Dialog open={showNewTeamDialog} onOpenChange={setShowNewTeamDialog}>
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
role="combobox"
aria-expanded={open}
aria-label="Select a team"
className={cn("w-[200px] justify-between", className)}
>
<Avatar className="mr-2 h-5 w-5">
<AvatarImage
src={`https://avatar.vercel.sh/${selectedTeam.value}.png`}
alt={selectedTeam.label}
className="grayscale"
/>
<AvatarFallback>SC</AvatarFallback>
</Avatar>
{selectedTeam.label}
<CaretSortIcon className="ml-auto h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput placeholder="Search team..." />
<CommandList>
<CommandEmpty>No team found.</CommandEmpty>
{groups.map((group) => (
<CommandGroup key={group.label} heading={group.label}>
{group.teams.map((team) => (
<CommandItem
key={team.value}
onSelect={() => {
setSelectedTeam(team)
setOpen(false)
}}
className="text-sm"
>
<Avatar className="mr-2 h-5 w-5">
<AvatarImage
src={`https://avatar.vercel.sh/${team.value}.png`}
alt={team.label}
className="grayscale"
/>
<AvatarFallback>SC</AvatarFallback>
</Avatar>
{team.label}
<CheckIcon
className={cn(
"ml-auto h-4 w-4",
selectedTeam.value === team.value
? "opacity-100"
: "opacity-0"
)}
/>
</CommandItem>
))}
</CommandGroup>
))}
</CommandList>
<CommandSeparator />
<CommandList>
<CommandGroup>
<DialogTrigger asChild>
<CommandItem
onSelect={() => {
setOpen(false)
setShowNewTeamDialog(true)
}}
>
<PlusCircledIcon className="mr-2 h-5 w-5" />
Create Team
</CommandItem>
</DialogTrigger>
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
<DialogContent>
<DialogHeader>
<DialogTitle>Create team</DialogTitle>
<DialogDescription>
Add a new team to manage products and customers.
</DialogDescription>
</DialogHeader>
<div>
<div className="space-y-4 py-2 pb-4">
<div className="space-y-2">
<Label htmlFor="name">Team name</Label>
<Input id="name" placeholder="Acme Inc." />
</div>
<div className="space-y-2">
<Label htmlFor="plan">Subscription plan</Label>
<Select>
<SelectTrigger>
<SelectValue placeholder="Select a plan" />
</SelectTrigger>
<SelectContent>
<SelectItem value="free">
<span className="font-medium">Free</span> -{" "}
<span className="text-muted-foreground">
Trial for two weeks
</span>
</SelectItem>
<SelectItem value="pro">
<span className="font-medium">Pro</span> -{" "}
<span className="text-muted-foreground">
$9/month per user
</span>
</SelectItem>
</SelectContent>
</Select>
</div>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setShowNewTeamDialog(false)}>
Cancel
</Button>
<Button type="submit">Continue</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/dashboard/components/team-switcher.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/dashboard/components/team-switcher.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 3516
} | 107 |
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/registry/new-york/ui/select"
interface AccountSwitcherProps {
isCollapsed: boolean
accounts: {
label: string
email: string
icon: React.ReactNode
}[]
}
export function AccountSwitcher({
isCollapsed,
accounts,
}: AccountSwitcherProps) {
const [selectedAccount, setSelectedAccount] = React.useState<string>(
accounts[0].email
)
return (
<Select defaultValue={selectedAccount} onValueChange={setSelectedAccount}>
<SelectTrigger
className={cn(
"flex items-center gap-2 [&>span]:line-clamp-1 [&>span]:flex [&>span]:w-full [&>span]:items-center [&>span]:gap-1 [&>span]:truncate [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0",
isCollapsed &&
"flex h-9 w-9 shrink-0 items-center justify-center p-0 [&>span]:w-auto [&>svg]:hidden"
)}
aria-label="Select account"
>
<SelectValue placeholder="Select an account">
{accounts.find((account) => account.email === selectedAccount)?.icon}
<span className={cn("ml-2", isCollapsed && "hidden")}>
{
accounts.find((account) => account.email === selectedAccount)
?.label
}
</span>
</SelectValue>
</SelectTrigger>
<SelectContent>
{accounts.map((account) => (
<SelectItem key={account.email} value={account.email}>
<div className="flex items-center gap-3 [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0 [&_svg]:text-foreground">
{account.icon}
{account.email}
</div>
</SelectItem>
))}
</SelectContent>
</Select>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/mail/components/account-switcher.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/mail/components/account-switcher.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 808
} | 108 |
"use client"
import * as React from "react"
import { SliderProps } from "@radix-ui/react-slider"
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from "@/registry/new-york/ui/hover-card"
import { Label } from "@/registry/new-york/ui/label"
import { Slider } from "@/registry/new-york/ui/slider"
interface MaxLengthSelectorProps {
defaultValue: SliderProps["defaultValue"]
}
export function MaxLengthSelector({ defaultValue }: MaxLengthSelectorProps) {
const [value, setValue] = React.useState(defaultValue)
return (
<div className="grid gap-2 pt-2">
<HoverCard openDelay={200}>
<HoverCardTrigger asChild>
<div className="grid gap-4">
<div className="flex items-center justify-between">
<Label htmlFor="maxlength">Maximum Length</Label>
<span className="w-12 rounded-md border border-transparent px-2 py-0.5 text-right text-sm text-muted-foreground hover:border-border">
{value}
</span>
</div>
<Slider
id="maxlength"
max={4000}
defaultValue={value}
step={10}
onValueChange={setValue}
className="[&_[role=slider]]:h-4 [&_[role=slider]]:w-4"
aria-label="Maximum Length"
/>
</div>
</HoverCardTrigger>
<HoverCardContent
align="start"
className="w-[260px] text-sm"
side="left"
>
The maximum number of tokens to generate. Requests can use up to 2,048
or 4,000 tokens, shared between prompt and completion. The exact limit
varies by model.
</HoverCardContent>
</HoverCard>
</div>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/playground/components/maxlength-selector.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/playground/components/maxlength-selector.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 806
} | 109 |
"use client"
import { Cross2Icon } from "@radix-ui/react-icons"
import { Table } from "@tanstack/react-table"
import { Button } from "@/registry/new-york/ui/button"
import { Input } from "@/registry/new-york/ui/input"
import { DataTableViewOptions } from "@/app/(app)/examples/tasks/components/data-table-view-options"
import { priorities, statuses } from "../data/data"
import { DataTableFacetedFilter } from "./data-table-faceted-filter"
interface DataTableToolbarProps<TData> {
table: Table<TData>
}
export function DataTableToolbar<TData>({
table,
}: DataTableToolbarProps<TData>) {
const isFiltered = table.getState().columnFilters.length > 0
return (
<div className="flex items-center justify-between">
<div className="flex flex-1 items-center space-x-2">
<Input
placeholder="Filter tasks..."
value={(table.getColumn("title")?.getFilterValue() as string) ?? ""}
onChange={(event) =>
table.getColumn("title")?.setFilterValue(event.target.value)
}
className="h-8 w-[150px] lg:w-[250px]"
/>
{table.getColumn("status") && (
<DataTableFacetedFilter
column={table.getColumn("status")}
title="Status"
options={statuses}
/>
)}
{table.getColumn("priority") && (
<DataTableFacetedFilter
column={table.getColumn("priority")}
title="Priority"
options={priorities}
/>
)}
{isFiltered && (
<Button
variant="ghost"
onClick={() => table.resetColumnFilters()}
className="h-8 px-2 lg:px-3"
>
Reset
<Cross2Icon className="ml-2 h-4 w-4" />
</Button>
)}
</div>
<DataTableViewOptions table={table} />
</div>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/tasks/components/data-table-toolbar.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/tasks/components/data-table-toolbar.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 857
} | 110 |
import { Metadata } from "next"
import { notFound } from "next/navigation"
import { siteConfig } from "@/config/site"
import { getAllBlockIds, getBlock } from "@/lib/blocks"
import { absoluteUrl, cn } from "@/lib/utils"
import { BlockChunk } from "@/components/block-chunk"
import { BlockWrapper } from "@/components/block-wrapper"
import { ThemesStyle } from "@/components/themes-styles"
import { Style, styles } from "@/registry/registry-styles"
import "@/styles/mdx.css"
export async function generateMetadata({
params,
}: {
params: {
style: Style["name"]
name: string
}
}): Promise<Metadata> {
const { name, style } = params
const block = await getBlock(name, style)
if (!block) {
return {}
}
return {
title: block.name,
description: block.description,
openGraph: {
title: block.name,
description: block.description,
type: "article",
url: absoluteUrl(`/blocks/${block.name}`),
images: [
{
url: siteConfig.ogImage,
width: 1200,
height: 630,
alt: siteConfig.name,
},
],
},
twitter: {
card: "summary_large_image",
title: block.name,
description: block.description,
images: [siteConfig.ogImage],
creator: "@shadcn",
},
}
}
export async function generateStaticParams() {
const blockIds = await getAllBlockIds()
return styles
.map((style) =>
blockIds.map((name) => ({
style: style.name,
name,
}))
)
.flat()
}
export default async function BlockPage({
params,
}: {
params: {
style: Style["name"]
name: string
}
}) {
const { name, style } = params
const block = await getBlock(name, style)
if (!block) {
return notFound()
}
const Component = block.component
const chunks = block.chunks?.map((chunk) => ({ ...chunk }))
delete block.component
block.chunks?.map((chunk) => delete chunk.component)
return (
<>
{/* <ThemesStyle /> */}
<div
className={cn(
"themes-wrapper bg-background",
block.container?.className
)}
>
<BlockWrapper block={block}>
<Component />
{chunks?.map((chunk, index) => (
<BlockChunk
key={chunk.name}
block={block}
chunk={block.chunks?.[index]}
>
<chunk.component />
</BlockChunk>
))}
</BlockWrapper>
</div>
</>
)
}
| shadcn-ui/ui/apps/www/app/(blocks)/blocks/[style]/[name]/page.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(blocks)/blocks/[style]/[name]/page.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1089
} | 111 |
"use client"
import Link from "next/link"
import { usePathname } from "next/navigation"
import { cn } from "@/lib/utils"
import { ScrollArea, ScrollBar } from "@/registry/new-york/ui/scroll-area"
const links = [
{
name: "Area Chart",
href: "/charts#area-chart",
},
{
name: "Bar Chart",
href: "/charts#bar-chart",
},
{
name: "Line Chart",
href: "/charts#line-chart",
},
{
name: "Pie Chart",
href: "/charts#pie-chart",
},
{
name: "Radar Chart",
href: "/charts#radar-chart",
},
{
name: "Radial Chart",
href: "/charts#radial-chart",
},
{
name: "Tooltip",
href: "/charts#tooltip",
},
]
export function ChartsNav({
className,
...props
}: React.ComponentProps<"div">) {
const pathname = usePathname()
return (
<ScrollArea className="max-w-[600px] lg:max-w-none">
<div className={cn("flex items-center", className)} {...props}>
{links.map((example, index) => (
<Link
href={example.href}
key={example.href}
className={cn(
"flex h-7 shrink-0 items-center justify-center rounded-full px-4 text-center text-sm transition-colors hover:text-primary",
pathname?.startsWith(example.href) ||
(index === 0 && pathname === "/")
? "bg-muted font-medium text-primary"
: "text-muted-foreground"
)}
>
{example.name}
</Link>
))}
</div>
<ScrollBar orientation="horizontal" className="invisible" />
</ScrollArea>
)
}
| shadcn-ui/ui/apps/www/components/charts-nav.tsx | {
"file_path": "shadcn-ui/ui/apps/www/components/charts-nav.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 739
} | 112 |
// @ts-nocheck
"use client"
import * as React from "react"
import Image from "next/image"
import Link from "next/link"
import { useMDXComponent } from "next-contentlayer2/hooks"
import { NpmCommands } from "types/unist"
import { Event } from "@/lib/events"
import { cn } from "@/lib/utils"
import { useConfig } from "@/hooks/use-config"
import { Callout } from "@/components/callout"
import { CodeBlockWrapper } from "@/components/code-block-wrapper"
import { ComponentExample } from "@/components/component-example"
import { ComponentPreview } from "@/components/component-preview"
import { ComponentSource } from "@/components/component-source"
import { CopyButton, CopyNpmCommandButton } from "@/components/copy-button"
import { FrameworkDocs } from "@/components/framework-docs"
import { StyleWrapper } from "@/components/style-wrapper"
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/registry/new-york/ui/accordion"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/registry/new-york/ui/alert"
import { AspectRatio } from "@/registry/new-york/ui/aspect-ratio"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/registry/new-york/ui/tabs"
import { Style } from "@/registry/registry-styles"
const components = {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
Alert,
AlertTitle,
AlertDescription,
h1: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h1
className={cn(
"font-heading mt-2 scroll-m-20 text-4xl font-bold",
className
)}
{...props}
/>
),
h2: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h2
className={cn(
"font-heading mt-12 scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0",
className
)}
{...props}
/>
),
h3: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h3
className={cn(
"font-heading mt-8 scroll-m-20 text-xl font-semibold tracking-tight",
className
)}
{...props}
/>
),
h4: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h4
className={cn(
"font-heading mt-8 scroll-m-20 text-lg font-semibold tracking-tight",
className
)}
{...props}
/>
),
h5: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h5
className={cn(
"mt-8 scroll-m-20 text-lg font-semibold tracking-tight",
className
)}
{...props}
/>
),
h6: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h6
className={cn(
"mt-8 scroll-m-20 text-base font-semibold tracking-tight",
className
)}
{...props}
/>
),
a: ({ className, ...props }: React.HTMLAttributes<HTMLAnchorElement>) => (
<a
className={cn("font-medium underline underline-offset-4", className)}
{...props}
/>
),
p: ({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) => (
<p
className={cn("leading-7 [&:not(:first-child)]:mt-6", className)}
{...props}
/>
),
ul: ({ className, ...props }: React.HTMLAttributes<HTMLUListElement>) => (
<ul className={cn("my-6 ml-6 list-disc", className)} {...props} />
),
ol: ({ className, ...props }: React.HTMLAttributes<HTMLOListElement>) => (
<ol className={cn("my-6 ml-6 list-decimal", className)} {...props} />
),
li: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
<li className={cn("mt-2", className)} {...props} />
),
blockquote: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
<blockquote
className={cn("mt-6 border-l-2 pl-6 italic", className)}
{...props}
/>
),
img: ({
className,
alt,
...props
}: React.ImgHTMLAttributes<HTMLImageElement>) => (
// eslint-disable-next-line @next/next/no-img-element
<img className={cn("rounded-md", className)} alt={alt} {...props} />
),
hr: ({ ...props }: React.HTMLAttributes<HTMLHRElement>) => (
<hr className="my-4 md:my-8" {...props} />
),
table: ({ className, ...props }: React.HTMLAttributes<HTMLTableElement>) => (
<div className="my-6 w-full overflow-y-auto rounded-lg">
<table
className={cn("w-full overflow-hidden rounded-lg", className)}
{...props}
/>
</div>
),
tr: ({ className, ...props }: React.HTMLAttributes<HTMLTableRowElement>) => (
<tr className={cn("m-0 border-t p-0", className)} {...props} />
),
th: ({ className, ...props }: React.HTMLAttributes<HTMLTableCellElement>) => (
<th
className={cn(
"border px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right",
className
)}
{...props}
/>
),
td: ({ className, ...props }: React.HTMLAttributes<HTMLTableCellElement>) => (
<td
className={cn(
"border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",
className
)}
{...props}
/>
),
pre: ({
className,
__rawString__,
__npmCommand__,
__yarnCommand__,
__pnpmCommand__,
__bunCommand__,
__withMeta__,
__src__,
__event__,
__style__,
...props
}: React.HTMLAttributes<HTMLPreElement> & {
__style__?: Style["name"]
__rawString__?: string
__withMeta__?: boolean
__src__?: string
__event__?: Event["name"]
} & NpmCommands) => {
return (
<StyleWrapper styleName={__style__}>
<pre
className={cn(
"mb-4 mt-6 max-h-[650px] overflow-x-auto rounded-lg border bg-zinc-950 py-4 dark:bg-zinc-900",
className
)}
{...props}
/>
{__rawString__ && !__npmCommand__ && (
<CopyButton
value={__rawString__}
src={__src__}
event={__event__}
className={cn("absolute right-4 top-4", __withMeta__ && "top-16")}
/>
)}
{__npmCommand__ &&
__yarnCommand__ &&
__pnpmCommand__ &&
__bunCommand__ && (
<CopyNpmCommandButton
commands={{
__npmCommand__,
__yarnCommand__,
__pnpmCommand__,
__bunCommand__,
}}
className={cn("absolute right-4 top-4", __withMeta__ && "top-16")}
/>
)}
</StyleWrapper>
)
},
code: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
<code
className={cn(
"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm",
className
)}
{...props}
/>
),
Image,
Callout,
ComponentPreview,
ComponentExample,
ComponentSource,
AspectRatio,
CodeBlockWrapper: ({ ...props }) => (
<CodeBlockWrapper className="rounded-md border" {...props} />
),
Step: ({ className, ...props }: React.ComponentProps<"h3">) => (
<h3
className={cn(
"font-heading mt-8 scroll-m-20 text-xl font-semibold tracking-tight",
className
)}
{...props}
/>
),
Steps: ({ ...props }) => (
<div
className="[&>h3]:step steps mb-12 ml-4 border-l pl-8 [counter-reset:step]"
{...props}
/>
),
Tabs: ({ className, ...props }: React.ComponentProps<typeof Tabs>) => (
<Tabs className={cn("relative mt-6 w-full", className)} {...props} />
),
TabsList: ({
className,
...props
}: React.ComponentProps<typeof TabsList>) => (
<TabsList
className={cn(
"w-full justify-start rounded-none border-b bg-transparent p-0",
className
)}
{...props}
/>
),
TabsTrigger: ({
className,
...props
}: React.ComponentProps<typeof TabsTrigger>) => (
<TabsTrigger
className={cn(
"relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none",
className
)}
{...props}
/>
),
TabsContent: ({
className,
...props
}: React.ComponentProps<typeof TabsContent>) => (
<TabsContent
className={cn(
"relative [&_h3.font-heading]:text-base [&_h3.font-heading]:font-semibold",
className
)}
{...props}
/>
),
FrameworkDocs: ({
className,
...props
}: React.ComponentProps<typeof FrameworkDocs>) => (
<FrameworkDocs className={cn(className)} {...props} />
),
Link: ({ className, ...props }: React.ComponentProps<typeof Link>) => (
<Link
className={cn("font-medium underline underline-offset-4", className)}
{...props}
/>
),
LinkedCard: ({ className, ...props }: React.ComponentProps<typeof Link>) => (
<Link
className={cn(
"flex w-full flex-col items-center rounded-xl border bg-card p-6 text-card-foreground shadow transition-colors hover:bg-muted/50 sm:p-10",
className
)}
{...props}
/>
),
}
interface MdxProps {
code: string
}
export function Mdx({ code }: MdxProps) {
const [config] = useConfig()
const Component = useMDXComponent(code, {
style: config.style,
})
return (
<div className="mdx">
<Component components={components} />
</div>
)
}
| shadcn-ui/ui/apps/www/components/mdx-components.tsx | {
"file_path": "shadcn-ui/ui/apps/www/components/mdx-components.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 4153
} | 113 |
"use client"
import * as React from "react"
import { useSelectedLayoutSegment } from "next/navigation"
import { useConfig } from "@/hooks/use-config"
export function ThemeSwitcher() {
const [config] = useConfig()
const segment = useSelectedLayoutSegment()
React.useEffect(() => {
document.body.classList.forEach((className) => {
if (className.match(/^theme.*/)) {
document.body.classList.remove(className)
}
})
const theme = segment === "themes" ? config.theme : null
if (theme) {
return document.body.classList.add(`theme-${theme}`)
}
}, [segment, config])
return null
}
| shadcn-ui/ui/apps/www/components/theme-switcher.tsx | {
"file_path": "shadcn-ui/ui/apps/www/components/theme-switcher.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 233
} | 114 |
import { useAtom } from "jotai"
import { atomWithStorage } from "jotai/utils"
import { ColorFormat } from "@/lib/colors"
import { useMounted } from "@/hooks/use-mounted"
type Config = {
format: ColorFormat
}
const colorsAtom = atomWithStorage<Config>("colors", {
format: "hsl",
})
export function useColors() {
const [colors, setColors] = useAtom(colorsAtom)
const mounted = useMounted()
return {
isLoading: !mounted,
format: colors.format,
setFormat: (format: ColorFormat) => setColors({ format }),
}
}
| shadcn-ui/ui/apps/www/hooks/use-colors.ts | {
"file_path": "shadcn-ui/ui/apps/www/hooks/use-colors.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 191
} | 115 |
import fs from "fs"
import path from "path"
import { UnistNode, UnistTree } from "types/unist"
import { u } from "unist-builder"
import { visit } from "unist-util-visit"
import { Index } from "../__registry__"
import { styles } from "../registry/registry-styles"
export function rehypeComponent() {
return async (tree: UnistTree) => {
visit(tree, (node: UnistNode) => {
// src prop overrides both name and fileName.
const { value: srcPath } =
(getNodeAttributeByName(node, "src") as {
name: string
value?: string
type?: string
}) || {}
if (node.name === "ComponentSource") {
const name = getNodeAttributeByName(node, "name")?.value as string
const fileName = getNodeAttributeByName(node, "fileName")?.value as
| string
| undefined
if (!name && !srcPath) {
return null
}
try {
for (const style of styles) {
let src: string
if (srcPath) {
src = srcPath
} else {
const component = Index[style.name][name]
src = fileName
? component.files.find((file: string) => {
return (
file.endsWith(`${fileName}.tsx`) ||
file.endsWith(`${fileName}.ts`)
)
}) || component.files[0]
: component.files[0]
}
// Read the source file.
const filePath = path.join(process.cwd(), src)
let source = fs.readFileSync(filePath, "utf8")
// Replace imports.
// TODO: Use @swc/core and a visitor to replace this.
// For now a simple regex should do.
source = source.replaceAll(
`@/registry/${style.name}/`,
"@/components/"
)
source = source.replaceAll("export default", "export")
// Add code as children so that rehype can take over at build time.
node.children?.push(
u("element", {
tagName: "pre",
properties: {
__src__: src,
__style__: style.name,
},
attributes: [
{
name: "styleName",
type: "mdxJsxAttribute",
value: style.name,
},
],
children: [
u("element", {
tagName: "code",
properties: {
className: ["language-tsx"],
},
children: [
{
type: "text",
value: source,
},
],
}),
],
})
)
}
} catch (error) {
console.error(error)
}
}
if (node.name === "ComponentPreview") {
const name = getNodeAttributeByName(node, "name")?.value as string
if (!name) {
return null
}
try {
for (const style of styles) {
const component = Index[style.name][name]
const src = component.files[0]
// Read the source file.
const filePath = path.join(process.cwd(), src)
let source = fs.readFileSync(filePath, "utf8")
// Replace imports.
// TODO: Use @swc/core and a visitor to replace this.
// For now a simple regex should do.
source = source.replaceAll(
`@/registry/${style.name}/`,
"@/components/"
)
source = source.replaceAll("export default", "export")
// Add code as children so that rehype can take over at build time.
node.children?.push(
u("element", {
tagName: "pre",
properties: {
__src__: src,
},
children: [
u("element", {
tagName: "code",
properties: {
className: ["language-tsx"],
},
children: [
{
type: "text",
value: source,
},
],
}),
],
})
)
}
} catch (error) {
console.error(error)
}
}
// if (node.name === "ComponentExample") {
// const source = getComponentSourceFileContent(node)
// if (!source) {
// return
// }
// // Replace the Example component with a pre element.
// node.children?.push(
// u("element", {
// tagName: "pre",
// properties: {
// __src__: src,
// },
// children: [
// u("element", {
// tagName: "code",
// properties: {
// className: ["language-tsx"],
// },
// children: [
// {
// type: "text",
// value: source,
// },
// ],
// }),
// ],
// })
// )
// const extractClassname = getNodeAttributeByName(
// node,
// "extractClassname"
// )
// if (
// extractClassname &&
// typeof extractClassname.value !== "undefined" &&
// extractClassname.value !== "false"
// ) {
// // Extract className from string
// // TODO: Use @swc/core and a visitor to extract this.
// // For now, a simple regex should do.
// const values = source.match(/className="(.*)"/)
// const className = values ? values[1] : ""
// // Add the className as a jsx prop so we can pass it to the copy button.
// node.attributes?.push({
// name: "extractedClassNames",
// type: "mdxJsxAttribute",
// value: className,
// })
// // Add a pre element with the className only.
// node.children?.push(
// u("element", {
// tagName: "pre",
// properties: {},
// children: [
// u("element", {
// tagName: "code",
// properties: {
// className: ["language-tsx"],
// },
// children: [
// {
// type: "text",
// value: className,
// },
// ],
// }),
// ],
// })
// )
// }
// }
// if (node.name === "ComponentSource") {
// const source = getComponentSourceFileContent(node)
// if (!source) {
// return
// }
// // Replace the Source component with a pre element.
// node.children?.push(
// u("element", {
// tagName: "pre",
// properties: {
// __src__: src,
// },
// children: [
// u("element", {
// tagName: "code",
// properties: {
// className: ["language-tsx"],
// },
// children: [
// {
// type: "text",
// value: source,
// },
// ],
// }),
// ],
// })
// )
// }
})
}
}
function getNodeAttributeByName(node: UnistNode, name: string) {
return node.attributes?.find((attribute) => attribute.name === name)
}
function getComponentSourceFileContent(node: UnistNode) {
const src = getNodeAttributeByName(node, "src")?.value as string
if (!src) {
return null
}
// Read the source file.
const filePath = path.join(process.cwd(), src)
const source = fs.readFileSync(filePath, "utf8")
return source
}
| shadcn-ui/ui/apps/www/lib/rehype-component.ts | {
"file_path": "shadcn-ui/ui/apps/www/lib/rehype-component.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 4647
} | 116 |
import Link from "next/link"
import {
Activity,
ArrowUpRight,
CircleUser,
CreditCard,
DollarSign,
Menu,
Package2,
Search,
Users,
} from "lucide-react"
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/registry/default/ui/avatar"
import { Badge } from "@/registry/default/ui/badge"
import { Button } from "@/registry/default/ui/button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/registry/default/ui/card"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/registry/default/ui/dropdown-menu"
import { Input } from "@/registry/default/ui/input"
import { Sheet, SheetContent, SheetTrigger } from "@/registry/default/ui/sheet"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/registry/default/ui/table"
export const description =
"An application shell with a header and main content area. The header has a navbar, a search input and and a user nav dropdown. The user nav is toggled by a button with an avatar image."
export const iframeHeight = "825px"
export const containerClassName = "w-full h-full"
export default function Dashboard() {
return (
<div className="flex min-h-screen w-full flex-col">
<header className="sticky top-0 flex h-16 items-center gap-4 border-b bg-background px-4 md:px-6">
<nav className="hidden flex-col gap-6 text-lg font-medium md:flex md:flex-row md:items-center md:gap-5 md:text-sm lg:gap-6">
<Link
href="#"
className="flex items-center gap-2 text-lg font-semibold md:text-base"
>
<Package2 className="h-6 w-6" />
<span className="sr-only">Acme Inc</span>
</Link>
<Link
href="#"
className="text-foreground transition-colors hover:text-foreground"
>
Dashboard
</Link>
<Link
href="#"
className="text-muted-foreground transition-colors hover:text-foreground"
>
Orders
</Link>
<Link
href="#"
className="text-muted-foreground transition-colors hover:text-foreground"
>
Products
</Link>
<Link
href="#"
className="text-muted-foreground transition-colors hover:text-foreground"
>
Customers
</Link>
<Link
href="#"
className="text-muted-foreground transition-colors hover:text-foreground"
>
Analytics
</Link>
</nav>
<Sheet>
<SheetTrigger asChild>
<Button
variant="outline"
size="icon"
className="shrink-0 md:hidden"
>
<Menu className="h-5 w-5" />
<span className="sr-only">Toggle navigation menu</span>
</Button>
</SheetTrigger>
<SheetContent side="left">
<nav className="grid gap-6 text-lg font-medium">
<Link
href="#"
className="flex items-center gap-2 text-lg font-semibold"
>
<Package2 className="h-6 w-6" />
<span className="sr-only">Acme Inc</span>
</Link>
<Link href="#" className="hover:text-foreground">
Dashboard
</Link>
<Link
href="#"
className="text-muted-foreground hover:text-foreground"
>
Orders
</Link>
<Link
href="#"
className="text-muted-foreground hover:text-foreground"
>
Products
</Link>
<Link
href="#"
className="text-muted-foreground hover:text-foreground"
>
Customers
</Link>
<Link
href="#"
className="text-muted-foreground hover:text-foreground"
>
Analytics
</Link>
</nav>
</SheetContent>
</Sheet>
<div className="flex w-full items-center gap-4 md:ml-auto md:gap-2 lg:gap-4">
<form className="ml-auto flex-1 sm:flex-initial">
<div className="relative">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
type="search"
placeholder="Search products..."
className="pl-8 sm:w-[300px] md:w-[200px] lg:w-[300px]"
/>
</div>
</form>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="secondary" size="icon" className="rounded-full">
<CircleUser className="h-5 w-5" />
<span className="sr-only">Toggle user menu</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuItem>Support</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Logout</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</header>
<main className="flex flex-1 flex-col gap-4 p-4 md:gap-8 md:p-8">
<div className="grid gap-4 md:grid-cols-2 md:gap-8 lg:grid-cols-4">
<Card x-chunk="A card showing the total revenue in USD and the percentage difference from last month.">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Total Revenue
</CardTitle>
<DollarSign className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">$45,231.89</div>
<p className="text-xs text-muted-foreground">
+20.1% from last month
</p>
</CardContent>
</Card>
<Card x-chunk="A card showing the total subscriptions and the percentage difference from last month.">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Subscriptions
</CardTitle>
<Users className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+2350</div>
<p className="text-xs text-muted-foreground">
+180.1% from last month
</p>
</CardContent>
</Card>
<Card x-chunk="A card showing the total sales and the percentage difference from last month.">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Sales</CardTitle>
<CreditCard className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+12,234</div>
<p className="text-xs text-muted-foreground">
+19% from last month
</p>
</CardContent>
</Card>
<Card x-chunk="A card showing the total active users and the percentage difference from last hour.">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Active Now</CardTitle>
<Activity className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+573</div>
<p className="text-xs text-muted-foreground">
+201 since last hour
</p>
</CardContent>
</Card>
</div>
<div className="grid gap-4 md:gap-8 lg:grid-cols-2 xl:grid-cols-3">
<Card
className="xl:col-span-2"
x-chunk="A card showing a table of recent transactions with a link to view all transactions."
>
<CardHeader className="flex flex-row items-center">
<div className="grid gap-2">
<CardTitle>Transactions</CardTitle>
<CardDescription>
Recent transactions from your store.
</CardDescription>
</div>
<Button asChild size="sm" className="ml-auto gap-1">
<Link href="#">
View All
<ArrowUpRight className="h-4 w-4" />
</Link>
</Button>
</CardHeader>
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Customer</TableHead>
<TableHead className="hidden xl:table-column">
Type
</TableHead>
<TableHead className="hidden xl:table-column">
Status
</TableHead>
<TableHead className="hidden xl:table-column">
Date
</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>
<div className="font-medium">Liam Johnson</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden xl:table-column">
Sale
</TableCell>
<TableCell className="hidden xl:table-column">
<Badge className="text-xs" variant="outline">
Approved
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell lg:hidden xl:table-column">
2023-06-23
</TableCell>
<TableCell className="text-right">$250.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Olivia Smith</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden xl:table-column">
Refund
</TableCell>
<TableCell className="hidden xl:table-column">
<Badge className="text-xs" variant="outline">
Declined
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell lg:hidden xl:table-column">
2023-06-24
</TableCell>
<TableCell className="text-right">$150.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Noah Williams</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden xl:table-column">
Subscription
</TableCell>
<TableCell className="hidden xl:table-column">
<Badge className="text-xs" variant="outline">
Approved
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell lg:hidden xl:table-column">
2023-06-25
</TableCell>
<TableCell className="text-right">$350.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Emma Brown</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden xl:table-column">
Sale
</TableCell>
<TableCell className="hidden xl:table-column">
<Badge className="text-xs" variant="outline">
Approved
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell lg:hidden xl:table-column">
2023-06-26
</TableCell>
<TableCell className="text-right">$450.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Liam Johnson</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden xl:table-column">
Sale
</TableCell>
<TableCell className="hidden xl:table-column">
<Badge className="text-xs" variant="outline">
Approved
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell lg:hidden xl:table-column">
2023-06-27
</TableCell>
<TableCell className="text-right">$550.00</TableCell>
</TableRow>
</TableBody>
</Table>
</CardContent>
</Card>
<Card x-chunk="A card showing a list of recent sales with customer names and email addresses.">
<CardHeader>
<CardTitle>Recent Sales</CardTitle>
</CardHeader>
<CardContent className="grid gap-8">
<div className="flex items-center gap-4">
<Avatar className="hidden h-9 w-9 sm:flex">
<AvatarImage src="/avatars/01.png" alt="Avatar" />
<AvatarFallback>OM</AvatarFallback>
</Avatar>
<div className="grid gap-1">
<p className="text-sm font-medium leading-none">
Olivia Martin
</p>
<p className="text-sm text-muted-foreground">
[email protected]
</p>
</div>
<div className="ml-auto font-medium">+$1,999.00</div>
</div>
<div className="flex items-center gap-4">
<Avatar className="hidden h-9 w-9 sm:flex">
<AvatarImage src="/avatars/02.png" alt="Avatar" />
<AvatarFallback>JL</AvatarFallback>
</Avatar>
<div className="grid gap-1">
<p className="text-sm font-medium leading-none">
Jackson Lee
</p>
<p className="text-sm text-muted-foreground">
[email protected]
</p>
</div>
<div className="ml-auto font-medium">+$39.00</div>
</div>
<div className="flex items-center gap-4">
<Avatar className="hidden h-9 w-9 sm:flex">
<AvatarImage src="/avatars/03.png" alt="Avatar" />
<AvatarFallback>IN</AvatarFallback>
</Avatar>
<div className="grid gap-1">
<p className="text-sm font-medium leading-none">
Isabella Nguyen
</p>
<p className="text-sm text-muted-foreground">
[email protected]
</p>
</div>
<div className="ml-auto font-medium">+$299.00</div>
</div>
<div className="flex items-center gap-4">
<Avatar className="hidden h-9 w-9 sm:flex">
<AvatarImage src="/avatars/04.png" alt="Avatar" />
<AvatarFallback>WK</AvatarFallback>
</Avatar>
<div className="grid gap-1">
<p className="text-sm font-medium leading-none">
William Kim
</p>
<p className="text-sm text-muted-foreground">
[email protected]
</p>
</div>
<div className="ml-auto font-medium">+$99.00</div>
</div>
<div className="flex items-center gap-4">
<Avatar className="hidden h-9 w-9 sm:flex">
<AvatarImage src="/avatars/05.png" alt="Avatar" />
<AvatarFallback>SD</AvatarFallback>
</Avatar>
<div className="grid gap-1">
<p className="text-sm font-medium leading-none">
Sofia Davis
</p>
<p className="text-sm text-muted-foreground">
[email protected]
</p>
</div>
<div className="ml-auto font-medium">+$39.00</div>
</div>
</CardContent>
</Card>
</div>
</main>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/dashboard-01.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-01.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 10286
} | 117 |
import Image from "next/image"
import Link from "next/link"
import {
ChevronLeft,
ChevronRight,
Copy,
CreditCard,
File,
Home,
LineChart,
ListFilter,
MoreVertical,
Package,
Package2,
PanelLeft,
Search,
Settings,
ShoppingCart,
Truck,
Users2,
} from "lucide-react"
import { Badge } from "@/registry/default/ui/badge"
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/registry/default/ui/breadcrumb"
import { Button } from "@/registry/default/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/registry/default/ui/card"
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/registry/default/ui/dropdown-menu"
import { Input } from "@/registry/default/ui/input"
import {
Pagination,
PaginationContent,
PaginationItem,
} from "@/registry/default/ui/pagination"
import { Progress } from "@/registry/default/ui/progress"
import { Separator } from "@/registry/default/ui/separator"
import { Sheet, SheetContent, SheetTrigger } from "@/registry/default/ui/sheet"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/registry/default/ui/table"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/registry/default/ui/tabs"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/registry/default/ui/tooltip"
export const description =
"An orders dashboard with a sidebar navigation. The sidebar has icon navigation. The content area has a breadcrumb and search in the header. The main area has a list of recent orders with a filter and export button. The main area also has a detailed view of a single order with order details, shipping information, billing information, customer information, and payment information."
export const iframeHeight = "1112px"
export const containerClassName = "w-full h-full"
export default function Dashboard() {
return (
<div className="flex min-h-screen w-full flex-col bg-muted/40">
<aside className="fixed inset-y-0 left-0 z-10 hidden w-14 flex-col border-r bg-background sm:flex">
<nav className="flex flex-col items-center gap-4 px-2 sm:py-5">
<Link
href="#"
className="group flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-full bg-primary text-lg font-semibold text-primary-foreground md:h-8 md:w-8 md:text-base"
>
<Package2 className="h-4 w-4 transition-all group-hover:scale-110" />
<span className="sr-only">Acme Inc</span>
</Link>
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<Home className="h-5 w-5" />
<span className="sr-only">Dashboard</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Dashboard</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg bg-accent text-accent-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<ShoppingCart className="h-5 w-5" />
<span className="sr-only">Orders</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Orders</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<Package className="h-5 w-5" />
<span className="sr-only">Products</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Products</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<Users2 className="h-5 w-5" />
<span className="sr-only">Customers</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Customers</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<LineChart className="h-5 w-5" />
<span className="sr-only">Analytics</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Analytics</TooltipContent>
</Tooltip>
</nav>
<nav className="mt-auto flex flex-col items-center gap-4 px-2 sm:py-5">
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<Settings className="h-5 w-5" />
<span className="sr-only">Settings</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Settings</TooltipContent>
</Tooltip>
</nav>
</aside>
<div className="flex flex-col sm:gap-4 sm:py-4 sm:pl-14">
<header className="sticky top-0 z-30 flex h-14 items-center gap-4 border-b bg-background px-4 sm:static sm:h-auto sm:border-0 sm:bg-transparent sm:px-6">
<Sheet>
<SheetTrigger asChild>
<Button size="icon" variant="outline" className="sm:hidden">
<PanelLeft className="h-5 w-5" />
<span className="sr-only">Toggle Menu</span>
</Button>
</SheetTrigger>
<SheetContent side="left" className="sm:max-w-xs">
<nav className="grid gap-6 text-lg font-medium">
<Link
href="#"
className="group flex h-10 w-10 shrink-0 items-center justify-center gap-2 rounded-full bg-primary text-lg font-semibold text-primary-foreground md:text-base"
>
<Package2 className="h-5 w-5 transition-all group-hover:scale-110" />
<span className="sr-only">Acme Inc</span>
</Link>
<Link
href="#"
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
>
<Home className="h-5 w-5" />
Dashboard
</Link>
<Link
href="#"
className="flex items-center gap-4 px-2.5 text-foreground"
>
<ShoppingCart className="h-5 w-5" />
Orders
</Link>
<Link
href="#"
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
>
<Package className="h-5 w-5" />
Products
</Link>
<Link
href="#"
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
>
<Users2 className="h-5 w-5" />
Customers
</Link>
<Link
href="#"
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
>
<LineChart className="h-5 w-5" />
Settings
</Link>
</nav>
</SheetContent>
</Sheet>
<Breadcrumb className="hidden md:flex">
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="#">Dashboard</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="#">Orders</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Recent Orders</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
<div className="relative ml-auto flex-1 md:grow-0">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
type="search"
placeholder="Search..."
className="w-full rounded-lg bg-background pl-8 md:w-[200px] lg:w-[336px]"
/>
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="icon"
className="overflow-hidden rounded-full"
>
<Image
src="/placeholder-user.jpg"
width={36}
height={36}
alt="Avatar"
className="overflow-hidden rounded-full"
/>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuItem>Support</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Logout</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</header>
<main className="grid flex-1 items-start gap-4 p-4 sm:px-6 sm:py-0 md:gap-8 lg:grid-cols-3 xl:grid-cols-3">
<div className="grid auto-rows-max items-start gap-4 md:gap-8 lg:col-span-2">
<div className="grid gap-4 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-2 xl:grid-cols-4">
<Card
className="sm:col-span-2"
x-chunk="A card for an orders dashboard with a description and a button to create a new order."
>
<CardHeader className="pb-3">
<CardTitle>Your Orders</CardTitle>
<CardDescription className="max-w-lg text-balance leading-relaxed">
Introducing Our Dynamic Orders Dashboard for Seamless
Management and Insightful Analysis.
</CardDescription>
</CardHeader>
<CardFooter>
<Button>Create New Order</Button>
</CardFooter>
</Card>
<Card x-chunk="A stats card showing this week's total sales in USD, the percentage difference from last week, and a progress bar.">
<CardHeader className="pb-2">
<CardDescription>This Week</CardDescription>
<CardTitle className="text-4xl">$1,329</CardTitle>
</CardHeader>
<CardContent>
<div className="text-xs text-muted-foreground">
+25% from last week
</div>
</CardContent>
<CardFooter>
<Progress value={25} aria-label="25% increase" />
</CardFooter>
</Card>
<Card x-chunk="A stats card showing this month's total sales in USD, the percentage difference from last month, and a progress bar.">
<CardHeader className="pb-2">
<CardDescription>This Month</CardDescription>
<CardTitle className="text-4xl">$5,329</CardTitle>
</CardHeader>
<CardContent>
<div className="text-xs text-muted-foreground">
+10% from last month
</div>
</CardContent>
<CardFooter>
<Progress value={12} aria-label="12% increase" />
</CardFooter>
</Card>
</div>
<Tabs defaultValue="week">
<div className="flex items-center">
<TabsList>
<TabsTrigger value="week">Week</TabsTrigger>
<TabsTrigger value="month">Month</TabsTrigger>
<TabsTrigger value="year">Year</TabsTrigger>
</TabsList>
<div className="ml-auto flex items-center gap-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="sm"
className="h-7 gap-1 text-sm"
>
<ListFilter className="h-3.5 w-3.5" />
<span className="sr-only sm:not-sr-only">Filter</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Filter by</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuCheckboxItem checked>
Fulfilled
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem>
Declined
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem>
Refunded
</DropdownMenuCheckboxItem>
</DropdownMenuContent>
</DropdownMenu>
<Button
size="sm"
variant="outline"
className="h-7 gap-1 text-sm"
>
<File className="h-3.5 w-3.5" />
<span className="sr-only sm:not-sr-only">Export</span>
</Button>
</div>
</div>
<TabsContent value="week">
<Card x-chunk="A table of recent orders showing the following columns: Customer, Type, Status, Date, and Amount.">
<CardHeader className="px-7">
<CardTitle>Orders</CardTitle>
<CardDescription>
Recent orders from your store.
</CardDescription>
</CardHeader>
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Customer</TableHead>
<TableHead className="hidden sm:table-cell">
Type
</TableHead>
<TableHead className="hidden sm:table-cell">
Status
</TableHead>
<TableHead className="hidden md:table-cell">
Date
</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow className="bg-accent">
<TableCell>
<div className="font-medium">Liam Johnson</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Sale
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="secondary">
Fulfilled
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-23
</TableCell>
<TableCell className="text-right">$250.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Olivia Smith</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Refund
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="outline">
Declined
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-24
</TableCell>
<TableCell className="text-right">$150.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Noah Williams</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Subscription
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="secondary">
Fulfilled
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-25
</TableCell>
<TableCell className="text-right">$350.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Emma Brown</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Sale
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="secondary">
Fulfilled
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-26
</TableCell>
<TableCell className="text-right">$450.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Liam Johnson</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Sale
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="secondary">
Fulfilled
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-23
</TableCell>
<TableCell className="text-right">$250.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Liam Johnson</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Sale
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="secondary">
Fulfilled
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-23
</TableCell>
<TableCell className="text-right">$250.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Olivia Smith</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Refund
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="outline">
Declined
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-24
</TableCell>
<TableCell className="text-right">$150.00</TableCell>
</TableRow>
<TableRow>
<TableCell>
<div className="font-medium">Emma Brown</div>
<div className="hidden text-sm text-muted-foreground md:inline">
[email protected]
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Sale
</TableCell>
<TableCell className="hidden sm:table-cell">
<Badge className="text-xs" variant="secondary">
Fulfilled
</Badge>
</TableCell>
<TableCell className="hidden md:table-cell">
2023-06-26
</TableCell>
<TableCell className="text-right">$450.00</TableCell>
</TableRow>
</TableBody>
</Table>
</CardContent>
</Card>
</TabsContent>
</Tabs>
</div>
<div>
<Card
className="overflow-hidden"
x-chunk="An order details card with order details, shipping information, customer information and payment information."
>
<CardHeader className="flex flex-row items-start bg-muted/50">
<div className="grid gap-0.5">
<CardTitle className="group flex items-center gap-2 text-lg">
Order Oe31b70H
<Button
size="icon"
variant="outline"
className="h-6 w-6 opacity-0 transition-opacity group-hover:opacity-100"
>
<Copy className="h-3 w-3" />
<span className="sr-only">Copy Order ID</span>
</Button>
</CardTitle>
<CardDescription>Date: November 23, 2023</CardDescription>
</div>
<div className="ml-auto flex items-center gap-1">
<Button size="sm" variant="outline" className="h-8 gap-1">
<Truck className="h-3.5 w-3.5" />
<span className="lg:sr-only xl:not-sr-only xl:whitespace-nowrap">
Track Order
</span>
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button size="icon" variant="outline" className="h-8 w-8">
<MoreVertical className="h-3.5 w-3.5" />
<span className="sr-only">More</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem>Edit</DropdownMenuItem>
<DropdownMenuItem>Export</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Trash</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</CardHeader>
<CardContent className="p-6 text-sm">
<div className="grid gap-3">
<div className="font-semibold">Order Details</div>
<ul className="grid gap-3">
<li className="flex items-center justify-between">
<span className="text-muted-foreground">
Glimmer Lamps x <span>2</span>
</span>
<span>$250.00</span>
</li>
<li className="flex items-center justify-between">
<span className="text-muted-foreground">
Aqua Filters x <span>1</span>
</span>
<span>$49.00</span>
</li>
</ul>
<Separator className="my-2" />
<ul className="grid gap-3">
<li className="flex items-center justify-between">
<span className="text-muted-foreground">Subtotal</span>
<span>$299.00</span>
</li>
<li className="flex items-center justify-between">
<span className="text-muted-foreground">Shipping</span>
<span>$5.00</span>
</li>
<li className="flex items-center justify-between">
<span className="text-muted-foreground">Tax</span>
<span>$25.00</span>
</li>
<li className="flex items-center justify-between font-semibold">
<span className="text-muted-foreground">Total</span>
<span>$329.00</span>
</li>
</ul>
</div>
<Separator className="my-4" />
<div className="grid grid-cols-2 gap-4">
<div className="grid gap-3">
<div className="font-semibold">Shipping Information</div>
<address className="grid gap-0.5 not-italic text-muted-foreground">
<span>Liam Johnson</span>
<span>1234 Main St.</span>
<span>Anytown, CA 12345</span>
</address>
</div>
<div className="grid auto-rows-max gap-3">
<div className="font-semibold">Billing Information</div>
<div className="text-muted-foreground">
Same as shipping address
</div>
</div>
</div>
<Separator className="my-4" />
<div className="grid gap-3">
<div className="font-semibold">Customer Information</div>
<dl className="grid gap-3">
<div className="flex items-center justify-between">
<dt className="text-muted-foreground">Customer</dt>
<dd>Liam Johnson</dd>
</div>
<div className="flex items-center justify-between">
<dt className="text-muted-foreground">Email</dt>
<dd>
<a href="mailto:">[email protected]</a>
</dd>
</div>
<div className="flex items-center justify-between">
<dt className="text-muted-foreground">Phone</dt>
<dd>
<a href="tel:">+1 234 567 890</a>
</dd>
</div>
</dl>
</div>
<Separator className="my-4" />
<div className="grid gap-3">
<div className="font-semibold">Payment Information</div>
<dl className="grid gap-3">
<div className="flex items-center justify-between">
<dt className="flex items-center gap-1 text-muted-foreground">
<CreditCard className="h-4 w-4" />
Visa
</dt>
<dd>**** **** **** 4532</dd>
</div>
</dl>
</div>
</CardContent>
<CardFooter className="flex flex-row items-center border-t bg-muted/50 px-6 py-3">
<div className="text-xs text-muted-foreground">
Updated <time dateTime="2023-11-23">November 23, 2023</time>
</div>
<Pagination className="ml-auto mr-0 w-auto">
<PaginationContent>
<PaginationItem>
<Button size="icon" variant="outline" className="h-6 w-6">
<ChevronLeft className="h-3.5 w-3.5" />
<span className="sr-only">Previous Order</span>
</Button>
</PaginationItem>
<PaginationItem>
<Button size="icon" variant="outline" className="h-6 w-6">
<ChevronRight className="h-3.5 w-3.5" />
<span className="sr-only">Next Order</span>
</Button>
</PaginationItem>
</PaginationContent>
</Pagination>
</CardFooter>
</Card>
</div>
</main>
</div>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/dashboard-05.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-05.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 18960
} | 118 |
import {
BadgeCheck,
Bell,
ChevronsUpDown,
CreditCard,
LogOut,
} from "lucide-react"
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/registry/default/ui/avatar"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/registry/default/ui/dropdown-menu"
export function NavUser({
user,
}: {
user: {
name: string
email: string
avatar: string
}
}) {
return (
<DropdownMenu>
<DropdownMenuTrigger className="w-full rounded-md outline-none ring-ring hover:bg-accent focus-visible:ring-2 data-[state=open]:bg-accent">
<div className="flex items-center gap-2 px-2 py-1.5 text-left text-sm transition-all">
<Avatar className="h-7 w-7 rounded-md border">
<AvatarImage
src={user.avatar}
alt={user.name}
className="animate-in fade-in-50 zoom-in-90"
/>
<AvatarFallback className="rounded-md">CN</AvatarFallback>
</Avatar>
<div className="grid flex-1 leading-none">
<div className="font-medium">{user.name}</div>
<div className="overflow-hidden text-xs text-muted-foreground">
<div className="line-clamp-1">{user.email}</div>
</div>
</div>
<ChevronsUpDown className="ml-auto mr-0.5 h-4 w-4 text-muted-foreground/50" />
</div>
</DropdownMenuTrigger>
<DropdownMenuContent
className="w-56"
align="end"
side="right"
sideOffset={4}
>
<DropdownMenuLabel className="p-0 font-normal">
<div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm transition-all">
<Avatar className="h-7 w-7 rounded-md">
<AvatarImage src={user.avatar} alt={user.name} />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<div className="grid flex-1">
<div className="font-medium">{user.name}</div>
<div className="overflow-hidden text-xs text-muted-foreground">
<div className="line-clamp-1">{user.email}</div>
</div>
</div>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem className="gap-2">
<BadgeCheck className="h-4 w-4 text-muted-foreground" />
Account
</DropdownMenuItem>
<DropdownMenuItem className="gap-2">
<CreditCard className="h-4 w-4 text-muted-foreground" />
Billing
</DropdownMenuItem>
<DropdownMenuItem className="gap-2">
<Bell className="h-4 w-4 text-muted-foreground" />
Notifications
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem className="gap-2">
<LogOut className="h-4 w-4 text-muted-foreground" />
Log out
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/sidebar-01/components/nav-user.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/sidebar-01/components/nav-user.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1514
} | 119 |
import {
Breadcrumb,
BreadcrumbEllipsis,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/registry/default/ui/breadcrumb"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/registry/default/ui/dropdown-menu"
export default function BreadcrumbDemo() {
return (
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">Home</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<DropdownMenu>
<DropdownMenuTrigger className="flex items-center gap-1">
<BreadcrumbEllipsis className="h-4 w-4" />
<span className="sr-only">Toggle menu</span>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>Documentation</DropdownMenuItem>
<DropdownMenuItem>Themes</DropdownMenuItem>
<DropdownMenuItem>GitHub</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="/docs/components">Components</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Breadcrumb</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/breadcrumb-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/breadcrumb-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 705
} | 120 |
"use client"
import * as React from "react"
import { Calendar } from "@/registry/default/ui/calendar"
export default function CalendarDemo() {
const [date, setDate] = React.useState<Date | undefined>(new Date())
return (
<Calendar
mode="single"
selected={date}
onSelect={setDate}
className="rounded-md border"
/>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/calendar-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/calendar-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 133
} | 121 |
import { useTheme } from "next-themes"
import { Bar, BarChart, Line, LineChart, ResponsiveContainer } from "recharts"
import { useConfig } from "@/hooks/use-config"
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "@/registry/default/ui/card"
import { baseColors } from "@/registry/registry-base-colors"
const data = [
{
revenue: 10400,
subscription: 240,
},
{
revenue: 14405,
subscription: 300,
},
{
revenue: 9400,
subscription: 200,
},
{
revenue: 8200,
subscription: 278,
},
{
revenue: 7000,
subscription: 189,
},
{
revenue: 9600,
subscription: 239,
},
{
revenue: 11244,
subscription: 278,
},
{
revenue: 26475,
subscription: 189,
},
]
export function CardsStats() {
const { theme: mode } = useTheme()
const [config] = useConfig()
const baseColor = baseColors.find(
(baseColor) => baseColor.name === config.theme
)
return (
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-2">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-base font-normal">Total Revenue</CardTitle>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">$15,231.89</div>
<p className="text-xs text-muted-foreground">
+20.1% from last month
</p>
<div className="h-[80px]">
<ResponsiveContainer width="100%" height="100%">
<LineChart
data={data}
margin={{
top: 5,
right: 10,
left: 10,
bottom: 0,
}}
>
<Line
type="monotone"
strokeWidth={2}
dataKey="revenue"
activeDot={{
r: 6,
style: { fill: "var(--theme-primary)", opacity: 0.25 },
}}
style={
{
stroke: "var(--theme-primary)",
"--theme-primary": `hsl(${
baseColor?.cssVars[mode === "dark" ? "dark" : "light"]
.primary
})`,
} as React.CSSProperties
}
/>
</LineChart>
</ResponsiveContainer>
</div>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-base font-normal">Subscriptions</CardTitle>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+2350</div>
<p className="text-xs text-muted-foreground">
+180.1% from last month
</p>
<div className="mt-4 h-[80px]">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={data}>
<Bar
dataKey="subscription"
style={
{
fill: "var(--theme-primary)",
opacity: 1,
"--theme-primary": `hsl(${
baseColor?.cssVars[mode === "dark" ? "dark" : "light"]
.primary
})`,
} as React.CSSProperties
}
/>
</BarChart>
</ResponsiveContainer>
</div>
</CardContent>
</Card>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/cards/stats.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/cards/stats.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 2013
} | 122 |
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { toast } from "@/registry/default/hooks/use-toast"
import { Button } from "@/registry/default/ui/button"
import { Checkbox } from "@/registry/default/ui/checkbox"
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/registry/default/ui/form"
const items = [
{
id: "recents",
label: "Recents",
},
{
id: "home",
label: "Home",
},
{
id: "applications",
label: "Applications",
},
{
id: "desktop",
label: "Desktop",
},
{
id: "downloads",
label: "Downloads",
},
{
id: "documents",
label: "Documents",
},
] as const
const FormSchema = z.object({
items: z.array(z.string()).refine((value) => value.some((item) => item), {
message: "You have to select at least one item.",
}),
})
export default function CheckboxReactHookFormMultiple() {
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
items: ["recents", "home"],
},
})
function onSubmit(data: z.infer<typeof FormSchema>) {
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
})
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<FormField
control={form.control}
name="items"
render={() => (
<FormItem>
<div className="mb-4">
<FormLabel className="text-base">Sidebar</FormLabel>
<FormDescription>
Select the items you want to display in the sidebar.
</FormDescription>
</div>
{items.map((item) => (
<FormField
key={item.id}
control={form.control}
name="items"
render={({ field }) => {
return (
<FormItem
key={item.id}
className="flex flex-row items-start space-x-3 space-y-0"
>
<FormControl>
<Checkbox
checked={field.value?.includes(item.id)}
onCheckedChange={(checked) => {
return checked
? field.onChange([...field.value, item.id])
: field.onChange(
field.value?.filter(
(value) => value !== item.id
)
)
}}
/>
</FormControl>
<FormLabel className="font-normal">
{item.label}
</FormLabel>
</FormItem>
)
}}
/>
))}
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/checkbox-form-multiple.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/checkbox-form-multiple.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1934
} | 123 |
"use client"
import * as React from "react"
import { addDays, format } from "date-fns"
import { Calendar as CalendarIcon } from "lucide-react"
import { DateRange } from "react-day-picker"
import { cn } from "@/lib/utils"
import { Button } from "@/registry/default/ui/button"
import { Calendar } from "@/registry/default/ui/calendar"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/registry/default/ui/popover"
export default function DatePickerWithRange({
className,
}: React.HTMLAttributes<HTMLDivElement>) {
const [date, setDate] = React.useState<DateRange | undefined>({
from: new Date(2022, 0, 20),
to: addDays(new Date(2022, 0, 20), 20),
})
return (
<div className={cn("grid gap-2", className)}>
<Popover>
<PopoverTrigger asChild>
<Button
id="date"
variant={"outline"}
className={cn(
"w-[300px] justify-start text-left font-normal",
!date && "text-muted-foreground"
)}
>
<CalendarIcon className="mr-2 h-4 w-4" />
{date?.from ? (
date.to ? (
<>
{format(date.from, "LLL dd, y")} -{" "}
{format(date.to, "LLL dd, y")}
</>
) : (
format(date.from, "LLL dd, y")
)
) : (
<span>Pick a date</span>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
initialFocus
mode="range"
defaultMonth={date?.from}
selected={date}
onSelect={setDate}
numberOfMonths={2}
/>
</PopoverContent>
</Popover>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/date-picker-with-range.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/date-picker-with-range.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 928
} | 124 |
import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp"
import {
InputOTP,
InputOTPGroup,
InputOTPSlot,
} from "@/registry/default/ui/input-otp"
export default function InputOTPPattern() {
return (
<InputOTP maxLength={6} pattern={REGEXP_ONLY_DIGITS_AND_CHARS}>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/input-otp-pattern.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/input-otp-pattern.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 259
} | 125 |
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/registry/default/ui/resizable"
export default function ResizableDemo() {
return (
<ResizablePanelGroup
direction="horizontal"
className="min-h-[200px] max-w-md rounded-lg border md:min-w-[450px]"
>
<ResizablePanel defaultSize={25}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Sidebar</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize={75}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Content</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/resizable-handle.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/resizable-handle.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 321
} | 126 |
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/registry/default/ui/table"
const invoices = [
{
invoice: "INV001",
paymentStatus: "Paid",
totalAmount: "$250.00",
paymentMethod: "Credit Card",
},
{
invoice: "INV002",
paymentStatus: "Pending",
totalAmount: "$150.00",
paymentMethod: "PayPal",
},
{
invoice: "INV003",
paymentStatus: "Unpaid",
totalAmount: "$350.00",
paymentMethod: "Bank Transfer",
},
{
invoice: "INV004",
paymentStatus: "Paid",
totalAmount: "$450.00",
paymentMethod: "Credit Card",
},
{
invoice: "INV005",
paymentStatus: "Paid",
totalAmount: "$550.00",
paymentMethod: "PayPal",
},
{
invoice: "INV006",
paymentStatus: "Pending",
totalAmount: "$200.00",
paymentMethod: "Bank Transfer",
},
{
invoice: "INV007",
paymentStatus: "Unpaid",
totalAmount: "$300.00",
paymentMethod: "Credit Card",
},
]
export default function TableDemo() {
return (
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.invoice}>
<TableCell className="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.paymentStatus}</TableCell>
<TableCell>{invoice.paymentMethod}</TableCell>
<TableCell className="text-right">{invoice.totalAmount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="text-right">$2,500.00</TableCell>
</TableRow>
</TableFooter>
</Table>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/table-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/table-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 924
} | 127 |
export default function TypographyInlineCode() {
return (
<code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold">
@radix-ui/react-alert-dialog
</code>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/typography-inline-code.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/typography-inline-code.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 89
} | 128 |
"use client"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/registry/new-york/ui/card"
import { Progress } from "@/registry/new-york/ui/progress"
export default function Component() {
return (
<Card x-chunk="dashboard-05-chunk-1">
<CardHeader className="pb-2">
<CardDescription>This Week</CardDescription>
<CardTitle className="text-4xl">$1,329</CardTitle>
</CardHeader>
<CardContent>
<div className="text-xs text-muted-foreground">+25% from last week</div>
</CardContent>
<CardFooter>
<Progress value={25} aria-label="25% increase" />
</CardFooter>
</Card>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-05-chunk-1.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-05-chunk-1.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 292
} | 129 |
import { ChevronRightIcon } from "@radix-ui/react-icons"
import { Button } from "@/registry/new-york/ui/button"
export default function ButtonIcon() {
return (
<Button variant="outline" size="icon">
<ChevronRightIcon className="h-4 w-4" />
</Button>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/button-icon.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/button-icon.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 102
} | 130 |
import { CardsActivityGoal } from "@/registry/new-york/example/cards/activity-goal"
import { CardsCalendar } from "@/registry/new-york/example/cards/calendar"
import { CardsChat } from "@/registry/new-york/example/cards/chat"
import { CardsCookieSettings } from "@/registry/new-york/example/cards/cookie-settings"
import { CardsCreateAccount } from "@/registry/new-york/example/cards/create-account"
import { CardsDataTable } from "@/registry/new-york/example/cards/data-table"
import { CardsMetric } from "@/registry/new-york/example/cards/metric"
import { CardsPaymentMethod } from "@/registry/new-york/example/cards/payment-method"
import { CardsReportIssue } from "@/registry/new-york/example/cards/report-issue"
import { CardsShare } from "@/registry/new-york/example/cards/share"
import { CardsStats } from "@/registry/new-york/example/cards/stats"
import { CardsTeamMembers } from "@/registry/new-york/example/cards/team-members"
export default function CardsDemo() {
return (
<div className="md:grids-col-2 grid md:gap-4 lg:grid-cols-10 xl:grid-cols-11 xl:gap-4">
<div className="space-y-4 lg:col-span-4 xl:col-span-6 xl:space-y-4">
<CardsStats />
<div className="grid gap-1 sm:grid-cols-[260px_1fr] md:hidden">
<CardsCalendar />
<div className="pt-3 sm:pl-2 sm:pt-0 xl:pl-4">
<CardsActivityGoal />
</div>
<div className="pt-3 sm:col-span-2 xl:pt-4">
<CardsMetric />
</div>
</div>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">
<div className="space-y-4 xl:space-y-4">
<CardsTeamMembers />
<CardsCookieSettings />
<CardsPaymentMethod />
</div>
<div className="space-y-4 xl:space-y-4">
<CardsChat />
<CardsCreateAccount />
<div className="hidden xl:block">
<CardsReportIssue />
</div>
</div>
</div>
</div>
<div className="space-y-4 lg:col-span-6 xl:col-span-5 xl:space-y-4">
<div className="hidden gap-1 sm:grid-cols-[260px_1fr] md:grid">
<CardsCalendar />
<div className="pt-3 sm:pl-2 sm:pt-0 xl:pl-3">
<CardsActivityGoal />
</div>
<div className="pt-3 sm:col-span-2 xl:pt-3">
<CardsMetric />
</div>
</div>
<div className="hidden md:block">
<CardsDataTable />
</div>
<CardsShare />
<div className="xl:hidden">
<CardsReportIssue />
</div>
</div>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/cards/index.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/cards/index.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1261
} | 131 |
"use client"
import * as React from "react"
import { Progress } from "@/registry/new-york/ui/progress"
export default function ProgressDemo() {
const [progress, setProgress] = React.useState(13)
React.useEffect(() => {
const timer = setTimeout(() => setProgress(66), 500)
return () => clearTimeout(timer)
}, [])
return <Progress value={progress} className="w-[60%]" />
}
| shadcn-ui/ui/apps/www/registry/new-york/example/progress-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/progress-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 129
} | 132 |
"use client"
import * as React from "react"
import * as AccordionPrimitive from "@radix-ui/react-accordion"
import { ChevronDownIcon } from "@radix-ui/react-icons"
import { cn } from "@/lib/utils"
const Accordion = AccordionPrimitive.Root
const AccordionItem = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn("border-b", className)}
{...props}
/>
))
AccordionItem.displayName = "AccordionItem"
const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
>
{children}
<ChevronDownIcon className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
))
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
const AccordionContent = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Content
ref={ref}
className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
{...props}
>
<div className={cn("pb-4 pt-0", className)}>{children}</div>
</AccordionPrimitive.Content>
))
AccordionContent.displayName = AccordionPrimitive.Content.displayName
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
| shadcn-ui/ui/apps/www/registry/new-york/ui/accordion.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/ui/accordion.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 705
} | 133 |
"use client"
import * as React from "react"
import {
CaretSortIcon,
CheckIcon,
ChevronDownIcon,
ChevronUpIcon,
} from "@radix-ui/react-icons"
import * as SelectPrimitive from "@radix-ui/react-select"
import { cn } from "@/lib/utils"
const Select = SelectPrimitive.Root
const SelectGroup = SelectPrimitive.Group
const SelectValue = SelectPrimitive.Value
const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
className={cn(
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
className
)}
{...props}
>
{children}
<SelectPrimitive.Icon asChild>
<CaretSortIcon className="h-4 w-4 opacity-50" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
))
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
const SelectScrollUpButton = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollUpButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronUpIcon />
</SelectPrimitive.ScrollUpButton>
))
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
const SelectScrollDownButton = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollDownButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronDownIcon />
</SelectPrimitive.ScrollDownButton>
))
SelectScrollDownButton.displayName =
SelectPrimitive.ScrollDownButton.displayName
const SelectContent = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
>(({ className, children, position = "popper", ...props }, ref) => (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
ref={ref}
className={cn(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className
)}
position={position}
{...props}
>
<SelectScrollUpButton />
<SelectPrimitive.Viewport
className={cn(
"p-1",
position === "popper" &&
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
)}
>
{children}
</SelectPrimitive.Viewport>
<SelectScrollDownButton />
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
))
SelectContent.displayName = SelectPrimitive.Content.displayName
const SelectLabel = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
>(({ className, ...props }, ref) => (
<SelectPrimitive.Label
ref={ref}
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
{...props}
/>
))
SelectLabel.displayName = SelectPrimitive.Label.displayName
const SelectItem = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Item
ref={ref}
className={cn(
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
{...props}
>
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<CheckIcon className="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
))
SelectItem.displayName = SelectPrimitive.Item.displayName
const SelectSeparator = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
>(({ className, ...props }, ref) => (
<SelectPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
/>
))
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
export {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
}
| shadcn-ui/ui/apps/www/registry/new-york/ui/select.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/ui/select.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 2056
} | 134 |
import { Registry } from "@/registry/schema"
export const blocks: Registry = [
{
name: "sidebar-01",
description:
"A collapsible sidebar with workspace switcher, main navigation, secondary navigation, project navigation, and user navigation.",
type: "registry:block",
registryDependencies: [
"avatar",
"button",
"collapsible",
"dropdown-menu",
"drawer",
"separator",
"input",
"popover",
"sheet",
"progress",
"card",
"use-mobile",
],
files: [
{
path: "block/sidebar-01/page.tsx",
type: "registry:page",
target: "app/dashboard/page.tsx",
},
{
path: "block/sidebar-01/components/app-sidebar.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/components/nav-main.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/components/nav-projects.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/components/nav-secondary.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/components/nav-user.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/components/storage-card.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/components/team-switcher.tsx",
type: "registry:component",
},
{
path: "block/sidebar-01/hooks/use-sidebar.tsx",
type: "registry:hook",
},
{
path: "block/sidebar-01/ui/sidebar.tsx",
type: "registry:ui",
},
],
category: "Application",
subcategory: "Dashboard",
},
{
name: "login-01",
type: "registry:block",
registryDependencies: ["button", "card", "input", "label"],
files: [
{
path: "block/login-01/page.tsx",
target: "app/login/page.tsx",
type: "registry:page",
},
{
path: "block/login-01/components/login-form.tsx",
type: "registry:component",
},
],
category: "Authentication",
subcategory: "Login",
},
{
name: "charts-01",
type: "registry:block",
registryDependencies: ["chart"],
files: ["block/charts-01.tsx"],
category: "Application",
subcategory: "Charts",
},
{
name: "dashboard-05",
type: "registry:block",
registryDependencies: [
"badge",
"breadcrumb",
"button",
"card",
"dropdown-menu",
"input",
"pagination",
"progress",
"separator",
"sheet",
"table",
"tabs",
"tooltip",
],
files: ["block/dashboard-05.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "dashboard-06",
type: "registry:block",
registryDependencies: [
"badge",
"breadcrumb",
"button",
"card",
"dropdown-menu",
"input",
"sheet",
"table",
"tabs",
"tooltip",
],
files: ["block/dashboard-06.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "dashboard-07",
type: "registry:block",
registryDependencies: [
"badge",
"breadcrumb",
"button",
"card",
"dropdown-menu",
"input",
"pagination",
"progress",
"separator",
"sheet",
"table",
"tabs",
"tooltip",
],
files: ["block/dashboard-07.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "dashboard-04",
type: "registry:block",
registryDependencies: ["button", "card", "dropdown-menu", "input"],
files: ["block/dashboard-04.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "dashboard-03",
type: "registry:block",
registryDependencies: [
"badge",
"button",
"drawer",
"input",
"label",
"select",
"textarea",
"tooltip",
],
files: ["block/dashboard-03.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "dashboard-02",
type: "registry:block",
registryDependencies: ["badge", "button", "card", "dropdown-menu", "input"],
files: ["block/dashboard-02.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "dashboard-01",
type: "registry:block",
registryDependencies: ["button", "dropdown-menu", "input", "sheet"],
files: ["block/dashboard-01.tsx"],
category: "Application",
subcategory: "Dashboard",
},
{
name: "authentication-01",
type: "registry:block",
registryDependencies: ["button", "card", "input", "label"],
files: ["block/authentication-01.tsx"],
category: "Authentication",
subcategory: "Login",
},
{
name: "authentication-02",
type: "registry:block",
registryDependencies: ["button", "card", "input", "label"],
files: ["block/authentication-02.tsx"],
category: "Authentication",
subcategory: "Login",
},
{
name: "authentication-03",
type: "registry:block",
registryDependencies: ["button", "card", "input", "label"],
files: ["block/authentication-03.tsx"],
category: "Authentication",
subcategory: "Login",
},
{
name: "authentication-04",
type: "registry:block",
registryDependencies: ["button", "card", "input", "label"],
files: ["block/authentication-04.tsx"],
category: "Authentication",
subcategory: "Login",
},
]
| shadcn-ui/ui/apps/www/registry/registry-blocks.ts | {
"file_path": "shadcn-ui/ui/apps/www/registry/registry-blocks.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 2530
} | 135 |
import { Icons } from "@/components/icons"
export interface NavItem {
title: string
href?: string
disabled?: boolean
external?: boolean
icon?: keyof typeof Icons
label?: string
}
export interface NavItemWithChildren extends NavItem {
items: NavItemWithChildren[]
}
export interface MainNavItem extends NavItem {}
export interface SidebarNavItem extends NavItemWithChildren {}
| shadcn-ui/ui/apps/www/types/nav.ts | {
"file_path": "shadcn-ui/ui/apps/www/types/nav.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 106
} | 136 |
import { existsSync } from "fs"
import path from "path"
import {
Config,
RawConfig,
getConfig,
resolveConfigPaths,
} from "@/src/utils/get-config"
import fg from "fast-glob"
import fs, { pathExists } from "fs-extra"
import { loadConfig } from "tsconfig-paths"
// TODO: Add support for more frameworks.
// We'll start with Next.js for now.
const PROJECT_TYPES = [
"next-app",
"next-app-src",
"next-pages",
"next-pages-src",
] as const
type ProjectType = (typeof PROJECT_TYPES)[number]
const PROJECT_SHARED_IGNORE = [
"**/node_modules/**",
".next",
"public",
"dist",
"build",
]
export async function getProjectInfo() {
const info = {
tsconfig: null,
srcDir: false,
appDir: false,
srcComponentsUiDir: false,
componentsUiDir: false,
}
try {
const tsconfig = await getTsConfig()
return {
tsconfig,
srcDir: existsSync(path.resolve("./src")),
appDir:
existsSync(path.resolve("./app")) ||
existsSync(path.resolve("./src/app")),
srcComponentsUiDir: existsSync(path.resolve("./src/components/ui")),
componentsUiDir: existsSync(path.resolve("./components/ui")),
}
} catch (error) {
return info
}
}
export async function getTsConfig() {
try {
const tsconfigPath = path.join("tsconfig.json")
const tsconfig = await fs.readJSON(tsconfigPath)
if (!tsconfig) {
throw new Error("tsconfig.json is missing")
}
return tsconfig
} catch (error) {
return null
}
}
export async function getProjectConfig(cwd: string): Promise<Config | null> {
// Check for existing component config.
const existingConfig = await getConfig(cwd)
if (existingConfig) {
return existingConfig
}
const projectType = await getProjectType(cwd)
const tailwindCssFile = await getTailwindCssFile(cwd)
const tsConfigAliasPrefix = await getTsConfigAliasPrefix(cwd)
if (!projectType || !tailwindCssFile || !tsConfigAliasPrefix) {
return null
}
const isTsx = await isTypeScriptProject(cwd)
const config: RawConfig = {
$schema: "https://ui.shadcn.com/schema.json",
rsc: ["next-app", "next-app-src"].includes(projectType),
tsx: isTsx,
style: "new-york",
tailwind: {
config: isTsx ? "tailwind.config.ts" : "tailwind.config.js",
baseColor: "zinc",
css: tailwindCssFile,
cssVariables: true,
prefix: "",
},
aliases: {
utils: `${tsConfigAliasPrefix}/lib/utils`,
components: `${tsConfigAliasPrefix}/components`,
},
}
return await resolveConfigPaths(cwd, config)
}
export async function getProjectType(cwd: string): Promise<ProjectType | null> {
const files = await fg.glob("**/*", {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
})
const isNextProject = files.find((file) => file.startsWith("next.config."))
if (!isNextProject) {
return null
}
const isUsingSrcDir = await fs.pathExists(path.resolve(cwd, "src"))
const isUsingAppDir = await fs.pathExists(
path.resolve(cwd, `${isUsingSrcDir ? "src/" : ""}app`)
)
if (isUsingAppDir) {
return isUsingSrcDir ? "next-app-src" : "next-app"
}
return isUsingSrcDir ? "next-pages-src" : "next-pages"
}
export async function getTailwindCssFile(cwd: string) {
const files = await fg.glob(["**/*.css", "**/*.scss"], {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
})
if (!files.length) {
return null
}
for (const file of files) {
const contents = await fs.readFile(path.resolve(cwd, file), "utf8")
// Assume that if the file contains `@tailwind base` it's the main css file.
if (contents.includes("@tailwind base")) {
return file
}
}
return null
}
export async function getTsConfigAliasPrefix(cwd: string) {
const tsConfig = await loadConfig(cwd)
if (tsConfig?.resultType === "failed" || !tsConfig?.paths) {
return null
}
// This assume that the first alias is the prefix.
for (const [alias, paths] of Object.entries(tsConfig.paths)) {
if (paths.includes("./*") || paths.includes("./src/*")) {
return alias.at(0)
}
}
return null
}
export async function isTypeScriptProject(cwd: string) {
// Check if cwd has a tsconfig.json file.
return pathExists(path.resolve(cwd, "tsconfig.json"))
}
export async function preFlight(cwd: string) {
// We need Tailwind CSS to be configured.
const tailwindConfig = await fg.glob("tailwind.config.*", {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
})
if (!tailwindConfig.length) {
throw new Error(
"Tailwind CSS is not installed. Visit https://tailwindcss.com/docs/installation to get started."
)
}
return true
}
| shadcn-ui/ui/packages/cli/src/utils/get-project-info.ts | {
"file_path": "shadcn-ui/ui/packages/cli/src/utils/get-project-info.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 1806
} | 137 |
import path from "path"
import { expect, test } from "vitest"
import { getPackageManager } from "../../src/utils/get-package-manager"
test("get package manager", async () => {
expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/project-yarn"))
).toBe("yarn")
expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/project-npm"))
).toBe("npm")
expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/project-pnpm"))
).toBe("pnpm")
expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/project-bun"))
).toBe("bun")
expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/next"))
).toBe("pnpm")
})
| shadcn-ui/ui/packages/cli/test/utils/get-package-manager.test.ts | {
"file_path": "shadcn-ui/ui/packages/cli/test/utils/get-package-manager.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 258
} | 138 |
import { highlighter } from "@/src/utils/highlighter"
import { logger } from "@/src/utils/logger"
import { z } from "zod"
export function handleError(error: unknown) {
logger.error(
`Something went wrong. Please check the error below for more details.`
)
logger.error(`If the problem persists, please open an issue on GitHub.`)
logger.error("")
if (typeof error === "string") {
logger.error(error)
logger.break()
process.exit(1)
}
if (error instanceof z.ZodError) {
logger.error("Validation failed:")
for (const [key, value] of Object.entries(error.flatten().fieldErrors)) {
logger.error(`- ${highlighter.info(key)}: ${value}`)
}
logger.break()
process.exit(1)
}
if (error instanceof Error) {
logger.error(error.message)
logger.break()
process.exit(1)
}
logger.break()
process.exit(1)
}
| shadcn-ui/ui/packages/shadcn/src/utils/handle-error.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/src/utils/handle-error.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 321
} | 139 |
import { Config } from "@/src/utils/get-config"
import { getPackageManager } from "@/src/utils/get-package-manager"
import { RegistryItem } from "@/src/utils/registry/schema"
import { spinner } from "@/src/utils/spinner"
import { execa } from "execa"
export async function updateDependencies(
dependencies: RegistryItem["dependencies"],
config: Config,
options: {
silent?: boolean
}
) {
dependencies = Array.from(new Set(dependencies))
if (!dependencies?.length) {
return
}
options = {
silent: false,
...options,
}
const dependenciesSpinner = spinner(`Installing dependencies.`, {
silent: options.silent,
})?.start()
const packageManager = await getPackageManager(config.resolvedPaths.cwd)
await execa(
packageManager,
[packageManager === "npm" ? "install" : "add", ...dependencies],
{
cwd: config.resolvedPaths.cwd,
}
)
dependenciesSpinner?.succeed()
}
| shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-dependencies.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-dependencies.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 320
} | 140 |
// @ts-nocheck
import type { Config } from 'tailwindcss'
const config: Config = {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}'
],
theme: {
extend: {
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))'
}
}
},
plugins: []
}
export default config
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages-src/tailwind.config.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages-src/tailwind.config.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 246
} | 141 |
/**
* This is intended to be a basic starting point for linting in the Indie Stack.
* It relies on recommended configs out of the box for simplicity, but you can
* and should modify this configuration to best suit your team's needs.
*/
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},
// Base config
extends: ["eslint:recommended"],
overrides: [
// React
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: ["react", "jsx-a11y"],
extends: [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
"prettier",
],
settings: {
react: {
version: "detect",
},
formComponents: ["Form"],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
],
},
rules: {
"react/jsx-no-leaked-render": [
"warn",
{ validStrategies: ["ternary"] },
],
},
},
// Typescript
{
files: ["**/*.{ts,tsx}"],
plugins: ["@typescript-eslint", "import"],
parser: "@typescript-eslint/parser",
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
node: {
extensions: [".ts", ".tsx"],
},
typescript: {
alwaysTryTypes: true,
},
},
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/stylistic",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
],
rules: {
"import/order": [
"error",
{
alphabetize: { caseInsensitive: true, order: "asc" },
groups: ["builtin", "external", "internal", "parent", "sibling"],
"newlines-between": "always",
},
],
},
},
// Markdown
{
files: ["**/*.md"],
plugins: ["markdown"],
extends: ["plugin:markdown/recommended-legacy", "prettier"],
},
// Jest/Vitest
{
files: ["**/*.test.{js,jsx,ts,tsx}"],
plugins: ["jest", "jest-dom", "testing-library"],
extends: [
"plugin:jest/recommended",
"plugin:jest-dom/recommended",
"plugin:testing-library/react",
"prettier",
],
env: {
"jest/globals": true,
},
settings: {
jest: {
// we're using vitest which has a very similar API to jest
// (so the linting plugins work nicely), but it means we have to explicitly
// set the jest version.
version: 28,
},
},
},
// Cypress
{
files: ["cypress/**/*.ts"],
plugins: ["cypress"],
extends: ["plugin:cypress/recommended", "prettier"],
},
// Node
{
files: [".eslintrc.js", "mocks/**/*.js"],
env: {
node: true,
},
},
],
};
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/.eslintrc.js | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/.eslintrc.js",
"repo_id": "shadcn-ui/ui",
"token_count": 1586
} | 142 |
import { createCookieSessionStorage, redirect } from "@remix-run/node";
import invariant from "tiny-invariant";
import type { User } from "~/models/user.server";
import { getUserById } from "~/models/user.server";
invariant(process.env.SESSION_SECRET, "SESSION_SECRET must be set");
export const sessionStorage = createCookieSessionStorage({
cookie: {
name: "__session",
httpOnly: true,
path: "/",
sameSite: "lax",
secrets: [process.env.SESSION_SECRET],
secure: process.env.NODE_ENV === "production",
},
});
const USER_SESSION_KEY = "userId";
export async function getSession(request: Request) {
const cookie = request.headers.get("Cookie");
return sessionStorage.getSession(cookie);
}
export async function getUserId(
request: Request,
): Promise<User["id"] | undefined> {
const session = await getSession(request);
const userId = session.get(USER_SESSION_KEY);
return userId;
}
export async function getUser(request: Request) {
const userId = await getUserId(request);
if (userId === undefined) return null;
const user = await getUserById(userId);
if (user) return user;
throw await logout(request);
}
export async function requireUserId(
request: Request,
redirectTo: string = new URL(request.url).pathname,
) {
const userId = await getUserId(request);
if (!userId) {
const searchParams = new URLSearchParams([["redirectTo", redirectTo]]);
throw redirect(`/login?${searchParams}`);
}
return userId;
}
export async function requireUser(request: Request) {
const userId = await requireUserId(request);
const user = await getUserById(userId);
if (user) return user;
throw await logout(request);
}
export async function createUserSession({
request,
userId,
remember,
redirectTo,
}: {
request: Request;
userId: string;
remember: boolean;
redirectTo: string;
}) {
const session = await getSession(request);
session.set(USER_SESSION_KEY, userId);
return redirect(redirectTo, {
headers: {
"Set-Cookie": await sessionStorage.commitSession(session, {
maxAge: remember
? 60 * 60 * 24 * 7 // 7 days
: undefined,
}),
},
});
}
export async function logout(request: Request) {
const session = await getSession(request);
return redirect("/", {
headers: {
"Set-Cookie": await sessionStorage.destroySession(session),
},
});
}
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/session.server.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/session.server.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 806
} | 143 |
const { http, passthrough } = require("msw");
const { setupServer } = require("msw/node");
// put one-off handlers that don't really need an entire file to themselves here
const miscHandlers = [
http.post(`${process.env.REMIX_DEV_HTTP_ORIGIN}/ping`, () => passthrough()),
];
const server = setupServer(...miscHandlers);
server.listen({ onUnhandledRequest: "bypass" });
console.info(" Mock server running");
process.once("SIGINT", () => server.close());
process.once("SIGTERM", () => server.close());
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/mocks/index.js | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/mocks/index.js",
"repo_id": "shadcn-ui/ui",
"token_count": 162
} | 144 |
import { installGlobals } from "@remix-run/node";
import "@testing-library/jest-dom/vitest";
installGlobals();
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/test/setup-test-env.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/test/setup-test-env.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 40
} | 145 |
const config = {
plugins: {
tailwindcss: {},
},
};
module.exports = config;
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/t3-app/postcss.config.cjs | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/t3-app/postcss.config.cjs",
"repo_id": "shadcn-ui/ui",
"token_count": 34
} | 146 |
import { type Config } from "tailwindcss";
export default {
content: ["./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
} satisfies Config;
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/t3-pages/tailwind.config.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/t3-pages/tailwind.config.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 67
} | 147 |
import path from "path"
import { expect, test } from "vitest"
import { getConfig } from "../../src/utils/get-config"
import { getItemTargetPath } from "../../src/utils/registry"
test("get item target path", async () => {
// Full config.
let appDir = path.resolve(__dirname, "../fixtures/config-full")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./src/ui"))
// Partial config.
appDir = path.resolve(__dirname, "../fixtures/config-partial")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./components/ui"))
// JSX.
appDir = path.resolve(__dirname, "../fixtures/config-jsx")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./components/ui"))
// Custom paths.
appDir = path.resolve(__dirname, "../fixtures/config-ui")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./src/ui"))
})
| shadcn-ui/ui/packages/shadcn/test/utils/get-item-target-path.test.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/utils/get-item-target-path.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 445
} | 148 |
import tsconfigPaths from "vite-tsconfig-paths"
import { configDefaults, defineConfig } from "vitest/config"
export default defineConfig({
test: {
exclude: [
...configDefaults.exclude,
"**/node_modules/**",
"**/fixtures/**",
],
},
plugins: [tsconfigPaths()],
})
| shadcn-ui/ui/vitest.config.ts | {
"file_path": "shadcn-ui/ui/vitest.config.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 116
} | 149 |
'use client'
import { useState, useEffect } from 'react'
import { ScrollArea } from "@/components/ui/scroll-area"
import { Menu, FileText, MessageSquare, LayoutDashboard, Palette, Book, Grid, Rocket, ShoppingCart, Mail, Box, Briefcase, Zap, Camera, BookOpen, List, Clock, Quote, ChevronRight, StickyNoteIcon, PaintBucketIcon, PuzzleIcon, LucideGitBranchPlus, KeyIcon, Command, TextCursorIcon } from 'lucide-react'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import EzBlog from '../(docs)/ez-blog/page'
import IntroductionPage from '../(docs)/introduction/page'
import CreateNewComponentt from '../(docs)/create-new-component/page'
import LaunchpadComponent from '../(docs)/launchpad-component/page'
import KeyButton from '@/components/easyui/key-button'
import { KeyboardIcon, StarFilledIcon, StarIcon } from '@radix-ui/react-icons'
import SparkleButton from '@/components/easyui/sparkle-button'
import KeyButtonComponent from '../(docs)/key-button-component/page'
import SparkleButtonComponent from '../(docs)/sparkle-button-component/page'
import { CommandShortcut } from '@/components/ui/command'
import SearchCommand from '@/components/easyui/search-command'
import SearchCommandComponent from '../(docs)/search-command-component/page'
import GlitchTextComponent from '../(docs)/glitch-text-component/page'
interface Item {
name: string;
isNew?: boolean;
isPaid?: boolean;
}
const components: Item[] = [
{ name: 'introduction' },
{ name: 'create-new', isNew: true },
{ name: 'launchpad', isNew: true},
{ name: 'key button', isNew: true},
{ name: 'sparkle button', isNew: true},
{ name: 'command search', isNew: true},
{ name: 'glitch text', isNew: true},
]
export default function TemplatePage() {
const [selectedItem, setSelectedItem] = useState('create-new')
const [isLargeScreen, setIsLargeScreen] = useState(true)
useEffect(() => {
const checkScreenSize = () => {
setIsLargeScreen(window.innerWidth >= 1024)
}
checkScreenSize()
window.addEventListener('resize', checkScreenSize)
return () => window.removeEventListener('resize', checkScreenSize)
}, [])
const handleItemClick = (item: string) => {
setSelectedItem(item)
}
const renderComponent = (componentName: string) => {
switch (componentName) {
case 'introduction':
return <IntroductionPage />
case 'create-new':
return <CreateNewComponentt />
case 'launchpad':
return <LaunchpadComponent />
case 'key button':
return <KeyButtonComponent />
case 'sparkle button':
return <SparkleButtonComponent />
case 'command search':
return <SearchCommandComponent />
case 'glitch text':
return <GlitchTextComponent />
default:
return <div>Component not found</div>
}
}
const getIcon = (name: string) => {
switch (name) {
case 'create-new': return <FileText className="mr-2 h-4 w-4" />
case 'launchpad': return <LucideGitBranchPlus className="mr-2 h-4 w-4" />
case 'key button': return <KeyboardIcon className="mr-2 h-4 w-4" />
case 'sparkle button': return <StarIcon className="mr-2 h-4 w-4" />
case 'command search': return <Command className="mr-2 h-4 w-4" />
case 'glitch text': return <TextCursorIcon className="mr-2 h-4 w-4" />
default: return <ChevronRight className="mr-2 h-4 w-4" />
}
}
const renderPaidBadge = (isNew?: boolean) => {
if (isNew) {
return <span className="ml-2 rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-800">New</span>
}
return null
}
return (
<div className="flex flex h-screen">
{isLargeScreen ? (
<>
<ScrollArea className="w-64">
<div className="p-4">
<h2 className="mb-2 px-4 text-lg font-semibold tracking-tight">
Getting Started
</h2>
{components.map((item) => (
<Button
key={item.name}
variant={selectedItem === item.name ? 'secondary' : 'ghost'}
className="w-full justify-start"
onClick={() => handleItemClick(item.name)}
>
{getIcon(item.name)}
{item.name}
{renderPaidBadge(item.isNew)}
</Button>
))}
</div>
</ScrollArea>
<div className="flex-1 overflow-auto">
{renderComponent(selectedItem)}
</div>
</>
) : (
<div className="flex flex-col flex-1 overflow-auto h-screen">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" className="w-full justify-between px-4 py-2">
<span className="flex items-center">
{getIcon(selectedItem)}
{selectedItem}
</span>
<Menu className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-screen max-h-[calc(100vh-200px)] overflow-auto h-screen">
{components.map((item) => (
<DropdownMenuItem key={item.name} onSelect={() => handleItemClick(item.name)}>
<span className="flex items-center w-full">
{getIcon(item.name)}
{item.name}
{renderPaidBadge(item.isNew)}
</span>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
<div className="flex-1 px-1 overflow-auto">
{renderComponent(selectedItem)}
</div>
</div>
)}
</div>
)
} | DarkInventor/easy-ui/app/component/page.tsx | {
"file_path": "DarkInventor/easy-ui/app/component/page.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 2423
} | 0 |
'use client'
import { DiscussionEmbed } from 'disqus-react'
interface DisqusCommentsProps {
url: string
identifier: string
title: string
}
export default function DisqusComments({ url, identifier, title }: DisqusCommentsProps) {
return (
<DiscussionEmbed
shortname="your-disqus-shortname"
config={{
url: url,
identifier: identifier,
title: title,
}}
/>
)
} | DarkInventor/easy-ui/components/DisqusComments.tsx | {
"file_path": "DarkInventor/easy-ui/components/DisqusComments.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 159
} | 1 |
"use client";
import { cn } from "@/lib/utils";
import { motion } from "framer-motion";
import { RefObject, useEffect, useId, useState } from "react";
export interface AnimatedBeamProps {
className?: string;
containerRef: RefObject<HTMLElement>; // Container ref
fromRef: RefObject<HTMLElement>;
toRef: RefObject<HTMLElement>;
curvature?: number;
reverse?: boolean;
pathColor?: string;
pathWidth?: number;
pathOpacity?: number;
gradientStartColor?: string;
gradientStopColor?: string;
delay?: number;
duration?: number;
startXOffset?: number;
startYOffset?: number;
endXOffset?: number;
endYOffset?: number;
}
export const AnimatedBeam: React.FC<AnimatedBeamProps> = ({
className,
containerRef,
fromRef,
toRef,
curvature = 0,
reverse = false, // Include the reverse prop
duration = Math.random() * 3 + 4,
delay = 0,
pathColor = "gray",
pathWidth = 2,
pathOpacity = 0.2,
gradientStartColor = "#ffaa40",
gradientStopColor = "#9c40ff",
startXOffset = 0,
startYOffset = 0,
endXOffset = 0,
endYOffset = 0,
}) => {
const id = useId();
const [pathD, setPathD] = useState("");
const [svgDimensions, setSvgDimensions] = useState({ width: 0, height: 0 });
// Calculate the gradient coordinates based on the reverse prop
const gradientCoordinates = reverse
? {
x1: ["90%", "-10%"],
x2: ["100%", "0%"],
y1: ["0%", "0%"],
y2: ["0%", "0%"],
}
: {
x1: ["10%", "110%"],
x2: ["0%", "100%"],
y1: ["0%", "0%"],
y2: ["0%", "0%"],
};
useEffect(() => {
const updatePath = () => {
if (containerRef.current && fromRef.current && toRef.current) {
const containerRect = containerRef.current.getBoundingClientRect();
const rectA = fromRef.current.getBoundingClientRect();
const rectB = toRef.current.getBoundingClientRect();
const svgWidth = containerRect.width;
const svgHeight = containerRect.height;
setSvgDimensions({ width: svgWidth, height: svgHeight });
const startX =
rectA.left - containerRect.left + rectA.width / 2 + startXOffset;
const startY =
rectA.top - containerRect.top + rectA.height / 2 + startYOffset;
const endX =
rectB.left - containerRect.left + rectB.width / 2 + endXOffset;
const endY =
rectB.top - containerRect.top + rectB.height / 2 + endYOffset;
const controlY = startY - curvature;
const d = `M ${startX},${startY} Q ${
(startX + endX) / 2
},${controlY} ${endX},${endY}`;
setPathD(d);
}
};
// Initialize ResizeObserver
const resizeObserver = new ResizeObserver((entries) => {
// For all entries, recalculate the path
for (let entry of entries) {
updatePath();
}
});
// Observe the container element
if (containerRef.current) {
resizeObserver.observe(containerRef.current);
}
// Call the updatePath initially to set the initial path
updatePath();
// Clean up the observer on component unmount
return () => {
resizeObserver.disconnect();
};
}, [
containerRef,
fromRef,
toRef,
curvature,
startXOffset,
startYOffset,
endXOffset,
endYOffset,
]);
return (
<svg
fill="none"
width={svgDimensions.width}
height={svgDimensions.height}
xmlns="http://www.w3.org/2000/svg"
className={cn(
"pointer-events-none absolute left-0 top-0 transform-gpu stroke-2",
className,
)}
viewBox={`0 0 ${svgDimensions.width} ${svgDimensions.height}`}
>
<path
d={pathD}
stroke={pathColor}
strokeWidth={pathWidth}
strokeOpacity={pathOpacity}
strokeLinecap="round"
/>
<path
d={pathD}
strokeWidth={pathWidth}
stroke={`url(#${id})`}
strokeOpacity="1"
strokeLinecap="round"
/>
<defs>
<motion.linearGradient
className="transform-gpu"
id={id}
gradientUnits={"userSpaceOnUse"}
initial={{
x1: "0%",
x2: "0%",
y1: "0%",
y2: "0%",
}}
animate={{
x1: gradientCoordinates.x1,
x2: gradientCoordinates.x2,
y1: gradientCoordinates.y1,
y2: gradientCoordinates.y2,
}}
transition={{
delay,
duration,
ease: [0.16, 1, 0.3, 1], // https://easings.net/#easeOutExpo
repeat: Infinity,
repeatDelay: 0,
}}
>
<stop stopColor={gradientStartColor} stopOpacity="0"></stop>
<stop stopColor={gradientStartColor}></stop>
<stop offset="32.5%" stopColor={gradientStopColor}></stop>
<stop
offset="100%"
stopColor={gradientStopColor}
stopOpacity="0"
></stop>
</motion.linearGradient>
</defs>
</svg>
);
};
| DarkInventor/easy-ui/components/magicui/animated-beam.tsx | {
"file_path": "DarkInventor/easy-ui/components/magicui/animated-beam.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 2297
} | 2 |
import Link from "next/link"
import { ChevronRightIcon } from "@radix-ui/react-icons"
import Marquee from "./magicui/marquee"
export interface ShowcaseCardProps {
title: string
image: string
href: string
affiliation?: string
}
export function ShowcaseCard({
title,
image,
href,
affiliation,
}: ShowcaseCardProps) {
return (
<Link
href={href}
className="flex flex-col gap-2 group relative overflow-hidden cursor-pointer"
>
<img
src={image}
alt={title}
width={500}
height={300}
className="size-full object-cover max-h-[300px] rounded-xl"
/>
<div className="flex flex-col">
<div className="group inline-flex cursor-pointer items-center justify-start gap-1 duration-200 hover:text-neutral-700 dark:hover:text-neutral-200 text-xl font-semibold text-neutral-700 dark:text-neutral-300">
{title}
<ChevronRightIcon className="size-4 translate-x-0 opacity-0 transition-all duration-300 ease-out group-hover:translate-x-1 group-hover:opacity-100" />
</div>
<p className="text-neutral-400 text-sm">{affiliation}</p>
</div>
</Link>
)
}
export default function Showcase() {
const manualShowcases = [
{
title: "Easy Chatbot",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-chatbot.png",
href: "https://www.easyui.pro/ez-tmp",
affiliation: "Easy UI",
},
{
title: "Easy Designfast",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-designfast.png",
href: "https://www.easyui.pro/designfast",
affiliation: "Easy UI",
},
{
title: "Easy Docs",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-docs.png",
href: "https://www.easyui.pro/ez-docs",
affiliation: "Easy UI",
},
{
title: "Easy Nextui",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-nextui.png",
href: "https://www.easyui.pro/ez-nextui",
affiliation: "Easy UI",
},
{
title: "Easy Portfolio",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-portfolio.png",
href: "https://www.easyui.pro/ez-portfolio",
affiliation: "Easy UI",
},
{
title: "Easy Quotes",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-quotes.png",
href: "https://www.easyui.pro/quotesai",
affiliation: "Easy UI",
},
{
title: "Easy Retro",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-retro.png",
href: "https://www.easyui.pro/retro",
affiliation: "Easy UI",
},
{
title: "Easy Template",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-template.png",
href: "https://www.easyui.pro/ez-tmp",
affiliation: "Easy UI",
},
{
title: "Easy Waitlist",
image: "https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/ez-waitlist.png",
href: "https://www.easyui.pro/ez-waitlist",
affiliation: "Easy UI",
},
]
return (
<section id="showcase" className="py-20 w-full hidden lg:block md:block">
<h2 className="mb-2 text-center text-3xl font-bold leading-[1.2] tracking-tighter text-foreground">
Showcase
</h2>
<p className="mx-auto mb-8 text-muted-foreground text-center text-lg font-medium tracking-tight sm:text-lg sm:leading-7">
Companies choose Easy UI to build their landing pages.
</p>
<div className="relative flex flex-col ">
<Marquee className="[--duration:40s]">
{manualShowcases.map((showcase, idx) => (
<ShowcaseCard key={idx} {...showcase} href={showcase.href} />
))}
</Marquee>
<div className="pointer-events-none absolute inset-y-0 left-0 h-full w-[1.2%] bg-gradient-to-r from-background"></div>
<div className="pointer-events-none absolute inset-y-0 right-0 h-full w-[1.2%] bg-gradient-to-l from-background"></div>
</div>
</section>
)
}
| DarkInventor/easy-ui/components/showcase.tsx | {
"file_path": "DarkInventor/easy-ui/components/showcase.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 1835
} | 3 |
<svg width="162" height="162" viewBox="0 0 162 162" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M119.928 72.36C104.7 77.3234 94.0024 87.3581 89.4061 103.173C84.3748 87.4907 73.4039 77.7557 58.0449 73.2142C73.2732 68.2544 83.9705 58.2157 88.5675 42.3992C93.5982 58.0827 104.569 67.8219 119.929 72.36L119.928 72.36Z" fill="black"/>
</svg>
| DarkInventor/easy-ui/public/star-dark.svg | {
"file_path": "DarkInventor/easy-ui/public/star-dark.svg",
"repo_id": "DarkInventor/easy-ui",
"token_count": 184
} | 4 |
import Providers from "@/components/providers";
import { Toaster } from "@/components/ui/sonner";
import "@/styles/globals.css";
import type { Metadata } from "next";
import { siteConfig } from "@/config/site";
import { Analytics } from "@vercel/analytics/react";
import { fontSans, fontHeading } from "@/lib/fonts";
const TITLE =
"Rapidlaunch | Open Source Nextjs SaaS Starterkits and Components";
const DESCRIPTION =
"Launch your apps faster with our SaaS starterkits, components, building blocks. Customizable. Open Source";
export const metadata: Metadata = {
metadataBase: new URL("https://www.rapidlaunch.xyz"),
title: TITLE,
description: DESCRIPTION,
icons: [{ rel: "icon", url: "/favicon.ico" }],
twitter: {
card: "summary_large_image",
title: TITLE,
description: DESCRIPTION,
creator: "@AliFarooqDev",
images: [
"https://utfs.io/f/4ae0ddb1-4260-46f5-aa7c-70408cc192b9-aadavt.png",
],
},
openGraph: {
type: "website",
title: TITLE,
description: DESCRIPTION,
images: [
{
url: "https://utfs.io/f/4ae0ddb1-4260-46f5-aa7c-70408cc192b9-aadavt.png",
width: 1280,
height: 760,
alt: "Rapidlaunch | Open Source Nextjs SaaS Starterkits and Components",
},
],
siteName: siteConfig.name,
},
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body
className={`${fontSans.variable} ${fontHeading.variable} font-sans`}
>
<Providers>
{children}
<Toaster position="top-center" />
</Providers>
<Analytics />
</body>
</html>
);
}
| alifarooq9/rapidlaunch/apps/www/src/app/layout.tsx | {
"file_path": "alifarooq9/rapidlaunch/apps/www/src/app/layout.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 900
} | 5 |
interface NavItem {
label: string;
href: string;
disabled?: boolean;
}
interface NavConfig {
items: NavItem[];
}
export const navConfig: NavConfig = {
items: [
{
label: "SaaS StarterKit",
href: "/saas-starterkit",
disabled: true,
},
{
label: "Blocks",
href: "/blocks",
disabled: true,
},
{
label: "Docs",
href: "/docs",
disabled: true,
},
{
label: "GitHub",
href: "/gh",
},
],
};
| alifarooq9/rapidlaunch/apps/www/src/config/nav.ts | {
"file_path": "alifarooq9/rapidlaunch/apps/www/src/config/nav.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 341
} | 6 |
const config = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
module.exports = config;
| alifarooq9/rapidlaunch/starterkits/saas/postcss.config.cjs | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/postcss.config.cjs",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 45
} | 7 |
"use client";
import { Button } from "@/components/ui/button";
import {
cancelPlan,
pausePlan,
resumePlan,
} from "@/server/actions/subscription/mutations";
import { useMutation } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { useAwaitableTransition } from "@/hooks/use-awaitable-transition";
import { Icons } from "@/components/ui/icons";
import type { OrgSubscription } from "@/types/org-subscription";
type CancelAndPauseBtnProps = {
subscription: OrgSubscription;
};
export function CancelPauseResumeBtns({
subscription,
}: CancelAndPauseBtnProps) {
const router = useRouter();
const [, startAwaitableTransition] = useAwaitableTransition();
const { isPending: isCancelling, mutate: cancelMutate } = useMutation({
mutationFn: async () => {
const response = await cancelPlan();
await startAwaitableTransition(() => {
router.refresh();
});
return response;
},
onError: () => {
toast.error("Failed to cancel plan");
},
onSuccess: () => {
toast.success("Plan cancelled successfully");
},
});
const { isPending: isResuming, mutate: resumeMutate } = useMutation({
mutationFn: async () => {
const response = await resumePlan();
await startAwaitableTransition(() => {
router.refresh();
});
return response;
},
onError: () => {
toast.error("Failed to resume plan");
},
onSuccess: () => {
toast.success("Plan resumed successfully");
},
});
const { isPending: isPausing, mutate: pauseMutate } = useMutation({
mutationFn: async () => {
const response = await pausePlan();
await startAwaitableTransition(() => {
router.refresh();
});
return response;
},
onError: () => {
toast.error("Failed to pause plan");
},
onSuccess: () => {
toast.success("Plan paused successfully");
},
});
const isAllActionsPending = isCancelling || isResuming || isPausing;
if (!subscription) return null;
if (subscription.status === "active") {
return (
<div className="flex items-center gap-2">
<Button
disabled={isAllActionsPending}
onClick={() => pauseMutate()}
variant="outline"
>
{isPausing && <Icons.loader className="mr-2 h-4 w-4" />}
Pause Plan
</Button>
<Button
onClick={() => cancelMutate()}
disabled={isAllActionsPending}
variant="destructive"
>
{isCancelling && <Icons.loader className="mr-2 h-4 w-4" />}
Cancel Plan
</Button>
</div>
);
}
return (
<Button
disabled={isAllActionsPending}
onClick={() => resumeMutate()}
variant="outline"
>
{isResuming && <Icons.loader className="mr-2 h-4 w-4" />}
Resume Plan
</Button>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/cancel-pause-resume-btns.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/cancel-pause-resume-btns.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 1636
} | 8 |
import { AppPageLoading } from "@/app/(app)/_components/page-loading";
import { Skeleton } from "@/components/ui/skeleton";
import { orgMembersInvitePageConfig } from "@/app/(app)/(user)/org/members/invite/_constants/page-config";
export default function InviteMembersLoading() {
return (
<AppPageLoading
title={orgMembersInvitePageConfig.title}
description={orgMembersInvitePageConfig.description}
>
<div className="space-y-4">
<Skeleton className="h-64 w-full" />
<Skeleton className="h-36 w-full" />
</div>
</AppPageLoading>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/invite/loading.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/invite/loading.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 267
} | 9 |
import { AppPageShell } from "@/app/(app)/_components/page-shell";
import { UserNameForm } from "@/app/(app)/(user)/profile/settings/_components/user-name-form";
import { UserImageForm } from "@/app/(app)/(user)/profile/settings/_components/user-image-form";
import { UserVerifyForm } from "@/app/(app)/(user)/profile/settings/_components/user-verify-form";
import { profileSettingsPageConfig } from "@/app/(app)/(user)/profile/settings/_constants/page-config";
import { UserAppearanceForm } from "@/app/(app)/(user)/profile/settings/_components/user-appearance-form";
import { getUser } from "@/server/auth";
import { type User } from "next-auth";
/**
* This is the settings page for the user profile.
* @add more settings related components here
*/
export default async function SettingsPage() {
const user = await getUser();
return (
<AppPageShell
title={profileSettingsPageConfig.title}
description={profileSettingsPageConfig.description}
>
<div className="mt-10 grid w-full grid-cols-1 gap-4 sm:grid-cols-2">
<UserImageForm user={user as User} />
<UserNameForm user={user as User} />
{user && !user.emailVerified && (
<UserVerifyForm user={user as User} />
)}
<UserAppearanceForm />
</div>
</AppPageShell>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/profile/settings/page.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/profile/settings/page.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 544
} | 10 |
import React from "react";
import { AppPageShell } from "@/app/(app)/_components/page-shell";
type AppPageLoadingProps = {
title: string;
description: string;
children: React.ReactNode;
};
export function AppPageLoading({
title,
description,
children,
}: AppPageLoadingProps) {
return (
<AppPageShell title={title} description={description}>
<div className="w-full">{children}</div>
</AppPageShell>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/page-loading.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/page-loading.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 178
} | 11 |
export const adminFeedbackPageConfig = {
title: "Feedback List",
description: "List of feedbacks from users, manage them here.",
} as const;
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/feedbacks/_constants/page-config.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/feedbacks/_constants/page-config.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 44
} | 12 |
import { AppPageShell } from "@/app/(app)/_components/page-shell";
import { usersPageConfig } from "@/app/(app)/admin/users/_constants/page-config";
import { getPaginatedUsersQuery } from "@/server/actions/user/queries";
import { UsersTable } from "./_components/users-table";
import { z } from "zod";
import type { SearchParams } from "@/types/data-table";
type UsersPageProps = {
searchParams: SearchParams;
};
const searchParamsSchema = z.object({
page: z.coerce.number().default(1),
per_page: z.coerce.number().default(10),
sort: z.string().optional(),
email: z.string().optional(),
status: z.string().optional(),
role: z.string().optional(),
operator: z.string().optional(),
});
export default async function UsersPage({ searchParams }: UsersPageProps) {
const search = searchParamsSchema.parse(searchParams);
const usersPromise = getPaginatedUsersQuery(search);
return (
<AppPageShell
title={usersPageConfig.title}
description={usersPageConfig.description}
>
<div className="w-full">
<UsersTable usersPromise={usersPromise} />
</div>
</AppPageShell>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/users/page.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/users/page.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 457
} | 13 |
Subsets and Splits