From 420a2ee27fbe9b1127a72ddc8cce3fe1f11cea87 Mon Sep 17 00:00:00 2001 From: Damien Schneider <74979845+damien-schneider@users.noreply.github.com> Date: Fri, 22 Nov 2024 23:29:05 +0100 Subject: [PATCH] :art: format code for consistency with new biome config --- apps/website/__mocks__/globals-mocks.ts | 34 +- .../components/component-categories.test.tsx | 176 +++--- .../get-file-content-as-string.test.tsx | 14 +- apps/website/__tests__/sidemenu.test.tsx | 46 +- apps/website/next.config.js | 24 +- apps/website/package.json | 7 +- .../scripts/generate-package-list-check.js | 64 +-- .../(site)/[section]/[category]/layout.tsx | 134 ++--- .../[category]/multiple-component-section.tsx | 106 ++-- .../app/(site)/[section]/[category]/page.tsx | 130 ++--- .../[category]/process-variant-data.ts | 160 +++--- .../[category]/single-component-section.tsx | 96 ++-- .../src/app/(site)/[section]/layout.tsx | 74 +-- .../website/src/app/(site)/[section]/page.tsx | 116 ++-- apps/website/src/app/(site)/about/page.tsx | 194 +++---- .../src/app/(site)/getting-started/page.tsx | 148 ++--- apps/website/src/app/(site)/layout.tsx | 48 +- .../get-components/get-components.utils.ts | 220 ++++---- .../src/app/api/get-components/route.ts | 92 +-- apps/website/src/app/card.tsx | 62 +-- .../generate-preview-images.tsx | 206 +++---- .../app/dev/generate-preview-images/page.tsx | 12 +- apps/website/src/app/dev/page.tsx | 2 +- .../src/app/dev/playground-component/page.tsx | 12 +- .../dev/playground-component/playground.tsx | 22 +- .../src/app/dev/playground-component/test.tsx | 2 +- apps/website/src/app/layout.tsx | 98 ++-- apps/website/src/app/not-found.tsx | 2 +- apps/website/src/app/page.tsx | 72 +-- apps/website/src/app/sitemap.ts | 86 +-- .../analytics/plausible-scripts.tsx | 34 +- .../animated-tab-motion-div.tsx | 26 +- .../component-tab-renderer.tsx | 312 +++++------ .../component-wrapper/component-wrapper.tsx | 122 ++-- .../copy-to-clipboard-button.tsx | 72 +-- .../get-container-height-class.tsx | 60 +- .../component-wrapper/github-edit-button.tsx | 38 +- .../component-wrapper/header-component.tsx | 68 +-- .../component-wrapper/variant-tabs.tsx | 154 ++--- .../components/custom-iframe-component.tsx | 128 ++--- .../floating-dock-toggle-theme.tsx | 72 +-- .../floating-dock.tsx | 86 +-- .../floating-docks-component.tsx | 428 +++++++------- .../main-menus/menu-category-wrapper.tsx | 20 +- .../navigation/animated-background.tsx | 148 ++--- .../components/navigation/desktop-menu.tsx | 66 +-- .../navigation-animated-background.tsx | 34 +- .../components/navigation/navigation-item.tsx | 148 ++--- .../first-section-command-group.tsx | 44 +- .../search-group-multi-component-section.tsx | 276 ++++----- .../components/search-menu/search-menu.tsx | 114 ++-- .../steps-to-install/step-to-install.tsx | 164 +++--- apps/website/src/lib/first-menu-section.ts | 70 +-- ...generated-package-check-list-to-install.ts | 440 +++++++-------- apps/website/src/ui/address-bar.tsx | 158 +++--- apps/website/src/ui/byline.tsx | 72 +-- .../website/src/ui/code-command-container.tsx | 26 +- apps/website/src/ui/code-highlighter.tsx | 28 +- ...opy-to-clipboard-code-snippet-dropdown.tsx | 148 ++--- .../src/ui/github-animated-star-number.tsx | 30 +- apps/website/src/ui/gradient-container.tsx | 168 +++--- apps/website/src/ui/shadcn/button.tsx | 84 +-- apps/website/src/ui/shadcn/command.tsx | 204 +++---- apps/website/src/ui/shadcn/dialog.tsx | 156 +++--- apps/website/src/ui/shadcn/dropdown-menu.tsx | 274 ++++----- apps/website/src/ui/shadcn/resizable.tsx | 52 +- apps/website/src/ui/shadcn/scrollarea.tsx | 100 ++-- apps/website/src/ui/shadcn/select.tsx | 238 ++++---- apps/website/src/ui/shadcn/tabs.tsx | 66 +-- .../src/ui/star-github-project-button.tsx | 26 +- .../src/utils/get-file-content-as-string.ts | 118 ++-- .../find-category-by-slug.ts | 36 +- .../find-section-by-slug.ts | 2 +- apps/website/tailwind.config.ts | 140 ++--- apps/website/tsconfig.json | 56 +- apps/website/vitest.config.mts | 10 +- biome.json | 3 + package.json | 10 +- packages/config-tailwind/package.json | 2 +- packages/config-tailwind/tsconfig.json | 6 +- packages/config-typescript/package.json | 2 +- packages/config-typescript/react-library.json | 2 +- .../ui/cuicui/all-in-one-themes/theme1.tsx | 10 +- .../action-menu/action-menu.category.tsx | 24 +- .../advanced-bottom-action-menu.component.tsx | 26 +- .../custom-tabs-content.tsx | 114 ++-- .../preview-advanced-bottom-action-menu.tsx | 254 ++++----- .../application-ui/alert/alert.category.tsx | 80 +-- .../modern-glassy-alert.tsx | 70 +-- .../preview-modern-glassy-alert.tsx | 16 +- .../application-ui/application-ui.section.ts | 48 +- .../authentication.category.tsx | 50 +- .../floating-growing-banner/variant1.tsx | 156 +++--- .../battery-indicator/battery-indicator.tsx | 176 +++--- .../preview-battery-indicator.tsx | 16 +- .../battery/battery.category.tsx | 50 +- .../advanced-code-block.component.tsx | 40 +- .../advanced-code-block.tsx | 74 +-- .../advanced-code-block/code-highlighter.tsx | 48 +- ...review-advanced-code-block-tab-variant.tsx | 106 ++-- .../preview-advanced-code-block.tsx | 20 +- .../code/code-card/code-card-preview.tsx | 2 +- .../code/code-card/code-card.component.tsx | 24 +- .../code-snippet/code-snippet.component.tsx | 24 +- .../code/code-snippet/variant1.tsx | 34 +- .../application-ui/code/code.category.tsx | 30 +- .../inline-code/inline-code.component.tsx | 24 +- .../code/inline-code/inline-code.tsx | 28 +- .../code/inline-code/preview-inline-code.tsx | 12 +- .../cookie-banner/category.cookie-banner.tsx | 22 +- .../component.simple-cookie-banner.tsx | 28 +- .../preview-simple-cookie-banner.tsx | 12 +- .../simple-cookie-banner.tsx | 52 +- .../application-ui/kbd/kbd.category.tsx | 76 +-- .../kbd/modern-detailed-kbd/variant1.tsx | 32 +- .../notification/category.notification.tsx | 20 +- .../component.dynamic-island-notification.tsx | 26 +- .../dynamic-island-notification.tsx | 178 +++--- .../preview.dynamic-island-notification.tsx | 44 +- .../search-bars/growing-search/variant1.tsx | 168 +++--- .../search-bars/search-bars.category.tsx | 48 +- .../settings/dynamic-settings/variant1.tsx | 454 +++++++-------- .../settings/settings.category.tsx | 54 +- .../preview-react-signature.tsx | 2 +- .../react-signature.component.tsx | 24 +- .../react-signature/react-signature.tsx | 308 +++++----- .../signature/signature.category.tsx | 20 +- .../sliders/sliders.category.tsx | 88 +-- .../static-steppers/code/variant1.tsx | 116 ++-- .../static-steppers.category.tsx | 56 +- .../following-header-preview.tsx | 108 ++-- .../modul-inspired/following-headers.tsx | 456 +++++++-------- .../table-of-contents.category.tsx | 58 +- .../theme-switcher/theme-switcher-button.tsx | 110 ++-- .../application-ui/theme/theme.category.tsx | 48 +- .../recursive-tree-less-animations.tsx | 136 ++--- .../recursive-tree.component.tsx | 38 +- .../tree/recursive-tree/recursive-tree.tsx | 194 +++---- .../application-ui/tree/tree.category.tsx | 20 +- .../common-ui/avatars/avatars.category.tsx | 14 +- .../badges/advanced-badges/variant1.tsx | 176 +++--- .../common-ui/badges/badges.category.tsx | 120 ++-- .../blockquotes/blockquotes.category.tsx | 48 +- .../before-effect-button.tsx | 52 +- .../preview-advanced-button.tsx | 28 +- .../before-effect-button/preview-default.tsx | 2 +- .../preview-hover-only.tsx | 2 +- .../common-ui/buttons/buttons.category.tsx | 250 ++++----- .../github-stars/component.github-stars.tsx | 258 ++++----- .../buttons/github-stars/github-stars.css | 8 +- .../github-stars/preview.github-stars.tsx | 28 +- .../preview.gradient-container.tsx | 18 +- .../buttons/github-stars/simple-container.tsx | 146 ++--- .../buttons/growing-button/variant1.tsx | 28 +- .../component.magnetic-background-button.tsx | 238 ++++---- .../component.magnetic-button.tsx | 92 +-- .../preview.magnetic-background-button.tsx | 40 +- .../preview.magnetic-button.tsx | 20 +- ...component.shiny-rotating-border-button.tsx | 130 ++--- .../preview.shiny-rotating-border-button.tsx | 2 +- .../cuicui/common-ui/cards/cards.category.tsx | 146 ++--- .../dynamic-square-background-preview.tsx | 18 +- .../hover-effect-card-preview.tsx | 42 +- .../hover-effect-card/hover-effect-card.tsx | 144 ++--- .../cards/modern-inner-shadow/variant1.tsx | 42 +- .../notification-card-preview.tsx | 10 +- .../notification-card/notification-card.tsx | 54 +- .../checkboxes/checkboxes.category.tsx | 52 +- .../simple-checkbox-preview.tsx | 2 +- .../simple-checkbox/simple-checkbox.tsx | 50 +- .../ui/cuicui/common-ui/common-ui.section.ts | 36 +- .../common-ui/inputs/inputs.category.tsx | 80 +-- .../modern-simple-input.tsx | 36 +- .../preview-simple-modern-input.tsx | 30 +- .../common-ui/loaders/loaders.category.tsx | 114 ++-- .../navigation/mac-dock/variant1.tsx | 130 ++--- .../navigation/navigation.category.tsx | 92 +-- .../skeletons/classic-pulse/variant1.tsx | 34 +- .../skeleton-shiny-gradient-horizontal.tsx | 20 +- .../skeleton-shiny-gradient-vertical.tsx | 26 +- .../skeleton-shiny-gradient.tsx | 70 +-- .../skeletons/skeletons.category.tsx | 102 ++-- .../common-ui/toggle/toggle.category.tsx | 14 +- packages/ui/cuicui/hooks/hooks.section.ts | 74 +-- .../hooks/use-battery/preview-use-battery.tsx | 68 +-- .../use-battery/use-battery.category.tsx | 42 +- .../category.use-click-outside.tsx | 42 +- .../preview.use-click-outside.tsx | 40 +- .../use-click-outside/use-click-outside.ts | 60 +- .../category.use-copy-to-clipboard.tsx | 40 +- .../preview-copy-to-clipboard.tsx | 52 +- .../use-counter/category.use-counter.tsx | 40 +- .../hooks/use-counter/preview-use-counter.tsx | 86 +-- .../use-debounce/category.use-debounce.tsx | 40 +- .../use-debounce/preview-use-debounce.tsx | 58 +- .../category.use-event-callback.tsx | 40 +- .../use-event-callback/use-event-callback.ts | 28 +- .../category.use-event-listener.tsx | 42 +- .../preview-use-event-listener.tsx | 52 +- .../use-event-listener/use-event-listener.ts | 116 ++-- .../category.use-first-visit.tsx | 42 +- .../preview.use-first-visit.tsx | 32 +- .../category-use-geolocation.tsx | 42 +- .../preview-use-geolocation.tsx | 4 +- .../use-in-view/category.use-in-view.tsx | 44 +- .../hooks/use-in-view/preview-in-view.tsx | 96 ++-- .../category.use-input-value.tsx | 40 +- .../preview-use-input-value.tsx | 4 +- .../category.use-isomorphic-layout-effect.tsx | 42 +- .../use-key-press/category.use-key-press.tsx | 42 +- .../use-key-press/preview-use-key-press.tsx | 58 +- .../category.use-konami-code.tsx | 42 +- .../preview-use-konami-code.tsx | 66 +-- .../category.use-local-storage.tsx | 42 +- .../preview-use-local-storage.tsx | 60 +- .../use-local-storage/use-local-storage.ts | 288 +++++----- .../use-location/category.use-location.tsx | 44 +- .../use-location/preview-use-location.tsx | 126 ++--- .../cuicui/hooks/use-location/use-location.ts | 230 ++++---- .../use-measure/category.use-measure.tsx | 42 +- .../hooks/use-measure/preview.use-measure.tsx | 64 +-- .../hooks/use-mouse/category.use-mouse.tsx | 12 +- .../hooks/use-mouse/component.use-mouse.tsx | 18 +- .../hooks/use-mouse/preview-use-mouse.tsx | 44 +- .../category.use-network.tsx | 42 +- .../preview-use-network-status.tsx | 66 +-- .../category.use-online-status.tsx | 42 +- .../preview-use-online-status.tsx | 12 +- .../use-rerender/component.use-rerender.tsx | 42 +- .../use-rerender/preview.use-rerender.tsx | 18 +- .../category.use-session-storage.tsx | 48 +- .../category.use-speech-to-text.tsx | 50 +- .../hooks/use-step/category.use-step.tsx | 34 +- .../hooks/use-step/preview-use-step.tsx | 66 +-- .../use-stopwatch/category.use-stopwatch.tsx | 42 +- .../use-stopwatch/preview.use-stopwatch.tsx | 76 +-- .../category.use-text-to-speech.tsx | 48 +- .../use-throttle/category.use-throttle.tsx | 42 +- .../use-throttle/preview.use-throttle.tsx | 34 +- .../hooks/use-video/category.use-video.tsx | 42 +- .../hooks/use-video/preview.use-video.tsx | 162 +++--- .../category.use-window-scroll-postion.tsx | 40 +- .../preview-use-window-scroll-position.tsx | 30 +- .../category.use-window-size.tsx | 40 +- .../preview-use-window-size.tsx | 12 +- .../carousels/category.carousels.tsx | 80 +-- .../cylindric-3d-carousel/variant1.tsx | 196 +++---- .../simple-carousel-preview.tsx | 66 +-- .../simple-carousel/simple-carousel.tsx | 526 +++++++++--------- .../cuicui/marketing-ui/faq/category.faq.tsx | 12 +- .../full-section/component.full-section.tsx | 26 +- .../faq/full-section/full-section.tsx | 108 ++-- .../gradient-qna/component.gradient-qna.tsx | 46 +- .../faq/gradient-qna/custom-chevron-style.tsx | 220 ++++---- .../faq/gradient-qna/double-container.tsx | 200 +++---- .../faq/gradient-qna/simple-container.tsx | 200 +++---- .../features/animated-cards/variant1.tsx | 152 ++--- .../features/category.features.tsx | 94 ++-- .../features/feature-four-images/variant1.tsx | 302 +++++----- .../features/feature-four-images/variant2.tsx | 302 +++++----- .../ui/cuicui/marketing-ui/footer/category.ts | 28 +- .../footer/sticky-footer/component.ts | 24 +- .../sticky-footer/preview.sticky-footer.tsx | 82 +-- .../footer/sticky-footer/sticky-footer.tsx | 38 +- .../category.pricing-tables.tsx | 26 +- .../component.gradient-pricing-table.tsx | 24 +- .../component.artlist-inspired.tsx | 28 +- .../many-offers/preview.artlist-inspired.tsx | 404 +++++++------- .../marketing-ui/section.marketing-ui.ts | 28 +- .../animated-counter-preview.tsx | 32 +- .../animated-counter/animated-counter.tsx | 132 ++--- .../animated-on-scroll/variant1.tsx | 114 ++-- .../statistics/category.statistics.tsx | 114 ++-- .../testimonials/category.testimonials.tsx | 88 +-- .../testimonials-component/variant1.tsx | 166 +++--- .../animated-noise/animated-noise.tsx | 46 +- .../component.animated-noise.tsx | 38 +- .../animated-noise/preview.animated-noise.tsx | 10 +- .../animated-noise/preview.static-noise.tsx | 22 +- .../animated-noise/static-noise.tsx | 36 +- .../border-trail/border-trail.tsx | 74 +-- .../border-trail/component.animated-noise.tsx | 26 +- .../border-trail/preview.border-trail.tsx | 42 +- .../component.bottom-blur-out.tsx | 30 +- .../preview.bottom-blur-out.tsx | 44 +- .../category.creative-effet.tsx | 32 +- .../wavy-line/definition.wavy-line.tsx | 24 +- .../wavy-line/preview.wavy-line.tsx | 2 +- .../creative-effects/wavy-line/wavy-line.tsx | 212 +++---- .../cuicui/other/cursors/cursor.category.tsx | 20 +- .../card-hover-cursor-effect.component.tsx | 40 +- .../card-mouse-highlighting-border.tsx | 56 +- .../dynamic-cards/gradient-card-effect.tsx | 52 +- .../cursors/dynamic-cards/gradient-card.tsx | 122 ++-- .../dynamic-cards/only-border-card-effect.tsx | 40 +- .../follow-cursor/follow-cursor.component.tsx | 38 +- .../cursors/follow-cursor/replace-cursor.tsx | 30 +- .../cursors/follow-cursor/with-cursor.tsx | 24 +- .../other/mock-ups/airpods/airpods-pro.tsx | 46 +- .../mock-ups/laptops/component.mackbook.tsx | 64 +-- .../mock-ups/laptops/preview.mackbook.tsx | 2 +- .../other/mock-ups/mock-ups.category.tsx | 150 ++--- packages/ui/cuicui/other/other.section.ts | 28 +- .../dots-pattern/dots-pattern-preview.tsx | 18 +- .../patterns/dots-pattern/dots-pattern.tsx | 86 +-- .../grid-pattern/component.grid-pattern.tsx | 24 +- .../moving-bands/moving-bands-preview.tsx | 2 +- .../other/patterns/patterns.category.tsx | 94 ++-- .../bar-code-generator.component.tsx | 24 +- .../preview-bar-code-generator.tsx | 44 +- .../qr-code/qr-code-generator/component.ts | 22 +- .../qr-code-generator/qr-code-generator.tsx | 264 ++++----- .../cuicui/other/qr-code/qr-code.category.tsx | 20 +- .../animated-number/animated-number.tsx | 36 +- .../preview-slide-in-on-scroll.tsx | 30 +- .../slide-in-on-scroll.component.tsx | 30 +- .../slide-in-on-scroll/slide-in-on-scroll.tsx | 24 +- .../component.text-effect-wrapper.tsx | 58 +- .../preview.text-effect-wrapper-per-char.tsx | 50 +- .../preview.text-effect-wrapper-per-line.tsx | 82 +-- .../preview.text-effect-wrapper-per-word.tsx | 50 +- .../text-effect-wrapper.tsx | 430 +++++++------- .../component.text-effect-wrapper.tsx | 58 +- .../preview.text-effect-wrapper-per-char.tsx | 50 +- .../preview.text-effect-wrapper-per-line.tsx | 82 +-- .../preview.text-effect-wrapper-per-word.tsx | 50 +- .../transition-wrappers.category.tsx | 58 +- packages/ui/cuicui/styles.css | 2 +- .../bezier-curve-editor.tsx | 288 +++++----- .../category.bezier-curve-generator.tsx | 12 +- .../page.bezier-curve-generator.tsx | 44 +- .../category.color-converter.tsx | 12 +- .../components/color-converter.tsx | 406 +++++++------- .../color-converter/components/to-tailwind.ts | 64 +-- .../color-converter/page.color-converter.tsx | 92 +-- .../css-selectors/category.css-selectors.tsx | 12 +- .../form-builder/category.form-builder.tsx | 12 +- .../category.noise-generator.tsx | 12 +- packages/ui/cuicui/tools/section.tools.ts | 26 +- .../catch-error/category.catch-error.tsx | 42 +- .../utils/catch-error/preview.catch-error.tsx | 106 ++-- packages/ui/cuicui/utils/cn/cn.category.tsx | 40 +- packages/ui/cuicui/utils/cn/preview.cn.tsx | 76 +-- .../ui/cuicui/utils/sleep/preview-sleep.tsx | 70 +-- .../ui/cuicui/utils/sleep/sleep.category.tsx | 40 +- packages/ui/cuicui/utils/utils.section.ts | 12 +- packages/ui/lib/sections-list.ts | 14 +- packages/ui/lib/types/component.d.ts | 136 ++--- packages/ui/package.json | 2 +- packages/ui/tailwind.config.ts | 6 +- packages/ui/tsconfig.json | 22 +- pnpm-lock.yaml | 24 +- turbo.json | 24 +- vitest.workspace.ts | 4 +- 354 files changed, 13656 insertions(+), 13666 deletions(-) diff --git a/apps/website/__mocks__/globals-mocks.ts b/apps/website/__mocks__/globals-mocks.ts index 99b014bb..c7c95d2c 100644 --- a/apps/website/__mocks__/globals-mocks.ts +++ b/apps/website/__mocks__/globals-mocks.ts @@ -4,9 +4,9 @@ import { vi } from "vitest"; // Mock implementation of ResizeObserver const ResizeObserverMock = vi.fn(() => ({ - observe: vi.fn(), - unobserve: vi.fn(), - disconnect: vi.fn(), + observe: vi.fn(), + unobserve: vi.fn(), + disconnect: vi.fn(), })); // Stub the global ResizeObserver with the mock @@ -14,24 +14,24 @@ vi.stubGlobal("ResizeObserver", ResizeObserverMock); // Example: Mock implementation of window.fetch const fetchMock = vi.fn(() => - Promise.resolve({ - json: () => Promise.resolve({}), - }), + Promise.resolve({ + json: () => Promise.resolve({}), + }), ); // Stub the global fetch with the mock vi.stubGlobal("fetch", fetchMock); Object.defineProperty(window, "matchMedia", { - writable: true, - value: vi.fn().mockImplementation((query: string) => ({ - matches: false, - media: query, - onchange: null, - addListener: vi.fn(), // Deprecated - removeListener: vi.fn(), // Deprecated - addEventListener: vi.fn(), - removeEventListener: vi.fn(), - dispatchEvent: vi.fn(), - })), + writable: true, + value: vi.fn().mockImplementation((query: string) => ({ + matches: false, + media: query, + onchange: null, + addListener: vi.fn(), // Deprecated + removeListener: vi.fn(), // Deprecated + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn(), + })), }); diff --git a/apps/website/__tests__/components/component-categories.test.tsx b/apps/website/__tests__/components/component-categories.test.tsx index e92277eb..ee492a7a 100644 --- a/apps/website/__tests__/components/component-categories.test.tsx +++ b/apps/website/__tests__/components/component-categories.test.tsx @@ -3,99 +3,99 @@ import { SectionsList } from "@cuicui/ui"; import { getFileContentAsString } from "#/src/utils/get-file-content-as-string"; describe("SectionsList", () => { - it("should have the correct number of sections", () => { - expect(SectionsList).toHaveLength(7); - }); + it("should have the correct number of sections", () => { + expect(SectionsList).toHaveLength(7); + }); - it("should have the correct section slugs in the good order", () => { - const sectionSlugs = SectionsList.map((section) => section.slug); - expect(sectionSlugs).toEqual([ - "common-ui", - "application-ui", - "marketing-ui", - "other", - "hooks", - "utils", - "tools", - ]); - }); + it("should have the correct section slugs in the good order", () => { + const sectionSlugs = SectionsList.map((section) => section.slug); + expect(sectionSlugs).toEqual([ + "common-ui", + "application-ui", + "marketing-ui", + "other", + "hooks", + "utils", + "tools", + ]); + }); - it("category should have componentList === null if comingSoonCategory === true", () => { - for (const section of SectionsList) { - if (section.type !== "multiple-component") { - continue; - } - //TODO: Handle the single-component test - for (const category of section.categoriesList) { - if (category.comingSoonCategory) { - expect(category.componentList).toBeNull(); - expect(category.componentList).not.toBeUndefined(); - } - } - } - }); + it("category should have componentList === null if comingSoonCategory === true", () => { + for (const section of SectionsList) { + if (section.type !== "multiple-component") { + continue; + } + //TODO: Handle the single-component test + for (const category of section.categoriesList) { + if (category.comingSoonCategory) { + expect(category.componentList).toBeNull(); + expect(category.componentList).not.toBeUndefined(); + } + } + } + }); - it("should not return error when reading the file code", async () => { - const testComponentCode = async ( - slug: string, - variantName: string, - shouldError: boolean, - ) => { - const code = await getFileContentAsString({ - componentSlug: slug, - variantName, - }); - const errorMessage = `Failed for component slug: ${slug}, variant: ${variantName}`; - // Get first 2 words of the code - const firstTwoWords = code.split(" ").slice(0, 2).join(" "); - if (shouldError) { - expect(firstTwoWords, errorMessage).toEqual("An error"); - } else { - expect(firstTwoWords, errorMessage).not.toEqual("An error"); - } - }; + it("should not return error when reading the file code", async () => { + const testComponentCode = async ( + slug: string, + variantName: string, + shouldError: boolean, + ) => { + const code = await getFileContentAsString({ + componentSlug: slug, + variantName, + }); + const errorMessage = `Failed for component slug: ${slug}, variant: ${variantName}`; + // Get first 2 words of the code + const firstTwoWords = code.split(" ").slice(0, 2).join(" "); + if (shouldError) { + expect(firstTwoWords, errorMessage).toEqual("An error"); + } else { + expect(firstTwoWords, errorMessage).not.toEqual("An error"); + } + }; - for (const section of SectionsList) { - if (section.type !== "multiple-component") { - continue; - } - for (const category of section.categoriesList) { - if (category.componentList) { - for (const component of category.componentList) { - for (const variant of component.variantList) { - // Test without error - await testComponentCode( - category.slug, - `${component.slug}/${variant.slugPreviewFile}`, - false, - ); + for (const section of SectionsList) { + if (section.type !== "multiple-component") { + continue; + } + for (const category of section.categoriesList) { + if (category.componentList) { + for (const component of category.componentList) { + for (const variant of component.variantList) { + // Test without error + await testComponentCode( + category.slug, + `${component.slug}/${variant.slugPreviewFile}`, + false, + ); - if (variant.slugComponentFile) { - await testComponentCode( - category.slug, - `${component.slug}/${variant.slugComponentFile}`, - false, - ); - } + if (variant.slugComponentFile) { + await testComponentCode( + category.slug, + `${component.slug}/${variant.slugComponentFile}`, + false, + ); + } - // Test with forced error - await testComponentCode( - category.slug, - `${component.slug}/${variant.slugPreviewFile}error`, - true, - ); + // Test with forced error + await testComponentCode( + category.slug, + `${component.slug}/${variant.slugPreviewFile}error`, + true, + ); - if (variant.slugComponentFile) { - await testComponentCode( - category.slug, - `${component.slug}/${variant.slugComponentFile}error`, - true, - ); - } - } - } - } - } - } - }); + if (variant.slugComponentFile) { + await testComponentCode( + category.slug, + `${component.slug}/${variant.slugComponentFile}error`, + true, + ); + } + } + } + } + } + } + }); }); diff --git a/apps/website/__tests__/components/get-file-content-as-string.test.tsx b/apps/website/__tests__/components/get-file-content-as-string.test.tsx index d3dc4db3..dd719d81 100644 --- a/apps/website/__tests__/components/get-file-content-as-string.test.tsx +++ b/apps/website/__tests__/components/get-file-content-as-string.test.tsx @@ -2,13 +2,13 @@ import { describe, expect, it } from "vitest"; import { getFileContentAsString } from "#/src/utils/get-file-content-as-string"; describe("getFileContentAsString", () => { - it("should return the content of the file", async () => { - const code = await getFileContentAsString({ - componentSlug: "badges", - variantName: "modern-simple-badges/variant1", - }); + it("should return the content of the file", async () => { + const code = await getFileContentAsString({ + componentSlug: "badges", + variantName: "modern-simple-badges/variant1", + }); - expect(code).toEqual(`export function BadgeSimpleVariantAmber() { + expect(code).toEqual(`export function BadgeSimpleVariantAmber() { return (
Amber badge @@ -16,5 +16,5 @@ describe("getFileContentAsString", () => { ); } `); - }); + }); }); diff --git a/apps/website/__tests__/sidemenu.test.tsx b/apps/website/__tests__/sidemenu.test.tsx index 6a9645d2..84582df8 100644 --- a/apps/website/__tests__/sidemenu.test.tsx +++ b/apps/website/__tests__/sidemenu.test.tsx @@ -6,33 +6,33 @@ import InfoMenuList from "#/src/components/navigation/info-menu-list"; const gettingStartedRegex = /getting-started$/; vi.mock("next/navigation", () => ({ - usePathname: () => { - return "/common-ui"; - }, - useSelectedLayoutSegments: () => [], + usePathname: () => { + return "/common-ui"; + }, + useSelectedLayoutSegments: () => [], })); describe("Sidemenu component", () => { - render( -
- - -
, - ); + render( +
+ + +
, + ); - it("should have href attribute of the 'Contribute' element set to https://github.com/damien-schneider/cuicui", () => { - const contributeElement = screen.getByTestId("navigation-link-Contribute"); + it("should have href attribute of the 'Contribute' element set to https://github.com/damien-schneider/cuicui", () => { + const contributeElement = screen.getByTestId("navigation-link-Contribute"); - const hrefValue = contributeElement.getAttribute("href"); - expect(hrefValue).toBe("https://github.com/damien-schneider/cuicui"); - }); - it("should have href attribute of the 'Getting started' element to finish by getting-started", () => { - const contributeElement = screen.getByTestId( - "navigation-link-Getting Started", - ); + const hrefValue = contributeElement.getAttribute("href"); + expect(hrefValue).toBe("https://github.com/damien-schneider/cuicui"); + }); + it("should have href attribute of the 'Getting started' element to finish by getting-started", () => { + const contributeElement = screen.getByTestId( + "navigation-link-Getting Started", + ); - // Check if the href attribute of the 'Getting started' element finishes by getting-started - const hrefValue = contributeElement.getAttribute("href"); - expect(hrefValue).toMatch(gettingStartedRegex); - }); + // Check if the href attribute of the 'Getting started' element finishes by getting-started + const hrefValue = contributeElement.getAttribute("href"); + expect(hrefValue).toMatch(gettingStartedRegex); + }); }); diff --git a/apps/website/next.config.js b/apps/website/next.config.js index 28a7c44a..c04dba92 100755 --- a/apps/website/next.config.js +++ b/apps/website/next.config.js @@ -1,17 +1,17 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - // experimental: { - // serverComponentsExternalPackages: ["shiki", "vscode-oniguruma"], - // }, - transpilePackages: ["shiki", "next-mdx-remote"], - images: { - remotePatterns: [ - { - protocol: "https", - hostname: "**", - }, - ], - }, + // experimental: { + // serverComponentsExternalPackages: ["shiki", "vscode-oniguruma"], + // }, + transpilePackages: ["shiki", "next-mdx-remote"], + images: { + remotePatterns: [ + { + protocol: "https", + hostname: "**", + }, + ], + }, }; module.exports = nextConfig; diff --git a/apps/website/package.json b/apps/website/package.json index f33970bd..d1d31224 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -37,7 +37,6 @@ }, "description": "An open-source all-in-one library for building an advanced SaaS application, a personal website, or anything else with micro-interactions, advanced user experiences, and a focus on performance and code quality.", "devDependencies": { - "@biomejs/biome": "1.9.2", "@tailwindcss/forms": "0.5.7", "@tailwindcss/typography": "0.5.12", "@testing-library/dom": "10.4.0", @@ -81,18 +80,14 @@ "build": "next build", "dev": "next dev --turbo", "start": "next start", - "format:check": "biome format --check ./src", - "format:write": "biome format --write ./src", "generate-package-list-check": "node scripts/generate-package-list-check.js", "lint": "next lint", "lint-format:check": "pnpm format:check && pnpm lint", "lint-staged": "lint-staged", - "lint:apply": "biome check --apply ./src", - "lint:check": "biome check ./src", "lint:write-unsafe": "biome check --write --unsafe ./src", "test": "vitest", "test:watch": "vitest --watch", "type-check": "tsc --noEmit" }, "version": "0.1.2" -} \ No newline at end of file +} diff --git a/apps/website/scripts/generate-package-list-check.js b/apps/website/scripts/generate-package-list-check.js index 94caaa01..45cee130 100755 --- a/apps/website/scripts/generate-package-list-check.js +++ b/apps/website/scripts/generate-package-list-check.js @@ -10,13 +10,13 @@ const packageJsonPath = path.resolve(process.cwd(), "package.json"); // Define the output TypeScript file path inside ./src/lib/ const outputDirectory = path.resolve(process.cwd(), "src", "lib"); const outputTsPath = path.join( - outputDirectory, - "generated-package-check-list-to-install.ts", + outputDirectory, + "generated-package-check-list-to-install.ts", ); const importStatement = `import type { PackageToInstallType } from "#/src/components/steps-to-install/packages";\n`; const commentStatement = - "// This is an automated generated file with the ./scripts/generate-package-list-check.ts script\n"; + "// This is an automated generated file with the ./scripts/generate-package-list-check.ts script\n"; // biome-ignore lint/style/noUnusedTemplateLiteral: const exportStatementStart = `export const packageCheckListToInstall: PackageToInstallType[] = [`; @@ -28,44 +28,44 @@ const exportStatementEnd = `];\n`; const escapeDoubleQuotes = (str) => str.replace(/"/g, '\\"'); try { - // Ensure the output directory exists; if not, create it - if (!fs.existsSync(outputDirectory)) { - fs.mkdirSync(outputDirectory, { recursive: true }); - } + // Ensure the output directory exists; if not, create it + if (!fs.existsSync(outputDirectory)) { + fs.mkdirSync(outputDirectory, { recursive: true }); + } - // Read and parse package.json - const packageJsonData = fs.readFileSync(packageJsonPath, "utf-8"); - const packageJson = JSON.parse(packageJsonData); + // Read and parse package.json + const packageJsonData = fs.readFileSync(packageJsonPath, "utf-8"); + const packageJson = JSON.parse(packageJsonData); - // Extract dependencies and devDependencies - const dependencies = packageJson.dependencies || {}; - const devDependencies = packageJson.devDependencies || {}; + // Extract dependencies and devDependencies + const dependencies = packageJson.dependencies || {}; + const devDependencies = packageJson.devDependencies || {}; - // Combine both dependencies and devDependencies - const allPackages = { ...dependencies, ...devDependencies }; + // Combine both dependencies and devDependencies + const allPackages = { ...dependencies, ...devDependencies }; - // Optionally, you can categorize packages or add comments - // For simplicity, we'll just list all packages together + // Optionally, you can categorize packages or add comments + // For simplicity, we'll just list all packages together - // Generate the checklist array as TypeScript objects - const packageCheckListToInstall = Object.keys(allPackages).map((pkg) => { - return ` { + // Generate the checklist array as TypeScript objects + const packageCheckListToInstall = Object.keys(allPackages).map((pkg) => { + return ` { find: [\`from "${escapeDoubleQuotes(pkg)}"\`], packageName: "${pkg}", },`; - }); + }); - // Combine all parts to form the complete TypeScript file content - const tsFileContent = [ - commentStatement, - importStatement, - exportStatementStart, - ...packageCheckListToInstall, - exportStatementEnd, - ].join("\n"); + // Combine all parts to form the complete TypeScript file content + const tsFileContent = [ + commentStatement, + importStatement, + exportStatementStart, + ...packageCheckListToInstall, + exportStatementEnd, + ].join("\n"); - // Write the TypeScript file - fs.writeFileSync(outputTsPath, tsFileContent, "utf-8"); + // Write the TypeScript file + fs.writeFileSync(outputTsPath, tsFileContent, "utf-8"); } catch (_error) { - process.exit(1); + process.exit(1); } diff --git a/apps/website/src/app/(site)/[section]/[category]/layout.tsx b/apps/website/src/app/(site)/[section]/[category]/layout.tsx index 3bacf0d4..6954ce9f 100644 --- a/apps/website/src/app/(site)/[section]/[category]/layout.tsx +++ b/apps/website/src/app/(site)/[section]/[category]/layout.tsx @@ -8,79 +8,79 @@ import { findCategoryBySlug } from "#/src/utils/section-category-components-util import { findSectionBySlug } from "#/src/utils/section-category-components-utils/find-section-by-slug"; type Props = { - children: ReactNode; - params: { - section: string; - category: string; - }; + children: ReactNode; + params: { + section: string; + category: string; + }; }; export function generateMetadata({ params }: Props): Metadata { - const section = findSectionBySlug(params.section); - if (!section) { - return {}; - } + const section = findSectionBySlug(params.section); + if (!section) { + return {}; + } - if (section.type === "page") { - const page = section.pageList.find((page) => page.slug === params.category); - if (page) { - return { - title: page.name, - description: page.description, - openGraph: { - title: page.name, - description: page.description, - }, - alternates: { - canonical: `${NEXT_PUBLIC_SITE_URL}/${section.slug}/${page.slug}`, - }, - robots: "all", - }; - } - return {}; - } + if (section.type === "page") { + const page = section.pageList.find((page) => page.slug === params.category); + if (page) { + return { + title: page.name, + description: page.description, + openGraph: { + title: page.name, + description: page.description, + }, + alternates: { + canonical: `${NEXT_PUBLIC_SITE_URL}/${section.slug}/${page.slug}`, + }, + robots: "all", + }; + } + return {}; + } - const category = findCategoryBySlug(section, params.category); - if (category) { - return { - title: `${category.name} React Components`, - description: `${category.description}. Advanced ${category.name} React components using tailwind CSS. Just copy paste amazing UI and UX.`, - openGraph: { - title: `${category.name} React Components`, - description: `${category.description}. Advanced ${category.name} React components using tailwind CSS. Just copy paste amazing UI and UX.`, - }, - alternates: { - canonical: `${NEXT_PUBLIC_SITE_URL}/${section.slug}/${category.slug}`, - }, - robots: "all", - }; - } - return {}; + const category = findCategoryBySlug(section, params.category); + if (category) { + return { + title: `${category.name} React Components`, + description: `${category.description}. Advanced ${category.name} React components using tailwind CSS. Just copy paste amazing UI and UX.`, + openGraph: { + title: `${category.name} React Components`, + description: `${category.description}. Advanced ${category.name} React components using tailwind CSS. Just copy paste amazing UI and UX.`, + }, + alternates: { + canonical: `${NEXT_PUBLIC_SITE_URL}/${section.slug}/${category.slug}`, + }, + robots: "all", + }; + } + return {}; } export default function CategoryLayout({ children, params }: Props) { - const section = findSectionBySlug(params.section); - if (!section) { - return notFound(); - } - const category = findCategoryBySlug(section, params.category); - if (!category) { - return notFound(); - } - return ( - <> - - - - -

- {category.name} components -

- {children} - - ); + const section = findSectionBySlug(params.section); + if (!section) { + return notFound(); + } + const category = findCategoryBySlug(section, params.category); + if (!category) { + return notFound(); + } + return ( + <> + + + + +

+ {category.name} components +

+ {children} + + ); } diff --git a/apps/website/src/app/(site)/[section]/[category]/multiple-component-section.tsx b/apps/website/src/app/(site)/[section]/[category]/multiple-component-section.tsx index 86993cae..96e1d9f4 100644 --- a/apps/website/src/app/(site)/[section]/[category]/multiple-component-section.tsx +++ b/apps/website/src/app/(site)/[section]/[category]/multiple-component-section.tsx @@ -8,62 +8,62 @@ import type { CategoryType, SectionType } from "@cuicui/ui/lib/types/component"; import GithubEditButton from "#/src/components/component-wrapper/github-edit-button"; export default async function MultipleComponentCategory({ - category, - sectionSlug, + category, + sectionSlug, }: Readonly<{ category: CategoryType; sectionSlug: SectionType["slug"] }>) { - if (category.comingSoonCategory) { - return ; - } + if (category.comingSoonCategory) { + return ; + } - if (!category.componentList) { - return notFound(); - } + if (!category.componentList) { + return notFound(); + } - // If the componentList is not an array, we convert it to an array - const componentArray = Array.isArray(category.componentList) - ? category.componentList - : [category.componentList]; + // If the componentList is not an array, we convert it to an array + const componentArray = Array.isArray(category.componentList) + ? category.componentList + : [category.componentList]; - const componentList = await fetchMultipleComponentData({ - categorySlug: category.slug, - componentList: componentArray, - }); + const componentList = await fetchMultipleComponentData({ + categorySlug: category.slug, + componentList: componentArray, + }); - return ( -
- {componentList.map((component) => ( -
-
- -
- - - -
- ))} -
- ); + return ( +
+ {componentList.map((component) => ( +
+
+ +
+ + + +
+ ))} +
+ ); } diff --git a/apps/website/src/app/(site)/[section]/[category]/page.tsx b/apps/website/src/app/(site)/[section]/[category]/page.tsx index 217c63e0..3721cbaa 100644 --- a/apps/website/src/app/(site)/[section]/[category]/page.tsx +++ b/apps/website/src/app/(site)/[section]/[category]/page.tsx @@ -3,81 +3,81 @@ import MultipleComponentCategory from "#/src/app/(site)/[section]/[category]/mul import SingleComponentCategory from "#/src/app/(site)/[section]/[category]/single-component-section"; import { SectionsList } from "@cuicui/ui"; import type { - CategoryType, - SingleComponentCategoryType, + CategoryType, + SingleComponentCategoryType, } from "@cuicui/ui/lib/types/component"; import { findCategoryBySlug } from "#/src/utils/section-category-components-utils/find-category-by-slug"; type Props = { - params: { - section: string; - category: string; - }; + params: { + section: string; + category: string; + }; }; export async function generateStaticParams() { - const params = SectionsList.flatMap((section) => { - if ( - section.type === "multiple-component" || - section.type === "single-component" - ) { - return section.categoriesList.map((category) => ({ - section: section.slug, - category: category.slug, - })); - } - if (section.type === "page") { - return section.pageList.map((page) => ({ - section: section.slug, - category: page.slug, - })); - } - }); + const params = SectionsList.flatMap((section) => { + if ( + section.type === "multiple-component" || + section.type === "single-component" + ) { + return section.categoriesList.map((category) => ({ + section: section.slug, + category: category.slug, + })); + } + if (section.type === "page") { + return section.pageList.map((page) => ({ + section: section.slug, + category: page.slug, + })); + } + }); - // Return the generated params array - return params; + // Return the generated params array + return params; } export default async function Page({ params }: Readonly) { - const section = SectionsList.find( - (section) => section.slug === params.section, - ); - if (!section) { - return notFound(); - } - if (section?.type === "page") { - const page = section.pageList.find((page) => page.slug === params.category); - if (!page) { - return notFound(); - } - return page.component; - } + const section = SectionsList.find( + (section) => section.slug === params.section, + ); + if (!section) { + return notFound(); + } + if (section?.type === "page") { + const page = section.pageList.find((page) => page.slug === params.category); + if (!page) { + return notFound(); + } + return page.component; + } - if (section?.type === "single-component") { - const category = findCategoryBySlug( - section, - params.category, - ) as SingleComponentCategoryType | null; - if (!category) { - return notFound(); - } - return ( - - ); - } + if (section?.type === "single-component") { + const category = findCategoryBySlug( + section, + params.category, + ) as SingleComponentCategoryType | null; + if (!category) { + return notFound(); + } + return ( + + ); + } - if (section?.type === "multiple-component") { - const category = findCategoryBySlug( - section, - params.category, - ) as CategoryType | null; - if (!category) { - return notFound(); - } - return ( - - ); - } + if (section?.type === "multiple-component") { + const category = findCategoryBySlug( + section, + params.category, + ) as CategoryType | null; + if (!category) { + return notFound(); + } + return ( + + ); + } } diff --git a/apps/website/src/app/(site)/[section]/[category]/process-variant-data.ts b/apps/website/src/app/(site)/[section]/[category]/process-variant-data.ts index 330bb977..1c5c55b6 100644 --- a/apps/website/src/app/(site)/[section]/[category]/process-variant-data.ts +++ b/apps/website/src/app/(site)/[section]/[category]/process-variant-data.ts @@ -1,110 +1,110 @@ import type { - ComponentType, - ProcessedVariantType, - SingleComponentType, - VariantType, + ComponentType, + ProcessedVariantType, + SingleComponentType, + VariantType, } from "@cuicui/ui/lib/types/component"; import { getFileContentAsString } from "#/src/utils/get-file-content-as-string"; interface ProcessedComponent extends ComponentType { - componentList: ProcessedVariantType[]; + componentList: ProcessedVariantType[]; } export async function fetchVariantData({ - categorySlug, - componentSlug, - variant, + categorySlug, + componentSlug, + variant, }: { - categorySlug: string; - componentSlug?: string; - variant: VariantType; + categorySlug: string; + componentSlug?: string; + variant: VariantType; }) { - const variantName = variant.name; - const variantSlugPreviewFile = variant.slugPreviewFile ?? variantName; - const variantSlugComponentFile = variant.slugComponentFile ?? variantName; + const variantName = variant.name; + const variantSlugPreviewFile = variant.slugPreviewFile ?? variantName; + const variantSlugComponentFile = variant.slugComponentFile ?? variantName; - let previewCode: string | null = null; - let componentCode: string | undefined; - if (componentSlug) { - previewCode = await getFileContentAsString({ - componentSlug: categorySlug, - variantName: `${componentSlug}/${variantSlugPreviewFile}`, - }); + let previewCode: string | null = null; + let componentCode: string | undefined; + if (componentSlug) { + previewCode = await getFileContentAsString({ + componentSlug: categorySlug, + variantName: `${componentSlug}/${variantSlugPreviewFile}`, + }); - componentCode = variant.slugComponentFile - ? await getFileContentAsString({ - componentSlug: categorySlug, - variantName: `${componentSlug}/${variantSlugComponentFile}`, - }) - : undefined; - } else { - previewCode = await getFileContentAsString({ - componentSlug: categorySlug, - variantName: variantSlugPreviewFile, - }); + componentCode = variant.slugComponentFile + ? await getFileContentAsString({ + componentSlug: categorySlug, + variantName: `${componentSlug}/${variantSlugComponentFile}`, + }) + : undefined; + } else { + previewCode = await getFileContentAsString({ + componentSlug: categorySlug, + variantName: variantSlugPreviewFile, + }); - componentCode = variant.slugComponentFile - ? await getFileContentAsString({ - componentSlug: categorySlug, - variantName: variantSlugComponentFile, - }) - : undefined; - } - return { - ...variant, - previewCode, - componentCode, - }; + componentCode = variant.slugComponentFile + ? await getFileContentAsString({ + componentSlug: categorySlug, + variantName: variantSlugComponentFile, + }) + : undefined; + } + return { + ...variant, + previewCode, + componentCode, + }; } export async function fetchMultipleComponentData({ - componentList, - categorySlug, + componentList, + categorySlug, }: { - componentList: ComponentType[]; - categorySlug: string; + componentList: ComponentType[]; + categorySlug: string; }) { - const processedComponents: ProcessedComponent[] = []; + const processedComponents: ProcessedComponent[] = []; - for (const component of componentList) { - const processedVariants: ProcessedVariantType[] = []; + for (const component of componentList) { + const processedVariants: ProcessedVariantType[] = []; - for (const variant of component.variantList) { - const processedVariant = await fetchVariantData({ - categorySlug, - componentSlug: component.slug, - variant, - }); - processedVariants.push(processedVariant); - } + for (const variant of component.variantList) { + const processedVariant = await fetchVariantData({ + categorySlug, + componentSlug: component.slug, + variant, + }); + processedVariants.push(processedVariant); + } - processedComponents.push({ - ...component, - sizePreview: component.sizePreview, - componentList: processedVariants, - isIframed: component.isIframed ?? false, - }); - } + processedComponents.push({ + ...component, + sizePreview: component.sizePreview, + componentList: processedVariants, + isIframed: component.isIframed ?? false, + }); + } - return processedComponents; + return processedComponents; } export async function fetchSingleComponentData({ - categorySlug, - component, + categorySlug, + component, }: { - categorySlug: string; - component: SingleComponentType; + categorySlug: string; + component: SingleComponentType; }) { - const processedVariants: ProcessedVariantType[] = []; + const processedVariants: ProcessedVariantType[] = []; - for (const variant of component.variantList) { - const processedVariant = await fetchVariantData({ categorySlug, variant }); - processedVariants.push(processedVariant); - } + for (const variant of component.variantList) { + const processedVariant = await fetchVariantData({ categorySlug, variant }); + processedVariants.push(processedVariant); + } - return { - ...component, - componentList: processedVariants, - }; + return { + ...component, + componentList: processedVariants, + }; } diff --git a/apps/website/src/app/(site)/[section]/[category]/single-component-section.tsx b/apps/website/src/app/(site)/[section]/[category]/single-component-section.tsx index e9a2e02a..51bc9831 100644 --- a/apps/website/src/app/(site)/[section]/[category]/single-component-section.tsx +++ b/apps/website/src/app/(site)/[section]/[category]/single-component-section.tsx @@ -5,61 +5,61 @@ import HeaderComponent from "#/src/components/component-wrapper/header-component import InspirationComponentFooter from "#/src/components/component-wrapper/inspiration-component-footer"; import VariantTabs from "#/src/components/component-wrapper/variant-tabs"; import type { - SectionType, - SingleComponentCategoryType, + SectionType, + SingleComponentCategoryType, } from "@cuicui/ui/lib/types/component"; import GithubEditButton from "#/src/components/component-wrapper/github-edit-button"; export default async function SingleComponentCategory({ - category, - sectionSlug, + category, + sectionSlug, }: Readonly<{ - category: SingleComponentCategoryType; - sectionSlug: SectionType["slug"]; + category: SingleComponentCategoryType; + sectionSlug: SectionType["slug"]; }>) { - if (category.comingSoonCategory) { - return ; - } + if (category.comingSoonCategory) { + return ; + } - if (!category.component) { - return notFound(); - } + if (!category.component) { + return notFound(); + } - const component = await fetchSingleComponentData({ - categorySlug: category.slug, - component: { ...category.component }, - }); + const component = await fetchSingleComponentData({ + categorySlug: category.slug, + component: { ...category.component }, + }); - return ( -
-
-
- -
- - - -
-
- ); + return ( +
+
+
+ +
+ + + +
+
+ ); } diff --git a/apps/website/src/app/(site)/[section]/layout.tsx b/apps/website/src/app/(site)/[section]/layout.tsx index 7a3d81a0..982fbba3 100644 --- a/apps/website/src/app/(site)/[section]/layout.tsx +++ b/apps/website/src/app/(site)/[section]/layout.tsx @@ -7,49 +7,49 @@ import { NEXT_PUBLIC_SITE_URL } from "#/src/lib/site.const"; import { findSectionBySlug } from "#/src/utils/section-category-components-utils/find-section-by-slug"; type Props = { - children: ReactNode; - params: { - section: string; - category: string; - }; + children: ReactNode; + params: { + section: string; + category: string; + }; }; export function generateMetadata({ params }: Props): Metadata { - const section = findSectionBySlug(params.section); + const section = findSectionBySlug(params.section); - // optionally access and extend (rather than replace) parent metadata + // optionally access and extend (rather than replace) parent metadata - if (!section) { - return {}; - } - return { - title: section.name, - description: section.description, - openGraph: { - title: section.name, - description: section.description, - }, - alternates: { - canonical: `${NEXT_PUBLIC_SITE_URL}/${section.slug}`, - }, - }; + if (!section) { + return {}; + } + return { + title: section.name, + description: section.description, + openGraph: { + title: section.name, + description: section.description, + }, + alternates: { + canonical: `${NEXT_PUBLIC_SITE_URL}/${section.slug}`, + }, + }; } export default function SectionLayout({ children, params }: Props) { - const section = findSectionBySlug(params.section); - if (!section) { - return notFound(); - } - return ( - <> - - - - {children} - - ); + const section = findSectionBySlug(params.section); + if (!section) { + return notFound(); + } + return ( + <> + + + + {children} + + ); } diff --git a/apps/website/src/app/(site)/[section]/page.tsx b/apps/website/src/app/(site)/[section]/page.tsx index 189e2f1e..cf5bdfb3 100644 --- a/apps/website/src/app/(site)/[section]/page.tsx +++ b/apps/website/src/app/(site)/[section]/page.tsx @@ -6,66 +6,66 @@ import { MainMenusGradientCard } from "@cuicui/ui/cuicui/other/cursors/dynamic-c import { findSectionBySlug } from "#/src/utils/section-category-components-utils/find-section-by-slug"; type Props = { - params: { section: string }; + params: { section: string }; }; export default function Page({ params }: Readonly) { - const section = findSectionBySlug(params.section); - if (!section) { - return notFound(); - } - if (section.slug !== params.section) { - return notFound(); - } - if (section.type === "page") { - return ( - <> -

{section.name} category

-

{section.description}

- - {section.pageList.map((category) => { - return ( - - - - ); - })} - - - ); - } - return ( - <> -

{section.name} category

-

{section.description}

- - {section.categoriesList.map((category) => { - return ( - - - - - - ); - })} - - - ); + const section = findSectionBySlug(params.section); + if (!section) { + return notFound(); + } + if (section.slug !== params.section) { + return notFound(); + } + if (section.type === "page") { + return ( + <> +

{section.name} category

+

{section.description}

+ + {section.pageList.map((category) => { + return ( + + + + ); + })} + + + ); + } + return ( + <> +

{section.name} category

+

{section.description}

+ + {section.categoriesList.map((category) => { + return ( + + + + + + ); + })} + + + ); - // return notFound(); + // return notFound(); } diff --git a/apps/website/src/app/(site)/about/page.tsx b/apps/website/src/app/(site)/about/page.tsx index e89794f9..75b63297 100644 --- a/apps/website/src/app/(site)/about/page.tsx +++ b/apps/website/src/app/(site)/about/page.tsx @@ -3,110 +3,110 @@ import type { Metadata } from "next"; const { NEXT_PUBLIC_SITE_URL } = process.env; export const metadata: Metadata = { - title: "About Us - CuiCui", - description: - "Discover our library focused on copy-paste simplicity, enabling easy code changes, good practices, and diverse artistic styles.", - keywords: [ - "copy-paste library", - "code simplicity", - "easy customization", - "good coding practices", - "diverse styles", - "glasmorphism", - "flat UI", - "skeuomorphism", - "neomorphism", - ], - openGraph: { - title: "About Us - CuiCui", - description: - "Learn more about the only UI library you need, simply copy-paste, use best React tools, best practices, and more creative components.", - url: `${NEXT_PUBLIC_SITE_URL}/about`, - type: "website", - siteName: "CuiCui", - }, + title: "About Us - CuiCui", + description: + "Discover our library focused on copy-paste simplicity, enabling easy code changes, good practices, and diverse artistic styles.", + keywords: [ + "copy-paste library", + "code simplicity", + "easy customization", + "good coding practices", + "diverse styles", + "glasmorphism", + "flat UI", + "skeuomorphism", + "neomorphism", + ], + openGraph: { + title: "About Us - CuiCui", + description: + "Learn more about the only UI library you need, simply copy-paste, use best React tools, best practices, and more creative components.", + url: `${NEXT_PUBLIC_SITE_URL}/about`, + type: "website", + siteName: "CuiCui", + }, }; const aboutContent = { - libraryIntroduction: { - title: "Why this Library?", - text: `Welcome to "CuiCui" library, where simplicity meets creativity! I believe in the power of copy-paste for learning and implementing code. By providing easy-to-use, clean, and well-documented components, I empower developers to quickly integrate and modify code to suit their needs.`, - subSection: { - title: "And Why CuiCui?", - text: `The name "CuiCui" is can't be more explicit with its repetition of "UI". I believe that a good UI is the key to a delightful and efficient user experience. Additionally, "CuiCui" phonetically resembles "quick UI," emphasizing how easy it is to use.`, - finalNote: `In French, "cui-cui" is an onomatopoeia for bird sounds, and... well, I think it sounds cute!`, - }, - }, - sections: [ - { - title: "Copy-Paste simplicity", - text: "Our library is designed to be as straightforward as possible. No hidden complexities, no unnecessary dependencies. Just pure, clean code that you can copy directly into your project. This approach not only saves time but also helps you understand what’s happening under the hood.", - }, - { - title: "Easy customization", - text: "Customization is at the heart of our library. I make it incredibly simple to tweak and adjust our components. Whether you want to change a color, adjust spacing, or even overhaul the entire look, our code is structured to make these changes easy and intuitive.", - }, - { - title: "Promoting good practices", - text: "I are committed to promoting good coding practices. Our components are built with clean, efficient, and optimized code. I avoid bloat and focus on delivering quality over quantity. Each component is a showcase of how to write effective and maintainable code.", - }, - { - title: "Diverse artistic directions", - text: "Uniformity can be boring. That’s why I offer a variety of artistic styles, from glasmorphism and flat UI to skeuomorphism and neomorphism. Our library is a playground of visual design, allowing you to choose and combine styles to create something truly unique.", - }, - { - title: "Dark & Light Mode", - text: "This high-quality component library supports both dark and light mode, ensuring that your components look great no matter the user’s preference. With a simple toggle, you can switch between modes and see your components adapt seamlessly to the new color scheme.", - }, - { - title: "Micro interactions", - text: "Micro interactions are the small animations and effects that bring a website to life. Our library includes a range of micro interactions that add polish and sophistication to your components. From hover effects to loading animations, these subtle details make a big difference in the overall user experience. This is rarely seen in other libraries, but I believe it’s an essential part of creating a truly engaging UI.", - }, - { - title: "Learning how the components work under the hood", - text: `I believe that understanding how a component works is essential for any developer. That’s why I provide detailed documentation for each component, explaining how it’s built and how you can customize it. By diving into the code, you can learn new techniques, improve your skills, and gain a deeper understanding of front-end development. + libraryIntroduction: { + title: "Why this Library?", + text: `Welcome to "CuiCui" library, where simplicity meets creativity! I believe in the power of copy-paste for learning and implementing code. By providing easy-to-use, clean, and well-documented components, I empower developers to quickly integrate and modify code to suit their needs.`, + subSection: { + title: "And Why CuiCui?", + text: `The name "CuiCui" is can't be more explicit with its repetition of "UI". I believe that a good UI is the key to a delightful and efficient user experience. Additionally, "CuiCui" phonetically resembles "quick UI," emphasizing how easy it is to use.`, + finalNote: `In French, "cui-cui" is an onomatopoeia for bird sounds, and... well, I think it sounds cute!`, + }, + }, + sections: [ + { + title: "Copy-Paste simplicity", + text: "Our library is designed to be as straightforward as possible. No hidden complexities, no unnecessary dependencies. Just pure, clean code that you can copy directly into your project. This approach not only saves time but also helps you understand what’s happening under the hood.", + }, + { + title: "Easy customization", + text: "Customization is at the heart of our library. I make it incredibly simple to tweak and adjust our components. Whether you want to change a color, adjust spacing, or even overhaul the entire look, our code is structured to make these changes easy and intuitive.", + }, + { + title: "Promoting good practices", + text: "I are committed to promoting good coding practices. Our components are built with clean, efficient, and optimized code. I avoid bloat and focus on delivering quality over quantity. Each component is a showcase of how to write effective and maintainable code.", + }, + { + title: "Diverse artistic directions", + text: "Uniformity can be boring. That’s why I offer a variety of artistic styles, from glasmorphism and flat UI to skeuomorphism and neomorphism. Our library is a playground of visual design, allowing you to choose and combine styles to create something truly unique.", + }, + { + title: "Dark & Light Mode", + text: "This high-quality component library supports both dark and light mode, ensuring that your components look great no matter the user’s preference. With a simple toggle, you can switch between modes and see your components adapt seamlessly to the new color scheme.", + }, + { + title: "Micro interactions", + text: "Micro interactions are the small animations and effects that bring a website to life. Our library includes a range of micro interactions that add polish and sophistication to your components. From hover effects to loading animations, these subtle details make a big difference in the overall user experience. This is rarely seen in other libraries, but I believe it’s an essential part of creating a truly engaging UI.", + }, + { + title: "Learning how the components work under the hood", + text: `I believe that understanding how a component works is essential for any developer. That’s why I provide detailed documentation for each component, explaining how it’s built and how you can customize it. By diving into the code, you can learn new techniques, improve your skills, and gain a deeper understanding of front-end development. And this is also the reason why I don't create a library but only provide copy paste code. I want developers to understand what you are using and how it works.`, - }, - ], - footer: { - text: "© 2024 CuiCui. All rights reserved. (on the site, I mean of course there is no right on copy pasted code)", - }, + }, + ], + footer: { + text: "© 2024 CuiCui. All rights reserved. (on the site, I mean of course there is no right on copy pasted code)", + }, }; export default function AboutPage() { - return ( - <> -
-
-

