File tree Expand file tree Collapse file tree
registry/new-york/blocks/loading Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { FilePickerExample } from "@/registry/new-york/blocks/file-picker/exampl
77import { FilePreviewExample } from "@/registry/new-york/blocks/file-preview/example" ;
88import { FormFieldExample } from "@/registry/new-york/blocks/form-field/example" ;
99import { ImagePreviewExample } from "@/registry/new-york/blocks/image-preview/example" ;
10+ import LoadingExample from "@/registry/new-york/blocks/loading/example" ;
1011import { PagerExample } from "@/registry/new-york/blocks/pager/example" ;
1112import { RangeInputExample } from "@/registry/new-york/blocks/range-input/example" ;
1213import { RestTableExample } from "@/registry/new-york/blocks/rest-table/example" ;
@@ -33,6 +34,13 @@ export default function Home() {
3334 < SpinnerExample />
3435 </ ComponentCard >
3536
37+ < ComponentCard
38+ name = "loading"
39+ description = "A full-screen loading overlay component with spinner and customizable message."
40+ >
41+ < LoadingExample />
42+ </ ComponentCard >
43+
3644 < ComponentCard
3745 name = "badge-bar"
3846 description = "A component for displaying a list of badges with optional click and delete handlers."
Original file line number Diff line number Diff line change 1616 }
1717 ]
1818 },
19+ {
20+ "name" : " loading" ,
21+ "type" : " registry:component" ,
22+ "title" : " Loading" ,
23+ "description" : " A full-screen loading overlay component with spinner and customizable message." ,
24+ "registryDependencies" : [" @mobx-restful-shadcn/spinner" ],
25+ "files" : [
26+ {
27+ "type" : " registry:component" ,
28+ "path" : " registry/new-york/blocks/loading/index.tsx" ,
29+ "target" : " components/ui/mobx-restful-shadcn/loading/index.tsx"
30+ }
31+ ]
32+ },
1933 {
2034 "name" : " badge-bar" ,
2135 "type" : " registry:component" ,
Original file line number Diff line number Diff line change 1+ "use client" ;
2+
3+ import { useState } from "react" ;
4+
5+ import { Button } from "@/components/ui/button" ;
6+ import { Loading } from "." ;
7+
8+ export default function LoadingExample ( ) {
9+ const [ isLoading , setIsLoading ] = useState ( false ) ;
10+
11+ return (
12+ < div className = "flex flex-col gap-4 items-center p-8" >
13+ < Button onClick = { ( ) => setIsLoading ( ! isLoading ) } >
14+ { isLoading ? "Hide Loading" : "Show Loading" }
15+ </ Button >
16+
17+ < p className = "text-sm text-muted-foreground" >
18+ Click the button to toggle the full-screen loading overlay
19+ </ p >
20+
21+ { isLoading && (
22+ < Loading >
23+ < span > Please wait...</ span >
24+ </ Loading >
25+ ) }
26+ </ div >
27+ ) ;
28+ }
Original file line number Diff line number Diff line change 1+ import { FC , HTMLAttributes , ReactNode } from "react" ;
2+
3+ import { cn } from "@/lib/utils" ;
4+ import { Spinner } from "../spinner" ;
5+
6+ export interface LoadingProps extends HTMLAttributes < HTMLDivElement > {
7+ children ?: ReactNode ;
8+ }
9+
10+ export const Loading : FC < LoadingProps > = ( {
11+ className,
12+ children = "Loading..." ,
13+ ...props
14+ } ) => (
15+ < div
16+ className = { cn (
17+ "fixed inset-0 z-50 flex h-full w-full items-center justify-center bg-black/25" ,
18+ className ,
19+ ) }
20+ { ...props }
21+ >
22+ < div className = "flex items-center gap-3" >
23+ < Spinner className = "text-primary" />
24+ { children && < span className = "text-white" > { children } </ span > }
25+ </ div >
26+ </ div >
27+ ) ;
28+
29+ Loading . displayName = "Loading" ;
You can’t perform that action at this time.
0 commit comments