@finsweet/webflow-apps-utils

中文文档
1.1.1发布于 2026/09/04TypeScriptES Module近 30 天下载 5796

Shared utilities for Webflow apps

原始使用文档
文档目录13 节
  1. Installation
  2. Usage
  3. Project Structure
  4. Coding Standards
  5. Naming Conventions
  6. Documentation Standards
  7. Testing UI Components
  8. Testing Strategy
  9. Test Structure
  10. Testing Best Practices
  11. Example: Button Component Testing
  12. Development
  13. Publishing

Webflow Apps Utils

Internal Finsweet Library

Shared UI components and utilities for Finsweet's Webflow applications.

🔗 Live Storybook Documentation

Installation

pnpm add @finsweet/webflow-apps-utils

Usage

import '@finsweet/webflow-apps-utils/index.css';

import { Button, Modal, Input, siteInfo } from '@finsweet/webflow-apps-utils';

Project Structure

src/
├── lib/
│   ├── router/          # Client-side routing utilities
│   ├── stores/          # Stores for state management
│   ├── types/           # TypeScript type definitions
│   ├── ui/              # UI components and styling
│   │   ├── components/  # Reusable UI components
│   │   └── icons/       # SVG icon components
│   └── utils/           # Helper functions and utilities

Coding Standards

Naming Conventions

File and Folder Names

  • Folders: Use kebab-case for all directory names

    ✅ custom-code/
    ✅ webflow-canvas/
    ✅ browser-storage/
    ❌ customCode/
    ❌ WebflowCanvas/
    
  • Files: Use camelCase and PascalCase for all file names

    ✅ localStorage.ts
    ✅ handlePaste.ts
    ✅ getAllAssets.ts
    ✅ Button.svelte
    ✅ Form.svelte
    ❌ local-storage.ts
    ❌ handle_paste.ts
    ❌ form.svelte
    
    

Code Naming

  • Components: Use PascalCase for component names
  • Functions: Use camelCase for function names
  • Variables: Use camelCase for variable names
  • Constants: Use UPPERCASE for constants
  • Types/Interfaces: Use PascalCase for type definitions

Documentation Standards

  • Keep function documentation concise

Testing UI Components

Testing Strategy

All UI components should include comprehensive tests covering:

  • Basic Rendering: Default props, custom props, and various configurations
  • Component Variants: All available variants (primary, secondary, danger, etc.)
  • Interactive States: Disabled, loading, invalid, and other state combinations
  • User Interactions: Click events, keyboard navigation, and form submissions
  • Accessibility: ARIA attributes, focus management, and screen reader support
  • Visual Features: Icons, tooltips, custom styling, and layout variations

Test Structure

Use Vitest and Testing Library for component testing:

import { fireEvent, render, screen, waitFor } from '@testing-library/svelte';
import { describe, expect, it, vi } from 'vitest';
import Component from './Component.svelte';

describe('Component Name', () => {
    describe('Basic Rendering', () => {
        it('renders with default props', () => {
            render(Component);
            const element = screen.getByRole('...');
            expect(element).toBeInTheDocument();
        });
    });

    describe('Variants', () => {
        // Test all component variants
    });

    describe('States', () => {
        // Test disabled, loading, invalid states
    });

    describe('Events', () => {
        // Test user interactions
    });

    describe('Accessibility', () => {
        // Test ARIA attributes and keyboard navigation
    });
});

Testing Best Practices

  • Comprehensive Coverage: Test all props, variants, and states
  • User-Centric Tests: Focus on user interactions rather than implementation details
  • Accessibility Testing: Verify ARIA attributes, keyboard navigation, and screen reader support
  • Async Behavior: Use waitFor for testing tooltips, modals, and dynamic content
  • Event Mocking: Mock external dependencies and event handlers properly
  • State Verification: Check both visual state and underlying attributes

Example: Button Component Testing

// Testing component variants
const variants: ButtonVariant[] = ['primary', 'secondary', 'danger', 'cms'];
variants.forEach((variant) => {
    it(`renders ${variant} variant correctly`, () => {
        render(Button, { variant });
        const button = screen.getByRole('button');
        expect(button).toHaveClass(`button--${variant}`);
    });
});

// Testing interactive states
it('renders loading state', () => {
    render(Button, { loading: true });
    const button = screen.getByRole('button');
    expect(button).toBeDisabled();
    expect(button).toHaveAttribute('aria-busy', 'true');
    expect(button).toHaveClass('button--loading');
});

// Testing accessibility
it('has proper ARIA attributes', () => {
    render(Button, { ariaLabel: 'Custom label', loading: true });
    const button = screen.getByRole('button');
    expect(button).toHaveAttribute('aria-label', 'Custom label');
    expect(button).toHaveAttribute('aria-busy', 'true');
});

// Testing async interactions (tooltips)
it('shows tooltip on hover', async () => {
    render(Button, {
        tooltip: { message: 'Help text', listener: 'hover', listenerout: 'hover' }
    });

    const button = screen.getByRole('button');
    const tooltipTarget = button.closest('.target');
    await fireEvent.mouseEnter(tooltipTarget || button);

    expect(screen.getByText('Help text')).toBeInTheDocument();
});

Development

# Setup
pnpm install

# Development
pnpm dev              # Start dev server
pnpm storybook        # Component development

# Building & Testing
pnpm build            # Build library
pnpm test             # Run tests
pnpm lint             # Check code quality
pnpm check            # Check code quality

Publishing

Uses Changesets for automated releases. Create a changeset:

pnpm changeset

Push changes to trigger automatic publishing to npm via GitHub Actions.

版本与发布记录

@finsweet/webflow-apps-utils 共发布 63 个版本,首次发布于 2025/06/19;过去 12 个月发布了 30 个版本。

版本发布日期距今
1.1.1latest2026/09/042 个月前
1.1.02026/09/022 个月前
1.0.632026/07/014 个月前
1.0.622026/06/264 个月前
1.0.612026/05/076 个月前
1.0.602026/04/296 个月前

关于 @finsweet/webflow-apps-utils 的常见问题

@finsweet/webflow-apps-utils 是什么?

Shared utilities for Webflow apps

如何安装 @finsweet/webflow-apps-utils?

在项目目录运行 npm install @finsweet/webflow-apps-utils,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:svelte(^5.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@finsweet/webflow-apps-utils 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@finsweet/webflow-apps-utils 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@finsweet/webflow-apps-utils 可以商用吗?

@finsweet/webflow-apps-utils 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@finsweet/webflow-apps-utils 的下载量有多少?

根据 npm 官方下载统计,@finsweet/webflow-apps-utils 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,796 次,日均约 193 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@finsweet/webflow-apps-utils 还在维护吗?

最新版本 1.1.1 发布于 2026/09/04(2 个月前);至今共发布 63 个版本,其中过去 12 个月发布了 30 个;首次发布于 2025/06/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。