Skip to content

Commit

Permalink
tauri styling issues, download files
Browse files Browse the repository at this point in the history
  • Loading branch information
mathis committed Oct 4, 2023
1 parent afdc728 commit 28e5999
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 32 deletions.
30 changes: 19 additions & 11 deletions client/src/ui/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,32 @@ import type { WebSocketServer } from '../../server/server'
import type { MapCreation, MapDetail } from '../../server/protocol'
import * as MapDir from '../../twmap/mapdir'
import { QuadsLayer } from '../../twmap/quadsLayer'
import { clearDialog, showInfo } from './dialog'

export type Ctor<T> = new (...args: any[]) => T

export type FormEvent<T> = Event & { currentTarget: EventTarget & T }
export type FormInputEvent = FormEvent<HTMLInputElement>

export async function download(file: string, name: string) {
const resp = await fetch(file)
const data = await resp.blob()
const url = URL.createObjectURL(data)

const link = document.createElement('a')
link.href = url
link.download = name

document.body.append(link)
link.click()
link.remove()
const id = showInfo(`Downloading '${name}'…`, 'none')
try {
const resp = await fetch(file)
const data = await resp.blob()
const url = URL.createObjectURL(data)

const link = document.createElement('a')
link.href = url
link.download = name

document.body.append(link)
link.click()
link.remove()
showInfo(`Downloaded '${name}'.`)
}
finally {
clearDialog(id)
}
}

export async function uploadMap(httpRoot: string, name: string, file: Blob) {
Expand Down
6 changes: 3 additions & 3 deletions client/src/ui/routes/lobby.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@
<Tile>
<p>
Teeworlds Web Editor is a multiplayer map editor for
<a href="https://ddnet.org/">DDRaceNetwork</a>
<a target="_blank" rel="noreferrer" href="https://ddnet.org/">DDRaceNetwork</a>
, a flavour of
<a href="https://www.teeworlds.com/">Teeworlds</a>
<a target="_blank" rel="noreferrer" href="https://www.teeworlds.com/">Teeworlds</a>
.
</p>
<p>
The project is currently in beta, expect some bugs and missing features! Please report
your bugs and make suggestions on the
<a href="https://github.com/k2d222/twwe/issues">GitHub issues page</a>
<a target="_blank" rel="noreferrer" href="https://github.com/k2d222/twwe/issues">GitHub issues page</a>
. Have fun!
</p>
</Tile>
Expand Down
15 changes: 10 additions & 5 deletions client/styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
text-overflow: ellipsis;
overflow: hidden;
background-color: #f2f2f2;
height: 2rem;

outline: 1px solid #aaaaaa;
outline-offset: -1px;
Expand Down Expand Up @@ -760,9 +761,14 @@ nav.hidden .context {
flex-direction: row;
gap: 1rem;

> :nth-child(3) {
>.channels {
flex-grow: 1;
}

.buttons {
display: flex;
gap: 1rem;
}
}

.graph {
Expand Down Expand Up @@ -807,14 +813,13 @@ nav.hidden .context {

.channels {
display: flex;
// gap: .5rem;
align-items: center;

label {
position: relative;
display: block;
width: 1.5rem;
height: 1.5rem;
width: 2rem;
height: 2rem;
user-select: none;

&.red span {
Expand Down Expand Up @@ -863,7 +868,7 @@ nav.hidden .context {
position: absolute;
inset: 0;
text-align: center;
padding: 0.25rem;
padding: 0.6rem;
}
}
}
Expand Down
96 changes: 86 additions & 10 deletions desktop/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.4.0", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.4.0", features = [] }
tauri = { version = "1.4.0", features = [ "shell-open", "fs-all"] }
twwe-server = { path = "../server" }
tokio = "1.32.0"
platform-dirs = "0.3.0"
Expand Down
10 changes: 8 additions & 2 deletions desktop/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
},
"tauri": {
"allowlist": {
"all": false
"all": false,
"fs": {
"all": true
},
"shell": {
"open": true
}
},
"bundle": {
"active": true,
Expand Down Expand Up @@ -62,4 +68,4 @@
}
]
}
}
}

0 comments on commit 28e5999

Please sign in to comment.