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

vue-module-class-generator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-module-class-generator

Vue class helper

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vue-module-class-generator

Module class helper generator for vue css modules

Install

yarn

yarn add vue-module-class-generator

npm

npm i vue-module-class-generator

Usage

Syntax

interface Mods {
  [key: string]: boolean | string
}

c(mainClass?: string | Mods, mods?: Mods)

Install as vue plugin

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
  },
})

Mixin

import { classMixin } from 'vue-module-class-generator'

export default {
  name: 'block',
  mixins: [classMixin(config)]
}

Use in template

<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>

Options

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('element', { active: true }) // ['element', $style.isActive]
// prefix.mod = ''
c('element', { active: true }) // ['element', $style.active]

prefix.modKey: string - set prefix to key mode

// prefix.modKey = 'is'
c('element', { color: 'red' }) // ['element', $style.colorIsRed]
// prefix.modKey = ''
c('element', { color: 'red' }) // ['element', $style.colorRed]

FAQs

Package last updated on 25 Oct 2018

Did you know?

Socket

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.

Install

Related posts

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