Skip to content

Commit

Permalink
Merge pull request #2 from ambercaravalho/design-updates
Browse files Browse the repository at this point in the history
design updates to main; add CSS styling to all elements and add favicons
  • Loading branch information
ambercaravalho authored Oct 6, 2024
2 parents 26e5280 + 8b7cee0 commit 37cddef
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Deploy drand-passgen files to GitHub Pages](https://github.com/ambercaravalho/drand-passgen/actions/workflows/static-html-deployment.yml/badge.svg)](https://github.com/ambercaravalho/drand-passgen/actions/workflows/static-html-deployment.yml)

![Homepage Screenshot](homepage-screenshot.png)
![Homepage Screenshot](src/homepage-screenshot.png)

<div align="center">

Expand Down
Binary file removed homepage-screenshot.png
Binary file not shown.
21 changes: 20 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

<!-- stylesheet -->
<link rel="stylesheet" href="styles.css">

<!-- viewport tag for mobile responsiveness -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- favicon references -->
<link rel="icon" type="image/png" href="/src/favicon-48x48.png" sizes="48x48" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<link rel="shortcut icon" href="/src/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/src/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="PassGen" />
<link rel="manifest" href="/src/site.webmanifest" />
</head>

<body>
Expand All @@ -29,9 +40,17 @@ <h1>drand Password Generator</h1>
<!-- generated password display -->
<div class="result">
<h2>Your Password:</h2>
<p id="password"></p>
<div class="password-container">
<p id="password" class="hint">Your password will appear here</p>
<button id="copyButton" title="Copy Password">Copy</button>
</div>
</div>

<!-- Footer with placeholder links -->
<footer>
<p>Made by Amber Caravalho with 💖 | <a href="https://ambercaravalho.com">My Website</a> | <a href="https://github.com/ambercaravalho/drand-passgen">About This Project ↗️</a></p>
</footer>

<!-- javascript -->
<script src="script.js"></script>
</body>
Expand Down
30 changes: 30 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,39 @@ document.addEventListener('DOMContentLoaded', function() {

// display the generated password
passwordDisplay.textContent = passwordArray.join('');

// Remove the hint styling class
passwordDisplay.classList.remove('hint');
}

/**
* Function to copy the password to the clipboard.
*/
function copyPassword() {
const password = passwordDisplay.textContent;
if (password && !passwordDisplay.classList.contains('hint')) {
// create a temporary textarea element to select the text
const textarea = document.createElement('textarea');
textarea.value = password;
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand('copy');
alert('Password copied to clipboard!');
} catch (err) {
console.error('Failed to copy password:', err);
alert('Failed to copy password.');
}
document.body.removeChild(textarea);
} else {
alert('Nothing to copy. Please generate a password first.');
}
}

// run the password generation function when the button is clicked
generateButton.addEventListener('click', generatePassword);

// Add event listener to the copy button
copyButton.addEventListener('click', copyPassword);

});
Binary file added src/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/favicon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions src/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/homepage-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "drand PassGen",
"short_name": "PassGen",
"icons": [
{
"src": "/src/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/src/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Binary file added src/web-app-manifest-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/web-app-manifest-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
166 changes: 162 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,182 @@
/* reset default styles for consistency across browsers */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

/* default body styling */
body {
font-family: Arial, sans-serif;
margin: 20px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
text-align: center;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
}

/* main heading styling */
h1 {
margin-bottom: 30px;
font-size: 3em;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* options container styling */
.options {
background-color: rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
max-width: 400px;
width: 100%;
margin: 0 auto 20px auto;
}

/* labels and input styling */
.options label {
display: block;
display: flex;
align-items: center;
margin: 10px 0;
font-size: 1em;
}

.options input[type="number"] {
width: 100%;
padding: 8px;
margin-bottom: 15px;
border-radius: 5px;
border: none;
font-size: 1em;
}

/* checkbox styling */
.options input[type="checkbox"] {
margin-right: 10px;
}

/* generate button styling */
button#generate {
background-color: #ffcc00;
color: #333;
border: none;
padding: 15px 30px;
border-radius: 50px;
font-size: 1.25em;
font-weight: bold;
cursor: pointer;
margin-top: 20px;
transition: background-color 0.3s;
}

button#generate:hover {
background-color: #ffdb4d;
}

/* result display styling */
.result {
background-color: rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 10px;
max-width: 500px;
width: 100%;
margin: 0 auto;
word-break: break-all;
}

.result h2 {
margin-bottom: 10px;
font-size: 1.5em;
}

/* password container styling */
.password-container {
display: flex;
align-items: center;
justify-content: center;
}

.password-container p {
margin-right: 10px;
word-break: break-all;
flex-grow: 1;
text-align: center;
font-size: 1.25em;
}

button {
/* copy button styling */
#copyButton {
background-color: #ffcc00;
color: #333;
border: none;
padding: 10px 20px;
border-radius: 50px;
font-size: 1em;
cursor: pointer;
transition: background-color 0.3s;
}

#copyButton:hover {
background-color: #ffdb4d;
}

/* hint styling */
.hint {
font-style: italic;
color: #ddd;
}

/* footer styling */
footer {
margin-top: auto;
padding: 20px 0;
background-color: rgba(0, 0, 0, 0.1);
}

footer p {
font-size: 0.9em;
}

footer a {
color: #ffcc00;
text-decoration: none;
margin: 0 5px;
}

footer a:hover {
text-decoration: underline;
}

/* mobile responsive design */
@media (max-width: 600px) {
body {
padding: 10px;
}

h1 {
font-size: 2em;
margin-bottom: 10px;
}

.options, .result {
padding: 15px;
font-size: 1em;
}

button#generate, #copy {
width: 100%;
margin-top: 10px;
}

.password-container {
flex-direction: column;
align-items: stretch;
}

.password-container p {
margin-bottom: 10px;
margin-right: 0;
}
}

0 comments on commit 37cddef

Please sign in to comment.