Skip to content

Instantly share code, notes, and snippets.

@bultas
bultas / colors.css
Last active November 16, 2020 11:48
CSS Colors
:root {
--black: #000;
--white: #fff;
--rose-50: #fff1f2;
--rose-100: #ffe4e6;
--rose-200: #fecdd3;
--rose-300: #fda4af;
--rose-400: #fb7185;
--rose-500: #f43f5e;
@bultas
bultas / base.css
Created September 19, 2019 09:47
CSS base framework
:root {
font-family: var(--default-font-family);
/* font-size: 1.125rem; */
font-size: calc(1rem + 0.333vw);
}
html, body {
height: 100%;
width: 100%;
}
import React, { useReducer } from 'react';
import { Form } from 'components/form';
import { Button } from 'components/button/newButton';
import { dataMapToObj } from 'components/formHelpers';
import { addImport } from './importMergeHelpers';
import { update, isNil, remove } from 'ramda';
import './importMerge.css';
@bultas
bultas / reducer.jsx
Last active January 22, 2020 19:49
react reducer/state reducer/state machine solution comparision
import React, { useReducer } from 'react';
const reducer = (state, action) => {
switch (action.type) {
case 'removeEntry': {
const newEntries = remove(action.payload, 1, state.entries);
return { ...state, entries: newEntries, editIndex: null };
}
case 'saveEntry': {
@bultas
bultas / guard.js
Last active March 6, 2020 20:20
Design by contract
function warn(a, b) {
console.warn(a, b);
}
export default guard( [ a => true , b => false ], () => true )( warn );
defp atomize_map(%{} = stringy_map) do
stringy_map
|> Map.new(fn {k, v} -> {String.to_atom(k), v} end)
end
defp atomize_map(_) do
%{}
end
.content-box {
--content-box-border-color: #ccc;
border: 1px solid;
border-color: var(--content-box-border-color);
border-radius: .4rem;
}
.content-row-headline {
display: block;
padding: 1.5rem;
@bultas
bultas / getMaxZIndex.js
Created May 13, 2020 14:57
Get max zIndex in NodeList (document)
function convertToNumber(value) {
const asNumber = parseFloat(value);
return Number.isNaN(asNumber) ? 0 : asNumber;
}
function getNodeZIndex(node) {
const computedIndex = convertToNumber(window.getComputedStyle(node).zIndex);
const styleIndex = convertToNumber(node.style.zIndex);
if (computedIndex > styleIndex) {
@bultas
bultas / machine.js
Last active May 28, 2020 22:05
Generated by XState Viz: https://xstate.js.org/viz
const persooMachine = Machine({
id: "persoo",
initial: "initialize",
states: {
initialize: {
type: "parallel",
states: {
waitForPersooJS: {
initial: "fetching",
states: {
@bultas
bultas / patternMatch.js
Created June 10, 2020 11:31
Pattern Match in javascript
import { cond, always, T, whereEq } from "ramda";
export const getProductPrice = cond([
[
whereEq({
type: "product1",
currency: "czk",
}),
({ price }) => `${price} Kc`,
],