Skip to content

Instantly share code, notes, and snippets.

View innocenzi's full-sized avatar
🦋

Enzo Innocenzi innocenzi

🦋
View GitHub Profile
@innocenzi
innocenzi / DoctrineReloadCommand.php
Created April 9, 2019 15:22
A Symfony 4.2 command made to make fixture reloading easier. Takes into account the foreign key constraints issue.
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
@innocenzi
innocenzi / ExampleComponent.vue
Last active March 30, 2022 08:51
Inertia route guards
<template>
<!-- ... -->
</template>
<script>
export default {
// ...
beforeRouteLeave (vm, options, event) {
// vm will now refer to this component instead of the link
return window.confirm(vm.$trans('ticket.confirm_leave_creation'));
@innocenzi
innocenzi / Layout.vue
Created October 17, 2019 17:44
Inertia + Vue dynamic layout
<template>
<component :is="layout"><slot /></component>
</template>
<script>
import Drawer from '@/Layout/Drawer';
import Fullscreen from '@/Layout/Fullscreen';
import v from 'voca';
const fallback = 'drawer';
@innocenzi
innocenzi / Input.vue
Created October 20, 2019 21:05
Material-inspired Input
<template>
<div class="flex flex-col">
<div class="flex flex-row relative font-title" :style="`--current-color: var(--color-${currentColor});`">
<label v-if="label"
class="z-64 px-2 font-semibold text-sm absolute pointer-events-none bg-surface rounded-full transition-all transition-250"
:active="active"
:class="labelClassObject"
v-html="labelText" />
<scale-transition origin="center">
<span v-show="canClear"
@innocenzi
innocenzi / Breakpoint.ts
Created October 23, 2019 11:44
Breakpoint helper in TypeScript
export enum Breakpoint {
sm = 640,
md = 768,
lg = 1024,
xl = 1080,
}
@innocenzi
innocenzi / output.css
Created October 26, 2019 18:41
Tailwind touch-actions
.touch-none {
touch-action: none;
}
.touch-auto {
touch-action: auto;
}
.touch-pan-x {
touch-action: pan-x;
@innocenzi
innocenzi / box-shadow buttons
Last active March 5, 2020 17:41
box-shadow with same colors as their borders with Tailwind
<div class="mr-4 p-4 rounded-lg border-2 font-bold text-white bg-red-300 border-red-400 shadow-button">border-red-400 shadow-button</div>
<div class="p-4 rounded-lg border-2 font-bold text-white bg-blue-300 border-blue-400 shadow-button">border-blue-400 shadow-button</div>
function withAlphaVariable({ color, property, variable }) {
if (_.isFunction(color)) {
return {
[property]: color(variable),
}
}
try {
const [r, g, b, a] = toRgba(color)
const { flags } = require('@oclif/parser');
module.exports = {
actions: () => [],
parse: () => ({
flags: {
auth: flags.boolean({ char: 'f' }),
},
args: [
{
@innocenzi
innocenzi / custom.css
Last active January 27, 2023 13:14
Visual Studio Code custom CSS
.title.breadcrumbs {
display: none !important;
}
.window-title {
visibility: hidden !important;
}
.monaco-editor .scroll-decoration,
.scroll-decoration {