Skip to content

Instantly share code, notes, and snippets.

@evdama
evdama / rollup.config.js
Created August 11, 2019 06:42
create a timestamp at compile time for later use inside the app
// @ts-nocheck //TODO: enable remove once there are typings in place
// TODO: uncomment all three eslint() occurrences once eslint warnings and errors are fixed
// for info on emitCSS etc. https://github.com/rollup/rollup-plugin-svelte#extracting-css and https://svelte.dev/docs#svelte_preprocess
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import config from 'sapper/config/rollup.js'
import getPreprocessor from 'svelte-preprocess'
import getTime from 'date-fns/getTime'
import path from 'path'
<script>
import { load } from 'recaptcha-v3'
import { onMount } from 'svelte';
import GoLiveDateInfo from '../components/GoLiveDateInfo.svelte';
onMount(() => {
async function reCaptcha() {
const recaptcha = await load('6Lcnm7EUAAAAAOWFIrRWVkA8zvckeG8RIjELdaSj', {useRecaptchaNet: true, autoHideBadge: true} )
const token = await recaptcha.execute('homepage')
console.log(token) // Will also print the token
const colors = {
transparent: 'transparent',
black: '#000000',
white: '#FFFFFF',
'red-50': '#FFEBEE',
'red-100': '#FFCDD2',
'red-200': '#EF9A9A',
'red-300': '#E57373',
'red-400': '#EF5350',
@evdama
evdama / template.html
Last active August 6, 2019 13:16
adding reCAPTCHA v3 to sapper app throws error
<!DOCTYPE html>
<html lang="en" class="min-h-full text-one antialiased font-family-one text-sm md:text-base bg-one" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="theme-color" content="#ffffff" />
<script src="https://www.google.com/recaptcha/api.js?render=6Lcnm7EUAAAAAOWFIrRWVkA8zvckeG8RIjELdaSj"></script>
%sapper.base%
<!DOCTYPE html>
<html lang="en" class="min-h-full text-one antialiased font-family-one text-sm md:text-base bg-one" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="theme-color" content="#ffffff" />
<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>
%sapper.base%
@evdama
evdama / ThemeToggle.svelte
Created August 5, 2019 17:50
how to move the window.matchMedia to <svelte:window>
<script>
import { onMount } from 'svelte';
let html, currentColorScheme = 'light';
onMount(
() => {
html = document.getElementsByTagName('html')[0]
window.matchMedia('(prefers-color-scheme: dark)').addListener(({ matches }) => {
if (matches) {
@evdama
evdama / tailwind.css
Created August 4, 2019 11:04
tailwind colors for light and dark theme via CSS variables
@import "tailwindcss/base";
@import "tailwindcss/components";
@import './components';
@import "tailwindcss/utilities";
@import './edm-utilities';
:root {
--font-family-one: Montserrat, sans-serif;
--font-family-two: Roboto, sans-serif;
@evdama
evdama / ThemeToggle.svelte
Created August 4, 2019 11:03
switch theme between light and dark
<script>
import { onMount } from 'svelte';
let html, currentColorScheme = 'light';
onMount(
() => {
html = document.getElementsByTagName('html')[0]
window.matchMedia('(prefers-color-scheme: dark)').addListener(({ matches }) => {
if (matches) {
@evdama
evdama / rollup.config.js
Created August 4, 2019 02:37
improve extractor for the case of 'class:'
// @ts-nocheck //TODO: enable remove once there are typings in place
// TODO: uncomment all three eslint() occurrences once eslint warnings and errors are fixed
// for info on emitCSS etc. https://github.com/rollup/rollup-plugin-svelte#extracting-css and https://svelte.dev/docs#svelte_preprocess
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import config from 'sapper/config/rollup.js'
import getPreprocessor from 'svelte-preprocess'
import path from 'path'
import postcss from 'rollup-plugin-postcss'
@evdama
evdama / rollup.config.js
Created August 2, 2019 02:13
including eslint() so at buildtime all code has to pass .eslintrc.js
// @ts-nocheck //TODO: enable remove once there are typings in place
// TODO: uncomment all three eslint() occurrences once eslint warnings and errors are fixed
// for info on emitCSS etc. https://github.com/rollup/rollup-plugin-svelte#extracting-css and https://svelte.dev/docs#svelte_preprocess
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import config from 'sapper/config/rollup.js';
import getPreprocessor from 'svelte-preprocess';
import path from 'path';
import postcss from 'rollup-plugin-postcss';