-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from whilefoo/nft-mint
- Loading branch information
Showing
35 changed files
with
3,691 additions
and
3,729 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import esbuild from "esbuild"; | ||
import fs from "fs"; | ||
import path, { basename, dirname } from "path"; | ||
|
||
export const invertColors: esbuild.Plugin = { | ||
name: "invert-colors", | ||
setup(build) { | ||
build.onEnd(async result => { | ||
console.log(result); | ||
}); | ||
build.onLoad({ filter: /\.css$/ }, async args => { | ||
const contents = await fs.promises.readFile(args.path, "utf8"); | ||
|
||
const updatedContents = contents.replace(/prefers-color-scheme: dark/g, "prefers-color-scheme: light"); | ||
|
||
// Invert greyscale colors and accommodate alpha channels in the CSS content | ||
const invertedContents = updatedContents.replace(/#([0-9A-Fa-f]{3,6})([0-9A-Fa-f]{2})?\b/g, (match, rgb, alpha) => { | ||
let color = rgb.startsWith("#") ? rgb.slice(1) : rgb; | ||
if (color.length === 3) { | ||
color = color | ||
.split("") | ||
.map((char: string) => char + char) | ||
.join(""); | ||
} | ||
const r = parseInt(color.slice(0, 2), 16); | ||
const g = parseInt(color.slice(2, 4), 16); | ||
const b = parseInt(color.slice(4, 6), 16); | ||
|
||
// Check if the color is greyscale (R, G, and B components are equal) | ||
if (r === g && g === b) { | ||
// Invert RGB values | ||
const invertedColorValue = (255 - r).toString(16).padStart(2, "0"); | ||
// Return the inverted greyscale color with alpha channel if present | ||
return `#${invertedColorValue}${invertedColorValue}${invertedColorValue}${alpha || ""}`; | ||
} | ||
|
||
// If the color is not greyscale, return it as is, including the alpha channel if present | ||
return `#${color}${alpha || ""}`; | ||
}); | ||
|
||
// Define the output path for the new CSS file | ||
const fileBasename = basename(args.path); | ||
const fileDirname = dirname(args.path); | ||
const outputPath = path.resolve(fileDirname, `inverted-${fileBasename}`); | ||
const outputDir = path.dirname(outputPath); | ||
await fs.promises.mkdir(outputDir, { recursive: true }); | ||
// Write the new contents to the output file | ||
await fs.promises.writeFile(outputPath, invertedContents, "utf8"); | ||
|
||
// Return an empty result to esbuild since we're writing the file ourselves | ||
return { contents: "", loader: "css" }; | ||
}); | ||
}, | ||
}; |
This file contains 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 file contains 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 file contains 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
2 changes: 1 addition & 1 deletion
2
static/scripts/rewards/abis/daiAbi.ts → static/scripts/rewards/abis/erc20Abi.ts
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./daiAbi"; | ||
export * from "./erc20Abi"; | ||
export * from "./permit2Abi"; |
Oops, something went wrong.
057a657
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
057a657