承接 humanmade/lottie-lite 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

humanmade/lottie-lite

Composer 安装命令:

composer require humanmade/lottie-lite

包简介

A lightweight Lottie Animations Extension for WordPress

README 文档

README

Playwright Tests Lint

Adds support for Lottie animations as an enhancement to the following blocks:

  • Core image block
  • Core cover block
  • Core media & text block

Allows overlaying or replacing the image with an animation.

🎮 Try it on WordPress Playground

Installation

  1. Download the plugin from the GitHub repository.
  2. Upload the plugin to your site's wp-content/plugins directory.
  3. Activate the plugin from the WordPress admin.

Development

Available npm Scripts

# Build production assets
npm run build

# Development watch mode
npm run start

# Format code
npm run format

# Linting
npm run lint:js        # Check JavaScript
npm run lint:css       # Check CSS
npm run lint:js:fix    # Fix JavaScript issues
npm run lint:css:fix   # Fix CSS issues

# Create distributable plugin ZIP
npm run plugin-zip

# Testing
npm run playground:start    # Start WordPress Playground server
npm run test:e2e           # Run end-to-end tests
npm run test:e2e:debug     # Run tests in debug mode
npm run test:e2e:watch     # Run tests in watch mode

The build process uses @wordpress/scripts to compile JavaScript and CSS from src/*.js into the build/ directory.

Testing

The plugin uses Playwright for end-to-end testing with WordPress Playground.

Running Tests Locally

  1. Start the WordPress Playground server (in one terminal):
npm run playground:start
  1. Run the tests (in another terminal):
npm run test:e2e

The Playground environment runs on http://localhost:9400 with WordPress 6.8, PHP 8.3, and auto-login enabled.

CI Testing

Tests run automatically on GitHub Actions using a matrix of:

  • PHP versions: 8.3, 8.4
  • WordPress versions: 6.7, 6.8, latest

This ensures compatibility across multiple PHP and WordPress versions.

Adding New Tests

Tests are located in the tests/e2e/ directory. Here's an example test:

const { test, expect } = require( '@playwright/test' );
const { Editor } = require( '@wordpress/e2e-test-utils-playwright' );

test.use( {
	editor: async ( { page }, use ) => {
		await use( new Editor( { page } ) );
	},
} );

test.describe( 'Lottie Lite Plugin', () => {
	test.beforeEach( async ( { page } ) => {
		await page.goto( '/wp-admin/' );
	} );

	test( 'should add Lottie Animation panel to image block', async ( {
		page,
		editor,
	} ) => {
		// Navigate to create new post
		await page.goto( '/wp-admin/post-new.php' );
		await page.getByRole( 'button', { name: 'Close' } ).click();
		await editor.openDocumentSettingsSidebar();

		// Insert an image block
		await page
			.locator( 'iframe[name="editor-canvas"]' )
			.contentFrame()
			.getByRole( 'button', { name: 'Add default block' } )
			.click();
		await page
			.locator( 'iframe[name="editor-canvas"]' )
			.contentFrame()
			.getByRole( 'document', { name: 'Empty block; start writing or' } )
			.fill( '/image' );
		await page
			.getByRole( 'option', { name: 'Image', exact: true } )
			.click();

		// Verify Lottie Animation panel exists
		await page
			.getByRole( 'button', { name: 'Lottie Animation Lottie Logo' } )
			.click();
		await expect( page.locator( '#tabs-3-settings-view' ) ).toContainText(
			'Lottie Animation'
		);
	} );
} );

For more information on writing Playwright tests, see:

Pull Request Previews

When you open or update a pull request, a workflow automatically:

  • Builds the plugin with your changes
  • Generates a unique WordPress Playground link
  • Adds a "Try it in Playground" button to your PR description

This allows reviewers to test your changes directly in their browser without any local setup required.

Advanced Usage

The plugin exposes the DotLottie web player object on the enhanced blocks. This allows you to interact with the player and control the animation.

To access the player object, you can use the following JavaScript code:

function doStuff(player) {
    // Do stuff with the player object
}

// Wait for the player to be ready as they may be loaded asynchronously,
// depending on the block's visibility and whether the image is lazy-loaded.
document.querySelectorAll( '[data-lottie]' ).forEach( ( element ) => {
    if ( element.lottie ) {
        doStuff( element.lottie );
    } else {
        element.addEventListener( 'lottieReady', () => {
            doStuff( element.lottie );
        } );
    }
} );

Full documentation for the DotLottie web player can be found here:

https://developers.lottiefiles.com/docs/dotlottie-player/dotlottie-web/

humanmade/lottie-lite 适用场景与选型建议

humanmade/lottie-lite 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 5.38k 次下载、GitHub Stars 达 37, 最近一次更新时间为 2024 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 humanmade/lottie-lite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 humanmade/lottie-lite 我们能提供哪些服务?
定制开发 / 二次开发

基于 humanmade/lottie-lite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 37
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 37
  • Watchers: 10
  • Forks: 2
  • 开发语言: JavaScript

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-09-02