{aboutContent.libraryIntroduction.title}

-

{aboutContent.libraryIntroduction.text}

-
-

- {aboutContent.libraryIntroduction.subSection.title} -

-

- {aboutContent.libraryIntroduction.subSection.text} -

-
And most of all
-

- {aboutContent.libraryIntroduction.subSection.finalNote} -

-
-
+ return ( + <> +
+
+

{aboutContent.libraryIntroduction.title}

+

{aboutContent.libraryIntroduction.text}

+
+

+ {aboutContent.libraryIntroduction.subSection.title} +

+

+ {aboutContent.libraryIntroduction.subSection.text} +

+
And most of all
+

+ {aboutContent.libraryIntroduction.subSection.finalNote} +

+
+
- {aboutContent.sections.map((section, _index) => ( -
-

{section.title}

-
-

{section.text}

-
- ))} -
-
-
-

{aboutContent.footer.text}

-
- - ); + {aboutContent.sections.map((section, _index) => ( +
+

{section.title}

+
+

{section.text}

+
+ ))} +
+
+
+

{aboutContent.footer.text}

+
+ + ); } diff --git a/apps/website/src/app/(site)/getting-started/page.tsx b/apps/website/src/app/(site)/getting-started/page.tsx index 38b7cc93..dd4f8047 100644 --- a/apps/website/src/app/(site)/getting-started/page.tsx +++ b/apps/website/src/app/(site)/getting-started/page.tsx @@ -5,81 +5,81 @@ import { StaticStep } from "#/src/ui/stepper"; import type { Metadata } from "next"; export const metadata: Metadata = { - title: "Getting Started - CuiCui", - description: - "Learn how to use the only UI library you need, simply copy-paste, use best React tools, best practices, and more creative components.", - keywords: [ - "copy-paste library", - "code simplicity", - "easy customization", - "good coding practices", - "diverse styles", - "glasmorphism", - "flat UI", - "skeuomorphism", - "neomorphism", - ], - openGraph: { - title: "Getting Started - CuiCui", - description: - "Learn how to use the only UI library you need, simply copy-paste, use best React tools, best practices, and more creative components.", - url: `${NEXT_PUBLIC_SITE_URL}/about`, - type: "website", - siteName: "CuiCui", - }, + title: "Getting Started - CuiCui", + description: + "Learn how to use the only UI library you need, simply copy-paste, use best React tools, best practices, and more creative components.", + keywords: [ + "copy-paste library", + "code simplicity", + "easy customization", + "good coding practices", + "diverse styles", + "glasmorphism", + "flat UI", + "skeuomorphism", + "neomorphism", + ], + openGraph: { + title: "Getting Started - CuiCui", + description: + "Learn how to use the only UI library you need, simply copy-paste, use best React tools, best practices, and more creative components.", + url: `${NEXT_PUBLIC_SITE_URL}/about`, + type: "website", + siteName: "CuiCui", + }, }; export default function Page() { - return ( -
-
-

Getting Started with Cuicui

-

- This library is designed for use in a React TypeScript environment. - Before integrating Cuicui components, ensure that your project is set - up with basic React tooling. -

-
+ return ( +
+
+

Getting Started with Cuicui

+

+ This library is designed for use in a React TypeScript environment. + Before integrating Cuicui components, ensure that your project is set + up with basic React tooling. +

+
-
-

The "cn" function

-

- The cn function is a utility for generating{" "} - className strings compatible with TailwindCSS utility - classes. Many Cuicui components rely on this function, making it an - essential part of your toolkit. -

-

- Benefits of Using the cn function -

-
    -
  • - Readable and maintainable className strings, with easy inline - comments for styles. -
  • -
  • - Supports conditional styles with TailwindCSS, enhancing flexibility. -
  • -
  • Simplifies maintenance by consolidating class name logic.
  • -
+
+

The "cn" function

+

+ The cn function is a utility for generating{" "} + className strings compatible with TailwindCSS utility + classes. Many Cuicui components rely on this function, making it an + essential part of your toolkit. +

+

+ Benefits of Using the cn function +

+
    +
  • + Readable and maintainable className strings, with easy inline + comments for styles. +
  • +
  • + Supports conditional styles with TailwindCSS, enhancing flexibility. +
  • +
  • Simplifies maintenance by consolidating class name logic.
  • +
-

How to Install the cn Function

-
- - tailwind-merge - +

How to Install the cn Function

+
+ + tailwind-merge + - - clsx - + + clsx + - -

- Create a cn.ts file in your project's{" "} - utils folder and add the following code: -

- - {`// ./src/utils/cn.ts + +

+ Create a cn.ts file in your project's{" "} + utils folder and add the following code: +

+ + {`// ./src/utils/cn.ts import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; @@ -87,10 +87,10 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } `} - -
-
-
-
- ); + + +
+ +
+ ); } diff --git a/apps/website/src/app/(site)/layout.tsx b/apps/website/src/app/(site)/layout.tsx index b0a40258..ea4a6cf5 100644 --- a/apps/website/src/app/(site)/layout.tsx +++ b/apps/website/src/app/(site)/layout.tsx @@ -7,33 +7,33 @@ import { StaticNoise } from "@/cuicui/other/creative-effects/animated-noise/stat import type React from "react"; export default function ComponentsLayout({ - children, + children, }: Readonly<{ children: React.ReactNode }>) { - return ( - <> -
- {/* Note: The noise effect is experimental and may affect the design. Consider its impact before using it officialy. */} - - + return ( + <> +
+ {/* Note: The noise effect is experimental and may affect the design. Consider its impact before using it officialy. */} + + -
- {/* Add overflow-auto if layout width problems */} +
+ {/* Add overflow-auto if layout width problems */} - + -
-
{children}
-
+
+
{children}
+
-
- -
-
-
- - - ); +
+ +
+
+
+ + + ); } diff --git a/apps/website/src/app/api/get-components/get-components.utils.ts b/apps/website/src/app/api/get-components/get-components.utils.ts index 9d404d8d..9b2d5800 100644 --- a/apps/website/src/app/api/get-components/get-components.utils.ts +++ b/apps/website/src/app/api/get-components/get-components.utils.ts @@ -2,131 +2,131 @@ import type { FileSystemNode } from "#/src/app/api/get-components/route"; // Helper function to extract categories from the tree export function extractCategories(node: FileSystemNode): CategoryType[] { - const categories: CategoryType[] = []; - - if ( - node.type === "directory" && - node.config && - node.config.type === "category" - ) { - const category: CategoryType = { - slug: node.config.slug, - name: node.config.name, - description: node.config.description, - releaseDateCategory: node.config.releaseDateCategory - ? new Date(node.config.releaseDateCategory) - : undefined, - icon: node.config.icon, - previewCategory: node.config.previewCategory, - componentList: [], - }; - - if (node.children) { - for (const child of node.children) { - const components = extractComponents(child); - category.componentList.push(...components); - } - } - - categories.push(category); - } else if (node.children) { - for (const child of node.children) { - categories.push(...extractCategories(child)); - } - } - - return categories; + const categories: CategoryType[] = []; + + if ( + node.type === "directory" && + node.config && + node.config.type === "category" + ) { + const category: CategoryType = { + slug: node.config.slug, + name: node.config.name, + description: node.config.description, + releaseDateCategory: node.config.releaseDateCategory + ? new Date(node.config.releaseDateCategory) + : undefined, + icon: node.config.icon, + previewCategory: node.config.previewCategory, + componentList: [], + }; + + if (node.children) { + for (const child of node.children) { + const components = extractComponents(child); + category.componentList.push(...components); + } + } + + categories.push(category); + } else if (node.children) { + for (const child of node.children) { + categories.push(...extractCategories(child)); + } + } + + return categories; } // Helper function to extract components from the tree export function extractComponents(node: FileSystemNode): ComponentType[] { - const components: ComponentType[] = []; - - if ( - node.type === "directory" && - node.config && - node.config.type === "component" - ) { - const component: ComponentType = { - title: node.config.title, - description: node.config.description, - sizePreview: node.config.sizePreview, - slug: node.config.slug, - isIframed: node.config.isIframed, - variantList: [], - inspiration: node.config.inspiration, - inspirationLink: node.config.inspirationLink, - }; - - if (node.children) { - for (const child of node.children) { - const variants = extractVariants(child); - component.variantList.push(...variants); - } - } - - components.push(component); - } else if (node.children) { - for (const child of node.children) { - components.push(...extractComponents(child)); - } - } - - return components; + const components: ComponentType[] = []; + + if ( + node.type === "directory" && + node.config && + node.config.type === "component" + ) { + const component: ComponentType = { + title: node.config.title, + description: node.config.description, + sizePreview: node.config.sizePreview, + slug: node.config.slug, + isIframed: node.config.isIframed, + variantList: [], + inspiration: node.config.inspiration, + inspirationLink: node.config.inspirationLink, + }; + + if (node.children) { + for (const child of node.children) { + const variants = extractVariants(child); + component.variantList.push(...variants); + } + } + + components.push(component); + } else if (node.children) { + for (const child of node.children) { + components.push(...extractComponents(child)); + } + } + + return components; } // Helper function to extract variants from the tree export function extractVariants(node: FileSystemNode): VariantType[] { - const variants: VariantType[] = []; - - if ( - node.type === "directory" && - node.config && - node.config.type === "variant" - ) { - const variant: VariantType = { - name: node.config.name, - slugPreviewFile: node.config.slugPreviewFile, - slugComponentFile: node.config.slugComponentFile, - }; - - variants.push(variant); - } else if (node.children) { - for (const child of node.children) { - variants.push(...extractVariants(child)); - } - } - - return variants; + const variants: VariantType[] = []; + + if ( + node.type === "directory" && + node.config && + node.config.type === "variant" + ) { + const variant: VariantType = { + name: node.config.name, + slugPreviewFile: node.config.slugPreviewFile, + slugComponentFile: node.config.slugComponentFile, + }; + + variants.push(variant); + } else if (node.children) { + for (const child of node.children) { + variants.push(...extractVariants(child)); + } + } + + return variants; } export type VariantType = { - name: string; - slugPreviewFile: string; - slugComponentFile?: string; + name: string; + slugPreviewFile: string; + slugComponentFile?: string; }; export type ComponentType = { - title: string; - description: string; - sizePreview: string; - slug: string; - isIframed?: boolean; - variantList: VariantType[]; - inspiration?: string; - inspirationLink?: string; + title: string; + description: string; + sizePreview: string; + slug: string; + isIframed?: boolean; + variantList: VariantType[]; + inspiration?: string; + inspirationLink?: string; }; export type CategoryType = { - slug: string; - name: string; - description: string; - releaseDateCategory?: Date; - icon?: string; // Adjusted to string for simplicity - previewCategory?: { - component?: string; // Adjusted to string for simplicity - previewImage?: string; - previewScale?: number; - }; - componentList: ComponentType[]; + slug: string; + name: string; + description: string; + releaseDateCategory?: Date; + icon?: string; // Adjusted to string for simplicity + previewCategory?: { + component?: string; // Adjusted to string for simplicity + previewImage?: string; + previewScale?: number; + }; + componentList: ComponentType[]; }; diff --git a/apps/website/src/app/api/get-components/route.ts b/apps/website/src/app/api/get-components/route.ts index 4c1df413..d83cabf1 100644 --- a/apps/website/src/app/api/get-components/route.ts +++ b/apps/website/src/app/api/get-components/route.ts @@ -3,59 +3,59 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs"; import { join } from "node:path"; import { - extractCategories, - extractComponents, - extractVariants, + extractCategories, + extractComponents, + extractVariants, } from "#/src/app/api/get-components/get-components.utils"; export type FileSystemNode = { - name: string; - path: string; - type: "file" | "directory"; - // biome-ignore lint/suspicious/noExplicitAny: - config?: any; - children?: FileSystemNode[]; + name: string; + path: string; + type: "file" | "directory"; + // biome-ignore lint/suspicious/noExplicitAny: + config?: any; + children?: FileSystemNode[]; }; function getDirectoryTree(dirPath: string): FileSystemNode { - const stats = statSync(dirPath); - const name = dirPath.split("/").pop() ?? dirPath; - const node: FileSystemNode = { - name, - path: dirPath, - type: stats.isDirectory() ? "directory" : "file", - }; - - if (stats.isDirectory()) { - // Check for config.json in the directory - const configPath = join(dirPath, "config.json"); - if (existsSync(configPath)) { - const configContent = readFileSync(configPath, "utf-8"); - try { - node.config = JSON.parse(configContent); - } catch (_error) { - // Ignore invalid JSON - } - } - - // Recursively read children - node.children = readdirSync(dirPath) - .filter((childName) => childName !== "config.json") // Exclude config.json from children - .map((childName) => { - return getDirectoryTree(join(dirPath, childName)); - }); - } - - return node; + const stats = statSync(dirPath); + const name = dirPath.split("/").pop() ?? dirPath; + const node: FileSystemNode = { + name, + path: dirPath, + type: stats.isDirectory() ? "directory" : "file", + }; + + if (stats.isDirectory()) { + // Check for config.json in the directory + const configPath = join(dirPath, "config.json"); + if (existsSync(configPath)) { + const configContent = readFileSync(configPath, "utf-8"); + try { + node.config = JSON.parse(configContent); + } catch (_error) { + // Ignore invalid JSON + } + } + + // Recursively read children + node.children = readdirSync(dirPath) + .filter((childName) => childName !== "config.json") // Exclude config.json from children + .map((childName) => { + return getDirectoryTree(join(dirPath, childName)); + }); + } + + return node; } export function GET() { - const basePath = join(process.cwd(), "../../packages/ui/cuicui/"); - const tree = getDirectoryTree(basePath); - - // Optionally, you can process the tree to extract categories, components, and variants - const categories = extractCategories(tree); - const components = extractComponents(tree); - const variants = extractVariants(tree); - return Response.json({ categories, components, variants, tree }); + const basePath = join(process.cwd(), "../../packages/ui/cuicui/"); + const tree = getDirectoryTree(basePath); + + // Optionally, you can process the tree to extract categories, components, and variants + const categories = extractCategories(tree); + const components = extractComponents(tree); + const variants = extractVariants(tree); + return Response.json({ categories, components, variants, tree }); } diff --git a/apps/website/src/app/card.tsx b/apps/website/src/app/card.tsx index 0393ac46..80b5aab8 100644 --- a/apps/website/src/app/card.tsx +++ b/apps/website/src/app/card.tsx @@ -1,40 +1,40 @@ import Image from "next/image"; import type { - CategoryType, - SingleComponentCategoryType, + CategoryType, + SingleComponentCategoryType, } from "@cuicui/ui/lib/types/component"; export const MainMenuCardContent = ({ - category, - sectionSlug, + category, + sectionSlug, }: { - category: CategoryType | SingleComponentCategoryType; - sectionSlug: string; + category: CategoryType | SingleComponentCategoryType; + sectionSlug: string; }) => { - if (category?.comingSoonCategory) { - return ( -

