Skip to content

Commit

Permalink
chore: yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Apr 13, 2024
1 parent 7b1a2fd commit 1081118
Show file tree
Hide file tree
Showing 25 changed files with 298 additions and 372 deletions.
130 changes: 40 additions & 90 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,31 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./tsconfig.json"
],
"project": ["./tsconfig.json"]
},
"plugins": [
"@typescript-eslint",
"sonarjs"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:sonarjs/recommended"
],
"ignorePatterns": [
"**/*.js"
],
"plugins": ["@typescript-eslint", "sonarjs"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"],
"ignorePatterns": ["**/*.js"],
"rules": {
"prefer-arrow-callback": [
"warn",
{
"allowNamedFunctions": true,
},
"allowNamedFunctions": true
}
],
"func-style": [
"warn",
"declaration",
{
"allowArrowFunctions": false,
},
"allowArrowFunctions": false
}
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": [
"error"
],
"no-restricted-syntax": [
"error",
"ForInStatement"
],
"@typescript-eslint/no-invalid-this": ["error"],
"no-restricted-syntax": ["error", "ForInStatement"],
"use-isnan": "error",
"@typescript-eslint/no-unused-vars": [
"error",
Expand All @@ -51,8 +35,8 @@
"ignoreRestSiblings": true,
"vars": "all",
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
},
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-misused-new": "error",
Expand All @@ -67,96 +51,62 @@
"error",
{
"selector": "interface",
"format": [
"PascalCase"
],
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": false,
},
"match": false
}
},
{
"selector": "memberLike",
"modifiers": [
"private"
],
"format": [
"camelCase"
],
"leadingUnderscore": "require",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": "typeLike",
"format": [
"PascalCase"
],
"format": ["PascalCase"]
},
{
"selector": "typeParameter",
"format": [
"PascalCase"
],
"prefix": [
"T"
],
"format": ["PascalCase"],
"prefix": ["T"]
},
{
"selector": "variable",
"format": [
"camelCase",
"UPPER_CASE"
],
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "variable",
"format": [
"camelCase"
],
"format": ["camelCase"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "variable",
"modifiers": [
"destructured"
],
"format": null,
"modifiers": ["destructured"],
"format": null
},
{
"selector": "variable",
"types": [
"boolean"
],
"format": [
"PascalCase"
],
"prefix": [
"is",
"should",
"has",
"can",
"did",
"will",
"does"
],
"types": ["boolean"],
"format": ["PascalCase"],
"prefix": ["is", "should", "has", "can", "did", "will", "does"]
},
{
"selector": "variableLike",
"format": [
"camelCase"
],
"format": ["camelCase"]
},
{
"selector": [
"function",
"variable"
],
"format": [
"camelCase"
],
"selector": ["variable"],
"format": ["camelCase"]
},
],
},
}
{
"selector": ["function"],
"format": ["camelCase", "PascalCase"]
}
]
}
}
2 changes: 0 additions & 2 deletions app/components/commit-hash.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useEffect, useState } from "react";

