Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
startijenn-rem
Advanced tools
Readme
JavaScript function to convert CSS rem units. Used by postcss-rem.
Install with npm i startijenn-rem
.
import rem, { em, px, convert } from "startijenn-rem";
const unitless = rem(24);
// '1.5rem'
const simple = rem("24px");
// '1.5rem'
const multipleValues = rem("5px -10px 1.5rem");
// '0.3125rem -0.625rem 1.5rem'
const multipleMixedValues = rem("1px solid black");
// '0.0625rem solid black'
const commaSeparatedValues = rem("0 0 2px #ccc, inset 0 0 5px #eee");
// '0 0 0.125rem #ccc, inset 0 0 0.3125rem #eee'
const variable = "5px";
const withVariable = rem(`${variable} 10px`);
// '0.3125rem 0.625rem'
const array = rem([24, "24px", "5px -10px 1.5rem"]);
// ['1.5rem', '1.5rem', '0.3125rem -0.625rem 1.5rem']
const object = rem({
fontSize: 24,
margin: "24px",
padding: "5px -10px 1.5rem",
});
// {fontSize: '1.5rem', margin: '1.5rem', padding: '0.3125rem -0.625rem 1.5rem'}
const changingBaseline = rem("24px", { baseline: 10 });
// '2.4rem'
const changingPrecision = rem("16px", { baseline: 12, precision: 3 });
// '1.333rem'
const convertToPx = px("1.5rem 24px");
// '24px 24px'
const convertFunction = convert("24px", "em", { baseline: 12 });
// '2em' (can only convert to rem, em or px)
const StyledComponent = styled.h1`
font-size: ${(fontSize) => rem(fontSize)};
padding: ${(fontSize) => em(12, fontSize)};
margin: ${rem("8px 16px")};
`;
// .StyledComponent { font-size: 1.5rem; padding: 0.5em; margin: 0.5rem 1rem; }
const h1 = (text) => <StyledComponent fontSize={24}>{text}</StyledComponent>;
You can change the default options of the functions by doing your own aliases.
import { convert } from "startijenn-rem";
export const rem = (value) => convert(value, "rem", { baseline: 10 });
export const em = (value, baseline = 10) => convert(value, "em", { baseline });
export default rem;
import rem, { em } from "./utils/rem";
const unitless = rem(24);
// '2.4rem'
const convertToEm = em("12px", "24px");
// '0.5em'
const object = rem({
fontSize: 24,
margin: "24px",
padding: "5px -10px 1.5rem",
});
// {fontSize: 2.4, margin: '2.4rem', padding: '0.5rem -1rem 1.5rem'}
const StyledComponent = styled.h1`
font-size: ${(fontSize) => rem(fontSize)};
padding: ${(fontSize) => em("6px 12px", fontSize)};
`;
// .StyledComponent { font-size: 2.4rem; padding: 0.25em 0.5em; }
const h1 = (text) => <StyledComponent fontSize={24}>{text}</StyledComponent>;
FAQs
JavaScript function to convert CSS rem units.
The npm package startijenn-rem receives a total of 3,485 weekly downloads. As such, startijenn-rem popularity was classified as popular.
We found that startijenn-rem 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.