STDF Documentation

repository·main·Indexed 21 days ago

https://github.com/any-tdf/stdf

A high-performance, lightweight, and customizable mobile web component library built on Svelte 5 and Tailwind CSS v4. Includes the create-stdf CLI for project scaffolding with support for SvelteKit, Vite, and TypeScript templates, as well as a VS Code extension for component API hover information.

Tokens
194.5K
Snippets
426
Records
1.1K
Agent score
72%

What's inside STDF

  1. Overview of STDF features

    main

    STDF is a mobile web component library built on Svelte 5, Tailwind CSS v4, and TypeScript. It is designed to be Simple, Tiny, Design-focused, and Fast.

    Key features include:

    • Performance: No runtime and no virtual DOM for faster online performance.
    • Customization: Rich API for component styling, configurable animation parameters, and support for multiple themes (including dark mode).
    • Zero Dependencies: No third-party dependencies, reducing security risks and version conflicts.
    • Optimization: Supports on-demand imports to minimize bundle size.
    • Internationalization: Built-in support for over 60 language packages.
    • Ecosystem Support: Compatible with Tailwind-based libraries like UnoCSS and includes an IDE plugin for quick API visualization.
    • Tooling: Includes a scaffolding tool for rapid project creation and a SVG merging plugin that supports Iconify.
  2. What is STDF?

    main

    STDF is a mobile web component library built on Svelte 5, Tailwind CSS v4, and TypeScript. It is designed to be Simple, Tiny, Design-focused, and Fast.

    Key features include:

    • No runtime or virtual DOM: Optimized for web performance.
    • Rich API: Easily configurable component styles and animation parameters.
    • Theming: Supports dark mode and multiple custom themes.
    • Internationalization: Built-in support for over 60 language packages.
    • Zero third-party dependencies: Reduces security risks and version conflicts.
    • On-demand imports: Supports tree-shaking to reduce bundle sizes.
    • Tooling: Includes a scaffolding tool for rapid project creation, an SVG merging plugin, and an IDE plugin for component API visibility.
  3. Introduction to STDF

    main

    STDF is a mobile web component library built with Svelte 5, Tailwind CSS v4, and TypeScript. It is designed to be Simple, Tiny, Design-focused, and Fast.

    Key features include:

    • Performance: No runtime overhead and no virtual DOM.
    • Customization: Rich API for component styling, configurable animation parameters, and support for multiple themes (including dark mode).
    • Zero Dependencies: No third-party dependencies, reducing security risks and version conflicts.
    • Modern Tooling: Supports on-demand imports for smaller bundles, an SVG fusion plugin, and an IDE plugin for quick API inspection.
    • Internationalization: Built-in support for over 60 language packages.
    • Compatibility: Works with Tailwind-compatible libraries like UnoCSS.
  4. What is STDF?

    main
    STDF is a simple, lightweight, design-friendly, and fast UI component library. It is built specifically on top of Svelte and Tailwind CSS, aiming to provide a high-quality mobile development experience similar to what is available for PC-centric libraries.
  5. What is STDF and its design philosophy

    main

    STDF is a mobile-focused UI component library built on top of Svelte and Tailwind CSS.

    Its core design philosophy focuses on:

    • Simplicity & Lightweight: Aiming for a small footprint suitable for mobile environments.
    • Design-Friendly: Providing APIs that are flexible enough for business requirements without being overly complex.
    • High Reusability: Avoiding overly personalized UI styles to ensure components can be reused across different projects.
    • Developer Experience: Leveraging the reactive capabilities of Svelte and the utility-first approach of Tailwind CSS to provide a comfortable development workflow.
  6. Customize Cell layout using Snippets

    main

    The Cell component supports three types of Snippets to allow custom rendering in specific areas:

    • leftChild: Renders content at the far left of the Cell (e.g., custom images or icons).
    • rightChild: Renders content at the far right of the Cell.
    • detailChild: Renders detailed content in the right-side area of the Cell.

    Use these snippets when the default icon or text layout does not meet your design requirements.

    <Cell>
      <div slot="leftChild">Custom Left Content</div>
      <div slot="detailChild">Custom Detail Content</div>
    </Cell>
  7. Use Card preset areas (header, children, footer)

    main

    The Card component provides three optional preset areas for organizing content:

    • header: The top area, typically used for titles, action buttons, etc.
    • children: The main body area for the primary content.
    • footer: The bottom area, typically used for action buttons or statistics.

    These areas are optional and can be combined flexibly based on your requirements.

  8. Understand the difference between BottomSheet and Popup

    main

    In STDF, both BottomSheet and Popup are floating UI elements used for secondary operations, but they serve different conceptual purposes:

    • Popup (Layer concept): Best for simple interactions. It is "style-heavy, logic-light." You can customize its position, size, transition animations, direction, and style. By default, clicking the mask (overlay) closes it.
    • BottomSheet (Window concept): Best for complex interactions. It is "logic-heavy, style-light." It always emerges from the bottom and features a dedicated header area that can be customized. It supports window-like interactions such as sliding to close or navigating back. By default, clicking the mask does not close it.
  9. Adjusting Badge position with offsetY and offsetX

    main
    By default, the Badge is positioned at the top-right corner of the content, with horizontal and vertical offsets equal to half of the badge's own width and height. To fine-tune the position for specific layout requirements, use the offsetY and offsetX properties to apply additional adjustments.
  10. When to use the Modal component

    main

    The Modal component is designed for high-awareness scenarios where users need to be notified of important information or specific steps.

    Key characteristics:

    • High Awareness: Provides a stronger sense of presence than a Toast.
    • Minimal Interaction: Simpler to implement than a Dialog; typically used for single confirmations or acknowledgments.
    • Safety: By default, clicking the background mask does not close the dialog to prevent accidental dismissals.

    Comparison with other feedback components in STDF:

    • Toast: Lightweight and non-blocking; used for short status feedback.
    • Alert: Card-style notifications; used for richer notices with titles, icons, or actions.
    • Modal: Strong awareness with minimal interaction (e.g., a single 'OK' button).
    • Dialog: Strong awareness for decision-making; used for complex flows requiring primary/secondary actions (e.g., confirming a risky operation).
  11. Understanding the dual theme color design

    main
    STDF uses a dual theme color system to maintain optimal contrast and readability across different modes. Instead of using a single color for both, the system uses a primary color for light mode and a dark color for dark mode. This prevents colors from appearing too harsh or lacking contrast when the background shifts from white to black.
  12. How Alert differs from Toast, Modal, and Dialog

    main

    In STDF, the Alert component is a card-style notification designed for richer content presentation (titles, icons, or actions) where readability is key. It sits in a hierarchy of feedback components:

    • Toast: Lightweight and non-blocking; used for short status feedback for quick actions.
    • Alert: Card-style; used for richer notices requiring more visual weight than a toast.
    • Modal: High awareness with minimal interaction (e.g., a single acknowledgment).
    • Dialog: High awareness for decision-making (e.g., primary/secondary actions for risky flows).

    Use Alert when you need to provide more context than a simple status message but don't want to interrupt the user's workflow as heavily as a Modal or Dialog would.