diff --git a/README.md b/README.md index aff6270..c016605 100644 --- a/README.md +++ b/README.md @@ -8,23 +8,25 @@ A **Pagination Table** & **Scroll List** component suite for [CRUD operation][1] ## Components -1. [Badge Bar](https://mobx-restful-shadcn.idea2.app/) -2. [Badge Input](https://mobx-restful-shadcn.idea2.app/) -3. [Image Preview](https://mobx-restful-shadcn.idea2.app/) -4. [File Preview](https://mobx-restful-shadcn.idea2.app/) -5. [File Picker](https://mobx-restful-shadcn.idea2.app/) -6. [File Uploader](https://mobx-restful-shadcn.idea2.app/) -7. [Form Field](https://mobx-restful-shadcn.idea2.app/) -8. [Range Input](https://mobx-restful-shadcn.idea2.app/) -9. [Array Field](https://mobx-restful-shadcn.idea2.app/) -10. [REST Form](https://mobx-restful-shadcn.idea2.app/) -11. [REST Form Modal](https://mobx-restful-shadcn.idea2.app/) -12. [Pager](https://mobx-restful-shadcn.idea2.app/) -13. [REST Table](https://mobx-restful-shadcn.idea2.app/) -14. [Scroll Boundary](https://mobx-restful-shadcn.idea2.app/) -15. [Scroll List](https://mobx-restful-shadcn.idea2.app/) -16. [Searchable Input](https://mobx-restful-shadcn.idea2.app/) -17. [Editor](https://mobx-restful-shadcn.idea2.app/) +1. [Spinner](https://mobx-restful-shadcn.idea2.app/r/spinner.json) +2. [Loading](https://mobx-restful-shadcn.idea2.app/r/loading.json) +3. [Badge Bar](https://mobx-restful-shadcn.idea2.app/r/badge-bar.json) +4. [Badge Input](https://mobx-restful-shadcn.idea2.app/r/badge-input.json) +5. [Image Preview](https://mobx-restful-shadcn.idea2.app/r/image-preview.json) +6. [File Preview](https://mobx-restful-shadcn.idea2.app/r/file-preview.json) +7. [File Picker](https://mobx-restful-shadcn.idea2.app/r/file-picker.json) +8. [File Uploader](https://mobx-restful-shadcn.idea2.app/r/file-uploader.json) +9. [Form Field](https://mobx-restful-shadcn.idea2.app/r/form-field.json) +10. [Range Input](https://mobx-restful-shadcn.idea2.app/r/range-input.json) +11. [Array Field](https://mobx-restful-shadcn.idea2.app/r/array-field.json) +12. [REST Form](https://mobx-restful-shadcn.idea2.app/r/rest-form.json) +13. [REST Form Modal](https://mobx-restful-shadcn.idea2.app/r/rest-form-modal.json) +14. [Pager](https://mobx-restful-shadcn.idea2.app/r/pager.json) +15. [REST Table](https://mobx-restful-shadcn.idea2.app/r/rest-table.json) +16. [Scroll Boundary](https://mobx-restful-shadcn.idea2.app/r/scroll-boundary.json) +17. [Scroll List](https://mobx-restful-shadcn.idea2.app/r/scroll-list.json) +18. [Searchable Input](https://mobx-restful-shadcn.idea2.app/r/searchable-input.json) +19. [Editor](https://mobx-restful-shadcn.idea2.app/r/editor.json) ## Installation diff --git a/app/page.tsx b/app/page.tsx index bb5140a..37d94ff 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,11 +7,13 @@ import { FilePickerExample } from "@/registry/new-york/blocks/file-picker/exampl import { FilePreviewExample } from "@/registry/new-york/blocks/file-preview/example"; import { FormFieldExample } from "@/registry/new-york/blocks/form-field/example"; import { ImagePreviewExample } from "@/registry/new-york/blocks/image-preview/example"; +import { LoadingExample } from "@/registry/new-york/blocks/loading/example"; import { PagerExample } from "@/registry/new-york/blocks/pager/example"; import { RangeInputExample } from "@/registry/new-york/blocks/range-input/example"; import { RestTableExample } from "@/registry/new-york/blocks/rest-table/example"; import { ScrollBoundaryExample } from "@/registry/new-york/blocks/scroll-boundary/example"; import { ScrollListExample } from "@/registry/new-york/blocks/scroll-list/example"; +import { SpinnerExample } from "@/registry/new-york/blocks/spinner/example"; export default function Home() { return ( @@ -25,6 +27,20 @@ export default function Home() {

+ + + + + + + + { src: string; @@ -77,7 +77,7 @@ export class ImagePreview extends ObservedComponent { {...props} > {downloading ? ( - + ) : ( loadedPath && ( + + +

+ Click the button to toggle the full-screen loading overlay +

+ + {isLoading && Please wait...} + + ); +} diff --git a/registry/new-york/blocks/loading/index.tsx b/registry/new-york/blocks/loading/index.tsx new file mode 100644 index 0000000..ec6c3cf --- /dev/null +++ b/registry/new-york/blocks/loading/index.tsx @@ -0,0 +1,28 @@ +import { FC, HTMLAttributes } from "react"; + +import { cn } from "@/lib/utils"; +import { Spinner } from "../spinner"; + +export type LoadingProps = HTMLAttributes; + +export const Loading: FC = ({ + className, + children = "Loading...", + ...props +}) => ( +
+
+ + + {children && {children}} +
+
+); + +Loading.displayName = "Loading"; diff --git a/registry/new-york/blocks/rest-table/index.tsx b/registry/new-york/blocks/rest-table/index.tsx index 4717daf..ebec7bb 100644 --- a/registry/new-york/blocks/rest-table/index.tsx +++ b/registry/new-york/blocks/rest-table/index.tsx @@ -25,6 +25,7 @@ import { FilePreview } from "../file-preview"; import { Pager } from "../pager"; import { Field, RestForm, RestFormProps } from "../rest-form"; import { RestFormModal } from "../rest-form-modal"; +import { Spinner } from "../spinner"; export interface Column extends Omit, "renderLabel"> { @@ -301,7 +302,7 @@ export class RestTable<
-
+
diff --git a/registry/new-york/blocks/searchable-input/index.tsx b/registry/new-york/blocks/searchable-input/index.tsx index 085ba34..ecf5595 100644 --- a/registry/new-york/blocks/searchable-input/index.tsx +++ b/registry/new-york/blocks/searchable-input/index.tsx @@ -15,6 +15,7 @@ import { TextInputType } from "../badge-input"; import { RestFormProps } from "../rest-form"; import { RestFormModal } from "../rest-form-modal"; import { ScrollList, ScrollListProps } from "../scroll-list"; +import { Spinner } from "../spinner"; export type OptionData = Record<"label" | "value", string>; @@ -112,7 +113,7 @@ export class SearchableInput< ) : ( this.observedProps.store.downloading > 0 && (
-
+
) ); diff --git a/registry/new-york/blocks/spinner/example.tsx b/registry/new-york/blocks/spinner/example.tsx new file mode 100644 index 0000000..0251f23 --- /dev/null +++ b/registry/new-york/blocks/spinner/example.tsx @@ -0,0 +1,26 @@ +import { Spinner } from "./index"; + +export const SpinnerExample = () => ( +
+
+ + Small Spinner +
+
+ + Medium Spinner (Default) +
+
+ + Large Spinner +
+
+ + Custom Color (Primary) +
+
+ + Custom Color (Destructive) +
+
+); diff --git a/registry/new-york/blocks/spinner/index.tsx b/registry/new-york/blocks/spinner/index.tsx new file mode 100644 index 0000000..bcb03e3 --- /dev/null +++ b/registry/new-york/blocks/spinner/index.tsx @@ -0,0 +1,32 @@ +import { FC, HTMLAttributes } from "react"; + +import { cn } from "@/lib/utils"; + +export interface SpinnerProps extends HTMLAttributes { + size?: "sm" | "md" | "lg"; +} + +const SizeClass: Record["size"], string> = { + sm: "h-4 w-4 border-2", + md: "h-8 w-8 border-2", + lg: "h-12 w-12 border-4", +}; + +export const Spinner: FC = ({ + className, + size = "md", + ...props +}) => ( +
+); + +Spinner.displayName = "Spinner";