Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@netlify/classnames-template-literals
Advanced tools
Small utility to format long classnames with template literals
Utility originally created to deal with long Tailwind classnames.
To make our code more readable, we extract our Tailwind classes into variables, for example:
const twClasses = `
tw-sr-only
focus:tw-not-sr-only
tw-bg-teal-darker
tw-text-white
tw-block
tw-text-sm
tw-l-0
`;
The issue with writing classes this way is that they are rendered as-is in the DOM.
Example:
<p
class="
tw-sr-only
focus:tw-not-sr-only
tw-bg-teal-darker
tw-text-white
tw-block
tw-text-sm
tw-l-0"
>
Hello world
</p>
Using the ctl
util formats classnames so they are rendered in a more standard way in the DOM.
Example:
<p class="tw-sr-only focus:tw-not-sr-only tw-bg-teal-darker tw-text-white tw-block tw-text-sm tw-l-0">
Hello world
</p>
npm install @netlify/classnames-template-literals
Wrap your classnames inside ctl
.
import ctl from "@netlify/classnames-template-literals";
const buttonClasses = ctl(`
bg-black
text-white
p-1
rounded-sm
`);
You can also use conditional classes:
import ctl from "@netlify/classnames-template-literals";
const buttonClasses = ctl(`
bg-black
text-white
p-1
rounded-sm
${someState && "bg-pink"}
`);
FAQs
Small utility to format long classnames with template literals
The npm package @netlify/classnames-template-literals receives a total of 4,431 weekly downloads. As such, @netlify/classnames-template-literals popularity was classified as popular.
We found that @netlify/classnames-template-literals demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 open source maintainers 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.