Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@daviddarnes/contrast-details
Advanced tools
A Web Component to display the contrast ratio and level of two colours using CSS custom properties
contrast-details
A Web Component to display the contrast ratio and level of two colours using CSS custom properties
Demo | Custom template demo | Further reading
General usage example:
<script type="module" src="contrast-details.js"></script>
<contrast-details
style="--foreground: #444; --background: #ccc"
></contrast-details>
<contrast-details
style="--foreground: #444; --background: #613fe8"
></contrast-details>
Example using inherited values:
<script type="module" src="contrast-details.js"></script>
<div style="--foreground: #444">
<contrast-details style="--background: #ccc"></contrast-details>
<contrast-details style="--background: #ffffff"></contrast-details>
<contrast-details style="--background: #613fe8"></contrast-details>
</div>
Example using level
attribute for styling
<style>
contrast-details[level^="aa"] [data-key="level"]::after {
content: " ✅";
}
contrast-details[level="fail"] [data-key="level"]::after {
content: " ❌";
}
</style>
<script type="module" src="contrast-details.js"></script>
<contrast-details
style="--foreground: #444; --background: #ccc"
></contrast-details>
<contrast-details
style="--foreground: #444; --background: #613fe8"
></contrast-details>
Example using a custom template:
<script type="module" src="contrast-details.js"></script>
<template id="contrast-details-template">
<p>
Contrast: <span data-key="ratio"></span> –
<span data-key="level"></span>
</p>
</template>
<contrast-details
style="--foreground: #444; --background: #ccc"
></contrast-details>
<contrast-details
style="--foreground: #444; --background: #613fe8"
></contrast-details>
This Web Component allows you to:
level
attribute selector to style elements differently depending on aaa
, aa
and fail
gradesYou have a few options (choose one of these):
npm install @daviddarnes/contrast-details
Make sure you include the <script>
in your project (choose one of these):
<!-- Host yourself -->
<script type="module" src="contrast-details.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
type="module"
src="https://www.unpkg.com/@daviddarnes/contrast-details@1.1.0/contrast-details.js"
></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
type="module"
src="https://esm.sh/@daviddarnes/contrast-details@1.1.0"
></script>
With thanks to the following people:
FAQs
A Web Component to display the contrast ratio and level of two colours using CSS custom properties
We found that @daviddarnes/contrast-details demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.