Git Product home page Git Product logo

vue-mods-names's Introduction

vue-mods-names

Simple adding class names mods to all components in your vue app

example

npm version Build Status JavaScript Style Guide

Docs with examples and playgrounds:
English
Русский
Українська

Install

So typically

npm i vue-mods-names -D

Usage

import VueModsNames from 'vue-mods-names'

Vue.use(VueModsNames)

If you want to change prefix (by default is equal: _), then just pass it in plugin options, like this:

import VueModsNames from 'vue-mods-names'

Vue.use(VueModsNames, { prefix: '-' })

After that any component in your app is ready to use mods. It will work if you declare name of base class in directive v-mods-names:

Declare behavior by adding special directive v-mods-names in your template. good - is name of base class, that will join with other mods.

Good.vue

<!-- Template of 'Good' component, that will be include in other places -->
<div v-mods-names:good>It's cool</div>

Now we may use component with different mods:

main page

<Good mods="main" />

In the issue you have component on main page, that has classes after render:

<div class="good good_main">It's cool</div>

All style modifications of component typically describe in component file itself (one file component).

.good {}

.good_main {}

.good_big {}

You can pass Array of mods:

<Good :mods="['main', 'big']" />

After render we get this:

<div class="good good_main good_big">It's cool</div>

KamilOcean

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.