Skip to content

Instantly share code, notes, and snippets.

View kosciolek's full-sized avatar

kosciolek

  • Poland - Małopolskie
View GitHub Profile
@kosciolek
kosciolek / .gitignore
Created February 15, 2019 13:44
.gitignore for Unity projects
/hex/[Ll]ibrary/
/hex/[Tt]emp/
/hex/[Oo]bj/
/hex/[Bb]uild/
/hex/[Bb]uilds/
/hex/[Ll]ogs/
/hex/[Aa]ssets/AssetStoreTools*
![Aa]ssets/**/*.meta
{
"title": "JSON schema for the TypeScript compiler's configuration file",
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"filesDefinition": {
"properties": {
"files": {
"description": "If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. When a 'files' property is specified, only those files and those specified by 'include' are included.",
"type": "array",
import Document, { Html, Head, Main, NextScript } from "next/document";
import { ServerStyleSheet } from "styled-components";
class MyDocument extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet();
const originalRenderPage = ctx.renderPage;
ctx.renderPage = () =>
originalRenderPage({
import {css} from "styled-components";
export function variant<R extends { variant?: keyof T },
T extends {
[variantName: string]: ReturnType<typeof css>;
}>(variantMap: T) {
return function ({variant: variantProp}: R) {
return variantMap[variantProp];
};
}
import React, { FC } from "react";
import dynamic from "next/dynamic";
import config from "../cms/config";
import { useEffect, useState } from "react";
import { Map } from "immutable";
const wrapInClass = (Component: FC) =>
class WrapperClass extends React.Component {
render() {
return <Component {...this.props} />;
@kosciolek
kosciolek / query.ts
Created June 3, 2021 17:15
media query
export const breakpoints = {
xs: "0px",
sm: "600px",
md: "960px",
lg: "1280px",
xl: "1920px"
};
export const query = Object.entries(breakpoints).reduce(
(acc, [breakpoint, value]) => {
import {useEffect, useState} from "react";
import {firstToUppercase} from "../utils/js";
export const breakpoints = {
xs: "0px",
sm: "600px",
md: "960px",
lg: "1280px",
xl: "1920px",
};
@kosciolek
kosciolek / measure.js
Last active July 3, 2021 13:38
Measure scrollbar width
function getScrollbarWidth() {
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.overflow = 'scroll';
document.body.appendChild(outer);
const inner = document.createElement('div');
outer.appendChild(inner);
@kosciolek
kosciolek / css
Last active July 14, 2021 19:54
fluid typography 1440px+
html {
font-size: max(8px, calc(8 / 1440 * 100vw));
font-family: 'Poppins', sans-serif;
line-height: 1;
letter-spacing: 0.02rem;
}
body {
font-size: max(18px, calc(18 / 1440 * 100vw));
margin: 0;
@kosciolek
kosciolek / query.ts
Last active July 18, 2021 11:54
Fancy media query hooks.
/* eslint-disable react-hooks/rules-of-hooks */
import {useLayoutEffect, useState} from "react";
export const firstToUppercase = (string: string) =>
string.charAt(0).toUpperCase() + string.slice(1);
export const breakpoints = {
xs: 0,
sm: 600,
md: 960,