Skip to content

Instantly share code, notes, and snippets.

@tresorama
tresorama / README.md
Last active March 20, 2024 21:29
Tailwind Config usage

Tailwind Config usage and snippets

Expose Theme tokens as CSS Variables

import plugin from 'tailwindcss/plugin';
import cssEscape from 'css.escape';

/** @type {import('tailwindcss').Config} */
export default {
  content: [],
@tresorama
tresorama / README.md
Last active April 10, 2024 15:22
How to move a Local by Flywheel site to a plain Docker (docker-compose) site

How to move a Local by Flywheel site to a plain Docker (docker-compose) site

  1. Open docker deskop

  2. Create a directory for your prject crete this file structure:

    docker-compose.yml # we fill this in next step
    data
      db-data # leave blank, this will be used by mysql to persist data
    
@tresorama
tresorama / dynamic-data.text.tsx
Created August 25, 2023 08:10
wordpress-gutenberg--POC--dynamic-data
import { createHigherOrderComponent } from '@wordpress/compose';
import * as wpHooks from '@wordpress/hooks';
import { BlockControls, InspectorControls } from '@wordpress/block-editor';
import { PanelBody, PanelRow } from '@wordpress/components';
import { Icon, backup as backupIcon } from '@wordpress/icons';
import { Post, useEntityRecord } from '@wordpress/core-data';
import { store as coreStore } from '@wordpress/core-data';
import { useSelect, useDispatch } from '@wordpress/data';
import { BlockEditProps } from '@wordpress/blocks';

In the #51327 PR by @torounit is emerged that on an other PR #42605 a "rename" block features is "booked" to be assigned to double click shortcut. The rename features is currently work in progress and is tracked at #42605 .


In a short discussion it's also emerged that "expand collapse" is a power user feature, so it is a good idea that its shortcut is under a modifier key (ctrl in Window and cmd in MacOS).

I would expect that double click would be to rename. Expand the entire tree feels like a power user level feature and so it would be ok to have this behind a modifier key requirement.

Originally posted by @getdave in WordPress/gutenberg#51327 (comment)

@tresorama
tresorama / Marquee_WithPlainCSS.tsx
Last active April 27, 2023 09:40
react-marquee
/* eslint-disable @next/next/no-img-element */
import React, { useRef } from 'react';
import cx from 'classnames';
import useIntersectionObserver from './hooks/use-intersection-observer';
type MarqueeProps = {
imagesUrls: string[],
};
export const ImagesSlider_WithPlainCSS = ({ imagesUrls }: MarqueeProps) => {
@tresorama
tresorama / jachi.mjs
Last active February 14, 2023 12:11
wp-fes-theme-json-script-tailwind
// Here we generate the "theme.json" programmatically
import resolveConfig from "tailwindcss/resolveConfig.js";
import * as tailwindConfig from "../tailwind.config.js";
import * as fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
// Utility - Disk
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

In this blog post we create a small React library and publish it to NPM.
We'll go through all steps required to do that.
Let's begin.

Overview

The library we will publish (package from now on) is written in Typescript, bundled with tsup, versioned and published with changeset.

To test the package we create one example app with Next.js and one with Vite.

@tresorama
tresorama / sleep.ts
Created January 21, 2023 20:09
sleep
/**
* Generic setTimeout implementation with Promise, used for wait some time then do something.
* Generally used for simulating async operation execution time while developing.
* @param time Time to wait for, in ms.
* @param returnValue Optional. What will be returned from the promise.
* @returns Promise that always resolve with "returnValue" after "time" ms.
*/
export const sleep = <T,>(time: number, returnValue?: T) => new Promise<T | undefined>(resolve => setTimeout(() => resolve(returnValue), time));
@tresorama
tresorama / app-shell.tsx
Last active January 16, 2023 04:07
useScrollRestoration for Next.js - V2
import { useScrollRestoration } from "./use-scroll-restoration";
type AppShellProps = {
content: React.ReactNode;
topBar?: React.ReactNode;
bottomBar?: React.ReactNode;
};
export const AppShell = ({ content, topBar, bottomBar }: AppShellProps) => {
useScrollRestoration();
@tresorama
tresorama / personal-suggestion.md
Last active January 15, 2023 23:34
Ebay UX Feedback / Suggestion Personal

Italiano

Dal mio punto di vista troverei utili queste funzioni:

  • Creare inserizoni multiple partendo da un modello. Ora è possibile scegliere un modello solo con l'inserzione singola percò chi ha intenzione di creare più inserzioni partendo da un modello deve prima creare una inserzione partendo da un modello con Crea Inserzione > Crea inserzione singola, e successivamente duplicare l'inserzione appena creata N volte