Compare commits
22 Commits
@advdomini
...
@advdomini
| Author | SHA1 | Date | |
|---|---|---|---|
|
49ce40cd7f
|
|||
|
1a8f77622b
|
|||
|
8cf1ddbaf5
|
|||
|
8f2cae3401
|
|||
|
a0074442ae
|
|||
|
791c160125
|
|||
|
095724c175
|
|||
|
f30793af80
|
|||
|
3605551f16
|
|||
|
f8d793195c
|
|||
|
a655e7b5e4
|
|||
|
fc11cdfa48
|
|||
|
650008ad76
|
|||
|
96ae522a8f
|
|||
|
9dc95dd47a
|
|||
|
bce960599a
|
|||
|
6f24952680
|
|||
|
e1756bd60f
|
|||
|
ea33198344
|
|||
|
ca88f622d1
|
|||
|
9131e220d2
|
|||
|
4012b982a6
|
1
.husky/pre-commit
Executable file
1
.husky/pre-commit
Executable file
@@ -0,0 +1 @@
|
|||||||
|
yarn lint-staged
|
||||||
2
.yarn/sdks/eslint/package.json
vendored
2
.yarn/sdks/eslint/package.json
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint",
|
"name": "eslint",
|
||||||
"version": "9.39.2-sdk",
|
"version": "10.0.0-sdk",
|
||||||
"main": "./lib/api.js",
|
"main": "./lib/api.js",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
2
.yarn/sdks/prettier/package.json
vendored
2
.yarn/sdks/prettier/package.json
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "prettier",
|
"name": "prettier",
|
||||||
"version": "3.7.4-sdk",
|
"version": "3.8.1-sdk",
|
||||||
"main": "./index.cjs",
|
"main": "./index.cjs",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"bin": "./bin/prettier.cjs"
|
"bin": "./bin/prettier.cjs"
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
## Публикация новых версий
|
## Публикация новых версий
|
||||||
|
|
||||||
```
|
```bash
|
||||||
yarn lerna publish
|
yarn lerna publish
|
||||||
```
|
```
|
||||||
|
|
||||||
## Обновление зависимостей
|
## Обновление зависимостей
|
||||||
|
|
||||||
```shell
|
```bash
|
||||||
yarn set version stable
|
yarn set version stable
|
||||||
|
|
||||||
yarn install
|
yarn install
|
||||||
|
|||||||
8
lint-staged.config.js
Normal file
8
lint-staged.config.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export default {
|
||||||
|
'*.js': (filenames) => {
|
||||||
|
return [`eslint --max-warnings 10 --fix ${filenames.join(' ')}`, `prettier --write ${filenames.join(' ')}`];
|
||||||
|
},
|
||||||
|
'*.{json,md,yml}': (filenames) => {
|
||||||
|
return [`prettier --write ${filenames.join(' ')}`];
|
||||||
|
},
|
||||||
|
};
|
||||||
14
package.json
14
package.json
@@ -5,10 +5,18 @@
|
|||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "husky",
|
||||||
|
"prepack": "pinst --disable",
|
||||||
|
"postpack": "pinst --enable"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@advdominion/eslint-config": "workspace:*",
|
"@advdominion/eslint-config": "workspace:*",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^10.0.0",
|
||||||
"lerna": "^9.0.3",
|
"husky": "^9.1.7",
|
||||||
"prettier": "^3.7.4"
|
"lerna": "^9.0.4",
|
||||||
|
"lint-staged": "^16.2.7",
|
||||||
|
"pinst": "^3.0.0",
|
||||||
|
"prettier": "^3.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ njk`
|
|||||||
|
|
||||||
## Опции
|
## Опции
|
||||||
|
|
||||||
- `templatesFolder` - строка, обязательный параметр. Путь до папки с файлами шаблонов
|
- `templatesFolder` - строка, обязательный параметр. Путь до папки с файлами шаблонов
|
||||||
- `globals` - массив, необязательный параметр. Глобальные переменные для Nunjucks (например, `[{name: "message", value: "Hello, world!"}]`)
|
- `globals` - массив, необязательный параметр. Глобальные переменные для Nunjucks (например, `[{name: "message", value: "Hello, world!"}]`)
|
||||||
|
|
||||||
**Важно:** Параметр `cacheDirectory` в опциях babel-loader должен быть отключён.
|
**Важно:** Параметр `cacheDirectory` в опциях babel-loader должен быть отключён.
|
||||||
|
|||||||
@@ -1,129 +1,25 @@
|
|||||||
/* eslint-disable unicorn/no-useless-spread */
|
import nunjucks from 'nunjucks';
|
||||||
|
|
||||||
import js from '@eslint/js';
|
const babelPluginNunjucks = ({ types: t }) => {
|
||||||
import eslintConfigPrettier from 'eslint-config-prettier';
|
return {
|
||||||
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
pre(state) {
|
||||||
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
const options = state.opts.plugins[0].options;
|
||||||
import pluginVue from 'eslint-plugin-vue';
|
this.njkenv = new nunjucks.Environment(new nunjucks.FileSystemLoader(options.templatesFolder));
|
||||||
import globals from 'globals';
|
if (options.globals) {
|
||||||
|
for (const { name, value } of options.globals) {
|
||||||
|
this.njkenv.addGlobal(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
visitor: {
|
||||||
|
TaggedTemplateExpression(path) {
|
||||||
|
if (path.get('tag').isIdentifier({ name: 'njk' })) {
|
||||||
|
const render = this.njkenv.renderString(path.node.quasi.quasis[0].value.raw);
|
||||||
|
path.replaceWith(t.stringLiteral(render));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const config = [
|
export default babelPluginNunjucks;
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
ecmaVersion: 'latest',
|
|
||||||
sourceType: 'module',
|
|
||||||
globals: {
|
|
||||||
...globals.browser,
|
|
||||||
...globals.nodeBuiltin,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
js.configs.recommended,
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
...{
|
|
||||||
'array-callback-return': 'error',
|
|
||||||
'no-await-in-loop': 'warn',
|
|
||||||
'no-duplicate-imports': 'warn',
|
|
||||||
'no-promise-executor-return': 'error',
|
|
||||||
'no-self-compare': 'error',
|
|
||||||
'no-template-curly-in-string': 'warn',
|
|
||||||
'no-unassigned-vars': 'warn',
|
|
||||||
'no-unmodified-loop-condition': 'error',
|
|
||||||
'no-unreachable-loop': 'error',
|
|
||||||
'no-use-before-define': 'error',
|
|
||||||
'no-useless-assignment': 'warn',
|
|
||||||
},
|
|
||||||
...{
|
|
||||||
'dot-notation': 'warn',
|
|
||||||
'eqeqeq': 'error',
|
|
||||||
'no-implicit-coercion': 'warn',
|
|
||||||
'no-negated-condition': 'warn',
|
|
||||||
'no-useless-concat': 'warn',
|
|
||||||
'object-shorthand': 'warn',
|
|
||||||
'func-style': 'error',
|
|
||||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
||||||
'no-param-reassign': 'error',
|
|
||||||
'no-var': 'error',
|
|
||||||
'one-var': ['warn', 'never'],
|
|
||||||
'prefer-const': 'warn',
|
|
||||||
'prefer-template': 'warn',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
plugins: {
|
|
||||||
'simple-import-sort': simpleImportSort,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'simple-import-sort/imports': 'warn',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
plugins: {
|
|
||||||
unicorn: eslintPluginUnicorn,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
...Object.fromEntries(
|
|
||||||
Object.entries(eslintPluginUnicorn.configs.recommended.rules).map(([rule, level]) => [
|
|
||||||
rule,
|
|
||||||
level === 'off' ? 'off' : 'warn',
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
'unicorn/better-regex': 'warn',
|
|
||||||
'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],
|
|
||||||
'unicorn/prefer-global-this': 'off',
|
|
||||||
'unicorn/prefer-import-meta-properties': 'warn',
|
|
||||||
'unicorn/prefer-top-level-await': 'off',
|
|
||||||
'unicorn/prevent-abbreviations': 'off',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...pluginVue.configs['flat/recommended'],
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
...{
|
|
||||||
'vue/no-v-html': 'off',
|
|
||||||
'vue/one-component-per-file': 'off',
|
|
||||||
},
|
|
||||||
...{
|
|
||||||
'vue/component-name-in-template-casing': 'warn',
|
|
||||||
'vue/component-options-name-casing': 'warn',
|
|
||||||
'vue/custom-event-name-casing': 'warn',
|
|
||||||
'vue/match-component-file-name': ['warn', { extensions: ['vue'], shouldMatchCase: true }],
|
|
||||||
'vue/match-component-import-name': 'warn',
|
|
||||||
'vue/no-boolean-default': 'warn',
|
|
||||||
'vue/no-potential-component-option-typo': 'warn',
|
|
||||||
'vue/no-useless-mustaches': 'warn',
|
|
||||||
'vue/no-useless-v-bind': 'warn',
|
|
||||||
'vue/require-direct-export': 'warn',
|
|
||||||
'vue/require-name-property': 'warn',
|
|
||||||
'vue/v-for-delimiter-style': 'warn',
|
|
||||||
'vue/v-on-handler-style': ['warn', 'inline'],
|
|
||||||
},
|
|
||||||
...{
|
|
||||||
'vue/dot-notation': 'warn',
|
|
||||||
'vue/eqeqeq': 'error',
|
|
||||||
'vue/no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
||||||
'vue/no-constant-condition': 'error',
|
|
||||||
'vue/no-empty-pattern': 'error',
|
|
||||||
'vue/no-implicit-coercion': 'warn',
|
|
||||||
'vue/no-irregular-whitespace': 'error',
|
|
||||||
'vue/no-loss-of-precision': 'error',
|
|
||||||
'vue/no-negated-condition': 'warn',
|
|
||||||
'vue/no-sparse-arrays': 'error',
|
|
||||||
'vue/no-useless-concat': 'warn',
|
|
||||||
'vue/object-shorthand': 'warn',
|
|
||||||
'vue/prefer-template': 'warn',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['**/*.vue'],
|
|
||||||
rules: {
|
|
||||||
'no-useless-assignment': 'off', // ESLint не умеет работать с этим правилом внутри <template>
|
|
||||||
},
|
|
||||||
},
|
|
||||||
eslintConfigPrettier,
|
|
||||||
];
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@advdominion/babel-plugin-nunjucks",
|
"name": "@advdominion/babel-plugin-nunjucks",
|
||||||
"version": "3.0.1",
|
"version": "3.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -11,10 +11,8 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"nunjucks": "^3.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0"
|
"@babel/core": "^7.0.0",
|
||||||
|
"nunjucks": "^3.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
packages/css-var/README.md
Normal file
25
packages/css-var/README.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# css-var
|
||||||
|
|
||||||
|
Получение значений CSS-переменных в JS
|
||||||
|
|
||||||
|
## Использование
|
||||||
|
|
||||||
|
```css
|
||||||
|
:root {
|
||||||
|
--z-index: 100;
|
||||||
|
--height: 100px;
|
||||||
|
--duration-ms: 100ms;
|
||||||
|
--duration-s: 100s;
|
||||||
|
--easing: cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { cssVar } from '@advdominion/css-var';
|
||||||
|
|
||||||
|
cssVar('--z-index'); // '1' (String)
|
||||||
|
cssVar('--height'); // '100px' (String)
|
||||||
|
cssVar('--duration-ms'); // 100 (Number)
|
||||||
|
cssVar('--duration-s'); // 100 (Number)
|
||||||
|
cssVar('--easing'); // cubic-bezier(0.4, 0, 0.2, 1) (String)
|
||||||
|
```
|
||||||
9
packages/css-var/index.js
Normal file
9
packages/css-var/index.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export const cssVar = (name, element = document.documentElement) => {
|
||||||
|
const value = window.getComputedStyle(element).getPropertyValue(name);
|
||||||
|
const durationRegExp = /(^[\d.]+)(ms|s)$/;
|
||||||
|
if (durationRegExp.test(value)) {
|
||||||
|
const [, numericValue, unit] = durationRegExp.exec(value);
|
||||||
|
return unit === 's' ? numericValue * 1000 : Number(numericValue);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
14
packages/css-var/package.json
Normal file
14
packages/css-var/package.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "@advdominion/css-var",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,19 +22,19 @@ const config = [
|
|||||||
{
|
{
|
||||||
rules: {
|
rules: {
|
||||||
...{
|
...{
|
||||||
|
// Включаем правила из категории Possible Problems, которые не включенны в recommended
|
||||||
'array-callback-return': 'error',
|
'array-callback-return': 'error',
|
||||||
'no-await-in-loop': 'warn',
|
'no-await-in-loop': 'warn',
|
||||||
'no-duplicate-imports': 'warn',
|
'no-duplicate-imports': 'warn',
|
||||||
'no-promise-executor-return': 'error',
|
'no-promise-executor-return': 'error',
|
||||||
'no-self-compare': 'error',
|
'no-self-compare': 'error',
|
||||||
'no-template-curly-in-string': 'warn',
|
'no-template-curly-in-string': 'warn',
|
||||||
'no-unassigned-vars': 'warn',
|
|
||||||
'no-unmodified-loop-condition': 'error',
|
'no-unmodified-loop-condition': 'error',
|
||||||
'no-unreachable-loop': 'error',
|
'no-unreachable-loop': 'error',
|
||||||
'no-use-before-define': 'error',
|
'no-use-before-define': 'error',
|
||||||
'no-useless-assignment': 'warn',
|
|
||||||
},
|
},
|
||||||
...{
|
...{
|
||||||
|
// Включаем правила из категории Suggestions, которые не включенны в recommended
|
||||||
'dot-notation': 'warn',
|
'dot-notation': 'warn',
|
||||||
'eqeqeq': 'error',
|
'eqeqeq': 'error',
|
||||||
'no-implicit-coercion': 'warn',
|
'no-implicit-coercion': 'warn',
|
||||||
@@ -49,6 +49,10 @@ const config = [
|
|||||||
'prefer-const': 'warn',
|
'prefer-const': 'warn',
|
||||||
'prefer-template': 'warn',
|
'prefer-template': 'warn',
|
||||||
},
|
},
|
||||||
|
...{
|
||||||
|
// Переопределяем правила, которые включены в recommended
|
||||||
|
'no-irregular-whitespace': ['error', { skipTemplates: true }],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -74,7 +78,6 @@ const config = [
|
|||||||
'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],
|
'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],
|
||||||
'unicorn/prefer-global-this': 'off',
|
'unicorn/prefer-global-this': 'off',
|
||||||
'unicorn/prefer-import-meta-properties': 'warn',
|
'unicorn/prefer-import-meta-properties': 'warn',
|
||||||
'unicorn/prefer-top-level-await': 'off',
|
|
||||||
'unicorn/prevent-abbreviations': 'off',
|
'unicorn/prevent-abbreviations': 'off',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -107,7 +110,7 @@ const config = [
|
|||||||
'vue/no-constant-condition': 'error',
|
'vue/no-constant-condition': 'error',
|
||||||
'vue/no-empty-pattern': 'error',
|
'vue/no-empty-pattern': 'error',
|
||||||
'vue/no-implicit-coercion': 'warn',
|
'vue/no-implicit-coercion': 'warn',
|
||||||
'vue/no-irregular-whitespace': 'error',
|
'vue/no-irregular-whitespace': ['error', { skipTemplates: true }],
|
||||||
'vue/no-loss-of-precision': 'error',
|
'vue/no-loss-of-precision': 'error',
|
||||||
'vue/no-negated-condition': 'warn',
|
'vue/no-negated-condition': 'warn',
|
||||||
'vue/no-sparse-arrays': 'error',
|
'vue/no-sparse-arrays': 'error',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@advdominion/eslint-config",
|
"name": "@advdominion/eslint-config",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -12,15 +12,15 @@
|
|||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^10.0.1",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"eslint-plugin-unicorn": "^62.0.0",
|
"eslint-plugin-unicorn": "^63.0.0",
|
||||||
"eslint-plugin-vue": "^10.6.2",
|
"eslint-plugin-vue": "^10.7.0",
|
||||||
"globals": "^16.5.0",
|
"globals": "^17.3.0",
|
||||||
"vue-eslint-parser": "^10.2.0"
|
"vue-eslint-parser": "^10.2.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^9.39.0"
|
"eslint": "^10.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# is
|
|
||||||
|
|
||||||
Check variable type
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { is } from '@advdominion/is';
|
|
||||||
|
|
||||||
console.log(is('Hello, world!', 'String'));
|
|
||||||
```
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export const is = (obj, type) => {
|
|
||||||
return Object.prototype.toString.call(obj).slice(8, -1) === type && obj !== undefined && obj !== null;
|
|
||||||
};
|
|
||||||
53
packages/lightningcss-loader/README.md
Normal file
53
packages/lightningcss-loader/README.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# lightningcss-loader
|
||||||
|
|
||||||
|
[Lightning CSS](https://lightningcss.dev) loader for [Webpack](https://webpack.js.org)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { transform } from 'lightningcss';
|
||||||
|
|
||||||
|
return {
|
||||||
|
...,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: '@advdominion/lightningcss-loader',
|
||||||
|
options: {
|
||||||
|
implementation: transform,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Passing options to Lightning CSS
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { transform } from 'lightningcss';
|
||||||
|
|
||||||
|
return {
|
||||||
|
...,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: '@advdominion/lightningcss-loader',
|
||||||
|
options: {
|
||||||
|
implementation: transform,
|
||||||
|
drafts: {
|
||||||
|
customMedia: true,
|
||||||
|
},
|
||||||
|
minify: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
```
|
||||||
22
packages/lightningcss-loader/index.js
Normal file
22
packages/lightningcss-loader/index.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const lightningcssLoader = function (source, sourceMap) {
|
||||||
|
const { implementation, ...options } = this.getOptions();
|
||||||
|
const callback = this.async();
|
||||||
|
|
||||||
|
if (typeof implementation !== 'function') {
|
||||||
|
throw new TypeError(
|
||||||
|
`[lightningcss-loader]: The "implementation" option is required and must provide "transform" function of the LightningCSS`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { code, map } = implementation({
|
||||||
|
filename: this.resourcePath,
|
||||||
|
code: Buffer.from(source),
|
||||||
|
sourceMap: this.sourceMap,
|
||||||
|
inputSourceMap: this.sourceMap && sourceMap ? JSON.stringify(sourceMap) : undefined,
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(undefined, code.toString(), map && JSON.parse(map.toString()));
|
||||||
|
};
|
||||||
|
|
||||||
|
export default lightningcssLoader;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@advdominion/is",
|
"name": "@advdominion/lightningcss-loader",
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
33
packages/scroll-to/README.md
Normal file
33
packages/scroll-to/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# scroll-to
|
||||||
|
|
||||||
|
Плавный скролл до элемента с поддержкой нативного события `scrollend` и гибкой настройкой отступов.
|
||||||
|
|
||||||
|
## Использование
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { scrollTo } from '@advdominion/scroll-to';
|
||||||
|
|
||||||
|
// Базовый скролл до элемента
|
||||||
|
await scrollTo(document.querySelector('#example'));
|
||||||
|
|
||||||
|
// Скролл с отступом 100px (например, для фиксированной шапки)
|
||||||
|
await scrollTo(document.querySelector('#example'), 100, true);
|
||||||
|
|
||||||
|
// Скролл с отступом в 10% от высоты экрана
|
||||||
|
await scrollTo(document.querySelector('#example'), 10);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Параметры
|
||||||
|
|
||||||
|
| Параметр | Тип | По умолчанию | Описание |
|
||||||
|
| :------------- | :------------ | :----------- | :------------------------------------------------------------------------- |
|
||||||
|
| **$el** | `HTMLElement` | — | DOM-элемент, к которому нужно прокрутить страницу |
|
||||||
|
| **offset** | `number` | `0` | Величина отступа сверху от целевого элемента |
|
||||||
|
| **offsetInPx** | `boolean` | `false` | Тип отступа: `true` — в пикселях, `false` — в процентах от высоты вьюпорта |
|
||||||
|
|
||||||
|
## Как это работает
|
||||||
|
|
||||||
|
1. **Точность:** Использует нативное событие `scrollend`, которое срабатывает строго после завершения анимации прокрутки.
|
||||||
|
2. **Безопасность:** Если браузер не поддерживает `scrollend` или анимация прервана, сработает автоматический fallback через 1500 мс.
|
||||||
|
3. **Плавность:** Использует нативный `behavior: 'smooth'`.
|
||||||
|
4. **Очистка данных:** Автоматически удаляет слушатели событий и таймеры после завершения или отмены скролла.
|
||||||
40
packages/scroll-to/index.js
Normal file
40
packages/scroll-to/index.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
export const scrollTo = ($el, offset = 0, offsetInPx = false) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (!$el) {
|
||||||
|
console.warn('Элемент не найден');
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const elementPosition = $el.getBoundingClientRect().top + window.scrollY;
|
||||||
|
const topOffset = offsetInPx ? offset : (window.innerHeight * offset) / 100;
|
||||||
|
const targetScrollTop = elementPosition - topOffset;
|
||||||
|
|
||||||
|
// Если элемент уже в нужной позиции
|
||||||
|
if (Math.abs(window.scrollY - targetScrollTop) < 1) {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let resolved = false; // На случай, если scrollend и fallback запустятся одновременно
|
||||||
|
let fallbackTimeout; // eslint-disable-line prefer-const
|
||||||
|
|
||||||
|
const done = () => {
|
||||||
|
if (resolved) return;
|
||||||
|
resolved = true;
|
||||||
|
|
||||||
|
window.removeEventListener('scrollend', done);
|
||||||
|
clearTimeout(fallbackTimeout);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('scrollend', done, { once: true });
|
||||||
|
fallbackTimeout = setTimeout(done, 1500);
|
||||||
|
|
||||||
|
window.scrollTo({
|
||||||
|
top: targetScrollTop,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
14
packages/scroll-to/package.json
Normal file
14
packages/scroll-to/package.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "@advdominion/scroll-to",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
||||||
22
packages/stylelint-config/README.md
Normal file
22
packages/stylelint-config/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Конфигурация для Stylelint
|
||||||
|
|
||||||
|
Включает в себя:
|
||||||
|
|
||||||
|
- [stylelint-config-standard-scss](https://github.com/stylelint-scss/stylelint-config-standard-scss)
|
||||||
|
- [stylelint-order](https://github.com/hudochenkov/stylelint-order)
|
||||||
|
- Проверку кода тега `<style>` в файлах `.vue`
|
||||||
|
|
||||||
|
## Использование
|
||||||
|
|
||||||
|
### Требования
|
||||||
|
|
||||||
|
- [Stylelint](https://stylelint.io/) ^10.0.0
|
||||||
|
|
||||||
|
### Подключание
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
extends: ['@advdominion/stylelint-config'],
|
||||||
|
// Дополнительная конфигурация проекта
|
||||||
|
};
|
||||||
|
```
|
||||||
54
packages/stylelint-config/index.js
Normal file
54
packages/stylelint-config/index.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/* eslint-disable unicorn/no-null */
|
||||||
|
|
||||||
|
export default {
|
||||||
|
extends: ['stylelint-config-standard-scss'],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['**/*.vue'],
|
||||||
|
customSyntax: 'postcss-html',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
plugins: ['stylelint-order'],
|
||||||
|
rules: {
|
||||||
|
'block-no-empty': null,
|
||||||
|
'no-invalid-double-slash-comments': null,
|
||||||
|
'property-disallowed-list': [
|
||||||
|
'animation',
|
||||||
|
'background',
|
||||||
|
'border',
|
||||||
|
'flex',
|
||||||
|
'font',
|
||||||
|
'grid',
|
||||||
|
'margin',
|
||||||
|
'padding',
|
||||||
|
'transition',
|
||||||
|
],
|
||||||
|
'color-hex-length': 'long',
|
||||||
|
'font-weight-notation': 'named-where-possible',
|
||||||
|
'container-name-pattern': null,
|
||||||
|
'custom-media-pattern': null,
|
||||||
|
'custom-property-pattern': null,
|
||||||
|
'keyframes-name-pattern': null,
|
||||||
|
'layer-name-pattern': null,
|
||||||
|
'selector-class-pattern': null,
|
||||||
|
'selector-id-pattern': null,
|
||||||
|
'declaration-block-no-redundant-longhand-properties': null,
|
||||||
|
'scss/double-slash-comment-empty-line-before': null,
|
||||||
|
'order/order': [
|
||||||
|
{
|
||||||
|
type: 'at-rule',
|
||||||
|
name: 'use',
|
||||||
|
},
|
||||||
|
'dollar-variables',
|
||||||
|
'custom-properties',
|
||||||
|
'declarations',
|
||||||
|
{
|
||||||
|
type: 'at-rule',
|
||||||
|
name: 'include',
|
||||||
|
},
|
||||||
|
'at-rules',
|
||||||
|
'rules',
|
||||||
|
],
|
||||||
|
'order/properties-alphabetical-order': true,
|
||||||
|
},
|
||||||
|
};
|
||||||
22
packages/stylelint-config/package.json
Normal file
22
packages/stylelint-config/package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "@advdominion/stylelint-config",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"postcss-html": "^1.8.1",
|
||||||
|
"stylelint-config-standard-scss": "^17.0.0",
|
||||||
|
"stylelint-order": "^7.0.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"stylelint": "^17.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user