Skip to content

Instantly share code, notes, and snippets.


Ιερεμίας Jayprecode

View GitHub Profile
Jayprecode / fiddle.ts
Created January 9, 2023 12:27 — forked from paulkoerbitz/fiddle.ts
Trying to use React.js with TypeScript and the definitions from definitely typed
View fiddle.ts
/// <reference path="react-0.13.0.d.ts"/>
import React = require('react');
var RD = React.DOM;
enum ElementType { A, B, C }
interface NameTypeI {name: string; type: ElementType;}
interface CallbackI { newNode: (x: NameTypeI) => void; }
class NewNode extends React.Component<CallbackI,{},{}> {
constructor(props: CallbackI, context: {}) {
Jayprecode /
Created October 3, 2022 20:32 — forked from dimitrinicolas/
Handle mouse down/up and click events once with React Hooks

Handle mouse down/up and click events once with React Hooks

The issue

Sometimes you need to make a button clickable with click and mouse down or mouse up actions.

The first solution that comes to mind would be to add only one event listener onMouseDown/onMouseUp but without an onClick event listener the element is not accessible anymore. It's now hard to click for people with disabilities or with keyboard navigation.

If we set both onMouseDown/onMouseUp and onClick event listeners, the common click handler function would be called twice with a mouse. So we have

Jayprecode /
Created September 30, 2022 02:59 — forked from JoeyBurzynski/
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;