Skip to content

Instantly share code, notes, and snippets.

View mityaua's full-sized avatar
🍀

Dmytro Shukaliuk mityaua

🍀
View GitHub Profile
@Andrii-Yukhymenko
Andrii-Yukhymenko / _adaptiv-value.scss
Created May 29, 2021 16:58
Миксин для адаптивных свойств
// Адаптивные свойства
$maxWidth: 1920;
$maxWidthContainer: 1200;
@mixin adaptiv-value($property, $startSize, $minSize, $type) {
$addSize: $startSize - $minSize;
@if $type==1 {
// Только если меньше контейнера
#{$property}: $startSize + px;
@margauxflores
margauxflores / passingDataThroughVueRouter.vue
Last active July 10, 2023 06:59
Passing Data Through Vue Router
# Use case:
# I have a route where there's an ID parameter and I want to be able to pass data through Vue Router.
# Code setup is Vue + TypeScript using vue-class-component
# Home.vue template section
# This list is rendered after fetching data from an API call.
<template>
<li v-for="item in items" :key="item.id" @click.prevent="goToItem(item)">...</li>
</template>
document.addEventListener("DOMContentLoaded", initDetect)
function initDetect(){
window.addEventListener("resize", detectDevice)
detectDevice()
}
detectDevice = () => {
let detectObj = {
device: !!navigator.maxTouchPoints ? 'mobile' : 'computer',
@luxplanjay
luxplanjay / flex-basis-calc.css
Last active August 9, 2024 14:19
Формула расчёта ширины flex-элемента в сетке
.element {
flex-basis: calc((100% - кол-во маржинов в строке * значение маржина) / кол-во элементов в строке);
}
@luxplanjay
luxplanjay / visually-hidden.css
Last active September 5, 2024 18:15
Visually hidden CSS pattern
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
clip-path: inset(100%);
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
@remarkablemark
remarkablemark / spy-resize-event.test.js
Created June 13, 2018 19:20
How to spy on window resize event in test.
const spy = jest.fn(); // or `jasmine.createSpy()`
const testWidth = 420;
beforeAll(() => {
window.addEventListener('resize', spy);
});
it('does not fire resize event by default', () => {
expect(spy).not.toHaveBeenCalled();
expect(window.innerWidth).not.toBe(testWidth);
@KRostyslav
KRostyslav / tsconfig.json
Last active September 8, 2024 20:40
tsconfig.json с комментариями.
// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".