Skip to content

Instantly share code, notes, and snippets.

View davidlagace's full-sized avatar

David Lagacé davidlagace

View GitHub Profile
@davidlagace
davidlagace / FormSelect.js
Last active January 18, 2021 03:40
REACT react-hook-form nested form with material-ui
import React, {useEffect} from "react";
import {useFormContext, Controller} from "react-hook-form";
import MenuItem from "@material-ui/core/MenuItem";
import {formSelectStyles} from "./FormSelect.styles";
import {TextField} from "@material-ui/core";
import InputLabel from "@material-ui/core/InputLabel";
function FormSelect(props) {
const {name, label, options} = props;
const classes = formSelectStyles();
<div class="js-position-sticky-bottom a-slide-from-bottom">
...
</div>
@davidlagace
davidlagace / _in-viewport-animation.scss
Created June 17, 2019 20:34
Detection in viewport element to animate.
/* *****************************************************************************
*
* Global animation setup
*
* ***************************************************************************** */
@keyframes fade-in-viewport {
0% {
opacity: 0
}
100% {
@davidlagace
davidlagace / _in-viewport-animation.scss
Created June 17, 2019 20:32
Detection in viewport element to animate.
/* *****************************************************************************
*
* Global animation setup
*
* ***************************************************************************** */
@keyframes fade-in-viewport {
0% {
opacity: 0
}
100% {
/* *****************************************************************************
*
* Utilities
*
* ***************************************************************************** */
// Paddings
// --------------------------------------------------------
.pl-card {
padding-left: $card-body-padding-x;
@davidlagace
davidlagace / package.json
Last active June 14, 2019 18:21
Webpack 4, SASS, ES6 config
{
"name": "webpack-4-bootstrap-config",
"version": "1.0.0",
"description": "Simple working webpack 4, bootstrap configuration",
"scripts": {
"webpack:build": "webpack --mode=production --env.production",
"webpack:dev": "webpack --mode=development --env.development",
"webpack:watch": "webpack --mode=development --env.development --watch"
},
"author": "David Lagace",
@davidlagace
davidlagace / bootstrap-4--oocss-adds-on.scss
Last active June 14, 2019 17:52
Bootstrap 4 OOCSS class add-ons
/* ----------------------------------
* Colors
*
* Use : .color--[my custom varibale in $theme-colors]
* ---------------------------------- */
@each $color, $value in $theme-colors {
.color--#{$color} {
color: $value !important;
}
@davidlagace
davidlagace / bootstrap-4--mixin-oocss-borders.scss
Last active June 14, 2019 17:56
Create OOCSS class with Bootstrap 4 theme variables.
/* *****************************************************************************
*
* Borders
*
* ***************************************************************************** */
/**
@mixin createClassBorders($bordersMap, $themeVariantsMap)
$borderMap<Map> An array of the borders property and abbreviation used for the OOCSS class name.
@davidlagace
davidlagace / bootstrap-4--mixin-media-scale.scss
Last active June 14, 2019 17:56
Mixins for Bootstrap 4 to implement a value on multiple breakpoint of a property
/* *****************************************************************************
*
* Media queries mixins
*
* ***************************************************************************** */
/**
@mixin media-scale($elem, $defaultValue, $mdValue, $lgValue)
$elem The CSS property
@davidlagace
davidlagace / device-orientation-detection.js
Last active August 2, 2018 19:01
Detect orientation (portrait/landscape) of device
// --------------------------------
// Single use
window.matchMedia("(orientation: portrait)").matches; // return true if device is in portrait
// --------------------------------
// Watch for changes
var mql = window.matchMedia("(orientation: portrait)");
mql.addListener(handleOrientationChange);
handleOrientationChange(mql);