vasille-css 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/fake-types/index.d.ts +32 -0
- package/lib/index.js +93 -0
- package/lib-node/index.js +100 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Vasille
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
`Vasille Web` is a front-end framework, which is developed to provide the best `developer experience` ever. **Our goal is to keep is as simple as possible.** Developing web applications using Vasille must be *as fast as possible*.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/vasille)
|
|
8
|
+
|
|
9
|
+
## Table of content
|
|
10
|
+
|
|
11
|
+
* [Installation](#installation)
|
|
12
|
+
* [How to use Vasille](#how-to-use-vasille)
|
|
13
|
+
* [How SAFE is Vasille](#how-safe-is-vasille)
|
|
14
|
+
* [How SIMPLE is Vasille](#how-simple-is-vasille)
|
|
15
|
+
* [How POWERFUL is Vasille](#how-powerful-is-vasille)
|
|
16
|
+
* [Road Map](#road-map)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<hr>
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
npm install vasille-web --save
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## How to use Vasille
|
|
28
|
+
|
|
29
|
+
Create an app from a template
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ npm create vasille
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Alternative method to create a TypeScript app.
|
|
36
|
+
```bash
|
|
37
|
+
$ npx degit vasille-js/example-typescript my-project
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Alternative method to create a JavaScript app.
|
|
41
|
+
```bash
|
|
42
|
+
$ npx degit vasille-js/example-javascript my-project
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Full documentation:
|
|
46
|
+
* [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v3/doc/V3-API.md)
|
|
47
|
+
|
|
48
|
+
### Examples
|
|
49
|
+
* [TypeScript Example](https://github.com/vasille-js/example-typescript)
|
|
50
|
+
* [JavaScript Example](https://github.com/vasille-js/example-javascript)
|
|
51
|
+
|
|
52
|
+
<hr>
|
|
53
|
+
|
|
54
|
+
## How SAFE is Vasille
|
|
55
|
+
|
|
56
|
+
The safe of your application is ensured by
|
|
57
|
+
* `100%` coverage of code by unit tests.
|
|
58
|
+
Each function, each branch is working as designed.
|
|
59
|
+
* OOP, DRY, KISS and SOLID principles are applied.
|
|
60
|
+
* `strong typing` makes your javascript/typescript code safe as C++ code.
|
|
61
|
+
All entities of `vasille` core library are strongly typed, including:
|
|
62
|
+
* data fields & properties.
|
|
63
|
+
* computed properties (function parameters & result).
|
|
64
|
+
* methods.
|
|
65
|
+
* events (defined handlers & event emit).
|
|
66
|
+
* DOM events & DOM operation (attributing, styling, etc.).
|
|
67
|
+
* slots of components.
|
|
68
|
+
* references to children.
|
|
69
|
+
* No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
|
|
70
|
+
|
|
71
|
+
## How SIMPLE is Vasille
|
|
72
|
+
|
|
73
|
+
There is the "Hello World":
|
|
74
|
+
```typescript jsx
|
|
75
|
+
import { compose, mount } from "vasille-dx";
|
|
76
|
+
|
|
77
|
+
const App = compose(() => {
|
|
78
|
+
<p>Hello world</p>;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
mount(document.body, App, {});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## How POWERFUL is Vasille
|
|
85
|
+
|
|
86
|
+
All of these are supported:
|
|
87
|
+
* Components.
|
|
88
|
+
* Reactive values (observables).
|
|
89
|
+
* Inline computed values.
|
|
90
|
+
* Multiline computed values.
|
|
91
|
+
* HTML & SVG tags.
|
|
92
|
+
* Component custom slots.
|
|
93
|
+
* 2-way data binding in components.
|
|
94
|
+
* Logic block (if, else).
|
|
95
|
+
* Loops (array, map, set).
|
|
96
|
+
|
|
97
|
+
<hr>
|
|
98
|
+
|
|
99
|
+
## Road map
|
|
100
|
+
|
|
101
|
+
* [x] Update the `Vasille Core` library to version 3.0.
|
|
102
|
+
* [x] `100%` Test Coverage for core Library v3.
|
|
103
|
+
* [x] Develop the `Vasille JSX` library.
|
|
104
|
+
* [x] `100%` Test Coverage for the JSX library.
|
|
105
|
+
* [x] Develop the `Vasille Babel Plugin`.
|
|
106
|
+
* [ ] `100%` Test Coverage fot babel plugin.
|
|
107
|
+
* [x] Add CSS support (define styles in components).
|
|
108
|
+
* [ ] Add custom `input` components with 2-way value binding.
|
|
109
|
+
* [ ] Add router.
|
|
110
|
+
* [ ] Develop dev-tools extension for debugging.
|
|
111
|
+
* [ ] Develop a lot of libraries for the framework.
|
|
112
|
+
|
|
113
|
+
## Questions
|
|
114
|
+
|
|
115
|
+
If you have questions, feel free to contact the maintainer of the project:
|
|
116
|
+
|
|
117
|
+
* [Author's Email](mailto:vas.lixcode@gmail.com)
|
|
118
|
+
* [Author's Telegram](https://t.me/lixcode)
|
|
119
|
+
|
|
120
|
+
<hr>
|
|
121
|
+
|
|
122
|
+
**Made in Moldova** 🇲🇩
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PropertiesHyphenFallback } from "csstype";
|
|
2
|
+
|
|
3
|
+
export declare function setMobileMaxWidth(value: number): void;
|
|
4
|
+
export declare function setTabletMaxWidth(value: number): void;
|
|
5
|
+
export declare function setLaptopMaxWidth(value: number): void;
|
|
6
|
+
|
|
7
|
+
type PropsSet = PropertiesHyphenFallback<number | number[], string> & {
|
|
8
|
+
[k: `--${string}`]: string;
|
|
9
|
+
};
|
|
10
|
+
type PseudoSet = PropsSet & {
|
|
11
|
+
[k: `:${string}`]: PropsSet;
|
|
12
|
+
};
|
|
13
|
+
type MediaSet = PseudoSet & {
|
|
14
|
+
[k: `@${string}`]: PseudoSet;
|
|
15
|
+
};
|
|
16
|
+
export declare function webStyleSheet<T = {
|
|
17
|
+
[k: string]: MediaSet;
|
|
18
|
+
}>(styles: T): {
|
|
19
|
+
[K in keyof T]: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
|
|
22
|
+
// fake functions
|
|
23
|
+
export declare function theme<T>(name: string, value: T): T;
|
|
24
|
+
export declare function dark<T>($: T): T;
|
|
25
|
+
// rules with target
|
|
26
|
+
export declare function mobile<T>($: T): T;
|
|
27
|
+
export declare function tablet<T>($: T): T;
|
|
28
|
+
export declare function laptop<T>($: T): T;
|
|
29
|
+
export declare function prefersDark<T>($: T): T;
|
|
30
|
+
export declare function prefersLight<T>($: T): T;
|
|
31
|
+
|
|
32
|
+
export {};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
let common;
|
|
2
|
+
let mobile;
|
|
3
|
+
let tablet;
|
|
4
|
+
let desktop;
|
|
5
|
+
let dark;
|
|
6
|
+
let light;
|
|
7
|
+
let mobileMaxWidth = 440;
|
|
8
|
+
let tabletMaxWidth = 880;
|
|
9
|
+
let laptopMaxWidth = 1320;
|
|
10
|
+
let index = Math.floor(Math.random() * 10);
|
|
11
|
+
export function setMobileMaxWidth(value) {
|
|
12
|
+
mobileMaxWidth = value;
|
|
13
|
+
}
|
|
14
|
+
export function setTabletMaxWidth(value) {
|
|
15
|
+
tabletMaxWidth = value;
|
|
16
|
+
}
|
|
17
|
+
export function setLaptopMaxWidth(value) {
|
|
18
|
+
laptopMaxWidth = value;
|
|
19
|
+
}
|
|
20
|
+
export function setIndex(value) {
|
|
21
|
+
index = value;
|
|
22
|
+
}
|
|
23
|
+
function createStyleSheet(media) {
|
|
24
|
+
const style = document.createElement("style");
|
|
25
|
+
style.media = media;
|
|
26
|
+
document.head.append(style);
|
|
27
|
+
return style.sheet;
|
|
28
|
+
}
|
|
29
|
+
function insertRule(target, rule) {
|
|
30
|
+
let sheet;
|
|
31
|
+
switch (target) {
|
|
32
|
+
case 1:
|
|
33
|
+
if (!mobile) {
|
|
34
|
+
mobile = createStyleSheet(`(max-width:${mobileMaxWidth}px)`);
|
|
35
|
+
}
|
|
36
|
+
sheet = mobile;
|
|
37
|
+
break;
|
|
38
|
+
case 2:
|
|
39
|
+
if (!tablet) {
|
|
40
|
+
tablet = createStyleSheet(`(min-width:${mobileMaxWidth}px)and(max-width:${tabletMaxWidth}px)`);
|
|
41
|
+
}
|
|
42
|
+
sheet = tablet;
|
|
43
|
+
break;
|
|
44
|
+
case 3:
|
|
45
|
+
if (!desktop) {
|
|
46
|
+
desktop = createStyleSheet(`(min-width:${tabletMaxWidth}px)and(max-width:${laptopMaxWidth}px)`);
|
|
47
|
+
}
|
|
48
|
+
sheet = desktop;
|
|
49
|
+
break;
|
|
50
|
+
case 4:
|
|
51
|
+
if (!dark) {
|
|
52
|
+
dark = createStyleSheet("(prefers-color-scheme:dark)");
|
|
53
|
+
}
|
|
54
|
+
sheet = dark;
|
|
55
|
+
break;
|
|
56
|
+
case 5:
|
|
57
|
+
if (!light) {
|
|
58
|
+
light = createStyleSheet("(prefers-color-scheme:light)");
|
|
59
|
+
}
|
|
60
|
+
sheet = light;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
if (sheet) {
|
|
64
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function webStyleSheet(styles) {
|
|
68
|
+
const result = {};
|
|
69
|
+
for (const key in styles) {
|
|
70
|
+
Object.defineProperty(result, key, {
|
|
71
|
+
get() {
|
|
72
|
+
const className = `v-${++index}`;
|
|
73
|
+
for (const item of styles[key]) {
|
|
74
|
+
if (item instanceof Array) {
|
|
75
|
+
const [target, rule] = item;
|
|
76
|
+
insertRule(target, rule.replace("{}", className));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (!common) {
|
|
80
|
+
common = createStyleSheet("");
|
|
81
|
+
}
|
|
82
|
+
common.insertRule(item.replace("{}", className), common.cssRules.length);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
styles[key].splice(0);
|
|
86
|
+
Object.defineProperty(result, key, { value: className });
|
|
87
|
+
return className;
|
|
88
|
+
},
|
|
89
|
+
configurable: true,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setMobileMaxWidth = setMobileMaxWidth;
|
|
4
|
+
exports.setTabletMaxWidth = setTabletMaxWidth;
|
|
5
|
+
exports.setLaptopMaxWidth = setLaptopMaxWidth;
|
|
6
|
+
exports.setIndex = setIndex;
|
|
7
|
+
exports.webStyleSheet = webStyleSheet;
|
|
8
|
+
let common;
|
|
9
|
+
let mobile;
|
|
10
|
+
let tablet;
|
|
11
|
+
let desktop;
|
|
12
|
+
let dark;
|
|
13
|
+
let light;
|
|
14
|
+
let mobileMaxWidth = 440;
|
|
15
|
+
let tabletMaxWidth = 880;
|
|
16
|
+
let laptopMaxWidth = 1320;
|
|
17
|
+
let index = Math.floor(Math.random() * 10);
|
|
18
|
+
function setMobileMaxWidth(value) {
|
|
19
|
+
mobileMaxWidth = value;
|
|
20
|
+
}
|
|
21
|
+
function setTabletMaxWidth(value) {
|
|
22
|
+
tabletMaxWidth = value;
|
|
23
|
+
}
|
|
24
|
+
function setLaptopMaxWidth(value) {
|
|
25
|
+
laptopMaxWidth = value;
|
|
26
|
+
}
|
|
27
|
+
function setIndex(value) {
|
|
28
|
+
index = value;
|
|
29
|
+
}
|
|
30
|
+
function createStyleSheet(media) {
|
|
31
|
+
const style = document.createElement("style");
|
|
32
|
+
style.media = media;
|
|
33
|
+
document.head.append(style);
|
|
34
|
+
return style.sheet;
|
|
35
|
+
}
|
|
36
|
+
function insertRule(target, rule) {
|
|
37
|
+
let sheet;
|
|
38
|
+
switch (target) {
|
|
39
|
+
case 1:
|
|
40
|
+
if (!mobile) {
|
|
41
|
+
mobile = createStyleSheet(`(max-width:${mobileMaxWidth}px)`);
|
|
42
|
+
}
|
|
43
|
+
sheet = mobile;
|
|
44
|
+
break;
|
|
45
|
+
case 2:
|
|
46
|
+
if (!tablet) {
|
|
47
|
+
tablet = createStyleSheet(`(min-width:${mobileMaxWidth}px)and(max-width:${tabletMaxWidth}px)`);
|
|
48
|
+
}
|
|
49
|
+
sheet = tablet;
|
|
50
|
+
break;
|
|
51
|
+
case 3:
|
|
52
|
+
if (!desktop) {
|
|
53
|
+
desktop = createStyleSheet(`(min-width:${tabletMaxWidth}px)and(max-width:${laptopMaxWidth}px)`);
|
|
54
|
+
}
|
|
55
|
+
sheet = desktop;
|
|
56
|
+
break;
|
|
57
|
+
case 4:
|
|
58
|
+
if (!dark) {
|
|
59
|
+
dark = createStyleSheet("(prefers-color-scheme:dark)");
|
|
60
|
+
}
|
|
61
|
+
sheet = dark;
|
|
62
|
+
break;
|
|
63
|
+
case 5:
|
|
64
|
+
if (!light) {
|
|
65
|
+
light = createStyleSheet("(prefers-color-scheme:light)");
|
|
66
|
+
}
|
|
67
|
+
sheet = light;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (sheet) {
|
|
71
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function webStyleSheet(styles) {
|
|
75
|
+
const result = {};
|
|
76
|
+
for (const key in styles) {
|
|
77
|
+
Object.defineProperty(result, key, {
|
|
78
|
+
get() {
|
|
79
|
+
const className = `v-${++index}`;
|
|
80
|
+
for (const item of styles[key]) {
|
|
81
|
+
if (item instanceof Array) {
|
|
82
|
+
const [target, rule] = item;
|
|
83
|
+
insertRule(target, rule.replace("{}", className));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (!common) {
|
|
87
|
+
common = createStyleSheet("");
|
|
88
|
+
}
|
|
89
|
+
common.insertRule(item.replace("{}", className), common.cssRules.length);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
styles[key].splice(0);
|
|
93
|
+
Object.defineProperty(result, key, { value: className });
|
|
94
|
+
return className;
|
|
95
|
+
},
|
|
96
|
+
configurable: true,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vasille-css",
|
|
3
|
+
"version": "3.0.3",
|
|
4
|
+
"description": "Add module CSS styles to Vasille Components",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"types": "./fake-types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./lib/index.js",
|
|
9
|
+
"browser": "./lib/index.js",
|
|
10
|
+
"node": "./lib-node/index.js",
|
|
11
|
+
"require": "./lib-node/index.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prepack": "cp -f ../README.md ./README.md",
|
|
15
|
+
"prettier": "prettier src test --write",
|
|
16
|
+
"build": "tsc --build tsconfig.json",
|
|
17
|
+
"build-node": "tsc --build tsconfig-build-node.json",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test-coverage": "jest --coverage"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"front-end",
|
|
23
|
+
"framework",
|
|
24
|
+
"css",
|
|
25
|
+
"styles"
|
|
26
|
+
],
|
|
27
|
+
"author": "lixcode",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/vasille-js/vasille-js/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/vasille-js/vasille-js#readme",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/vasille-js/vasille-js.git"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"csstype": "^3.1.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/jest": "^29.5.14",
|
|
42
|
+
"@types/jsdom": "^21.1.7",
|
|
43
|
+
"csstype": "^3.1.3",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"jsdom": "^25.0.1",
|
|
46
|
+
"prettier": "^3.3.3",
|
|
47
|
+
"ts-jest": "^29.2.5",
|
|
48
|
+
"typescript": "^5.6.3"
|
|
49
|
+
}
|
|
50
|
+
}
|