This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| const TailwindConfig = require('./tailwind.config'); | |
| const colors = TailwindConfig.colors; | |
| const outPath = path.join(__dirname, 'theme-variables.scss'); | |
| // If the file exists, delete it. | |
| fs.unlink(outPath, err => { | |
| if (err && err.code !== 'ENOENT') return console.error(err); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| When developing, it's always a good idea to create comments so future you and other developers can better understand the logic that was thought of at that moment in time. Since comments can be used for different reasons and be formatted differently as well, I figured it would be a good idea to use specific formats for different types of comments. | |
| 1. Function Declarations | |
| The typical way of commenting function declarations with slash stars. | |
| Example: | |
| /** | |
| * Map array items to work with select options. | |
| * | |
| * @param {Array} arr Array of items that have properties id and name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * This injects Tailwind's base styles, which is a combination of | |
| * Normalize.css and some additional base styles. | |
| * | |
| * You can see the styles here: | |
| * https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css | |
| * | |
| * If using `postcss-import`, use this import instead: | |
| * | |
| * @import "tailwindcss/preflight"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Feature Flags | |
| * | |
| * Settings to turn on a feature. Currently, Flags can be set through either a | |
| * query param or from local storage. | |
| */ | |
| import env from '@beam-australia/react-env'; | |
| import UrlParse from 'url-parse'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react'; | |
| import { | |
| ActionButton, | |
| Text, | |
| Toggle, | |
| } from '@open-raven/react-styleguide'; | |
| import { Flex } from 'reflexbox'; | |
| import { | |
| LOCAL_STORAGE_KEY, | |
| getFlagsFromLocalStorage, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { getTokenFromGCPServiceAccount } from '@sagi.io/workers-jwt' | |
| /** | |
| * Getting the access token to use in the header. | |
| */ | |
| // For example's sake, the file contents (modified) from the private key has been | |
| // listed below, but the recommended way would be to use environment variables. | |
| export async function getAccessToken() { | |
| const jwtToken = await getTokenFromGCPServiceAccount({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Update an existing document in a collection. | |
| */ | |
| export async function updateDocumentInCollection({ docID, title, published, modified }) { | |
| const accessToken = await getAccessToken() | |
| const response = await ( | |
| await fetch( | |
| 'https://firestore.googleapis.com/v1/projects/<PROJECTIDHERE>/databases/(default)/documents/<COLLECTIONNAME>/<DOCID>?updateMask.fieldPaths=title&updateMask.fieldPaths=published&updateMask.fieldPaths=modified', | |
| { |