Skip to content
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 web app support #49

Merged
merged 6 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added internal/assets/static/app-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions internal/assets/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,14 @@ body {
}
}

@media (display-mode: standalone) {
@supports (-webkit-touch-callout: none) {
.mobile-navigation {
bottom: 15px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an iPhone so I can't test this, however could we use something like this?

env(safe-area-inset-bottom, 20px);

Docs: https://developer.mozilla.org/en-US/docs/Web/CSS/env

If it works, it should provide a more flexible approach to offsetting the mobile navigation. Might require some extra work as well to get the "SHOW LESS" labels to also account for this offset since they get stickied to the bottom.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Now the safe-area variables are used, but because of this I went a little further since the way of hiding the page bar caused it to be exposed due to the offset, that's why I made some adjustments to compensate for it, I hope you don't mind. This is the final result:

iOS:

ios.mp4

Chrome:

chrome.mov

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into it! There's a high likelihood that more stuff will end up going there in the future so a static height that only accounts for the navigation links won't work. I've changed the implementation so that it can work with content of any height:

(fake navigation bar btw)

mobile-navigation.mp4

Let me know if this works and I'll get it merged.

}
}
}

.size-h1 { font-size: var(--font-size-h1); }
.size-h2 { font-size: var(--font-size-h2); }
.size-h3 { font-size: var(--font-size-h3); }
Expand Down
13 changes: 13 additions & 0 deletions internal/assets/static/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Glance",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{
"src": "/static/app-icon.png",
"type": "image/png",
"sizes": "512x512"
}
]
}
8 changes: 8 additions & 0 deletions internal/assets/templates/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<meta charset="UTF-8">
<meta name="color-scheme" content="dark">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Glance">
<meta name="theme-color" content="{{ if ne nil .App.Config.Theme.BackgroundColor }}{{ .App.Config.Theme.BackgroundColor }}{{ else }}hsl(240, 8%, 9%){{ end }}">
<link rel="apple-touch-icon" sizes="512x512" href="/static/app-icon.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/app-icon.png">
<link rel="manifest" href="/static/manifest.json">
<link rel="icon" type="image/png" href="/static/favicon.png" />
<link rel="stylesheet" href="/static/main.css?v={{ .App.Config.Server.StartedAt.Unix }}">
<script async src="/static/main.js?v={{ .App.Config.Server.StartedAt.Unix }}"></script>
Expand Down