Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
stylis-plugin-rtl
Advanced tools
Fork of stylis-rtl, uses cssjanus under the hood to flip style orientations for RTL
The stylis-plugin-rtl npm package is a plugin for Stylis, a lightweight CSS preprocessor. This plugin automatically converts CSS styles to support right-to-left (RTL) languages, making it easier to develop applications that need to support RTL layouts.
Automatic RTL Conversion
This feature automatically converts left-to-right (LTR) CSS properties to their right-to-left (RTL) equivalents. For example, 'margin-left' becomes 'margin-right' and 'padding-right' becomes 'padding-left'.
const stylis = require('stylis');
const rtl = require('stylis-plugin-rtl');
stylis.use(rtl);
const css = `.example { margin-left: 10px; padding-right: 20px; }`;
const rtlCss = stylis('', css);
console.log(rtlCss); // Outputs: .example { margin-right: 10px; padding-left: 20px; }`
Integration with Stylis
This feature allows seamless integration with Stylis, enabling automatic RTL conversion during the CSS preprocessing stage. This ensures that all styles are correctly converted without additional manual intervention.
const stylis = require('stylis');
const rtl = require('stylis-plugin-rtl');
stylis.use(rtl);
const css = `.example { float: left; text-align: right; }`;
const rtlCss = stylis('', css);
console.log(rtlCss); // Outputs: .example { float: right; text-align: left; }`
rtlcss is a framework for transforming CSS from LTR to RTL. It provides a more comprehensive set of tools and options for handling RTL conversion, including custom directives and plugins. Unlike stylis-plugin-rtl, which is a plugin for Stylis, rtlcss can be used as a standalone tool or integrated into various build processes.
postcss-rtl is a PostCSS plugin that adds RTL support to your CSS. It offers more flexibility and customization options compared to stylis-plugin-rtl, as it can be integrated into any PostCSS workflow. It also supports custom rules and configurations for more complex RTL transformations.
Stylis RTL plugin based on CSSJanus
NOTE! Use v1 of this plugin for styled-components v5, NOT v2 (v2 is for libraries that have upgraded to stylis v4, which s-c has not yet. At the moment only emotion 11 is updated.)
yarn add stylis-plugin-rtl@^1
yarn add stylis-plugin-rtl stylis
import styled, { StyleSheetManager } from "styled-components";
import rtlPlugin from "stylis-plugin-rtl";
const Box = styled.div`
padding-left: 10px;
`;
function MakeItRTL() {
return (
<StyleSheetManager stylisPlugins={[rtlPlugin]}>
<Box>My padding will be on the right!</Box>
</StyleSheetManager>
);
}
Because minification removes all comments from your CSS before it passes to <StyleSheetManager>
, /* @noflip */
comment won't work.
You will have to either:
/*! @noflip */
, to prevent it from being removedminify
to false
in .babelrc
(see styled-components documentation).This is a fork of stylis-rtl
for use with styled-components v5+
FAQs
Fork of stylis-rtl, uses cssjanus under the hood to flip style orientations for RTL
We found that stylis-plugin-rtl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.