Compare commits
12 Commits
@advdomini
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
369595c2de
|
|||
|
49ce40cd7f
|
|||
|
1a8f77622b
|
|||
|
8cf1ddbaf5
|
|||
|
8f2cae3401
|
|||
|
a0074442ae
|
|||
|
791c160125
|
|||
|
095724c175
|
|||
|
f30793af80
|
|||
|
3605551f16
|
|||
|
f8d793195c
|
|||
|
a655e7b5e4
|
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",
|
||||
"version": "9.39.2-sdk",
|
||||
"version": "10.0.0-sdk",
|
||||
"main": "./lib/api.js",
|
||||
"type": "commonjs",
|
||||
"bin": {
|
||||
|
||||
2
.yarn/sdks/prettier/package.json
vendored
2
.yarn/sdks/prettier/package.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "3.8.0-sdk",
|
||||
"version": "3.8.1-sdk",
|
||||
"main": "./index.cjs",
|
||||
"type": "commonjs",
|
||||
"bin": "./bin/prettier.cjs"
|
||||
|
||||
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(' ')}`];
|
||||
},
|
||||
};
|
||||
11
package.json
11
package.json
@@ -5,10 +5,15 @@
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"postinstall": "husky"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@advdominion/eslint-config": "workspace:*",
|
||||
"eslint": "^9.39.2",
|
||||
"lerna": "^9.0.3",
|
||||
"prettier": "^3.8.0"
|
||||
"eslint": "^10.0.0",
|
||||
"husky": "^9.1.7",
|
||||
"lerna": "^9.0.4",
|
||||
"lint-staged": "^16.2.7",
|
||||
"prettier": "^3.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import nunjucks from 'nunjucks';
|
||||
|
||||
const babelPluginNunjucks = ({types: t}) => {
|
||||
const babelPluginNunjucks = ({ types: t }) => {
|
||||
return {
|
||||
pre(state) {
|
||||
const options = state.opts.plugins[0].options;
|
||||
this.njkenv = new nunjucks.Environment(new nunjucks.FileSystemLoader(options.templatesFolder));
|
||||
if (options.globals) {
|
||||
for (const {name, value} of options.globals) {
|
||||
for (const { name, value } of options.globals) {
|
||||
this.njkenv.addGlobal(name, value);
|
||||
}
|
||||
}
|
||||
},
|
||||
visitor: {
|
||||
TaggedTemplateExpression(path) {
|
||||
if (path.get('tag').isIdentifier({name: 'njk'})) {
|
||||
if (path.get('tag').isIdentifier({ name: 'njk' })) {
|
||||
const render = this.njkenv.renderString(path.node.quasi.quasis[0].value.raw);
|
||||
path.replaceWith(t.stringLiteral(render));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@advdominion/babel-plugin-nunjucks",
|
||||
"version": "3.0.3",
|
||||
"version": "3.1.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -11,10 +11,8 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"nunjucks": "^3.2.4"
|
||||
},
|
||||
"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: {
|
||||
...{
|
||||
// Включаем правила из категории Possible Problems, которые не включенны в recommended
|
||||
'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',
|
||||
},
|
||||
...{
|
||||
// Включаем правила из категории Suggestions, которые не включенны в recommended
|
||||
'dot-notation': 'warn',
|
||||
'eqeqeq': 'error',
|
||||
'no-implicit-coercion': 'warn',
|
||||
@@ -49,6 +49,10 @@ const config = [
|
||||
'prefer-const': '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/prefer-global-this': 'off',
|
||||
'unicorn/prefer-import-meta-properties': 'warn',
|
||||
'unicorn/prefer-top-level-await': 'off',
|
||||
'unicorn/prevent-abbreviations': 'off',
|
||||
},
|
||||
},
|
||||
@@ -107,7 +110,7 @@ const config = [
|
||||
'vue/no-constant-condition': 'error',
|
||||
'vue/no-empty-pattern': 'error',
|
||||
'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-negated-condition': 'warn',
|
||||
'vue/no-sparse-arrays': 'error',
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-unicorn": "^62.0.0",
|
||||
"eslint-plugin-unicorn": "^63.0.0",
|
||||
"eslint-plugin-vue": "^10.7.0",
|
||||
"globals": "^17.0.0",
|
||||
"globals": "^17.3.0",
|
||||
"vue-eslint-parser": "^10.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^9.39.0"
|
||||
"eslint": "^10.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
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