Skip to content

An open-source cross-platform alternative to AirDrop

Web UI styles added and small fixes (#388)

Gabriel Lima7e5e4c47ad0f
diff --git a/README.md b/README.md
index bd4cefd1..d91547ee 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@ You can help translating this app to other languages!
### Bug fixes and improvements
- **Bug Fixes:** If you find a bug, please create a pull request with a clear description of the issue and how to fix it.
-- **Improvements:** Have an idea for how to improve LocalSend? Please create an issue first so we can discuss why the improvement is needed.
+- **Improvements:** Have an idea for how to improve LocalSend? Please create an issue first, so we can discuss why the improvement is needed.
For more information, see the [contributing guide](https://github.com/localsend/localsend/blob/main/CONTRIBUTING.md).
@@ -175,6 +175,6 @@ Feel free to open a pull request. There is a `snap` branch to play with.
## Contributors
-<a align="center" href="https://github.com/localsend/localsend/graphs/contributors">
- <img src="https://contrib.rocks/image?repo=localsend/localsend" />
+<a href="https://github.com/localsend/localsend/graphs/contributors">
+ <img src="https://contrib.rocks/image?repo=localsend/localsend" alt="Localsend Contributors"/>
</a>
diff --git a/assets/web/index.html b/assets/web/index.html
index f104d303..04464af9 100644
--- a/assets/web/index.html
+++ b/assets/web/index.html
@@ -6,22 +6,172 @@
<title>LocalSend</title>
<script src="main.js"></script>
<style>
- table, th, td {
- border: 1px solid black;
- border-collapse: collapse;
+ :root {
+ --gray: rgb(236, 240, 241);
+ --black: rgb(38, 38, 38);
+ --teal: rgb(38,166,154);
+ --p-1: 1rem;
+ --p-2: 2rem;
}
- th, td {
- padding: 10px;
+ html {
+ font-family: sans-serif, system-ui;
+ color: var(--black);
+ height: 100%;
+ font-size: 16px;
}
- .size-cell {
- white-space: nowrap;
+ body {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ line-height: 1.5;
+ align-items: center;
}
a {
text-decoration: none;
}
+
+ a:link {
+ color: blue;
+ }
+
+ *,
+ *::before,
+ *::after {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ font-family: inherit;
+ border: 0;
+ outline: 0;
+ color: inherit;
+ }
+
+ #file-list {
+ padding: var(--p-2);
+ min-width: 50vw;
+ width: fit-content;
+ }
+
+ .size-cell {
+ background-color: var(--teal);
+ white-space: nowrap;
+ }
+
+ .filesTable {
+ border-collapse: collapse;
+ width: 100%;
+ border: 1px solid;
+ }
+
+ .filesTable tr th {
+ padding: 5px;
+ }
+
+
+ .filesTable tr td {
+ padding: 5px;
+ text-align: center;
+ font-weight: 500;
+ word-wrap: break-word;
+ max-width: 75vw;
+ }
+
+ .filesTable tr th:not(:first-of-type) {
+ width: calc(100% / 8);
+ }
+
+ .filesTable tbody tr:nth-of-type(2n + 2) {
+ background-color: var(--gray);
+ }
+
+ @media (max-width: 1124px) {
+ #file-list {
+ width: 100%;
+ }
+
+ .filesTable {
+ margin-left: -10px;
+ border: 0;
+ }
+
+ a::after {
+ content: "(" attr(sizeData) ")";
+ }
+
+ .size-cell {
+ display: none;
+ }
+
+ .filesTable thead {
+ display: none;
+ }
+
+ .filesTable tbody {
+ display: flex;
+ flex-wrap: wrap;
+ }
+
+ .filesTable tbody tr {
+ display: flex;
+ flex-direction: column;
+ margin-top: 10px;
+ width: calc(50% - 10px);
+ margin-left: 10px;
+ }
+
+ .filesTable tr {
+ border-radius: 5px !important;
+ }
+
+ .filesTable tr td {
+ border: 1px solid var(--gray);
+ }
+
+ .filesTable tbody tr td {
+ padding: 5px 10px !important;
+ text-align: right !important;
+ position: relative;
+ height: 100%;
+ }
+
+ .filesTable tbody tr td:before {
+ position: absolute;
+ left: 5px;
+ content: "";
+ width: 100px;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ top: 0;
+ background-repeat: no-repeat;
+ background-size: contain;
+ background-position: left;
+ }
+
+ .filesTable tbody tr:nth-of-type(2n + 2) {
+ background-color: transparent;
+ }
+ }
+
+ @media (max-width: 768px) {
+ .filesTable {
+ margin-left: 0;
+ border: 0;
+ }
+
+ .filesTable tr td {
+ max-width: 90vw;
+ }
+
+ .filesTable tbody tr {
+ width: 100%;
+ margin-left: 0;
+ }
+ }
</style>
</head>
<body>
@@ -29,7 +179,7 @@
This site requires JavaScript. I will only be visible if you have it disabled.
</noscript>
-<h1>LocalSend</h1>
+<h1 style="padding: var(--p-1)">LocalSend</h1>
<p id="status-text"></p>
<div id="file-list"></div>
diff --git a/assets/web/main.js b/assets/web/main.js
index 351e98b2..62376d6b 100644
--- a/assets/web/main.js
+++ b/assets/web/main.js
@@ -26,18 +26,18 @@ async function requestFiles() {
document.getElementById('status-text').innerText = `${i18n.files} (${Object.keys(data.files).length})`;
document.getElementById('file-list').innerHTML = `
- <table>
+ <table class="filesTable">
<thead>
<tr>
<th>${i18n.fileName}</th>
- <th>${i18n.size}</th>
+ <th class="size-cell">${i18n.size}</th>
</tr>
</thead>
<tbody>
${Object.keys(files).map((key) => `
<tr>
<td>
- <a href="${BASE_URL}/receive?sessionId=${sessionId}&fileId=${key}" target="_blank">
+ <a sizeData="${formatBytes(files[key].size)}" href="${BASE_URL}/receive?sessionId=${sessionId}&fileId=${key}" target="_blank">
${files[key].fileName}
</a>
</td>
diff --git a/lib/util/user_agent_analyzer.dart b/lib/util/user_agent_analyzer.dart
index 3b3e4ad4..33ce6fe4 100644
--- a/lib/util/user_agent_analyzer.dart
+++ b/lib/util/user_agent_analyzer.dart
@@ -22,15 +22,15 @@ class UserAgentAnalyzer {
String? getOS(String userAgent) {
print(userAgent);
- if (userAgent.contains("Windows")) {
+ if (userAgent.contains("Win")) {
return "Windows";
} else if (userAgent.contains("Android")) {
return "Android";
- } else if (userAgent.contains("Macintosh") || userAgent.contains("Mac OS")) {
+ } else if (userAgent.contains("Macintosh")) {
return "macOS";
} else if (userAgent.contains("iPhone") || userAgent.contains("iPad") || userAgent.contains("iPod")) {
return "iOS";
- } else if (userAgent.contains("Linux")) {
+ } else if (userAgent.contains("X11")) {
return "Linux";
} else {
return null;