Skip to content

Instantly share code, notes, and snippets.

View dorinvancea's full-sized avatar
🎯
Focusing

Dorin Vancea dorinvancea

🎯
Focusing
View GitHub Profile
@viclafouch
viclafouch / modal.jsx
Last active January 23, 2023 21:14
An implementation of a Modal Component with React Hooks ! See https://react-modal.viclafouch.vercel.app
import React, { useEffect, useImperativeHandle, useState, forwardRef, useCallback } from 'react'
import { createPortal } from 'react-dom'
import './styles.css'
const modalElement = document.getElementById('modal-root')
export function Modal({ children, fade = false, defaultOpened = false }, ref) {
const [isOpen, setIsOpen] = useState(defaultOpened)
const close = useCallback(() => setIsOpen(false), [])
@FFKL
FFKL / cell-ellipsis.css
Last active June 1, 2024 18:21
Auto-resizable ellipsis without fixed width 😮
.ellipsis {
position: relative;
}
.ellipsis:before {
content: ' ';
visibility: hidden;
}
.ellipsis span {
import { useRef, useState, useEffect } from 'react';
// Usage
function App() {
const [hoverRef, isHovered] = useHover();
return (
<div ref={hoverRef}>
{isHovered ? '😁' : '☹️'}
</div>
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active January 21, 2024 16:28
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@solancer
solancer / htaccess.expires.headers
Created December 13, 2016 21:01
htaccess expires headers
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/atom+xml "access plus 1 hour"
@ademers
ademers / craft-cms-language-toggle.html
Last active October 17, 2017 11:49
Craft CMS: Language Toggle
{# Language switcher #}
{# Loop through all of the site locales, except the current one #}
{% set otherLocales = craft.i18n.getSiteLocaleIds()|without(craft.locale) %}
{% for locale in otherLocales %}
{# Is this an entry page? #}
{% if entry is defined %}
{# Find the current entry in the other locale #}
{% set localeEntry = craft.entries.id(entry.id).locale(locale).first %}