-
Notifications
You must be signed in to change notification settings - Fork 0
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
393 changed files
with
3,595 additions
and
756 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>bundlephobia info</title> | ||
<!-- normalize --> | ||
<link rel="stylesheet" href="../../node_modules/normalize.css/normalize.css" /> | ||
<!-- global styles --> | ||
<link rel="stylesheet" href="../styles/global.css" /> | ||
<!-- main css --> | ||
<link rel="stylesheet" href="main.css" /> | ||
<script defer src="renderer.js"></script> | ||
</head> | ||
|
||
<body> | ||
<navbar-stack></navbar-stack> | ||
<main class="container"> | ||
<section class="app-glass"> | ||
<form id="bundlephobia-search"> | ||
<fieldset class="input-field col s12"> | ||
<input | ||
type="search" | ||
id="pkg-name" | ||
class="input-field-text" | ||
autocomplete="off" | ||
placeholder="enter a npm pkg name" | ||
required | ||
/> | ||
</fieldset> | ||
<fieldset class="input-field"> | ||
<button class="btn-submit full-btn" type="submit"> | ||
search pkg | ||
</button> | ||
</fieldset> | ||
</form> | ||
</section> | ||
|
||
<section class="glass module"> | ||
<h2 class="module-title"> | ||
<span id="module_name">no module</span> - <span id="module_ver"></span> | ||
</h2> | ||
|
||
<p id="module_description" class="module-description"> | ||
no description | ||
</p> | ||
|
||
<ul class="module-details"> | ||
<li> | ||
size: <span id="module_size"></span> | ||
</li> | ||
<li> | ||
gzip: <span id="module_gzip"></span> | ||
</li> | ||
</ul> | ||
|
||
<a id="module_repo" class="btn" href="#"> | ||
no repo | ||
</a> | ||
</section> | ||
</main> | ||
</body> | ||
|
||
</html> |
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 @@ | ||
.module { | ||
margin-block: 10px; | ||
padding: 12px; | ||
} | ||
|
||
.module-title { | ||
text-align: center; | ||
} | ||
|
||
.module-description {} | ||
|
||
.module-details { | ||
list-style: none; | ||
display: flex; | ||
justify-content: space-around; | ||
} | ||
|
||
.btn { | ||
all: unset; | ||
cursor: pointer; | ||
display: block; | ||
font-weight: bold; | ||
max-width: 100%; | ||
width: 96%; | ||
height: 2%; | ||
padding: 2px; | ||
border-radius: 15px; | ||
text-align: center; | ||
outline: 2px solid #00f; | ||
margin-inline: auto; | ||
} | ||
|
||
@media(hover: hover) { | ||
.btn:hover { | ||
background-color: #00f; | ||
color: #fff; | ||
text-decoration: underline; | ||
} | ||
} |
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,76 @@ | ||
// modules | ||
const { ipcRenderer, shell } = require('electron') | ||
const axios = require('axios') | ||
|
||
const toast = require('../scripts/toast') | ||
|
||
// DOM modules | ||
const form = document.querySelector('#bundlephobia-search') | ||
const pkgInput = document.querySelector('#pkg-name') | ||
const moduleName = document.querySelector('#module_name') | ||
const moduleVer = document.querySelector('#module_ver') | ||
const moduleDescription = document.querySelector('#module_description') | ||
const moduleSize = document.querySelector('#module_size') | ||
const moduleGzip = document.querySelector('#module_gzip') | ||
const moduleRepo = document.querySelector('#module_repo') | ||
|
||
// convert size | ||
const kilobyteConvert = size => ( | ||
size < 1024 ? `${size} B` : `${(size / 1024).toFixed(2)} KB` | ||
) | ||
|
||
// loaded | ||
document.addEventListener('DOMContentLoaded', () => { | ||
moduleVer.textContent = '0.0.0' | ||
moduleSize.textContent = kilobyteConvert(0) | ||
moduleGzip.textContent = kilobyteConvert(0) | ||
}); | ||
|
||
const bundlephobia = async () => { | ||
try { | ||
const { data } = await axios.get('https://bundlephobia.com/api/size', { | ||
params: { package: pkgInput.value } | ||
}); | ||
|
||
moduleName.textContent = data.name | ||
moduleVer.textContent = data.version | ||
moduleDescription.textContent = data.description | ||
moduleSize.textContent = kilobyteConvert(data.size) | ||
moduleGzip.textContent = kilobyteConvert(data.gzip) | ||
|
||
moduleRepo.textContent = `${data.name} repo` | ||
moduleRepo.href = data.repository | ||
moduleRepo.target = '_blank' | ||
} catch (err) { | ||
toast(err.message) | ||
} | ||
} | ||
|
||
// sumbit | ||
form.addEventListener('submit', e => { | ||
bundlephobia() | ||
|
||
e.preventDefault() | ||
form.reset() | ||
}) | ||
|
||
// open external browser | ||
moduleRepo.addEventListener('click', e => { | ||
if(e.target.href.startsWith('http')) { | ||
e.preventDefault() | ||
shell.openExternal(e.target.href) | ||
} | ||
}) | ||
|
||
// anime clear | ||
ipcRenderer.on('clear-stack', () => { | ||
moduleName.textContent = 'no module' | ||
moduleVer.textContent = '0.0.0' | ||
moduleDescription.textContent = 'no description' | ||
moduleSize.textContent = kilobyteConvert(0) | ||
moduleGzip.textContent = kilobyteConvert(0) | ||
|
||
moduleRepo.textContent = 'no repo' | ||
moduleRepo.href = '#' | ||
moduleRepo.removeAttribute('target') | ||
}) |
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
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
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.
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.