Skip to content

Instantly share code, notes, and snippets.

View bellodesign's full-sized avatar

BelloDesign bellodesign

View GitHub Profile
@bellodesign
bellodesign / _redirect
Created September 4, 2024 14:30
Redirect for SPA in Netlify
/* /index.html 200
@function encodecolor($string) {
@if type-of($string) == 'color' {
$hex: str-slice(ie-hex-str($string), 4);
$string:unquote("#{$hex}");
}
$string: '%23' + $string;
@return $string;
}
@mixin x-twitter-icon($color: white, $width: 16px, $height: 16px, $square: false) {
@bellodesign
bellodesign / onReadyState.js
Created December 6, 2023 09:17
onreadystatechange
document.onreadystatechange = () => {
document.addEventListener("afOnReady", (ev) => {
console.log("ready", ev);
})
if (document.readyState === "complete") {
console.log("complete")
}
}
@bellodesign
bellodesign / setResponsiveTables.js
Created November 28, 2023 07:37
setResponsiveTables()
function setResponsiveTables() {
document.onreadystatechange = () => {
if(document.readyState === 'complete') {
const tables = document.querySelectorAll('table');
tables.forEach((table) => {
const clone = table.cloneNode(true);
const wrapper = document.createElement('div');
wrapper.classList.add('table-responsive');
wrapper.appendChild(clone);
@bellodesign
bellodesign / git-delete-branch
Created October 6, 2023 06:26
GIT delete branch locally and remotely
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
git init
git add .
git commit -m "Add existing project files to Git"
git remote add origin https://github.com/cameronmcnz/example-website.git
git push -u -f origin master
@bellodesign
bellodesign / nvm-use-windows.js
Created September 7, 2023 11:19
Nvm use (windows)
nvm use `cat .nvmrc`
@bellodesign
bellodesign / registerWebComponents.ts
Created July 1, 2022 12:58
Define web components in React (TypeScript)
// Workaround found here: https://github.com/ionic-team/stencil/issues/1090#issuecomment-501124883
// eslint will shout about using declare global
// but this is keeping me going for now
import { defineCustomElements, JSX as LocalJSX } from '@digi/core/loader';
import { HTMLAttributes } from 'react';
type StencilToReact<T> = {
[P in keyof T]?: T[P] & Omit<HTMLAttributes<Element>, 'className'> & {
class?: string;
import { DigiButton } from '@digi/core';
const customElementPromise = customElements.whenDefined('digi-button').then(() => console.log('customEl is defined'));
await customElementPromise;
const myButton:any = document.querySelector('#myButton')
const buttonRef:HTMLButtonElement = await (myButton as DigiButton).afMGetButtonElement().then(res => res);
console.log('buttonRef', buttonRef);
--- .html
<digi-button #myButton></digi-button>
--- .ts
import { DigiButton } from '@digi/core-angular';
@ViewChild('myButton') myButtonRef!: DigiButton;
setTimeout(async () => {
const buttonRef:HTMLButtonElement = await this.myButtonRef.afMGetButtonElement().then((res) => res)