1.1.30 • Published 5 months ago

class2css v1.1.30

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

class2css

class2css is a plugin for Vite that converts CSS classes into meaningful CSS styles, simplifying the process of working with CSS in JavaScript applications. This plugin supports HMR (Hot Module Replacement) during development, enhancing performance and development experience.

Installation

You can install class2css via npm:

npm install class2css

Configuration

To configure class2css with Vite, add it to your Vite configuration file (vite.config.js):

import { defineConfig } from 'vite';
import class2css from 'class2css';

export default defineConfig({
    plugins: [class2css()]
});

Usage

In all templates in your .vue files, you can use the following keywords as class names to generate the corresponding CSS styles. Here is a list of supported keywords: Dưới đây là danh sách các key:

KeyPropertyExample
ccolorc-red -> color: red;
bgbackground-colorbg-blue -> background-color: blue;
fsfont-sizefs-14 -> font-size: 14px;
fwfont-weightfw-bold -> font-weight: bold;
wwidthw-100 -> width: 100px;
hheighth-200 -> height: 200px;
mmarginm-10 -> margin: 10px;
ppaddingp-20 -> padding: 20px;
bdborderbd-1px-solid-black -> border: 1px solid black;
brborder-radiusbr-5 -> border-radius: 5px;
wswhite-spacews-nowrap -> white-space: nowrap;
ovoverflowov-x-hidden -> overflow-x: hidden;
zz-indexz-10 -> z-index: 10;
blockdisplayblock -> display: block;
inlinedisplayinline -> display: inline;
inline_blockdisplayinline_block -> display: inline-block;
nonedisplaynone -> display: none;
ifont-stylei -> font-style: italic;
utext-decorationu -> text-decoration: underline;
lttext-decorationlt -> text-decoration: line-through;
otext-decorationo -> text-decoration: overline;
fnfont-stylefn -> font-style: normal;
tntext-decorationtn -> text-decoration: none;
tbfont-weighttb -> font-weight: bold;
upptext-transformupp -> text-transform: uppercase;
lowtext-transformlow -> text-transform: lowercase;
captext-transformcap -> text-transform: capitalize;
usnuser-selectusn -> user-select: none;
usauser-selectusa -> user-select: auto;
rowlayout (flex-direction: row)row -> flex-direction: row;
collayout (flex-direction: column)col -> flex-direction: column;
staticpositionstatic -> position: static;
relativepositionrelative -> position: relative;
fixedpositionfixed -> position: fixed;
absolutepositionabsolute -> position: absolute;
stickypositionsticky -> position: sticky;
tedgePosition (top)t-0 -> top: 0;
redgePosition (right)r-0 -> right: 0;
bedgePosition (bottom)b-0 -> bottom: 0;
ledgePosition (left)l-0 -> left: 0;
vtvertical-alignvt -> vertical-align: top;
vmvertical-alignvm -> vertical-align: middle;
vbvertical-alignvb -> vertical-align: bottom;
tltext-aligntl -> text-align: left;
tctext-aligntc -> text-align: center;
trtext-aligntr -> text-align: right;
tjtext-aligntj -> text-align: justify;
rlalign (left)rl -> align: left;
rcalign (center)rc -> align: center;
rralign (right)rr -> align: right;
rtalign (top)rt -> align: top;
rmalign (middle)rm -> align: middle;
rbalign (bottom)rb -> align: bottom;
rwalign (space-between)rw -> align: space-between;
raalign (space-around)ra -> align: space-around;
realign (space-evenly)re -> align: space-evenly;
clalign (left)cl -> align: left;
ccalign (center)cc -> align: center;
cralign (right)cr -> align: right;
ctalign (top)ct -> align: top;
cmalign (middle)cm -> align: middle;
cbalign (bottom)cb -> align: bottom;
cwalign (space-between)cw -> align: space-between;
caalign (space-around)ca -> align: space-around;
cealign (space-evenly)ce -> align: space-evenly;
sdbox-shadowsd-2px-2px-5px-gray -> box-shadow: 2px 2px 5px gray;
curcursorcur-pointer -> cursor: pointer;
opopacityop-50 -> opacity: 0.5;
totext-overflowto-ellipsis -> text-overflow: ellipsis;

Here’s a basic example of how to use class2css in your .vue files:

<template>
  <div class="cap i c-red bg-blue">abc</div>
</template>

<script>
export default {
  name: 'ExampleComponent'
}
</script>

<style>
</style>

Automatically generate CSS as shown below. This helps us save a lot of time.

<template>
  <div class="cap i c-red bg-blue">abc</div>
</template>

<script>
export default {
  name: 'ExampleComponent'
}
</script>

<style>
/* The generated CSS will be: */
.cap {
  text-transform: uppercase;
}
.i {
  font-style: italic;
}
.c-red {
  color: red;
}
.bg-blue {
  background-color: blue;
}
</style>
1.1.29

5 months ago

1.1.30

5 months ago

1.1.28

8 months ago

1.1.23

9 months ago

1.1.22

9 months ago

1.1.27

9 months ago

1.1.26

9 months ago

1.1.25

9 months ago

1.1.24

9 months ago

1.1.16

9 months ago

1.1.15

9 months ago

1.1.19

9 months ago

1.1.18

9 months ago

1.1.17

9 months ago

1.1.21

9 months ago

1.1.20

9 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.12

10 months ago

1.1.11

10 months ago

1.1.10

10 months ago

1.1.14

9 months ago

1.1.13

10 months ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago