-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add all files #1
base: main
Are you sure you want to change the base?
Changes from 1 commit
61e7d36
96b36a2
3ee28eb
c398ea6
b9f092b
94dc553
f17982c
221f0b4
bed053f
9f075e6
7931232
692355e
d4b4678
75af4e5
c2f1060
b1ce200
a86be5a
6c5ade7
2a08027
a871d98
005fc8d
5284aa6
6e2a02f
da4e84a
ad8a394
bbc0357
b63449c
5566d6a
5dea12a
e54d5dc
a84a25a
6a38d35
728540c
8444cb5
95738ed
2c1e643
b813360
46deff2
f3ae26f
ab68d1a
f5f7136
48157b3
604a830
dde49b4
c6e6cc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Ekaterine (Catherine) Mitagvaria | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
![Fylo data storage component](https://github.com/catherineisonline/fylo-data-storage-component-frontendmentor/blob/main/images/project-preview.png?raw=true) | ||
|
||
|
||
<h1 align="center">Fylo data storage component</h1> | ||
|
||
<div align="center"> | ||
|
||
[Live](https://catherineisonline.github.io/fylo-data-storage-component-frontendmentor/) | ||
| [Solution](https://www.frontendmentor.io/solutions/fylo-data-storage-component-gpaJOs4EP) | ||
| [Challenge](https://www.frontendmentor.io/challenges/fylo-data-storage-component-1dZPRbV5n) | ||
|
||
Solution for a challenge from [frontendmentor.io](https://www.frontendmentor.io/) | ||
</div> | ||
|
||
|
||
|
||
## About The Project | ||
|
||
This component has some interesting CSS challenges in the design. If you're looking to test your CSS skills, this will be a great project for you! | ||
The main challenge is to build out this data storage component and get it looking as close to the design as possible. | ||
You can use any tools you like to help you complete the challenge. So if you've got something you'd like to practice, feel free to give it a go. | ||
|
||
Your users should be able to: | ||
1. View the optimal layout depending on their device's screen size</p> | ||
|
||
I do not have access to the Figma sketch so the design is not pixel perfect.</p> | ||
|
||
|
||
|
||
|
||
## Built with | ||
|
||
- Semantic HTML5 markup | ||
- CSS custom properties | ||
- Grid | ||
- Desktop-first workflow | ||
|
||
## What I learned | ||
|
||
This project helped me to practice some grid as it's a little difficult for me to make the grid responsive. My goal is to make grid change from 1 row to 2 rows without using media query however I lack enough experience in this. I decided to finish this project as it is and deepen my knowledge of the grid in another project that I plan to make, specifically - a photography portfolio website. | ||
|
||
|
||
## Useful resources | ||
|
||
1. [Figma](https://www.figma.com/) - Paste your design image to check the size of containers, width, etc. | ||
2. [Perfect Pixel](https://chrome.google.com/webstore/detail/perfectpixel-by-welldonec/dkaagdgjmgdmbnecmcefdhjekcoceebi) - Awesome Chrome extension that helps you to match the pixels of the provided design. | ||
|
||
## Acknowledgments | ||
|
||
A big thank you to anyone providing feedback on my [solution](https://www.frontendmentor.io/solutions/fylo-data-storage-component-gpaJOs4EP). It definitely helps to find new ways to code and find easier solutions! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="description" content="Frontend Mentor - Fylo data storage component"> | ||
<meta name="keywords" content="Fylo data storage component, Frontend Mentor"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link href="styles.css" rel="stylesheet"> | ||
</link> | ||
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png"> | ||
<title>Fylo data storage component</title> | ||
</head> | ||
|
||
<body> | ||
<main> | ||
<!--Fylo Container --> | ||
<section class="fylo-container"> | ||
<img class="logo" src="images/logo.svg" alt="Fylo logo" /> | ||
<section class="icons"> | ||
<div class="icon-img"> | ||
<img src="images/icon-document.svg" alt="" aria-hidden="true" /> | ||
</div> | ||
<div class="icon-img"> | ||
<img src="images/icon-folder.svg" alt="" aria-hidden="true" /> | ||
</div> | ||
<div class="icon-img"> | ||
<img src="images/icon-upload.svg" alt="" aria-hidden="true" /> | ||
</div> | ||
<button type="button" class="icon-img" onclick="openFile()"> | ||
<strong>Upload Image</strong> | ||
</button> | ||
<input type="file" id="fileInput" accept=".jpg, .jpeg, .gif, .png" onchange="fileSelection()" multiple> | ||
</section> | ||
</section> | ||
<!-- Storage Container --> | ||
<section class="storage-container"> | ||
<h1>You've used <span id="usedStorage">0 MB</span> of your storage</h1> | ||
<!-- Progress Bar --> | ||
<section class="progress-bar"> | ||
<div class="gradient-bar"> | ||
<div id="progressDot" class="dot-container"> | ||
<div class="dot"></div> | ||
</div> | ||
</div> | ||
</section> | ||
<h2> | ||
<span id="minStorage">0 MB</span> | ||
<span id="maxStorage">15 MB</span> | ||
</h2> | ||
<!-- GB left --> | ||
<section class="gb-left"> | ||
<p id="mbLeft">15 <span>MB left</span></p> | ||
</section> | ||
</section> | ||
</main> | ||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
var totalSizeLimit = 15; // 15 MB maximum | ||
var totalUploadedSize = 0; // aggregated size of all files uploaded in bytes | ||
|
||
function openFile() { | ||
document.getElementById('fileInput').click(); // opens the Finder/File Explorer | ||
} | ||
|
||
function fileSelection() { | ||
var selectedFiles = document.getElementById('fileInput').files; | ||
var validFiles = [".png", ".jpg", ".gif", ".jpeg"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A more elegant solution utilizes regular expressions (regex). For instance, consider the following example employing regex: (/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i).test(filename) This approach efficiently checks if the filename has any of the specified image file extensions, enhancing code readability and conciseness. |
||
|
||
for (var i = 0; i < selectedFiles.length; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using a for loop, utilize the forEach function on the array. |
||
var selectedFile = selectedFiles[i]; | ||
var filesFormat = selectedFile.name.split('.').pop().toLowerCase(); // split the files extensions by "." (.jpg, .jpeg ...) | ||
|
||
if (validFiles.indexOf('.' + filesFormat) === -1) { | ||
alert("File format isn't supported: " + selectedFile.name); | ||
} else { | ||
var fileSize = selectedFile.size; | ||
var remainingStorage = totalSizeLimit - (totalUploadedSize / (1024 * 1024)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if u are gonna use a lot in files size make a consts in the top of the code const GB = 1024 * 1024 * 1024;
const MB = 1024 * 1024;
const KB = 1024; and then it looks like this: (totalUploadedSize / MB) |
||
|
||
if (fileSize / (1024 * 1024) > remainingStorage) { // (fileSize / (1024 * 1024)) -> convert to MB | ||
alert("There is not enough space on the disk"); | ||
return; | ||
} | ||
totalUploadedSize += fileSize; | ||
} | ||
} | ||
updateProgressBar(); | ||
updateUploadedStorage(); | ||
} | ||
|
||
function updateProgressBar() { | ||
|
||
var progressBar = document.querySelector('.gradient-bar'); | ||
var progressDot = document.getElementById('progressDot'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove if it not used |
||
var mbLeft = document.getElementById('mbLeft'); | ||
var percentageCalc = (totalUploadedSize / (totalSizeLimit * 1024 * 1024)) * 100; // (totalSizeLimit * 1024 * 1024) convert from MB to bytes and multiply by 100 to convert to a percentage | ||
progressBar.style.width = percentageCalc + '%'; | ||
var remainingStorage = totalSizeLimit - (totalUploadedSize / (1024 * 1024)); | ||
mbLeft.textContent = remainingStorage.toFixed(2) + ' MB LEFT'; | ||
} | ||
|
||
function updateUploadedStorage() { | ||
var usedStorageElement = document.getElementById('usedStorage'); | ||
var uploadedSizeInMB = totalUploadedSize / (1024 * 1024); // convert bytes to MB | ||
usedStorageElement.textContent = uploadedSizeInMB.toFixed(2) + ' MB'; | ||
} | ||
|
||
// place the progress bar at starting point | ||
window.onload = function () { | ||
updateProgressBar(); | ||
} |
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.
Why didn't you utilize the
onclick
attribute of the element?