Skip to content

Instantly share code, notes, and snippets.

View chrisdrackett's full-sized avatar
🐳

Chris Drackett chrisdrackett

🐳
View GitHub Profile
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@chrisdrackett
chrisdrackett / useMousePosition.ts
Created September 17, 2020 19:33 — forked from eldh/useMousePosition.ts
useMousePosition
import * as React from "react";
import { throttle } from "lodash";
/**
* Mouse position as a tuple of [x, y]
*/
type MousePosition = [number, number];
/**
* Hook to get the current mouse position
@chrisdrackett
chrisdrackett / _readme.md
Created January 24, 2010 16:43 — forked from kneath/_readme.md
Kyle's Guide

Kyle's Guide

Just a placeholder for now, move along. Going to add what I consider vital design & development practices for use somewhere else in more complete form.

I am writing this down so I remember it. I have been writing HTML & CSS since somewhere around 1998, and much of what I have ingrained in my brain is outdated (body{ text-align:center; } anyone?). I need to rid this of my brain, and this is the only way I know how.

# Traditional - 9 lines
def view(request, template):
if request.method == "POST":
form = FormCls(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect("")
else:
form = FormCls()
return render_to_response(template, {"form": form})