-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,217 additions
and
0 deletions.
There are no files selected for viewing
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,73 @@ | ||
{ | ||
"name": "hashlips-art-engine-app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@electron/remote": "^2.0.8", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/react": "^12.1.4", | ||
"@testing-library/user-event": "^13.5.0", | ||
"canvas": "^2.9.1", | ||
"electron-is-dev": "^2.0.0", | ||
"electron-squirrel-startup": "^1.0.0", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0", | ||
"react-icons": "^4.3.1", | ||
"react-scripts": "5.0.0", | ||
"react-sort-list": "^0.0.13", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"main": "public/electron.js", | ||
"homepage": "./", | ||
"author": "HashLips", | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject", | ||
"electron-dev": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"", | ||
"electron-pack": "electron-builder -c.extraMetadata.main=build/electron.js", | ||
"electron-pack-mac": "electron-builder --mac --x64 -c.extraMetadata.main=build/electron.js", | ||
"electron-pack-win": "electron-builder --win --x64 -c.extraMetadata.main=build/electron.js" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@electron-forge/cli": "^6.0.0-beta.63", | ||
"@electron-forge/maker-deb": "^6.0.0-beta.63", | ||
"@electron-forge/maker-rpm": "^6.0.0-beta.63", | ||
"@electron-forge/maker-squirrel": "^6.0.0-beta.63", | ||
"@electron-forge/maker-zip": "^6.0.0-beta.63", | ||
"concurrently": "^7.1.0", | ||
"electron": "^18.0.3", | ||
"electron-builder": "^23.0.3", | ||
"wait-on": "^6.0.1" | ||
}, | ||
"build": { | ||
"appId": "com.hashlips.ea", | ||
"icon": "build/icon.ico", | ||
"files": [ | ||
"build/**/*", | ||
"node_modules/**/*" | ||
], | ||
"directories": { | ||
"buildResources": "assets" | ||
} | ||
} | ||
} |
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,53 @@ | ||
const path = require("path"); | ||
const { app, BrowserWindow } = require("electron"); | ||
const isDev = require("electron-is-dev"); | ||
|
||
require("@electron/remote/main").initialize(); | ||
|
||
function createWindow() { | ||
// Create the browser window. | ||
const win = new BrowserWindow({ | ||
width: 1080, | ||
height: 720, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
enableRemoteModule: true, | ||
contextIsolation: false, | ||
webSecurity: false, | ||
}, | ||
}); | ||
|
||
require("@electron/remote/main").enable(win.webContents); | ||
|
||
// and load the index.html of the app. | ||
// win.loadFile("index.html"); | ||
win.loadURL( | ||
isDev | ||
? "http://localhost:3000" | ||
: `file://${path.join(__dirname, "../build/index.html")}` | ||
); | ||
// Open the DevTools. | ||
if (isDev) { | ||
win.webContents.openDevTools({ mode: "detach" }); | ||
} | ||
} | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.whenReady().then(createWindow); | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
// for applications and their menu bar to stay active until the user quits | ||
// explicitly with Cmd + Q. | ||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on("activate", () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); |
Binary file not shown.
Binary file not shown.
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,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="HashLips Art Engine is a tool used to create multiple different instances of artworks based on provided layers." | ||
/> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>HashLips Art Engine</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
}, | ||
{ | ||
"src": "logo192.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
}, | ||
{ | ||
"src": "logo512.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
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,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
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,39 @@ | ||
:root { | ||
--pink: #dc16d9; | ||
--yellow: #f2d21e; | ||
--grey: #2e2e2e; | ||
--white: #fdfdfd; | ||
--offWhite: #e6e6e6; | ||
} | ||
|
||
body { | ||
color: var(--white); | ||
background-color: var(--white); | ||
font-size: 16px; | ||
} | ||
|
||
.grid-container { | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
grid-template-rows: 50px 1fr 35px; | ||
|
||
grid-template-areas: | ||
"header" | ||
"main" | ||
"footer"; | ||
height: 150vh; | ||
} | ||
|
||
/* responsive layout */ | ||
@media only screen and (min-width: 750px) { | ||
.grid-container { | ||
display: grid; | ||
grid-template-columns: 240px 1fr; | ||
grid-template-rows: 50px 1fr 35px; | ||
grid-template-areas: | ||
"aside header" | ||
"aside main" | ||
"aside footer"; | ||
height: 100vh; | ||
} | ||
} |
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,126 @@ | ||
import { useEffect, useState } from "react"; | ||
import Header from "./components/Header"; | ||
import Aside from "./components/Aside"; | ||
import Main from "./components/Main"; | ||
import Footer from "./components/Footer"; | ||
import "./App.css"; | ||
|
||
const { app } = window.require("@electron/remote"); | ||
const fs = window.require("fs"); | ||
const path = window.require("path"); | ||
|
||
function App() { | ||
const [sideBarOpen, setSideBarOpen] = useState(false); | ||
const [config, setConfig] = useState({ | ||
supply: 5, | ||
name: "HashLips NFT", | ||
symbol: "HNFT", | ||
description: "This is a collection about...", | ||
width: 1024, | ||
height: 1024, | ||
baseUri: "ipfs://ReplaceCID", | ||
inputPath: app.getAppPath(), | ||
outputPath: app.getAppPath(), | ||
}); | ||
const [folderNames, setFolderNames] = useState([]); | ||
const [progress, setProgress] = useState(0); | ||
const [status, setStatus] = useState(""); | ||
|
||
const handleConfigChange = (event) => { | ||
console.log(event.target.name); | ||
setConfig({ ...config, [event.target.name]: event.target.value }); | ||
console.log(config); | ||
}; | ||
|
||
const toggleSideBar = () => { | ||
setSideBarOpen(!sideBarOpen); | ||
}; | ||
|
||
const getRarityWeight = (_str) => { | ||
let nameWithoutExtension = _str.slice(0, -4); | ||
var nameWithoutWeight = Number(nameWithoutExtension.split("$").pop()); | ||
if (isNaN(nameWithoutWeight)) { | ||
nameWithoutWeight = 1; | ||
} | ||
return nameWithoutWeight; | ||
}; | ||
|
||
const cleanName = (_str) => { | ||
let nameWithoutExtension = _str.slice(0, -4); | ||
var nameWithoutWeight = nameWithoutExtension.split("$").shift(); | ||
return nameWithoutWeight; | ||
}; | ||
|
||
const getElements = (_path) => { | ||
return fs | ||
.readdirSync(_path) | ||
.filter((item) => !/(^|\/)\.[^\/\.]/g.test(item)) | ||
.map((i, index) => { | ||
if (i.includes("-")) { | ||
setStatus(`Layer name can not contain dashes, please fix: ${i}`); | ||
throw new Error( | ||
`Layer name can not contain dashes, please fix: ${i}` | ||
); | ||
} | ||
return { | ||
id: index, | ||
name: cleanName(i), | ||
filename: i, | ||
path: `${_path}/${i}`, | ||
weight: getRarityWeight(i), | ||
}; | ||
}); | ||
}; | ||
|
||
const getFolders = async () => { | ||
fs.readdir(config.inputPath, (err, files) => { | ||
if (err) { | ||
setStatus("Unable to load the folder set"); | ||
return; | ||
} | ||
let newFiles = files | ||
.filter((item) => !/(^|\/)\.[^\/\.]/g.test(item)) | ||
.map((file, index) => { | ||
return { | ||
id: index + 1, | ||
elements: getElements(path.join(config.inputPath, file)), | ||
name: file, | ||
}; | ||
}); | ||
setFolderNames(newFiles); | ||
}); | ||
}; | ||
|
||
console.log(status); | ||
|
||
useEffect(() => { | ||
setStatus(""); | ||
}, [config, folderNames]); | ||
|
||
return ( | ||
<div className="grid-container"> | ||
<Header toggleSideBar={toggleSideBar} /> | ||
<Aside | ||
toggleSideBar={toggleSideBar} | ||
sideBarOpen={sideBarOpen} | ||
config={config} | ||
setConfig={setConfig} | ||
handleConfigChange={handleConfigChange} | ||
getFolders={getFolders} | ||
folderNames={folderNames} | ||
setFolderNames={setFolderNames} | ||
setProgress={setProgress} | ||
setStatus={setStatus} | ||
/> | ||
<Main | ||
config={config} | ||
folderNames={folderNames} | ||
progress={progress} | ||
status={status} | ||
/> | ||
<Footer /> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.