# @cio/ui UI component library for ClassroomIO, built with Svelte 5 and Tailwind CSS. ## Package Information - **Name**: `@cio/ui` - **Type**: Svelte component library - **Framework**: Svelte 5 - **Styling**: Tailwind CSS with custom `ui` prefix ## Folder Structure ``` packages/ui/ ├── src/ │ ├── base/ # Components from shadcn-svelte │ ├── custom/ # Components from other sources or built on top of base components │ ├── hooks/ # Reusable Svelte hooks │ ├── tools/ # Utility functions (cn, sanitize, etc.) │ ├── index.css # Global styles │ └── index.ts # Main export file ├── package.json ├── components.json # shadcn-svelte configuration └── jsrepo.json # jsrepo configuration ``` ## Content Structure ### Base Components (`src/base/`) All components in the `base` directory are primarily from [shadcn-svelte](https://www.shadcn-svelte.com/). These are the foundational UI components that follow the shadcn design system. **Guidelines:** - Any new component from shadcn-svelte should be added to the `base` directory - Components are organized in their own folders with an `index.ts` file for exports - Each component folder typically contains the main component file(s) and an `index.ts` export file **Examples:** - `base/button/` - Button component from shadcn-svelte - `base/dialog/` - Dialog component from shadcn-svelte - `base/tooltip/` - Tooltip component from shadcn-svelte ### Custom Components (`src/custom/`) Components in the `custom` directory come from various sources or are built on top of base components: 1. **External Sources:** - Components from [shadcn-svelte-extras](https://www.shadcn-svelte-extras.com/) - Components from [Edra Editor](http://edra.tsuzat.com/) (rich text editor) - Other third-party component libraries 2. **Extended Components:** - Any component that builds on top of shadcn-svelte base components - Custom implementations that extend base component functionality **Examples:** - `custom/code/` - From shadcn-svelte-extras (syntax-highlighted code block with copy and overflow) - `custom/underline-tabs/` - From shadcn-svelte-extras - `custom/editor/` - Rich text editor based on Edra/Tiptap - `custom/image-cropper/` - Custom image cropping component - `custom/checkbox-field/` - Field component built on top of base Checkbox ### Hooks (`src/hooks/`) Reusable Svelte hooks are located in the `src/hooks/` directory. These are Svelte 5 runes-based utilities that can be used across components. **Available Hooks:** - `is-mobile.svelte.ts` - Media query hook for mobile breakpoints - `use-clipboard.svelte.ts` - Clipboard copy functionality with state management **Usage:** ```svelte ``` ### Tools (`src/tools/`) Utility functions and helpers are located in `src/tools/`. The main utility is the `cn` function for class name merging. ## Importing `cn` The `cn` utility function is used throughout the codebase for merging Tailwind CSS classes. It combines `clsx` and `tailwind-merge` to handle class conflicts intelligently. **Import:** ```typescript import { cn } from '../../tools'; ``` **Example usage:** ```svelte