Skip to content

Instantly share code, notes, and snippets.

View drublic's full-sized avatar
🌐
Remote by default

Hans Christian Reinl drublic

🌐
Remote by default
View GitHub Profile
@drublic
drublic / dabblet.css
Created February 29, 2012 15:40
Pseudo-elements for select
/**
* Pseudo-elements for select
*/
select {
-webkit-appearance: none;
}
select:after {
content: 'abc';
@drublic
drublic / sublime-plugins.md
Last active October 4, 2022 02:24
My Sublime Plugins

Sublime Text Plugins

  • All Autocomplete
  • Bower
  • Editor Config
  • Emmet
  • Grunt
  • Image2Base64
  • LESS
@drublic
drublic / rem-fallback.less
Last active March 28, 2020 23:57
Fallback rem-mixin in Sass and LESS
@main-font-size: 16px;
.x-rem (@property, @value) {
// This is a workaround, inspired by https://github.com/borodean/less-properties
@px-fallback: @value * @main-font-size;
-: ~`(function () { return ';@{property}: @{px-fallback}'; }())`;
-: ~`(function () { return ';@{property}: @{value}rem'; }())`;
}
@drublic
drublic / whitespacing.html
Created April 22, 2012 19:21
Using whitespace for big parts of a website
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Whitespace is important</title>
</head>
<body>
<div class="wrapper">
/**
* Testing @supports
*/
body {
background: red;
}
@supports (box-shadow: 2px 2px 2px black) {
body {
@drublic
drublic / useHasLoader.ts
Created September 22, 2019 07:55
Custom Hook
// Testable Custom Hooks
import { useEffect } from "react";
// Function that can be tested with clear API, easily unit-testable
const handleHasLoader = ({ isLoading, hasFocus, setHasLoader }) => {
if (isLoading && !hasFocus) {
return setHasLoader(true);
}
return setHasLoader(false);
@drublic
drublic / Button.tsx
Last active September 21, 2019 19:42
Conceptual Hooks
// Presentational Component
// contains only the UI and has a clear UI (props) for testing
import React from "react";
import Loader from "../Loader";
const Button = ({ onFocus, onBlur, hasLoader, label }) => (
<button type="button" onFocus={onFocus} onBlur={onBlur}>
{hasLoader ? <Loader /> : label}
</button>
@drublic
drublic / Button.tsx
Last active September 21, 2019 19:04
Without Conceptual Hooks
import React, { useState, useEffect, useCallback } from 'react';
import Loader from '../Loader';
const Button = ({ label, isLoading }) => {
const [hasFocus, setHasFocus] = useState<boolean>(false);
const [hasLoader, setHasLoader] = useState<boolean>(false);
const handleFocus = useCallback(() => {
setHasFocus(true);
}, []);
const handleBlur = useCallback(() => {
@drublic
drublic / Card.jsx
Last active September 7, 2019 08:05
Component JS to TS
// This is an exisiting React Component written as a Function Component using JavaScript.
import React from "react";
import { string, any } from "prop-types";
const Card = ({
headline,
createdAt,
children,
}) => {
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"noImplicitAny": false,