drop-in Documentation

repository·main·Indexed 18 days ago

https://github.com/stolinski/drop-in

A collection of SvelteKit libraries and utilities, including @drop-in/pass for secure runtime-agnostic authentication with HttpOnly JWT cookies, @drop-in/decks for overlay components (Dialog, Drawer, AreYouSure) and gesture utilities like pannable, and @drop-in/graffiti for base CSS styling. The suite provides tools for session management, global state handling via $state/store.svelte, and UI components utilizing Svelte 5 callbacks.

Tokens
37.4K
Snippets
136
Records
168
Agent score
62%

What's inside drop-in

  1. Understand the Starlight project structure

    main

    A Starlight project follows a specific directory structure for content and assets:

    • src/content/docs/: The primary location for documentation. Starlight automatically exposes .md or .mdx files in this directory as routes based on their filenames.
    • src/assets/: Place images here to embed them in Markdown using relative links.
    • public/: Use this directory for static assets like favicons.
    • astro.config.mjs: The configuration file for the Astro project.
    • src/content.config.ts: Configuration for content collections.
    .
    ├── public/
    ├── src/
    │   ├── assets/
    │   ├── content/
    │   │   ├── docs/
    │   └── content.config.ts
    ├── astro.config.mjs
    ├── package.json
    └── tsconfig.json
  2. Understand the (app) route group in the z template

    main
    The (app) route group is a specialized directory used for application-specific content, such as user profiles or core app functionality. Routes defined within this group are strictly Client-Side Rendered (CSR), making them ideal for highly interactive, user-specific views where state management and client-side logic are prioritized over initial server-side HTML generation.
  3. How to use the $state global store

    main

    The $state module provides a mechanism for storing global state that is accessible across different routes and components. This is intended for state that is not tightly scoped to a single component or route.

    To access the global store, import create_store from the $state/store.svelte module.

    ⚠️ Security Warning: Do not use $state for Server-Side Rendering (SSR) as your state may be insecure. This module is designed for client-side state management.

    import { create_store } from '$state/store.svelte';
  4. Understand the (app) route group behavior

    main
    In this project, the (app) route group is reserved for client-side rendered (CSR) routes. Routes placed within this group are intended for user-specific content, such as application dashboards, user profiles, and other authenticated views. Because these routes are CSR'd only, they are ideal for highly interactive, user-centric parts of the application where client-side state management is preferred over server-side rendering.
  5. How Tabs accessibility and keyboard navigation works

    main

    The Tabs component follows the WAI-ARIA Tabs pattern to ensure accessibility:

    ARIA Roles

    • role="tablist" is applied to the TabList.
    • role="tab" is applied to Tab buttons.
    • role="tabpanel" is applied to TabPanel components.
    • aria-selected="true" is used to indicate the active tab.
    • aria-controls and aria-labelledby link tabs to their respective panels.

    Keyboard Navigation

    • Tab: Move focus into or out of the tablist.
    • Left/Right Arrow (horizontal orientation): Navigate between tabs.
    • Up/Down Arrow (vertical orientation): Navigate between tabs.
    • Home: Jump to the first tab.
    • End: Jump to the last tab.
    • Enter/Space: Activate the focused tab.
  6. How @drop-in/pass works with SvelteKit hooks

    main

    Pass handles authentication via a set of server routes managed by the pass_routes hook. This hook automatically handles server responses for logging in, logging out, signing up, resetting passwords, and verifying emails, meaning you do not need to manually create these API routes.

    To enable Pass, you must include pass_routes in your src/hooks.server.ts file using the sequence function from @sveltejs/kit/hooks.

    import { sequence } from '@sveltejs/kit/hooks';
    import { pass_routes } from '@drop-in/pass';
    import { drop_hook } from '@drop-in/plugin/hook';
    
    // pass_routes handles auth authentication and the auth routes.
    // drop_hook ensures drop-in.config.js is read and applied to globals.
    export const handle = sequence(pass_routes, drop_hook);
  7. How workspace dependency bumping works

    main
    The monorepo uses Changesets to automatically manage the dependency chain. If you modify a package (e.g., @drop-in/pass) that is used by another package in the workspace (e.g., @drop-in/ramps) via a workspace:^ reference, Changesets will automatically bump the version of the dependent package as well. Both packages will then be published together to maintain compatibility.