Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/laoer536/style-to-dom

Fast create dom by less or sass or css.
https://github.com/laoer536/style-to-dom

Last synced: about 1 month ago
JSON representation

Fast create dom by less or sass or css.

Awesome Lists containing this project

README

        

# style-to-dom
Fast create dom file by less or scss or css file.

## Install

npm

```js
npm install style-to-dom -D
```

pnpm

```js
pnpm add style-to-dom -D
```

yarn

```js
yarn add style-to-dom -D
```

## Use

Execute the following command in the project root directory

```js
create-style-dom
```

Such as './src/pages/list/card/style/index.module.less'

`` is relative to the root directory of your project.

Then will create dom file for this style file. This file may be Vue, tsx, jsx, or HTML, depending on what framework your project uses and whether your project has typescript. If your project does not use React or Vue, an HTML file will be generated for you.

## Pay attention to the following points

For the case where the class is labeled at this level, you need to write it as follows

```less
.home {
width: 100%;
height: 100vh;
text-align: center;
.title {
font-size: 18px;
font-weight: bold;
//&.active{
// color: red;
//}
&.self-active{ // Mark this level with 'self'
color: red;
}
& > img {
width: 32px;
height: 32px;
transition: transform 0.3s ease-in-out;
&:hover {
transform: scale(1.2);
}
}
h2 {
//&.sub-title {
// font-size: 14px;
// .sss {
// font-size: 57px;
// }
//}
&.self-sub-title { // Mark this level with 'self'
font-size: 14px;
.sss {
font-size: 57px;
}
}
}
}
input[type='text'] {
background-color: aqua;
}
}
```

If in `vue3-ts` project, will create a `vue` file

```vue










@import './index.scss';

```

If in `react-ts` project, will create a `tsx` file

```tsx
import React from "react";
import Style from "./index.module.scss";
export default function index() {
return (













);
}
```

> react-js | vue2-js | vue3-js are also supported, so I won't give an example here.

Additionally, since class selectors only generate 'div' tags, if you want to specify which tags to generate, please use tag selectors when writing style selectors.