@mlut/core 1.0.0
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 +24 -0
- package/_index.scss +1 -0
- package/_tools.scss +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/jit/JitEngine.d.ts +19 -0
- package/dist/jit/JitEngine.js +124 -0
- package/dist/jit/index.d.ts +1 -0
- package/dist/jit/index.js +1 -0
- package/dist/sass/addons/demo-theme.scss +112 -0
- package/dist/sass/css/_base-setup.scss +3 -0
- package/dist/sass/css/_index.scss +2 -0
- package/dist/sass/css/helpers/_index.scss +3 -0
- package/dist/sass/css/helpers/btn.scss +28 -0
- package/dist/sass/css/helpers/gs-debug.scss +28 -0
- package/dist/sass/css/helpers/ratio-box.scss +47 -0
- package/dist/sass/css/helpers/row.scss +98 -0
- package/dist/sass/css/helpers/wrapper.scss +21 -0
- package/dist/sass/css/styles/_index.scss +2 -0
- package/dist/sass/css/styles/generic.scss +296 -0
- package/dist/sass/css/styles/variables.scss +32 -0
- package/dist/sass/css/utils/_bg-bd.scss +27 -0
- package/dist/sass/css/utils/_grid.scss +37 -0
- package/dist/sass/css/utils/_index.scss +2 -0
- package/dist/sass/css/utils/_load.scss +9 -0
- package/dist/sass/css/utils/_transition.scss +16 -0
- package/dist/sass/css/utils/box-alignment.scss +29 -0
- package/dist/sass/css/utils/box-model.scss +48 -0
- package/dist/sass/css/utils/grid-system.scss +17 -0
- package/dist/sass/css/utils/init.scss +107 -0
- package/dist/sass/css/utils/other.scss +35 -0
- package/dist/sass/css/utils/text.scss +33 -0
- package/dist/sass/css/utils/visual.scss +32 -0
- package/dist/sass/index.scss +4 -0
- package/dist/sass/tools/_index.scss +4 -0
- package/dist/sass/tools/functions/_index.import.scss +3 -0
- package/dist/sass/tools/functions/_index.scss +9 -0
- package/dist/sass/tools/functions/base/_error.scss +9 -0
- package/dist/sass/tools/functions/base/_getters.scss +124 -0
- package/dist/sass/tools/functions/base/_index.scss +11 -0
- package/dist/sass/tools/functions/base/_list.scss +56 -0
- package/dist/sass/tools/functions/base/_math.scss +149 -0
- package/dist/sass/tools/functions/base/_string.scss +300 -0
- package/dist/sass/tools/functions/common/_custom-units.scss +231 -0
- package/dist/sass/tools/functions/common/_forward-tools.scss +2 -0
- package/dist/sass/tools/functions/common/_helpers.scss +57 -0
- package/dist/sass/tools/functions/common/_index.scss +9 -0
- package/dist/sass/tools/functions/common/_utils.scss +211 -0
- package/dist/sass/tools/functions/high/_at-rules.scss +296 -0
- package/dist/sass/tools/functions/high/_forward-tools.scss +3 -0
- package/dist/sass/tools/functions/high/_index.scss +8 -0
- package/dist/sass/tools/functions/high/utils/_index.scss +288 -0
- package/dist/sass/tools/functions/high/utils/_parse-util.scss +107 -0
- package/dist/sass/tools/functions/high/utils/_range-generators.scss +355 -0
- package/dist/sass/tools/functions/high/utils/_util-apply-selector.scss +134 -0
- package/dist/sass/tools/functions/high/utils/_value-converters.scss +294 -0
- package/dist/sass/tools/functions/high/utils/_value-transformers.scss +65 -0
- package/dist/sass/tools/mixins/_index.import.scss +2 -0
- package/dist/sass/tools/mixins/_index.scss +8 -0
- package/dist/sass/tools/mixins/base/_forward-tools.scss +2 -0
- package/dist/sass/tools/mixins/base/_index.scss +93 -0
- package/dist/sass/tools/mixins/base/_mk-ar.scss +96 -0
- package/dist/sass/tools/mixins/base/_mk-state.scss +175 -0
- package/dist/sass/tools/mixins/high/_forward-tools.scss +3 -0
- package/dist/sass/tools/mixins/high/_index.scss +1 -0
- package/dist/sass/tools/mixins/high/utils/_index.scss +188 -0
- package/dist/sass/tools/mixins/high/utils/_mk-util.scss +366 -0
- package/dist/sass/tools/settings/_index.import.scss +3 -0
- package/dist/sass/tools/settings/_index.scss +3 -0
- package/dist/sass/tools/settings/base/_general.scss +175 -0
- package/dist/sass/tools/settings/base/_index.scss +2 -0
- package/dist/sass/tools/settings/base/_utils.scss +578 -0
- package/dist/sass/tools/settings/common/_at-rules.scss +213 -0
- package/dist/sass/tools/settings/common/_index.scss +2 -0
- package/dist/sass/tools/settings/common/_utils.scss +1926 -0
- package/dist/sass/tools/settings/high/_forward-tools.scss +2 -0
- package/dist/sass/tools/settings/high/_grid.scss +55 -0
- package/dist/sass/tools/settings/high/_index.scss +2 -0
- package/dist/sass/tools/settings/high/_utils.scss +104 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.js +13 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# mlut core #
|
|
2
|
+
|
|
3
|
+
<img alt="Logo" src="https://github.com/mr150/mlut/raw/master/docs/img/logo-full.png" width="350"/>
|
|
4
|
+
|
|
5
|
+
The [mlut](https://github.com/mr150/mlut) core contains:
|
|
6
|
+
- Sass tools
|
|
7
|
+
- CSS library
|
|
8
|
+
- JIT engine
|
|
9
|
+
|
|
10
|
+
### Installation ###
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
npm i -D @mlut/core sass-embedded
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
When using this package, you will need to install Sass separately. We recommend [sass-embedded](https://www.npmjs.com/package/sass-embedded), but regular [sass](https://www.npmjs.com/package/sass) is also suitable.
|
|
17
|
+
|
|
18
|
+
This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.
|
|
19
|
+
|
|
20
|
+
## Documentation ##
|
|
21
|
+
Full documentation available [here](https://mr150.github.io/mlut/)
|
|
22
|
+
|
|
23
|
+
## License ##
|
|
24
|
+
MIT
|
package/_index.scss
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward 'dist/sass';
|
package/_tools.scss
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward 'dist/sass/tools';
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class JitEngine {
|
|
2
|
+
private utils;
|
|
3
|
+
private inputFilePath;
|
|
4
|
+
private inputFileDir;
|
|
5
|
+
private sassModuleName;
|
|
6
|
+
private inputFileCache;
|
|
7
|
+
private generationDebounce;
|
|
8
|
+
private readonly defaultSassConfig;
|
|
9
|
+
private readonly utilsByFile;
|
|
10
|
+
private readonly utilsRegexps;
|
|
11
|
+
private readonly configRegexps;
|
|
12
|
+
init([inputPath, inputContent]?: [string | undefined, string | undefined]): Promise<void>;
|
|
13
|
+
putAndGenerateCss(id: string, content: string): Promise<string | undefined>;
|
|
14
|
+
private extractUtils;
|
|
15
|
+
private normalizeClassNameStr;
|
|
16
|
+
private extractUserSassConfig;
|
|
17
|
+
private loadUtils;
|
|
18
|
+
}
|
|
19
|
+
export declare const jitEngine: JitEngine;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { logger } from '../utils/index.js';
|
|
3
|
+
const sass = await import('sass-embedded')
|
|
4
|
+
.catch(() => import('sass'))
|
|
5
|
+
.catch(() => {
|
|
6
|
+
throw new Error('The Sass package is not installed. You can do this with `npm i -D sass-embedded`');
|
|
7
|
+
});
|
|
8
|
+
const __dirname = new URL('.', import.meta.url).pathname;
|
|
9
|
+
export class JitEngine {
|
|
10
|
+
utils = new Set();
|
|
11
|
+
inputFilePath = '';
|
|
12
|
+
inputFileDir = __dirname;
|
|
13
|
+
sassModuleName = 'tools';
|
|
14
|
+
inputFileCache = '@use "../sass/tools";';
|
|
15
|
+
generationDebounce;
|
|
16
|
+
defaultSassConfig = '@use "sass:map";\n @use "../sass/tools/settings" as ml;';
|
|
17
|
+
utilsByFile = new Map();
|
|
18
|
+
utilsRegexps = {
|
|
19
|
+
quotedContent: /"\n?[^"]*?[A-Z][^"\n]*\n?"/g,
|
|
20
|
+
singleQuotedContent: /'\n?[^']*?[A-Z][^'\n]*\n?'/g,
|
|
21
|
+
tooMoreSpaces: /\s{2,}|\n/g,
|
|
22
|
+
utilName: /^-?[A-Z]{1}[a-zA-Z]*/,
|
|
23
|
+
};
|
|
24
|
+
configRegexps = {
|
|
25
|
+
userSettings: /@use ['"][^'"]*(tools|mlut|core)['"](\s*as\s+[\w]+)?\s+with\s*\(([^;]+)\);/s,
|
|
26
|
+
sassModuleName: /@use ['"][^'"]*(tools|mlut|core)['"]\s*;/s,
|
|
27
|
+
};
|
|
28
|
+
async init([inputPath, inputContent] = ['', '']) {
|
|
29
|
+
let sassConfig = this.defaultSassConfig;
|
|
30
|
+
if (inputPath && inputContent) {
|
|
31
|
+
this.inputFilePath = path.join(process.cwd(), inputPath);
|
|
32
|
+
this.inputFileDir = path.dirname(this.inputFilePath);
|
|
33
|
+
this.inputFileCache = inputContent;
|
|
34
|
+
sassConfig = this.extractUserSassConfig(inputContent);
|
|
35
|
+
}
|
|
36
|
+
await this.loadUtils(sassConfig);
|
|
37
|
+
}
|
|
38
|
+
async putAndGenerateCss(id, content) {
|
|
39
|
+
if (this.utils.size === 0) {
|
|
40
|
+
logger.warn('Config with utilities is not loaded!');
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
if (id === this.inputFilePath) {
|
|
44
|
+
this.inputFileCache = content;
|
|
45
|
+
const sassConfig = this.extractUserSassConfig(content);
|
|
46
|
+
if (sassConfig) {
|
|
47
|
+
await this.loadUtils(sassConfig);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (content) {
|
|
51
|
+
this.utilsByFile.set(id, this.extractUtils(content));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.utilsByFile.delete(id);
|
|
55
|
+
}
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
//eslint-disable-next-line
|
|
58
|
+
let timeout;
|
|
59
|
+
clearTimeout(this.generationDebounce);
|
|
60
|
+
this.generationDebounce = setTimeout(async () => {
|
|
61
|
+
clearTimeout(timeout);
|
|
62
|
+
const allUniqueUtils = [...new Set([...this.utilsByFile.values()].flat())];
|
|
63
|
+
const applyStr = `\n@include ${this.sassModuleName}.apply(${JSON.stringify(allUniqueUtils)},(),true);`;
|
|
64
|
+
// `compileStringAsync` is almost always faster than `compile` in sass-embedded
|
|
65
|
+
const css = await sass.compileStringAsync(this.inputFileCache + applyStr, { loadPaths: [this.inputFileDir, 'node_modules'] }).then(({ css }) => css, (e) => (logger.error('Sass compilation error.', e), undefined));
|
|
66
|
+
resolve(css);
|
|
67
|
+
}, 100);
|
|
68
|
+
timeout = setTimeout(() => resolve(undefined), 300);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
extractUtils(content) {
|
|
72
|
+
const allClassNames = [];
|
|
73
|
+
const quotedClassNames = content
|
|
74
|
+
.match(this.utilsRegexps.quotedContent)
|
|
75
|
+
//eslint-disable-next-line
|
|
76
|
+
?.map(this.normalizeClassNameStr, this);
|
|
77
|
+
const singleQuotedClassNames = content
|
|
78
|
+
.replace(this.utilsRegexps.quotedContent, '')
|
|
79
|
+
.match(this.utilsRegexps.singleQuotedContent)
|
|
80
|
+
//eslint-disable-next-line
|
|
81
|
+
?.map(this.normalizeClassNameStr, this);
|
|
82
|
+
for (const item of [quotedClassNames, singleQuotedClassNames]) {
|
|
83
|
+
if (item instanceof Array) {
|
|
84
|
+
allClassNames.push(...item);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return [...allClassNames.join(' ').split(' ').reduce((acc, cssClass) => {
|
|
88
|
+
const utility = cssClass.split('_').find((str) => (this.utilsRegexps.utilName.test(str)));
|
|
89
|
+
if (utility) {
|
|
90
|
+
const utilName = utility.match(this.utilsRegexps.utilName)?.[0];
|
|
91
|
+
if (this.utils.has(utilName) || utilName[0] === '-') {
|
|
92
|
+
acc.add(cssClass);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return acc;
|
|
96
|
+
}, new Set())];
|
|
97
|
+
}
|
|
98
|
+
normalizeClassNameStr(str) {
|
|
99
|
+
return str.replace(this.utilsRegexps.tooMoreSpaces, ' ').slice(1, -1);
|
|
100
|
+
}
|
|
101
|
+
extractUserSassConfig(content) {
|
|
102
|
+
let matchResult = content.match(this.configRegexps.userSettings);
|
|
103
|
+
if (matchResult != null) {
|
|
104
|
+
const userSettings = matchResult.at(-1);
|
|
105
|
+
this.sassModuleName = matchResult[2] ?
|
|
106
|
+
matchResult[2].replace(/\s*as\s*/, '') :
|
|
107
|
+
matchResult[1];
|
|
108
|
+
return this.defaultSassConfig.slice(0, -1) + ` with (${userSettings});`;
|
|
109
|
+
}
|
|
110
|
+
matchResult = content.match(this.configRegexps.sassModuleName);
|
|
111
|
+
if (matchResult != null) {
|
|
112
|
+
this.sassModuleName = matchResult[1];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async loadUtils(userConfig = this.defaultSassConfig) {
|
|
116
|
+
const { css } = (await sass.compileStringAsync(userConfig + '\n a{ all: map.keys(map.get(ml.$utils-db, "utils", "registry")); }', {
|
|
117
|
+
style: 'compressed',
|
|
118
|
+
loadPaths: [__dirname, 'node_modules'],
|
|
119
|
+
}));
|
|
120
|
+
const strEnd = css.lastIndexOf('"') - css.length + 1;
|
|
121
|
+
this.utils = new Set(JSON.parse('[' + css.split('all:')[1].slice(0, strEnd) + ']'));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export const jitEngine = new JitEngine();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './JitEngine.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './JitEngine.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use '../tools' as ml;
|
|
3
|
+
|
|
4
|
+
// Demo theme
|
|
5
|
+
//
|
|
6
|
+
// A full-fledged design theme to create an interface. Contains a set of utilities and a colors palette.
|
|
7
|
+
//
|
|
8
|
+
// By default (in JIT mode), only the palette will be loaded. If you want to load and generate utilities (AOT), pass `$is-aot: true` to the module configuration.
|
|
9
|
+
//
|
|
10
|
+
// Styleguide: addons.catalog.demo_theme
|
|
11
|
+
|
|
12
|
+
// Colors
|
|
13
|
+
//
|
|
14
|
+
// Colors are automatically loaded into the mlut settings, so you can use them when adding utilities or styles. Utilities with colors are generated with [range syntax](section-how_to.html#kssref-how_to-mk_utils-range-color).
|
|
15
|
+
// - step of color shade: **25**
|
|
16
|
+
// - step in the value of utilities: **50**
|
|
17
|
+
// - shades for each color: **8**. This means that for each color there are shades from 0 to 350. For example: `C-red0`, `Bgc-blue150`
|
|
18
|
+
//
|
|
19
|
+
// Name | Base color
|
|
20
|
+
// :--- | :---
|
|
21
|
+
// gray | <span style="background-color: #c5ccd3">#c5ccd3</span>
|
|
22
|
+
// red | <span style="background-color: #ff5c5c"><span style="color: white">#ff5c5c</span></span>
|
|
23
|
+
// orange | <span style="background-color: #ffad5c">#ffad5c</span>
|
|
24
|
+
// yellow | <span style="background-color: #faeb61">#faeb61</span>
|
|
25
|
+
// green | <span style="background-color: #70fa61">#70fa61</span>
|
|
26
|
+
// aqua | <span style="background-color: #5cffbb">#5cffbb</span>
|
|
27
|
+
// blue | <span style="background-color: #62a8f8">#62a8f8</span>
|
|
28
|
+
// purple | <span style="background-color: #d35cff">#d35cff</span>
|
|
29
|
+
//
|
|
30
|
+
// Styleguide: addons.catalog.demo_theme.colors
|
|
31
|
+
|
|
32
|
+
$demo-colors: (
|
|
33
|
+
'gray0': #c5ccd3,
|
|
34
|
+
'red0': #ff5c5c,
|
|
35
|
+
'orange0': #ffad5c,
|
|
36
|
+
'yellow0': #faeb61,
|
|
37
|
+
'green0': #70fa61,
|
|
38
|
+
'aqua0': #5cffbb,
|
|
39
|
+
'blue0': #62a8f8,
|
|
40
|
+
'purple0': #d35cff,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
ml.$utils-db: map.merge(
|
|
44
|
+
ml.$utils-db, 'common', 'keywords', 'colors',
|
|
45
|
+
map.merge(
|
|
46
|
+
$demo-colors,
|
|
47
|
+
map.get(ml.$utils-db, 'common', 'keywords', 'colors')
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
$is-aot: false !default;
|
|
52
|
+
$shade-step: -25 !default;
|
|
53
|
+
$-color-names: map.keys($demo-colors);
|
|
54
|
+
|
|
55
|
+
@if $is-aot {
|
|
56
|
+
$generate: true !default;
|
|
57
|
+
$colors-at-rules: ml.$kBpAll !default;
|
|
58
|
+
$colors-pre-states: '^:h' !default;
|
|
59
|
+
$colors-post-states: 'h f fw ph' !default;
|
|
60
|
+
|
|
61
|
+
$colors-at-rules: $colors-at-rules and $colors-at-rules + '_';
|
|
62
|
+
$colors-pre-states: $colors-pre-states and $colors-pre-states + ' _';
|
|
63
|
+
$colors-post-states: $colors-post-states and '_ ' + $colors-post-states;
|
|
64
|
+
|
|
65
|
+
$-colors-key: $colors-at-rules + $colors-pre-states + 'Colors' + $colors-post-states;
|
|
66
|
+
|
|
67
|
+
//stylelint-disable
|
|
68
|
+
$demo-utils: (
|
|
69
|
+
ml.$cBpAllCp + 'W': (5u, 10u, 20u, 25u, 40u, 70u),
|
|
70
|
+
ml.$cBpAllCp + 'H': (5u, 10u, 20u, 25u),
|
|
71
|
+
$-colors-key: ([
|
|
72
|
+
$-color-names, 8, ('rgb': $shade-step)
|
|
73
|
+
], 'white'),
|
|
74
|
+
ml.$cBpAllCp + 'Fns': ([1u, 8], 3gg, 14u, 4gg, 5gg),
|
|
75
|
+
ml.$cBpAllCp + 'Lnh': (
|
|
76
|
+
'md': 1.4,
|
|
77
|
+
'lg': 1.6,
|
|
78
|
+
'xl': 1.8,
|
|
79
|
+
'xxl': 2,
|
|
80
|
+
),
|
|
81
|
+
ml.$cBpAllCp + 'Offsets': ([1u, 8],),
|
|
82
|
+
ml.$cBpAllCp + 'Translates': ([1u, 8], [-8u, -1]),
|
|
83
|
+
ml.$cBpAllCp + 'BdWidth': (1u, 2u),
|
|
84
|
+
ml.$cBpAllCp + 'BdRadius': (2, [1u, 4]),
|
|
85
|
+
ml.$kBpAll + ' #{ml.$kArSt}_^:h _O_ h f fw': ([10p, 90, 10],),
|
|
86
|
+
ml.$kBpAll + ' #{ml.$kArSt}_^:h _Bxsd_ h f fw': (
|
|
87
|
+
'sm': rgba(0, 0, 0, 0.16) 0px 1px 4px,
|
|
88
|
+
'md': rgba(0, 0, 0, 0.24) 0px 3px 8px,
|
|
89
|
+
'lg': rgba(0, 0, 0, 0.35) 0px 5px 15px,
|
|
90
|
+
),
|
|
91
|
+
ml.$cArStBp + '-S_ h f': (0.8, 0.9, 1.1, 1.2, 1.5),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
@if $generate {
|
|
95
|
+
ml.$utils-map: map.set(
|
|
96
|
+
ml.$utils-map,
|
|
97
|
+
'demo-theme',
|
|
98
|
+
$demo-utils
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
} @else {
|
|
102
|
+
ml.$utils-db: map.merge(
|
|
103
|
+
ml.$utils-db, 'common', 'keywords', 'colors',
|
|
104
|
+
map.merge(
|
|
105
|
+
map.get(
|
|
106
|
+
ml.generate-uv-color-range([$-color-names, 8, ('rgb': $shade-step)], 'C'),
|
|
107
|
+
'values',
|
|
108
|
+
),
|
|
109
|
+
map.get(ml.$utils-db, 'common', 'keywords', 'colors')
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@use '../../tools' as ml;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Btn
|
|
5
|
+
|
|
6
|
+
Helper for creating buttons. Prepares any element to styling as a button.
|
|
7
|
+
|
|
8
|
+
Markup: ../../../docs/examples/css_lib-helpers/btn/btn.html
|
|
9
|
+
|
|
10
|
+
Styleguide: css_lib.helpers.btn
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
.btn {
|
|
14
|
+
display: inline-block;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
line-height: inherit;
|
|
18
|
+
text-align: center;
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
vertical-align: middle;
|
|
21
|
+
background: none;
|
|
22
|
+
border: 0;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
|
|
25
|
+
@if not ml.$base-border-box {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@use '../../tools' as ml;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Grid-system debug
|
|
5
|
+
|
|
6
|
+
Helper for debugging layouts that built with grid system. It displays a grid system columns and gutters in the background of the container. The grid system are generated depending on the [settings](section-settings.html#kssref-settings-gs).
|
|
7
|
+
|
|
8
|
+
There may be minor inaccuracies in the drawing of the grid, because the grid is generated with CSS `linear-gradient()`. For gutters calculation are used [CSS custom properties](section-css_lib.html#kssref-css_lib-styles-css_vars).
|
|
9
|
+
|
|
10
|
+
It **not included** in the default mlut distributive.
|
|
11
|
+
|
|
12
|
+
Markup: ../../../docs/examples/css_lib-helpers/grid-debug/grid-debug.html
|
|
13
|
+
|
|
14
|
+
Styleguide: css_lib.helpers.gs-debug
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
.gs-debug {
|
|
18
|
+
/* autoprefixer: off */
|
|
19
|
+
padding: calc(var(ml.$var-gg) * 3) 0px;
|
|
20
|
+
background-image: linear-gradient(
|
|
21
|
+
90deg,
|
|
22
|
+
ml.$gs-debug-gtr-color var(ml.$var-gg),
|
|
23
|
+
ml.$gs-debug-col-color var(ml.$var-gg),
|
|
24
|
+
ml.$gs-debug-col-color calc(100% - var(ml.$var-gg)),
|
|
25
|
+
ml.$gs-debug-gtr-color 0
|
|
26
|
+
);
|
|
27
|
+
background-size: calc(1 / var(ml.$var-gscc) * 100%);
|
|
28
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@use '../../tools' as ml;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Ratio-box
|
|
5
|
+
|
|
6
|
+
Helper for creating containers, with proportional width and height. Implemented using a pseudo-element with a `padding-bottom` in %.
|
|
7
|
+
|
|
8
|
+
The default aspect ratio is 16:9.
|
|
9
|
+
|
|
10
|
+
.Pt75p_b - 4:3 aspect ratio.
|
|
11
|
+
.Pt100p_b - 1:1 aspect ratio.
|
|
12
|
+
|
|
13
|
+
Markup: ../../../docs/examples/css_lib-helpers/ratio-block/ratio-block.hbs
|
|
14
|
+
|
|
15
|
+
Styleguide: css_lib.helpers.ratio-box
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
.ratio-box {
|
|
19
|
+
position: relative;
|
|
20
|
+
|
|
21
|
+
&::before {
|
|
22
|
+
display: block;
|
|
23
|
+
width: 100%;
|
|
24
|
+
padding-top: 56.25%;
|
|
25
|
+
content: '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
> :first-child {
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 0px;
|
|
31
|
+
left: 0px;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@if ml.$ratio-box-flex {
|
|
38
|
+
.ratio-box-flex {
|
|
39
|
+
&::before {
|
|
40
|
+
float: left;
|
|
41
|
+
padding-top: 56.25%;
|
|
42
|
+
content: '';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@include ml.apply('-Cl');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
@use '../../tools' as ml;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Row
|
|
5
|
+
|
|
6
|
+
Helper for creating layouts. Suitable for columns, cards and horizontal lists. By default, flexbox technology is used for layouts.
|
|
7
|
+
|
|
8
|
+
Parts of the layout within a `row` are created using the elements:
|
|
9
|
+
* [row__col](#kssref-css_lib-helpers-row-row__col)
|
|
10
|
+
* [row__item](#kssref-css_lib-helpers-row-row__item)
|
|
11
|
+
|
|
12
|
+
`Rows` can be put into each other an unlimited number of times.
|
|
13
|
+
|
|
14
|
+
`Row` contains CSS counter named `ml-row-item`.
|
|
15
|
+
|
|
16
|
+
It **not included** in the default mlut distributive because partially based on the legacy grid system. It is recommended to use the [CSS grid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) utilities instead.
|
|
17
|
+
|
|
18
|
+
Markup: ../../../docs/examples/css_lib-helpers/row/row.html
|
|
19
|
+
|
|
20
|
+
Styleguide: css_lib.helpers.row
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
row__col
|
|
25
|
+
|
|
26
|
+
The main element for creating columns in layout. By default, it stretches the entire width of the container. The columns have gutters on the sides and bottom.
|
|
27
|
+
|
|
28
|
+
The gutters are implemented using the `margin` and [CSS custom properties](section-css_lib.html#kssref-css_lib-styles-css_vars).
|
|
29
|
+
|
|
30
|
+
Column width is set using [W utility](section-utils-reference.html#kssref-utils-reference-w). See example [above](#kssref-css_lib-helpers-row). The formulas for calculating the width and offset for the column are stored in the custom properties. In `--ml-gscf` for W and `--ml-gsof` for [Ml utility](section-utils-reference.html#kssref-utils-reference-ml). These formulas:
|
|
31
|
+
```scss
|
|
32
|
+
--ml-gscf: calc(var(--ml-gsc) / var(--ml-gscc) * 100% - var(--ml-gsfd, var(--ml-gg)) * 2);
|
|
33
|
+
--ml-gsof: calc(var(--ml-gso) / var(--ml-gscc) * 100% + var(--ml-gsfd, var(--ml-gg)));
|
|
34
|
+
```
|
|
35
|
+
`--ml-gsc` or `--ml-gso` is the value of the width or offset in the grid columns. This is a custom property of the utility.<br>
|
|
36
|
+
`--ml-gscc` - the number of columns in the grid system. This is a [global](section-css_lib.html#kssref-css_lib-styles-css_vars) custom property that can be changed on any DOM node.<br>
|
|
37
|
+
`--ml-gsfd` - variable is equal to the gutter if the gutter at the columns is created using margin. In `row__col` is equal `1gg`.<br>
|
|
38
|
+
Some of these variables can be changed using [custom utilities](section-utils-reference.html#kssref-utils-reference--gscc).
|
|
39
|
+
|
|
40
|
+
You can create nested layouts with a mix of `row` and `row__col` on the same DOM node. If you don't need double fields in the nested row, use the mix with the `row__item`. See example below.
|
|
41
|
+
|
|
42
|
+
Markup: ../../../docs/examples/css_lib-helpers/row/row__col.html
|
|
43
|
+
|
|
44
|
+
Styleguide: css_lib.helpers.row.row__col
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
row__item
|
|
49
|
+
|
|
50
|
+
Element for creating parts of the layout. By default, it stretches across the width of the content.
|
|
51
|
+
|
|
52
|
+
The sizes and offsets are set with help of utilities.
|
|
53
|
+
|
|
54
|
+
Like a `row__col`, an element contains formulas for calculating width and offset. But `--ml-gsfd` here is equal 0px.
|
|
55
|
+
|
|
56
|
+
Markup: ../../../docs/examples/css_lib-helpers/row/row__item.html
|
|
57
|
+
|
|
58
|
+
Styleguide: css_lib.helpers.row.row__item
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
.row {
|
|
62
|
+
position: relative;
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-wrap: wrap;
|
|
65
|
+
padding: 0px;
|
|
66
|
+
list-style: none;
|
|
67
|
+
counter-reset: ml-row-item;
|
|
68
|
+
|
|
69
|
+
@include ml.apply('M0;-1gg');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.row__col,
|
|
73
|
+
.row__item {
|
|
74
|
+
#{ml.$var-gsfd}: 0px;
|
|
75
|
+
max-width: 100%;
|
|
76
|
+
|
|
77
|
+
@if not ml.$base-border-box {
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@include ml.apply('-Gsf');
|
|
82
|
+
|
|
83
|
+
& > :first-child:not([class]) {
|
|
84
|
+
margin-top: 0px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
& > :last-child:not([class]) {
|
|
88
|
+
margin-bottom: 0px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.row__col {
|
|
93
|
+
@include ml.apply('-Gsfd1gg W12gc M0;1gg;2gg');
|
|
94
|
+
|
|
95
|
+
&.row {
|
|
96
|
+
margin-bottom: 0px;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use '../../tools' as ml;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Wrapper
|
|
5
|
+
|
|
6
|
+
The helper-container for the main content of the page. The maximum width is set in the [settings](section-settings.html#kssref-settings-general). The default is `1200px`.
|
|
7
|
+
|
|
8
|
+
The container has sides `padding` that equal to gutters so that the content does not stick to sides on small screens. On wide screens the container is centered.
|
|
9
|
+
|
|
10
|
+
Markup: ../../../docs/examples/css_lib-helpers/wrapper/wrapper.html
|
|
11
|
+
|
|
12
|
+
Styleguide: css_lib.helpers.wrapper
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
.wrapper {
|
|
16
|
+
display: block;
|
|
17
|
+
max-width: ml.$wrapper-max-width;
|
|
18
|
+
margin: 0 auto;
|
|
19
|
+
|
|
20
|
+
@include ml.apply('-Px1gg');
|
|
21
|
+
}
|