Skip to content

Instantly share code, notes, and snippets.

View Danetag's full-sized avatar
🕺
Entertaining

Arnaud Tanielian Danetag

🕺
Entertaining
View GitHub Profile
import { Component, h, Prop, State, Watch } from '@stencil/core';
const Constants = {
baseClassname: 'my-button',
}
@Component({
tag: 'my-button',
styleUrl: 'button.scss'
})
<!-- Template definition -->
<template id="fancy-element-template">
<style>
...
</style>
<div class="container">
<p>Some fancy markup goes here...</p>
</div>
</template>
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
// my-component-library is the name of our made up Web Component library
// that we have published on npm
import { applyPolyfills, defineCustomElements } from 'my-component-library/loader';
ReactDOM.render(<App />, document.getElementById('root'));
@Danetag
Danetag / _app.js
Last active March 27, 2020 02:59
Emotion extractCritical() with NextJS
import React from "react";
import App from "next/app";
import Head from "next/head";
import createCache from '@emotion/cache'
import { CacheProvider } from '@emotion/core'
const cache = createCache()
class MyApp extends App {
@Danetag
Danetag / Sound.js
Last active March 14, 2025 01:34
Sound Manager using Web Audio API
// Constants
import { SOUNDS } from './constants';
// Utils
import { loadSound } from 'utils/load';
import { IS_SAFARI, IS_IE } from 'utils/misc';
class Sound {
constructor(options) {
@Danetag
Danetag / critical.js
Last active March 5, 2021 21:18
Using critical.js with cluster for maxi perf
const cluster = require('cluster');
const fs = require('fs');
const path = require('path');
const critical = require('critical');
const minify = require('html-minifier').minify;
/*** Step 01 - define pages */
// Manifest is created with Webpack on build
const manifest = JSON.parse(fs.readFileSync('./static/bundles/manifest.json', 'utf8'));
@Danetag
Danetag / no.class.js
Created April 8, 2019 15:04
Testing a pattern getting rid of `Class`, `new`, `this` and `null`
const Component = () => {
const states = {
isInit: false,
};
const setState = (partialState = {}, callback) => {
if (
typeof partialState !== "object" &&
typeof partialState !== "function" &&
<?
// // Load Manifest Asset
$manifest = WP_DEBUG ? array('main.css' => '', 'main.js' => '') : json_decode(file_get_contents(dirname(__FILE__)."/static/manifest.json"), true);
/**
* Register Scripts().
*/
function register_scripts($manifest) {
{
"homepage.css": "1-c554ec31e68977100d81.css",
"homepage.js": "homepage-c554ec31e68977100d81.js",
"main.css": "main.7f74f1d39af13e4eef77.css",
"main.js": "main.7f74f1d39af13e4eef77.js"
}
module.exports = {
...
output: {
...
chunkFilename: "[name]-[chunkhash].js",
}
}