Skip to content

Instantly share code, notes, and snippets.

View BrunoQuaresma's full-sized avatar

Bruno Quaresma BrunoQuaresma

View GitHub Profile
@BrunoQuaresma
BrunoQuaresma / blog.tsx
Created May 29, 2021 16:39
Next/mdx blog index page
export async function getStaticProps() {
const postDirectory = path.join(process.cwd(), "src/pages/blog");
const postFilenames = fs
.readdirSync(postDirectory)
.filter((file) => path.extname(file).toLowerCase() === ".mdx");
const postModules = await Promise.all(
postFilenames.map(async (p) => require(`./${p}`))
);
return {
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@BrunoQuaresma
BrunoQuaresma / tailwind-colors.js
Last active May 15, 2023 17:31
TailwindCSS colors object to be used outside of Tailwind projects like MUI
// Generated from https://tailwindcss.com/docs/customizing-colors
export default {
slate: {
50: "#f8fafc",
100: "#f1f5f9",
200: "#e2e8f0",
300: "#cbd5e1",
400: "#94a3b8",
500: "#64748b",
600: "#475569",
@BrunoQuaresma
BrunoQuaresma / withWebSocket.tsx
Created February 23, 2024 14:32
Storybook decorator that supports WebSocket messages
export const withWebSocket = (Story: FC, { parameters }: StoryContext) => {
if (!parameters.webSocket) {
console.warn(
"Looks like you forgot to add websocket messages to the story",
);
}
// @ts-expect-error -- TS doesn't know about the global WebSocket
window.WebSocket = function () {
return {