Skip to content

Instantly share code, notes, and snippets.

View Danetag's full-sized avatar
🕺
Entertaining

Arnaud Tanielian Danetag

🕺
Entertaining
View GitHub Profile
import "scss/partials/pages/_homepage.scss";
export default class Homepage {
...
}
let currentView = null;
const pageLoaded = () => {
// "Routing"
const currentPage = document.querySelector("#content").firstElementChild;
switch (currentPage.id) {
case "home-page":
import(/* webpackChunkName: "homepage" */ "pages/homepage/homepage")
.then(currentViewImported)
<?
function register_scripts() {
// include the base style in the header.
$base_js = WP_DEBUG ? 'http://localhost:8080/bundle.js' : get_stylesheet_directory_uri() . ( '/static/app.js' );
wp_register_script(
'base-script', // handle name.
$base_js,
null, // an array of dependent styles.
const devServer = {};
const webpack = require("webpack");
const ENV = process.env.NODE_ENV === "production" ? "production" : "development";
const outputPath =
ENV === "production"
? path.resolve(__dirname + "../../static/")
: path.resolve(__dirname + "/dist/");
...
render() {
const { items, openedMenu, onClose } = this.props;
return (
<Transition in={openedMenu} timeout={openedMenu ? 0 : 300}>
{(status) => (
<nav
id="menu-mobile"
...
render() {
const { openedMenu, onOpenMenu, state } = this.props;
return <button
id="menu-hamburger"
aria-controls="menu-mobile"
aria-expanded={openedMenu}
aria-haspopup={true}
@Danetag
Danetag / Sprite.js
Last active May 13, 2024 17:28
Simple class to play a PNG sequence into a canvas
// Here is a simple class that contains loading methods.
// Nothing fancy, but the idea is simply to return a Promise
import { loadImg } from './load';
class Sprite {
/*
@Example
import Sprite from './Sprite';
// Update the path of the assets in the animation data to use CMS assets instead (optmized)
const updateAnimationData = (assets, animationData, maxAssetWidth) => {
const refIdDictionary = [];
animationData.assets.forEach((asset, i) => {
if (!asset.u || !asset.id) return;
// replace id
const newId = asset.p.split('.')[0];
const prevId = asset.id !== newId ? asset.id : `image_${i}`;
class LottieWebAnimation extends React.Component {
/*
.. render()...
*/
// Capturing mouse move
onMouseMove = (e) => {
this.mouseCoords.x = e.clientX || e.pageX;
this.mouseCoords.y = e.clientY || e.pageY;