Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vue-module-class-generator
Advanced tools
Module class helper generator for vue css modules
yarn
yarn add vue-module-class-generator
npm
npm i vue-module-class-generator
interface Mods {
[key: string]: boolean | string
}
c(mainClass?: string | Mods, mods?: Mods)
import Vue from 'vue'
import ClassGenerator from 'vue-module-class-generator'
Vue.use(classGenerator, {
methodName: 'c', // default
prefix: {
mod: '', // if 'is' === isActive else 'active'
modKey: '', // if is === colorIsRed else colorRed
},
})
import { classMixin } from 'vue-module-class-generator'
export default {
name: 'block',
mixins: [classMixin(config)]
}
<template>
<div :class="c($style.block, { active, color })">
</div> <!-- result :class="[$style.block, $style.active, $style.colorRed]" -->
</template>
<script>
import { classMixin } from 'vue-module-class-generator'
export default {
name: 'block',
props: {
active: Boolean,
color: String,
},
mixins: [classMixin()]
}
</script>
<style module>
.block {
display: block;
}
.active {
background-color: blue;
}
.colorRed {
color: red;
}
</style>
methodName: string
- set methodName in component
import { classMixin } from 'vue-module-class-generator'
export default {
mixins: [classMixin(), classMixin({ methodName: 'gen' })],
mounted() {
typeof this.c === 'function' // true
typeof this.gen === 'function' // true
}
}
prefix.mod: string
- set prefix to boolean mode
// prefix.mod = 'is'
c($style.element, { active: true }) // [$style.element, $style.isActive]
// prefix.mod = ''
c($style.element, { active: true }) // [$style.element, $style.active]
prefix.modKey: string
- set prefix to key mode
// prefix.modKey = 'is'
c($style.element, { color: 'red' }) // [$style.element, $style.colorIsRed]
// prefix.modKey = ''
c($style.element, { color: 'red' }) // [$style.element, $style.colorRed]
FAQs
Vue class helper
We found that vue-module-class-generator 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.