Skip to content

Instantly share code, notes, and snippets.

View lekoala's full-sized avatar

Thomas Portelange lekoala

View GitHub Profile
/* More compact dropdown + visible if collapsed */
.cms .cms-menu .cms-subsites {
padding: 0;
}
.cms .cms-menu .cms-subsites .field.dropdown {
margin: 0;
}
@lekoala
lekoala / dump.php
Last active August 20, 2021 12:32
Dump php variables like a pro
<?php
// This file need to be included before vendor/autoload.php
if (!function_exists('dump')) {
function dump(...$vars)
{
$placeholder = "vscode://file/{file}:{line}:0";
// Get caller info
$file = '';
@lekoala
lekoala / toaster.js
Created February 21, 2022 15:09
Bootstrap 5 Toaster
"use strict";
/**
* Create a toast object
*
* @param {string} attr.body Body content. Can also be filled with html tags (eg: Hello <b>World</b>)
* @param {string} attr.header (none) Header content. Can also be filled with html tags (eg : <h6 class="mb-0">Success</h6>)
* @param {string} attr.className (none) Additional classes for toast element (eg: 'border-0 bg-danger text-white')
* @param {boolean} attr.animation (true) Apply transition to the toast
* @param {boolean} attr.autohide (true) Auto hide the toast
@lekoala
lekoala / print.scss
Created February 20, 2023 17:09
bootstrap 5 print styles
@import "../bootstrap/bootstrap-common";
// Print styles
@media print {
// Our custom styles
*,
*::before,
*::after {
text-shadow: none !important;
box-shadow: none !important;
// Split bootstrap media queries by stylesheet
// @link https://alistapart.com/article/mobile-first-css-is-it-time-for-a-rethink/
// Sample usage:
// <link href="/css/default.min.css" rel="stylesheet" />
// <link href="/css/mobile.min.css" media="screen and (max-width: 767.98px)" rel="stylesheet" />
// <link href="/css/tablet.min.css" media="screen and (min-width: 768px) and (max-width: 991.98px)" rel="stylesheet" />
// <link href="/css/desktop.min.css" media="screen and (min-width: 992px)" rel="stylesheet" />
// <link href="/css/print.min.css" media="print" rel="stylesheet" />
/**
* @callback ElementCallback
* @param {HTMLElement} el
* @returns {void}
*/
const set = new WeakSet();
/**
* Initialize an element exactly once
/**
* Listen to any events on any elements
* Set passive elements by default
* Avoid listening multiple times to the same event for the same handler
* Support a virtual "connected" event that allows triggering code only once
*/
const CONNECTED = "connected";
const supportedPassiveTypes = [
"scroll",
/**
* Delegate listener to any events on any elements
* Set passive elements by default
* Avoid listening multiple times to the same event for the same handler
*/
const supportedPassiveTypes = [
"scroll",
"wheel",
"touchstart",
/**
* Entwine is inspired by a js lib (https://github.com/hafriedlander/jquery.entwine)
* that allows binding behaviour to a give selector
*
* This library is a modern take on the same subject
*
* All elements get their own event listeners attached. This is an alternative approach
* to have one big delegator that deals with everything (see listen.js if that's what you want)
* I'm actually not sure what's the course of action ? :-)
*