swissup/module-rtl
Composer 安装命令:
composer require swissup/module-rtl
包简介
Magento2 RTL detection
关键字:
README 文档
README
Magento module that helps to add RTL support to your modules and themes.
Installation
composer require swissup/module-rtl bin/magento module:enable Swissup_Rtl
Usage
CSS class
Module automatically adds rtl class name to the body element
when current language is detected as RTL. This allows you to write plain
RTL-specific styles in your css/less files:
.my-element { right: 20px; } .rtl .my-element { right: auto; left: 20px; }
While this approach is nice for the small files, it becomes a headache when dealing with large portion of css that should be adjusted. Additionally, this approach make your style files larger.
We recommend to use LESS mixins for the best experience.
LESS mixins
This approach allows to keep minimal size of generated CSS file:
@import 'Swissup_Rtl::css/_modrtl.less'; .sidebar-popup { .left(0); .modrtl(transform, ~"translateX(-100%)", ~"translateX(100%)"); &.shown { transform: translateX(0); } .close { .right(0); } }
Additionally, you can use @modrtl-dir variable in & when statements:
@import 'Swissup_Rtl::css/_modrtl.less'; & when (@modrtl-dir = rtl) { .my-element { right: auto; left: 20px; } }
Mixins list
| Mixin | Example |
|---|---|
| Misc | |
| .modrtl(@property, @ltrValue, @rtlValue) | .modrtl(display, block, inline) |
| .direction() | .direction() // will output current direction |
| .direction(@value) | .direction(rtl) |
| .background-position(@ltrValue, @rtlValue) | .background-position(100% 50%, 0 50%) |
| .text-align(@direction) | .text-align(left) |
| Padding | |
| .padding(@value) | .padding(10px 25px 10px 5px) |
| .padding-left(@value) | .padding-left(5px) |
| .padding-right(@value) | .padding-right(25px) |
| Margin | |
| .margin(@value) | .margin(10px 25px 10px 5px) |
| .margin-left(@value) | .margin-left(5px) |
| .margin-right(@value) | .margin-right(25px) |
| Positioning | |
| .float(@direction) | .float(left) |
| .clear(@direction) | .clear(left) |
| .left(@distance) | .left(20px) |
| .right(@distance) | .right(20px) |
| Border | |
| .border-radius(@value) | .border-radius(5px 0 0 5px) |
| .border-[top|right|bottom|left]-radius(@radius) | .border-top-radius(5px) |
| .border-[top|bottom]-[left|right]-radius(@radius) | .border-top-left-radius(5px) |
| .border-left(@border-style) | .border-left(1px solid #f4f4f4); |
| .border-right(@border-style) | .border-right(1px solid #f4f4f4); |
| .border-color(@value) | .border-color(#f4f4f4 transparent #eee #f4f4f4) |
| .border-left-color(@color) | .border-left-color(#f4f4f4) |
| .border-right-color(@color) | .border-right-color(transparent) |
| .border-style(@value) | .border-style(dotted dashed none solid) |
| .border-left-style(@style) | .border-left-style(solid) |
| .border-right-style(@style) | .border-right-style(none) |
| .border-width(@value) | .border-width(1px 0 1px 2px) |
| .border-left-width(@width) | .border-left-width(0) |
| .border-right-width(@width) | .border-right-width(2px) |
PHP helper
class Example { public function __construct(\Swissup\Rtl\Helper\Data $rtlHelper) { // Check current locale $rtlHelper->isRtl(); // Check locale code $rtlHelper->isRtl('en_US'); } }
License
Distributed under the MIT license
Credits
Mixins are taken from anasnakawa/bi-app-sass. Thanks!
swissup/module-rtl 适用场景与选型建议
swissup/module-rtl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 475.25k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 09 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rtl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 swissup/module-rtl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 swissup/module-rtl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 swissup/module-rtl 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Twitter Bootstrap Rtl extension for the Yii 2.0 framework
It is a free admin template for backend of yii framework 2 based on gentelella-rtl theme.
Adds RTL support to CMS fields of sites that use fluent.
RTL Extension.
Rtl theme for Laravel Nova.
Add a text into jpg images with customized align (ltr, center and rtl)
统计信息
- 总下载量: 475.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 28
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-26