Skip to content

Instantly share code, notes, and snippets.

View wiseoldman's full-sized avatar
🔥

Phil. wiseoldman

🔥
View GitHub Profile
@wiseoldman
wiseoldman / _letter-spacing.scss
Last active August 27, 2021 12:13
[Adobe XD letter-spacing] SCSS mixin to convert letter-spacing from Adobe XD to CSS #xd #letter-spacing
@mixin letter-spacing($spacing) {
letter-spacing: ($spacing / 1000) * 1em;
}
@wiseoldman
wiseoldman / _event-delegation.js
Last active June 2, 2023 12:47
[Event delegation] Vanilla js event delegation. This also works for complex HTML markup with overlaying children #event #delegation
Element.prototype.on = function (eventName, selector, fn) {
this.addEventListener(eventName, function (event) {
const target = event.target.closest(selector)
if (target && this.contains(target)) {
return fn.call(target, event, target)
}
})
}
@wiseoldman
wiseoldman / _close.scss
Last active December 17, 2018 13:20
[Single div X button] Close button created with a single div and pseudo elements #close #button #scss
$xSize: 40px;
$xColor: #000;
.x-btn {
cursor: pointer;
width: $xSize;
height: $xSize;
position: relative;
&:before, &:after {