humanmade/hm-tabs-block
Composer 安装命令:
composer require humanmade/hm-tabs-block
包简介
Simple tab block for the WordPress block editor
README 文档
README
Super simple tab block for the WordPress block editor.
The Objective is to create something incredibly flexible, providing simple markup without any styling, allowing you to integrate with your theme easily.
It also aims to be accessible. The implementation is adapted from the MDN Aria tab role documentation.
Performance is also important. The JS is lightweight and has no dependencies.
The tabs block is made up of 2 blocks. A container tabs block, and a child tabs-item block. The tabs item block is simply a wrapper, allowing you to add any content you wish.
Saved markup.
One of the aims of this block is to keep the saved HTML really minimal. It should look OK even if this plugin is deactivated.
All of the functionality and interactive elements are created on the fly either rendered server side or constructed in JS.
Styling the tabs.
The tabs are functional but unstyled.
Here is a sample of the markup to show the classes you can use to style the tabs.
<div class="hm-tabs hm-tabs--is-initialized"> <div class="hm-tabs__nav" role="tablist"> <button class="hm-tabs__nav-button hm-tabs__nav-button--is-active">Tab 1</button> <button class="hm-tabs__nav-button">Tab 2</button> ... </div> <div class="hm-tabs__content"> <div class="wp-block-hm-tabs-item hm-tabs-item"> <h2 class="hm-tabs-item__title">Tab 1</h2> <div class="hm-tabs-item__content"> </div> </div> <div class="wp-block-hm-tabs-item hm-tabs-item"> <h2 class="hm-tabs-item__title">Tab 2</h2> <div class="hm-tabs-item__content"> </div> </div> ... </div> </div>
Example styling
And here's some CSS to style up some nice old school looking tabs.
.hm-tabs__nav { display: flex; position: relative; z-index: 1; margin: 0 0 -1px 0; } .hm-tabs__nav-button { background-color: #ddd; border: 1px solid #aaa; padding: 12px 16px; margin: 0; font-size: 12px; } .hm-tabs__nav-button + .hm-tabs__nav-button { border-left: none; } .hm-tabs__nav-button--is-active { background-color: #fff; border-bottom-color: #fff; } .hm-tabs__content { background-color: #fff; border: 1px solid #aaa; padding: 16px; }
Some useful classes for styling and animation.
.hm-tabs--is-initializedAdded once JS has initialized the tab functionality..hm-tabs--is-visibleAdded when the tab if first scrolled into view.- `.hm-tabs--is-focused`` Added when a tab is active.
.hm-tabs-item--is-activeAdded when the tab is shown and removed after.
Example of animation
Use this in addition to the styles above to create a slide/fade effect when switching tabs
@keyframes testFadeInLeft {
from {
visibility: hidden;
opacity: 0;
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
}
1% {
visibility: visible;
}
to {
opacity: 1;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
}
@keyframes testFadeOutRight {
from {
opacity: 1;
visibility: visible;
}
99% {
visibility: visible;
}
to {
opacity: 0;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
visibility: hidden;
}
}
.hm-tabs__content {
position: relative;
display: grid;
overflow: hidden;
.hm-tabs-item {
grid-column: 1;
grid-row: 1;
&[hidden="true"] {
display: block;
opacity: 0;
visibility: hidden;
}
}
}
.hm-tabs-item {
position: relative;
&:not(.hm-tabs-item--is-active) {
animation-duration: 0.25s;
animation-name: testFadeOutRight;
}
&--is-active {
opacity: 1;
animation-duration: 0.25s;
animation-name: testFadeInLeft;
}
}
humanmade/hm-tabs-block 适用场景与选型建议
humanmade/hm-tabs-block 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 4.03k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2024 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 humanmade/hm-tabs-block 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 humanmade/hm-tabs-block 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2024-02-14