Compare commits
10 Commits
@advdomini
...
master
Author | SHA1 | Date |
---|---|---|
|
9ac5f6bd28 | |
|
09f069b727 | |
|
f9dc305aae | |
|
7d56c06702 | |
|
0bb60a0e0a | |
|
205ea19086 | |
|
1eff119186 | |
|
78e4fa36c0 | |
|
ee74819f9e | |
|
4f059e3298 |
|
@ -0,0 +1,13 @@
|
|||
# helpers
|
||||
|
||||
## Добавление нового пакета
|
||||
|
||||
1. Скопировать один из существующих пакетов в папке `packages`
|
||||
2. На его основе подготовить новый пакет
|
||||
3. Запустить `yarn`
|
||||
|
||||
## Публикация новых версий
|
||||
|
||||
```
|
||||
yarn lerna publish
|
||||
```
|
|
@ -0,0 +1,17 @@
|
|||
# get-scrollbar-width
|
||||
|
||||
Get window scrollbar width (if present):
|
||||
|
||||
```js
|
||||
import { getScrollbarWidth } from '@advdominion/get-scrollbar-width';
|
||||
|
||||
console.log(getScrollbarWidth());
|
||||
```
|
||||
|
||||
Get system scrollbar width:
|
||||
|
||||
```js
|
||||
import { getScrollbarWidth } from '@advdominion/get-scrollbar-width';
|
||||
|
||||
console.log(getScrollbarWidth(false));
|
||||
```
|
|
@ -0,0 +1,24 @@
|
|||
const scrollbarWidth = () => {
|
||||
const outer = document.createElement('div');
|
||||
outer.style.visibility = 'hidden';
|
||||
outer.style.width = '100px';
|
||||
document.body.append(outer);
|
||||
const widthNoScroll = outer.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
const inner = document.createElement('div');
|
||||
inner.style.width = '100%';
|
||||
outer.append(inner);
|
||||
const widthWithScroll = inner.offsetWidth;
|
||||
outer.remove();
|
||||
return widthNoScroll - widthWithScroll;
|
||||
};
|
||||
|
||||
export const getScrollbarWidth = (getWindowScrollbar = true) => {
|
||||
if (getWindowScrollbar) {
|
||||
if (document.body.clientHeight > window.innerHeight) {
|
||||
return scrollbarWidth();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return scrollbarWidth();
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "@advdominion/get-scrollbar-width",
|
||||
"version": "2.0.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/helpers.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
# is
|
||||
|
||||
Usage:
|
||||
Check variable type
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { is } from '@advdominion/is';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@advdominion/is",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# pluralize
|
||||
|
||||
Склонение существительных в зависимости от чила
|
||||
|
||||
## Использование
|
||||
|
||||
```js
|
||||
import { pluralize } from '@advdominion/pluralize';
|
||||
|
||||
console.log(pluralize(1, ['яблоко', 'яблока', 'яблок']));
|
||||
```
|
|
@ -0,0 +1,14 @@
|
|||
export const pluralize = (count, words) => {
|
||||
count = Math.abs(count) % 100;
|
||||
const count10 = count % 10;
|
||||
if (count > 10 && count < 20) {
|
||||
return words[2];
|
||||
}
|
||||
if (count10 > 1 && count10 < 5) {
|
||||
return words[1];
|
||||
}
|
||||
if (count10 === 1) {
|
||||
return words[0];
|
||||
}
|
||||
return words[2];
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "@advdominion/pluralize",
|
||||
"version": "1.0.1",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/helpers.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
12
yarn.lock
12
yarn.lock
|
@ -5,12 +5,24 @@ __metadata:
|
|||
version: 8
|
||||
cacheKey: 10c0
|
||||
|
||||
"@advdominion/get-scrollbar-width@workspace:packages/get-scrollbar-width":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/get-scrollbar-width@workspace:packages/get-scrollbar-width"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@advdominion/is@workspace:packages/is":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/is@workspace:packages/is"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@advdominion/pluralize@workspace:packages/pluralize":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/pluralize@workspace:packages/pluralize"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@babel/code-frame@npm:^7.0.0":
|
||||
version: 7.24.2
|
||||
resolution: "@babel/code-frame@npm:7.24.2"
|
||||
|
|
Loading…
Reference in New Issue