Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-preset-mantine

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-preset-mantine - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

package.json
{
"name": "postcss-preset-mantine",
"version": "1.0.7",
"version": "1.0.8",
"description": "PostCSS preset for Mantine (7.0+) applications",

@@ -5,0 +5,0 @@ "main": "preset.js",

const postcss = require('postcss');
const re = /light-dark\(([^,]+),([^)]+)\)/;
const FUNCTION = 'light-dark(';
function getValue(index) {
function extractValue(input) {
const match = input.match(re);
function splitStringAtCharacter(character, search) {
let characterIndex = 0;
let openedParentheses = 0;
if (match) {
const value = match[index];
const replaced = input.replace(re, value.trim());
return extractValue(replaced);
while (
characterIndex < search.length &&
(search[characterIndex] !== character || openedParentheses)
) {
if (search[characterIndex] === '(') {
openedParentheses += 1;
}
if (search[characterIndex] === ')') {
openedParentheses -= 1;
}
characterIndex += 1;
}
return input;
return [search.slice(0, characterIndex), search.slice(characterIndex + 1)];
}
function getLightDarkValue(value) {
const [prefix, ...search] = value.split(FUNCTION);
if (!search.length) {
return { light: value, dark: value };
}
return extractValue;
const [macro, suffix] = splitStringAtCharacter(')', search.join(FUNCTION));
const [light, dark] = splitStringAtCharacter(',', macro);
const parsedSuffix = getLightDarkValue(suffix);
return {
light: prefix + getLightDarkValue(light.trim()).light + parsedSuffix.light,
dark: prefix + getLightDarkValue(dark.trim()).dark + parsedSuffix.dark,
};
}
const getLightValue = getValue(1);
const getDarkValue = getValue(2);
module.exports = () => {

@@ -33,4 +51,3 @@ return {

if (value.includes('light-dark')) {
const lightVal = getLightValue(value);
const darkVal = getDarkValue(value);
const { light: lightVal, dark: darkVal } = getLightDarkValue(value);

@@ -37,0 +54,0 @@ const lightRule = postcss.rule({

@@ -7,3 +7,3 @@ const postcss = require('postcss');

(
await postcss([preset]).process('a { border: 1rem solid light-dark(red, blue) }', {
await postcss([preset]).process('a { border: 1rem solid light-dark(red, var(--blue)); }', {
from: undefined,

@@ -10,0 +10,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc