Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
postcss-modules-values
Advanced tools
PostCSS plugin for CSS Modules to pass arbitrary constants between your module files
The postcss-modules-values package is a PostCSS plugin that allows you to define and use custom values (variables) within your CSS modules. This can help you manage and reuse values like colors, sizes, and other design tokens across your stylesheets.
Define Custom Values
This feature allows you to define custom values in one CSS file and import them into another. This helps in maintaining consistency and reusability of design tokens across different stylesheets.
/* variables.css */
@value primaryColor: #3498db;
@value padding: 10px;
/* styles.css */
@value primaryColor, padding from './variables.css';
.button {
background-color: primaryColor;
padding: padding;
}
Scoped Values
Scoped values allow you to import and use values in a specific scope, ensuring that the values are only available where they are needed. This helps in avoiding global namespace pollution.
/* variables.css */
@value primaryColor: #3498db;
/* component.css */
@value primaryColor from './variables.css';
.header {
color: primaryColor;
}
Nested Values
Nested values allow you to group related values together, making it easier to manage and use them in a structured way. This is particularly useful for organizing design tokens.
/* variables.css */
@value colors: {
primary: #3498db,
secondary: #2ecc71
};
/* styles.css */
@value colors from './variables.css';
.button {
background-color: colors.primary;
}
postcss-simple-vars is a PostCSS plugin that allows you to use Sass-like variables in your CSS. It provides a simpler syntax for defining and using variables, but lacks the scoping and nesting capabilities of postcss-modules-values.
postcss-custom-properties is a PostCSS plugin that transforms W3C CSS Custom Properties (CSS variables) syntax into a static representation. It is more aligned with the native CSS variables specification and provides broader browser compatibility, but does not offer the same level of modularity as postcss-modules-values.
postcss-advanced-variables is a PostCSS plugin that extends the capabilities of CSS variables with features like conditionals, loops, and functions. It offers more advanced features compared to postcss-modules-values, but may be overkill for simpler use cases.
Pass arbitrary values between your module files
/* colors.css */
@value primary: #BF4040;
@value secondary: #1F4F7F;
.text-primary {
color: primary;
}
.text-secondary {
color: secondary;
}
/* breakpoints.css */
@value small: (max-width: 599px);
@value medium: (min-width: 600px) and (max-width: 959px);
@value large: (min-width: 960px);
/* my-component.css */
@value colors: "./colors.css";
@value primary, secondary from colors;
@value small as bp-small, large as bp-large from "./breakpoints.css";
.header {
composes: text-primary from colors;
box-shadow: 0 0 10px secondary;
}
@media bp-small {
.header {
box-shadow: 0 0 4px secondary;
}
}
@media bp-large {
.header {
box-shadow: 0 0 20px secondary;
}
}
Note that the :
in a @value
definition is optional as to not break Sass.
See this PR for more background
ISC
Glen Maddern, 2015.
FAQs
PostCSS plugin for CSS Modules to pass arbitrary values between your module files
The npm package postcss-modules-values receives a total of 7,584,458 weekly downloads. As such, postcss-modules-values popularity was classified as popular.
We found that postcss-modules-values demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.