- Coming Soon -

- ); - } + if (category?.comingSoonCategory) { + return ( +

+ Coming Soon +

+ ); + } - return ( - <> - {`${category.name} - {`${category.name} - - ); + return ( + <> + {`${category.name} + {`${category.name} + + ); }; diff --git a/apps/website/src/app/dev/generate-preview-images/generate-preview-images.tsx b/apps/website/src/app/dev/generate-preview-images/generate-preview-images.tsx index ffc6dbc7..e7919cf4 100644 --- a/apps/website/src/app/dev/generate-preview-images/generate-preview-images.tsx +++ b/apps/website/src/app/dev/generate-preview-images/generate-preview-images.tsx @@ -11,123 +11,123 @@ const HEIGHT_SCREENSHOT = 500; const THEMES_ARRAY = ["light", "dark"]; export default function GeneratePreviewImages() { - const [currentComponent, setCurrentComponent] = useState(null); - const [isProcessing, setIsProcessing] = useState(false); - const { setTheme } = useTheme(); - useEffect(() => { - if (!isProcessing) { - processComponents(); - } + const [currentComponent, setCurrentComponent] = useState(null); + const [isProcessing, setIsProcessing] = useState(false); + const { setTheme } = useTheme(); + useEffect(() => { + if (!isProcessing) { + processComponents(); + } - async function processComponents() { - const sections = SectionsList.filter( - (section) => - section.type === "multiple-component" || - section.type === "single-component", - ); - for (const theme of THEMES_ARRAY) { - setTheme(theme); - for (const section of sections) { - // @ts-ignore - for (const category of section.categoriesList) { - setCurrentComponent( - - {category.previewCategory?.component} - , - ); + async function processComponents() { + const sections = SectionsList.filter( + (section) => + section.type === "multiple-component" || + section.type === "single-component", + ); + for (const theme of THEMES_ARRAY) { + setTheme(theme); + for (const section of sections) { + // @ts-ignore + for (const category of section.categoriesList) { + setCurrentComponent( + + {category.previewCategory?.component} + , + ); - // Wait for the component to render and capture the screenshot - await new Promise((resolve) => setTimeout(resolve, 1500)); // Adjust delay as needed - } - } - } + // Wait for the component to render and capture the screenshot + await new Promise((resolve) => setTimeout(resolve, 1500)); // Adjust delay as needed + } + } + } - // All components have been processed - setIsProcessing(false); - setCurrentComponent(null); - } - }, [isProcessing, setTheme]); - if (isProcessing) { - return <>{currentComponent}; - } - return ( - - ); + // All components have been processed + setIsProcessing(false); + setCurrentComponent(null); + } + }, [isProcessing, setTheme]); + if (isProcessing) { + return <>{currentComponent}; + } + return ( + + ); } const ComponentToRender = ({ - fileName, - children, - scale, + fileName, + children, + scale, }: { - fileName: string; - children: ReactNode; - scale?: number; + fileName: string; + children: ReactNode; + scale?: number; }) => { - const ref = useRef(null); - const hasCaptured = useRef(false); + const ref = useRef(null); + const hasCaptured = useRef(false); - useEffect(() => { - if (hasCaptured.current) { - return; - } - hasCaptured.current = true; - const captureComponent = async () => { - // Wait for the component to fully render - await new Promise((resolve) => setTimeout(resolve, 1000)); // Adjust delay as needed + useEffect(() => { + if (hasCaptured.current) { + return; + } + hasCaptured.current = true; + const captureComponent = async () => { + // Wait for the component to fully render + await new Promise((resolve) => setTimeout(resolve, 1000)); // Adjust delay as needed - if (ref.current) { - domtoimage - .toPng(ref.current, { - copyDefaultStyles: false, - width: WIDTH_SCREENSHOT, - height: HEIGHT_SCREENSHOT, - scale: 1, - }) - .then((dataUrl: string) => { - const link = document.createElement("a"); - link.download = `${fileName}.png`; - link.href = dataUrl; - link.click(); - }) - .catch((error: unknown) => { - console.error("Oops, something went wrong!", error); - }); - } - }; + if (ref.current) { + domtoimage + .toPng(ref.current, { + copyDefaultStyles: false, + width: WIDTH_SCREENSHOT, + height: HEIGHT_SCREENSHOT, + scale: 1, + }) + .then((dataUrl: string) => { + const link = document.createElement("a"); + link.download = `${fileName}.png`; + link.href = dataUrl; + link.click(); + }) + .catch((error: unknown) => { + console.error("Oops, something went wrong!", error); + }); + } + }; - captureComponent(); - }, [fileName]); + captureComponent(); + }, [fileName]); - return ( - <> - -
- {children} -
- - ); + +
+ {children} +
+ + ); }; diff --git a/apps/website/src/app/dev/generate-preview-images/page.tsx b/apps/website/src/app/dev/generate-preview-images/page.tsx index 8cf959db..d976d658 100644 --- a/apps/website/src/app/dev/generate-preview-images/page.tsx +++ b/apps/website/src/app/dev/generate-preview-images/page.tsx @@ -2,14 +2,14 @@ import GeneratePreviewImages from "./generate-preview-images"; import type { Metadata } from "next"; export const metadata: Metadata = { - referrer: "no-referrer", - robots: "noindex, nofollow", + referrer: "no-referrer", + robots: "noindex, nofollow", }; export default function PageGeneratePreviewImages() { - if (process.env.NODE_ENV === "production") { - return null; - } + if (process.env.NODE_ENV === "production") { + return null; + } - return ; + return ; } diff --git a/apps/website/src/app/dev/page.tsx b/apps/website/src/app/dev/page.tsx index 02330c93..84a2db66 100644 --- a/apps/website/src/app/dev/page.tsx +++ b/apps/website/src/app/dev/page.tsx @@ -2,5 +2,5 @@ import Modern3dKbdVariant1 from "@/cuicui/application-ui/kbd/modern-3d-kbd/varia import React from "react"; export default function Page() { - return ; + return ; } diff --git a/apps/website/src/app/dev/playground-component/page.tsx b/apps/website/src/app/dev/playground-component/page.tsx index 7c9ca61c..eb7e0ea0 100644 --- a/apps/website/src/app/dev/playground-component/page.tsx +++ b/apps/website/src/app/dev/playground-component/page.tsx @@ -2,14 +2,14 @@ import Playground from "#/src/app/dev/playground-component/playground"; import type { Metadata } from "next"; export const metadata: Metadata = { - referrer: "no-referrer", - robots: "noindex, nofollow", + referrer: "no-referrer", + robots: "noindex, nofollow", }; export default function PageGeneratePreviewImages() { - if (process.env.NODE_ENV === "production") { - return null; - } + if (process.env.NODE_ENV === "production") { + return null; + } - return ; + return ; } diff --git a/apps/website/src/app/dev/playground-component/playground.tsx b/apps/website/src/app/dev/playground-component/playground.tsx index 253babd6..291b1faa 100644 --- a/apps/website/src/app/dev/playground-component/playground.tsx +++ b/apps/website/src/app/dev/playground-component/playground.tsx @@ -1,15 +1,15 @@ import React from "react"; export default function Playground() { - return ( -
- -
- ); + return ( +
+ +
+ ); } diff --git a/apps/website/src/app/dev/playground-component/test.tsx b/apps/website/src/app/dev/playground-component/test.tsx index 203f468f..510a2e90 100644 --- a/apps/website/src/app/dev/playground-component/test.tsx +++ b/apps/website/src/app/dev/playground-component/test.tsx @@ -2,5 +2,5 @@ import Modern3dKbdVariant1 from "@/cuicui/application-ui/kbd/modern-3d-kbd/varia import React from "react"; export default function test() { - return ; + return ; } diff --git a/apps/website/src/app/layout.tsx b/apps/website/src/app/layout.tsx index d761d779..1a2be539 100644 --- a/apps/website/src/app/layout.tsx +++ b/apps/website/src/app/layout.tsx @@ -7,64 +7,64 @@ import type { ReactNode } from "react"; import Providers from "#/src/app/providers"; import PlausibleScripts from "#/src/components/analytics/plausible-scripts"; const font = DM_Sans({ - subsets: ["latin"], - display: "swap", - variable: "--font-dm-sans", + subsets: ["latin"], + display: "swap", + variable: "--font-dm-sans", }); const { NEXT_PUBLIC_SITE_URL } = process.env; export const metadata: Metadata = { - metadataBase: new URL(NEXT_PUBLIC_SITE_URL ?? "https://www.cuicui.day"), - title: { - default: - "CuiCui | High-Quality React and Tailwind Components for Copy-Paste", - template: "%s | CuiCui", - }, - description: - "CuiCui is a modern UI copy paste library that helps you build beautiful websites and applications.", - keywords: - "UI library, UI components, copy paste UI, web design, front-end development, modern UI, React, Tailwind CSS, TypeScript, JavaScript, Framer Motion", - authors: { - name: "Damien Schneider", - url: "https://github.com/damien-schneider", - }, - publisher: "Cuicui - Damien Schneider", - openGraph: { - title: "CuiCui | High-Quality React and Tailwind Components for Copy-Paste", - description: - "CuiCui is a modern UI copy paste library using React that helps you build beautiful websites and applications with customizable, and modern components.", - url: "https://www.cuicui.day", - type: "website", - locale: "en", - siteName: "CuiCui", - }, - twitter: { - card: "summary_large_image", - site: "@damien_schneid", - creator: "@damien_schneid", - title: "CuiCui | High-Quality React and Tailwind Components for Copy-Paste", - description: - "CuiCui is a modern UI copy paste library that helps you build beautiful websites and applications as easy as copy paste.", - }, + metadataBase: new URL(NEXT_PUBLIC_SITE_URL ?? "https://www.cuicui.day"), + title: { + default: + "CuiCui | High-Quality React and Tailwind Components for Copy-Paste", + template: "%s | CuiCui", + }, + description: + "CuiCui is a modern UI copy paste library that helps you build beautiful websites and applications.", + keywords: + "UI library, UI components, copy paste UI, web design, front-end development, modern UI, React, Tailwind CSS, TypeScript, JavaScript, Framer Motion", + authors: { + name: "Damien Schneider", + url: "https://github.com/damien-schneider", + }, + publisher: "Cuicui - Damien Schneider", + openGraph: { + title: "CuiCui | High-Quality React and Tailwind Components for Copy-Paste", + description: + "CuiCui is a modern UI copy paste library using React that helps you build beautiful websites and applications with customizable, and modern components.", + url: "https://www.cuicui.day", + type: "website", + locale: "en", + siteName: "CuiCui", + }, + twitter: { + card: "summary_large_image", + site: "@damien_schneid", + creator: "@damien_schneid", + title: "CuiCui | High-Quality React and Tailwind Components for Copy-Paste", + description: + "CuiCui is a modern UI copy paste library that helps you build beautiful websites and applications as easy as copy paste.", + }, }; export default function RootLayout({ - children, + children, }: Readonly<{ - children: ReactNode; + children: ReactNode; }>) { - return ( - - - - {/* */} - - + return ( + + + + {/* */} + + - {children} - - - - ); + {children} + + + + ); } diff --git a/apps/website/src/app/not-found.tsx b/apps/website/src/app/not-found.tsx index 718f49a6..43a3b6c3 100644 --- a/apps/website/src/app/not-found.tsx +++ b/apps/website/src/app/not-found.tsx @@ -1,5 +1,5 @@ import NotFoundCard from "#/src/components/not-found-card"; export default function NotFound() { - return ; + return ; } diff --git a/apps/website/src/app/page.tsx b/apps/website/src/app/page.tsx index 85dab1d6..e4ed2353 100644 --- a/apps/website/src/app/page.tsx +++ b/apps/website/src/app/page.tsx @@ -10,41 +10,41 @@ import { DotsPattern } from "@/cuicui/other/patterns/dots-pattern/dots-pattern"; import { PreviewUseMeasure } from "@/cuicui/hooks/use-measure/preview.use-measure"; export default function HomePage() { - return ( -
- -
- -
-
- -
+ return ( +
+ +
+ +
+
+ +
-
-
Cuicui
-

- Every UI components, hooks, tools, ... you need -

-

- More than 100 variants of Open-Source components, hooks and tools made - for React. Just Copy Paste. -

- - Start Copy Pasting - -
-
- -
-
- -
-
- ); +
+
Cuicui
+

+ Every UI components, hooks, tools, ... you need +

+

+ More than 100 variants of Open-Source components, hooks and tools made + for React. Just Copy Paste. +

+ + Start Copy Pasting + +
+
+ +
+
+ +
+
+ ); } diff --git a/apps/website/src/app/sitemap.ts b/apps/website/src/app/sitemap.ts index fc655788..a5c52bdf 100644 --- a/apps/website/src/app/sitemap.ts +++ b/apps/website/src/app/sitemap.ts @@ -4,55 +4,55 @@ import { SectionsList } from "@cuicui/ui"; export const port = process.env.PORT ?? 3000; export const HOST = - process.env.NEXT_PUBLIC_SITE_URL ?? `http://localhost:${port}`; + process.env.NEXT_PUBLIC_SITE_URL ?? `http://localhost:${port}`; export default function sitemap(): MetadataRoute.Sitemap { - // Google's limit is 50,000 URLs per sitemap + // Google's limit is 50,000 URLs per sitemap - return [...staticSitemap, ...getComponentsSitemap()]; + return [...staticSitemap, ...getComponentsSitemap()]; } const staticSitemap: MetadataRoute.Sitemap = [ - { - url: HOST, - lastModified: new Date("2024-08-14"), - changeFrequency: "monthly", - priority: 1, - }, - { - url: `${HOST}/about`, - lastModified: new Date("2024-08-14"), - changeFrequency: "monthly", - priority: 0.9, - }, - { - url: `${HOST}/getting-started`, - lastModified: new Date("2024-08-14"), - changeFrequency: "monthly", - priority: 0.9, - }, + { + url: HOST, + lastModified: new Date("2024-08-14"), + changeFrequency: "monthly", + priority: 1, + }, + { + url: `${HOST}/about`, + lastModified: new Date("2024-08-14"), + changeFrequency: "monthly", + priority: 0.9, + }, + { + url: `${HOST}/getting-started`, + lastModified: new Date("2024-08-14"), + changeFrequency: "monthly", + priority: 0.9, + }, ]; function getComponentsSitemap(): MetadataRoute.Sitemap { - const componentSitemap: MetadataRoute.Sitemap = []; - SectionsList.flatMap((section) => { - if ( - section.type === "multiple-component" || - section.type === "single-component" - ) { - for (const category of section.categoriesList) { - if (category.comingSoonCategory) { - return; - } - if (section.slug && category.slug) { - componentSitemap.push({ - url: `${HOST}/${section.slug}/${category.slug}`, - lastModified: category.releaseDateCategory, - changeFrequency: "monthly", - priority: 0.9, - }); - } - } - } - }); - return componentSitemap; + const componentSitemap: MetadataRoute.Sitemap = []; + SectionsList.flatMap((section) => { + if ( + section.type === "multiple-component" || + section.type === "single-component" + ) { + for (const category of section.categoriesList) { + if (category.comingSoonCategory) { + return; + } + if (section.slug && category.slug) { + componentSitemap.push({ + url: `${HOST}/${section.slug}/${category.slug}`, + lastModified: category.releaseDateCategory, + changeFrequency: "monthly", + priority: 0.9, + }); + } + } + } + }); + return componentSitemap; } diff --git a/apps/website/src/components/analytics/plausible-scripts.tsx b/apps/website/src/components/analytics/plausible-scripts.tsx index bb197ab4..b62c0cf0 100644 --- a/apps/website/src/components/analytics/plausible-scripts.tsx +++ b/apps/website/src/components/analytics/plausible-scripts.tsx @@ -2,21 +2,21 @@ import { IS_PRODUCTION, PLAUSIBLE_DOMAIN } from "#/src/lib/site.const"; import Script from "next/script"; export default function PlausibleScripts() { - if (!(IS_PRODUCTION && PLAUSIBLE_DOMAIN)) { - return null; - } - return ( - <> - - - ); + if (!(IS_PRODUCTION && PLAUSIBLE_DOMAIN)) { + return null; + } + return ( + <> + + + ); } diff --git a/apps/website/src/components/component-wrapper/animated-tab-motion-div.tsx b/apps/website/src/components/component-wrapper/animated-tab-motion-div.tsx index f653eeaa..9ad11ae9 100644 --- a/apps/website/src/components/component-wrapper/animated-tab-motion-div.tsx +++ b/apps/website/src/components/component-wrapper/animated-tab-motion-div.tsx @@ -3,18 +3,18 @@ import { type MotionProps, motion } from "framer-motion"; import type React from "react"; import { cn } from "#/src/utils/cn"; export default function AnimatedTabMotionDiv({ - className, - ...props + className, + ...props }: React.HTMLProps & MotionProps) { - return ( - - ); + return ( + + ); } diff --git a/apps/website/src/components/component-wrapper/component-tab-renderer.tsx b/apps/website/src/components/component-wrapper/component-tab-renderer.tsx index 2f349140..9a257701 100644 --- a/apps/website/src/components/component-wrapper/component-tab-renderer.tsx +++ b/apps/website/src/components/component-wrapper/component-tab-renderer.tsx @@ -5,106 +5,106 @@ import "./full-component.css"; import { ComponentWrapper } from "#/src/components/component-wrapper/component-wrapper"; import StepToInstall from "#/src/components/steps-to-install/step-to-install"; import type { - ComponentHeightType, - ProcessedVariantType, + ComponentHeightType, + ProcessedVariantType, } from "@cuicui/ui/lib/types/component"; import CodeHighlighter from "#/src/ui/code-highlighter"; import { - ResizableHandle, - ResizablePanel, - ResizablePanelGroup, + ResizableHandle, + ResizablePanel, + ResizablePanelGroup, } from "#/src/ui/shadcn/resizable"; import { - ScrollArea, - ScrollAreaViewport, - ScrollBar, + ScrollArea, + ScrollAreaViewport, + ScrollBar, } from "#/src/ui/shadcn/scrollarea"; import { cn } from "#/src/utils/cn"; import { getContainerHeightClass } from "#/src/components/component-wrapper/get-container-height-class"; const tabs = [ - { - name: "Preview", - value: "preview", - }, - { - name: "Preview Code", - value: "code-preview", - }, - { - name: "Component Code", - value: "code-component", - }, + { + name: "Preview", + value: "preview", + }, + { + name: "Preview Code", + value: "code-preview", + }, + { + name: "Component Code", + value: "code-component", + }, ]; export default function ComponentTabRenderer({ - // name, - component, - previewCode, - componentCode, - isResizable, - rerenderButton, - isIframed = false, - size, - componentParams, + // name, + component, + previewCode, + componentCode, + isResizable, + rerenderButton, + isIframed = false, + size, + componentParams, }: { - isResizable?: boolean; - rerenderButton?: boolean; - isIframed?: boolean; - size: ComponentHeightType; - componentParams: { - sectionSlug: string; - categorySlug: string; - componentSlug: string; - variantSlug: string; - }; + isResizable?: boolean; + rerenderButton?: boolean; + isIframed?: boolean; + size: ComponentHeightType; + componentParams: { + sectionSlug: string; + categorySlug: string; + componentSlug: string; + variantSlug: string; + }; } & ProcessedVariantType) { - return ( - - - {tabs.map((tab) => { - if ( - (tab.value === "code-preview" && previewCode) || - (tab.value === "code-component" && componentCode) || - tab.value === "preview" - ) { - return ( - - - {tab.name} - - - ); - } - })} - - - {isResizable ? ( - - - {/* {rerenderButton && } */} - {/*

+ return ( + + + {tabs.map((tab) => { + if ( + (tab.value === "code-preview" && previewCode) || + (tab.value === "code-component" && componentCode) || + tab.value === "preview" + ) { + return ( + + + {tab.name} + + + ); + } + })} + + + {isResizable ? ( + + + {/* {rerenderButton && } */} + {/*

{`/preview/${componentParams.sectionSlug}/${componentParams.categorySlug}/${componentParams.componentSlug}/${componentParams.variantSlug}`}