export function CommitHashDisplay() {
const commitHash = process.env.COMMIT_HASH;

Expand Down
100 changes: 55 additions & 45 deletions app/components/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function GridBackground() {
}

// Create canvas and WebGL context
node.appendChild(canvas);
node?.appendChild(canvas);

// Enable alpha blending
gl.enable(gl.BLEND);
Expand Down Expand Up @@ -131,63 +131,73 @@ export function GridBackground() {
gl.enableVertexAttribArray(positionAttributeLocation);
gl.vertexAttribPointer(positionAttributeLocation, 2, gl.FLOAT, false, 0, 0);

// Resize function
function resizeCanvasToDisplaySize(canvas: HTMLCanvasElement) {
// Lookup the size the browser is displaying the canvas.
const displayWidth = window.innerWidth;
const displayHeight = window.innerHeight;

// Check if the canvas is not the same size.
if (canvas.width != displayWidth || canvas.height != displayHeight) {
// Make the canvas the same size
canvas.width = displayWidth;
canvas.height = displayHeight;
// Start the render loop
render(canvas, gl, timeUniformLocation, resolutionUniformLocation);

// Update WebGL viewport to match
gl.viewport(0, 0, canvas.width, canvas.height);
}
}
window.addEventListener("resize", handleResize.bind(null, canvas, gl));
document.body.classList.add("grid-loaded");

// Render function
function render() {
if (!canvas) return;
if (!gl) return;
return () => {
window.removeEventListener("resize", handleResize.bind(null, canvas, gl));
};
}, []);

resizeCanvasToDisplaySize(canvas); // Check and update canvas size each frame
function handleResize(canvas: HTMLCanvasElement, gl: WebGLRenderingContext) {
if (!canvas) return;
if (!gl) return;

// Update resolution uniform
gl.uniform2f(resolutionUniformLocation, canvas.width, canvas.height);
canvas.width = window.innerWidth * devicePixelRatio;
canvas.height = window.innerHeight * devicePixelRatio;
// Update WebGL viewport and possibly other uniforms here...
gl.viewport(0, 0, canvas.width, canvas.height);
}

gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
function resizeCanvasToDisplaySize(canvas: HTMLCanvasElement, gl: WebGLRenderingContext) {
if (!canvas) return;
if (!gl) return;

// Update time uniform
gl.uniform1f(timeUniformLocation, performance.now() / 1000.0);
// Lookup the size the browser is displaying the canvas.
const displayWidth = window.innerWidth;
const displayHeight = window.innerHeight;

// Draw
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
// Check if the canvas is not the same size.
if (canvas.width != displayWidth || canvas.height != displayHeight) {
// Make the canvas the same size
canvas.width = displayWidth;
canvas.height = displayHeight;

// Request next frame
requestAnimationFrame(render);
// Update WebGL viewport to match
gl.viewport(0, 0, canvas.width, canvas.height);
}
}

// Render function
function render(
canvas: HTMLCanvasElement,
gl: WebGLRenderingContext,
timeUniformLocation: WebGLUniformLocation,
resolutionUniformLocation: WebGLUniformLocation
) {
if (!canvas) return;
if (!gl) return;

// Start the render loop
render();
resizeCanvasToDisplaySize(canvas, gl); // Check and update canvas size each frame

const handleResize = () => {
canvas.width = window.innerWidth * devicePixelRatio;
canvas.height = window.innerHeight * devicePixelRatio;
// Update WebGL viewport and possibly other uniforms here...
gl.viewport(0, 0, canvas.width, canvas.height);
};
// Update resolution uniform
gl.uniform2f(resolutionUniformLocation, canvas.width, canvas.height);

window.addEventListener("resize", handleResize);
document.body.classList.add("grid-loaded");
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);

return () => {
window.removeEventListener("resize", handleResize);
};
}, []);
// Update time uniform
gl.uniform1f(timeUniformLocation, performance.now() / 1000.0);

// Draw
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);

// Request next frame
requestAnimationFrame(render.bind(null, canvas, gl, timeUniformLocation, resolutionUniformLocation));
}

return (
<div id="background">
Expand Down
20 changes: 10 additions & 10 deletions app/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export function Icon({ name }: { name: string }) {
export function Icon({ name, className }: { name: string; className?: string }) {
switch (name) {
case "opener":
return opener();
return opener(className);
case "closer":
return closer();
return closer(className);
case "claimLoader":
return claimLoader();
case "makeClaim":
Expand All @@ -21,17 +21,17 @@ export function Icon({ name }: { name: string }) {
}
}

function opener() {
function opener(className: string | undefined) {
return (
<svg className="closer" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path d="M356-173.847 313.847-216 480-382.153 646.153-216 604-173.847l-124-124-124 124Zm124-404L313.847-744 356-786.153l124 124 124-124L646.153-744 480-577.847Z" />
<svg className={className} xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path d="M480-134.616 313.078-301.539l43.383-43.383L480-221.384l123.539-123.538 43.383 43.383L480-134.616Zm-123.539-478L313.078-656 480-822.922 646.922-656l-43.383 43.384L480-736.155 356.461-612.616Z"></path>
</svg>
);
}

function closer() {
function closer(className: string | undefined) {
return (
<svg className="closer" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<svg className={className} xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path d="M356-173.847 313.847-216 480-382.153 646.153-216 604-173.847l-124-124-124 124Zm124-404L313.847-744 356-786.153l124 124 124-124L646.153-744 480-577.847Z" />
</svg>
);
Expand Down Expand Up @@ -73,8 +73,8 @@ function viewClaim() {

function invalidator() {
return (
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24" id="link-icon">
<path d="M212.309-140.001q-30.308 0-51.308-21t-21-51.308v-535.382q0-30.308 21-51.308t51.308-21h252.305V-760H212.309q-4.616 0-8.463 3.846-3.846 3.847-3.846 8.463v535.382q0 4.616 3.846 8.463 3.847 3.846 8.463 3.846h535.382q4.616 0 8.463-3.846 3.846-3.847 3.846-8.463v-252.305h59.999v252.305q0 30.308-21 51.308t-51.308 21H212.309Zm176.46-206.615-42.153-42.153L717.847-760H560v-59.999h259.999V-560H760v-157.847L388.769-346.616Z" />
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path d="M256-213.847 213.847-256l224-224-224-224L256-746.153l224 224 224-224L746.153-704l-224 224 224 224L704-213.847l-224-224-224 224Z"></path>
</svg>
);
}
Expand Down
Loading

0 comments on commit 1081118

Please sign in to comment.