Skip to content

Instantly share code, notes, and snippets.

View astahmer's full-sized avatar

Alexandre Stahmer astahmer

View GitHub Profile
@astahmer
astahmer / getLineStart.js
Created August 27, 2020 18:35
Get line start
const getLineStart = (content, fromWord) =>
content.substring(
content.lastIndexOf('\n', content.indexOf(fromWord)),
content.indexOf(fromWord)
)
@astahmer
astahmer / Collapse.tsx
Created August 15, 2020 23:34
Collapse component with auto height open/close transition
import React, { useState } from "react";
import AnimateHeight from "react-animate-height";
export const Collapse = ({ children, minHeight = 0 }) => {
const [height, setHeight] = useState<any>(minHeight);
const isClosed = height === minHeight;
const toggle = () => setHeight(isClosed ? "auto" : minHeight);
return (
<div>
@astahmer
astahmer / docusaurus2-webpack-plugin.js
Created August 15, 2020 00:28
Tiny docusaurus 2 plugin that enables you to easiliy extend config and/or add module aliases
const path = require("path");
function fromEntries(iterable) {
return [...iterable].reduce((obj, [key, val]) => {
obj[key] = val;
return obj;
}, {});
}
/**