Skip to content

Instantly share code, notes, and snippets.

@romainavalle
romainavalle / vue.json
Last active September 12, 2022 14:59
scaffold snippet for .vue files
{
// Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@romainavalle
romainavalle / observer.js
Last active June 10, 2022 09:54
observer mixin for nuxtjs
export default {
data() {
return { isShown: false, isActive: false, boundingClientRect: {} }
},
methods: {
intersectionCb(entries) {
if (entries[0].intersectionRatio > 0) {
this.isShown = true
this.isActive = true
this.boundingClientRect = entries[0].boundingClientRect
<template>
<div class="dev-design" v-show="isShown" :style="{ opacity }">
<img
v-for="(img, i) in imgsUrl"
:src="img"
:key="`img-${i}`"
v-show="currentImg === i"
/>
</div>
</template>
@romainavalle
romainavalle / text-formater.js
Last active May 4, 2022 07:15
replace lsep chars in nuxt plugin
export default ({ app }, inject) => {
inject('tf', (text) => text.replace(/[\u2028]/g, ' '))
}
@romainavalle
romainavalle / duotone.glsl
Last active June 10, 2022 09:54
duotone glsl
float g = greyscale(texture2D(tMap, uv).r;
vec3 finalColor = mix(colorA, colorB, g);
@romainavalle
romainavalle / line-ellipsis.scss
Last active June 10, 2022 09:53
scss line ellipsis
.line-ellipsis{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; /* number of lines to show */
line-clamp: 2;
-webkit-box-orient: vertical;
}
@romainavalle
romainavalle / write-redirects.js
Last active June 10, 2022 09:59
Dato write redirects module (to include in build module)
const { SiteClient } = require('datocms-client')
const client = new SiteClient(process.env.GRAPHQL_TOKEN)
const fs = require('fs')
export default function () {
client.items
.all({ 'filter[type]': 'your_redirect_modelApiKey' }, { allPages: true })
.then((records) => {
const array = records.map((el) => {
return {
@romainavalle
romainavalle / border-radius.scss
Created June 10, 2022 09:56
border-radius scss class
.b-r{
border-radius: $radius;
overflow: hidden;
&.-animating{
-webkit-mask-image: -webkit-radial-gradient(white, black);
}
}
const rating = '★★★★★☆☆☆☆☆'.slice(5-stars,10-stars)
@romainavalle
romainavalle / texture-resize.glsl
Last active January 17, 2023 14:27
texture resize glsl
float scale(float _val, float _scale) {
_val -= 0.5;
_val *= _scale;
_val += 0.5;
return _val;
}
vec2 coverImage(vec2 _pos) {
float rS = uRes.x / uRes.y;
float rI = uImageRes.x / uImageRes.y;