Skip to content

Instantly share code, notes, and snippets.

View NicolasDurant's full-sized avatar

zzvbm NicolasDurant

View GitHub Profile
@NicolasDurant
NicolasDurant / BaseAlert.vue
Last active October 10, 2024 08:28
[Vue3 / HTML / JS / CSS - Tailwind theme components build in Vue3] This is a whole custom flat design implementation with colors and custom forms, built with tailwind css and Vue3. It contains the necessary tailwind config and css basis, and the implementation of 16! basic design elements like cards, buttons, lists, tables, etc. in Vue3. All com…
<template>
<div v-if="showMe" :class="[`variant-${variant}`]" class="rounded-md p-4">
<div class="flex">
<!-- LEADING ICON -->
<div class="flex-shrink-0 icon">
<CheckCircleIcon v-if="variant === 'success'" class="h-5 w-5" aria-hidden="true"/>
<InformationCircleIcon v-if="variant === 'info'" class="h-5 w-5 text-blue-400" aria-hidden="true"/>
<ExclamationTriangleIcon v-if="variant === 'warn'" class="h-5 w-5" aria-hidden="true"/>
<XCircleIcon v-if="variant === 'error'" class="h-5 w-5" aria-hidden="true"/>
</div>
@NicolasDurant
NicolasDurant / ScrollSnap.vue
Created December 9, 2021 22:42
[Vue / Nuxt - Scroll a single page or container] This is a reusable component, that allows to add a scroll snapping effect to a container or the full page. It is important that the children receive the `item` class and have special css applied when not using full page. For an example of that refer to the HomeScreen class.This code comes from the…
<!--suppress CssInvalidFunction -->
<template>
<div :class="{'fullscreen': fullscreen, 'horizontal': horizontal }" class='scroll-snap-container'>
<!-- Items (pages or containers) that should be scroll snapped -->
<slot></slot>
</div>
</template>
<script lang='ts'>
import { Component, Prop, Vue } from 'vue-property-decorator'
@NicolasDurant
NicolasDurant / pubspec.sh
Last active December 9, 2021 22:39
[Flutter / Script - Assets generator] Generates a text file of all the assets in your assets folder, in a format that you can just copy paste into the pubspec.yml assets definition. #Flutter #!/bin/sh #Shell #Assets #Generation
#!/bin/sh
# If you don't have the GNU commands (amazing stuff) on your mac, install with:
# $ brew install autoconf bash binutils coreutils diffutils ed findutils flex gawk \
# gnu-indent gnu-sed gnu-tar gnu-which gpatch grep gzip less m4 make nano \
# screen watch wdiff wget
# If you don't have the tree command on your mac, install with:
# $ brew install tree
#
# Just a quick shell script that outputs all asset files with their path and writes them into assets_list.txt.
# Prefixed with "- assets/${path}" so you can copy that into the pubspec.yml.
@NicolasDurant
NicolasDurant / VideoSnippet.vue
Created December 9, 2021 22:35
[Vue / Nuxt - Play multiple videos in a loop] Just some listeners and methods to play a list of videos. #NuxtJS #VueJS #JavaScript #FileHandling #Video
<video
:id='videoId'
autoplay
muted
>
</video>
// element id of the video tag
private videoId: string = 'video-appetizer'
// those are all the videos that should play after each other, when the one before finishes
@NicolasDurant
NicolasDurant / DragDrop.vue
Last active August 25, 2023 00:11
[Vue / Nuxt - Image Drag & Drop or Choose Image] Component that provides an area for the user to drop an image onto. It's restricted to image file types only. As soon as the image is uploaded it will trigger an emit event 'uploaded', which the parent can listen to. Also includes the ChooseImage Component, but without adding another image preview…
<template>
<div
class="d-flex flex-column justify-center align-end"
style="height: 100%; width: 100%"
>
<!-- DRAG & DROP AREA -->
<div
class="drop d-flex flex-column justify-center align-center"
:class="classes"
@dragover.prevent="dragOver"
@NicolasDurant
NicolasDurant / TheNotification.vue
Last active September 2, 2022 08:34
[Vue / Vuex / Nuxt - Request Error Handling Store + Example] A Notification Component that lets an v-alert pop up when a request fails. It is connected with the Vuex notification.js store. The Vue Components in this example use the vue-decorators. But this would obviously also work with normal Vue-Components. #JavaScript #VueJS #NuxtJS #Vuex #Er…
<template>
<div class="container-style">
<v-alert
:type="notification.type"
v-for="(notification,index) in notifications"
:key="index"
class="alert-style"
elevation="3"
dismissible
dense
@NicolasDurant
NicolasDurant / helper.js
Last active July 12, 2020 16:41
[Nuxt - Jest Extracted Mountfunction] Helper file that I created to follow the DRY principle. Mocks most used variables/methods so the test files aren't so stacked. You can add mock-data for vuetify/components in this file, but keep in mind this will be added to all tests importing this helper. Jest could become slower if you stub stuff that is …
import { shallowMount, createLocalVue } from '@vue/test-utils'
import Vuetify from 'vuetify'
// You can add mock-data for vuetify/components in this file, but keep in mind this will be added to all tests importing this helper
// -> jest could become slower if you stub stuff that is not useful for each test
const localVue = createLocalVue();
// if you need to stub more vuetify variables or methods add them here
const vuetify = new Vuetify({
mocks: {
@NicolasDurant
NicolasDurant / create-fitler-module.js
Last active July 12, 2020 16:40
[Vue - Mixin - Vuex Dynamically Generate Stores (Blueprints)] Mixin that generates Vuex stores dynamically under different names. Useful for stores that follow a 'blueprint/base' store. #VueJS #Vuex #JavaScript #Stores
import { mapActions } from 'vuex'
import * as filter from '@/store/filter/filter.js'
/** Mixin responsible for creating our filter store module based on a blue print store called filter.js
* Is also able to create multiple stores if needed.
* @author Nicolas Durant
* @mixin create-filter-module
* @summary Usually mixed into default Page Components that use tables
* @requires vuex - to set the inital filter and sort arrays
* @requires filter - store blueprint for our dynamic stores
@NicolasDurant
NicolasDurant / base.js
Last active July 12, 2020 16:40
[Nuxt - BaseComponents Globally Register Plugin] Plugin Script for the Nuxt.js Framework that goes through every file in the src/components/base folder and registers the components with Base+ComponentName globally, so you can access them anywhere in the code without the need of importing them. #NuxtJS #JavaScript #VueJS #NuxtConfig
// Has to be in the Nuxt plugins/ folder
import Vue from 'vue'
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
const requireComponent = require.context(
// The relative path of the components folder
'@/components/base',
// Whether or not to look in subfolders
false,
@NicolasDurant
NicolasDurant / swagger-generator.js
Last active June 30, 2020 21:51
[Node - MirageJS to Swagger-Generator] A script that can sit in the MirageJS-Folder and generate as much documentation as possible out of the factories configuration. Filepaths might need tweaking according to paths. Can be run with `node swagger-generator.js` #MirageJS #JavaScript #Swagger #yml
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const opt = 'utf8';
const routes = fs.readFileSync('./routes.js', opt);
rl.question('Want to generate Swagger Info Object (y/n)? ', (answer) => {