Skip to content

Commit

Permalink
Light app.css (#386)
Browse files Browse the repository at this point in the history
* light app css implementation

* update style

* update css
  • Loading branch information
maxence-charriere committed Apr 20, 2020
1 parent 9aed64e commit 43815bc
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 1 deletion.
147 changes: 147 additions & 0 deletions pkg/app/gen/app.light.css
@@ -0,0 +1,147 @@
/* Basics */

/* Loader and Not Found */
.app-wasm-layout {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}

.app-wasm-icon {
max-width: 100px;
max-height: 100px;
user-select: none;
margin: 0 6px;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none;
}

.app-wasm-label {
margin-top: 6px;
font-size: 16pt;
font-weight: 100;
letter-spacing: 1px;
max-width: 480px;
text-align: center;
text-transform: lowercase;
}

.app-notfound-title {
display: flex;
justify-content: center;
align-items: center;
font-size: 65pt;
font-weight: 100;
}

.app-spin {
animation: app-spin-frames 2.5s infinite linear;
}

@keyframes app-spin-frames {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}

/* Menu */
#app-contextmenu-background {
position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
left: 0;
top: 0;
z-index: 42000;
}

.app-contextmenu {
position: fixed;
min-width: 150px;
max-width: 480px;
padding: 6px 0;
border-radius: 6px;
border: solid 1px rgba(255, 255, 255, 0.1);
background-color: rgba(40, 38, 37, 0.97);
color: white;
-webkit-box-shadow: -1px 12px 38px 0px rgba(0, 0, 0, 0.6);
-moz-box-shadow: -1px 12px 38px 0px rgba(0, 0, 0, 0.6);
box-shadow: -1px 12px 38px 0px rgba(0, 0, 0, 0.6);
}

.app-contextmenu-hidden {
display: none;
}

.app-contextmenu-visible {
display: block;
}

@media (prefers-color-scheme: light) {
.app-contextmenu {
color: black;
background-color: rgba(221, 221, 221, 0.97);
border: solid 1px rgba(0, 0, 0, 0.2);
}
}

.app-menuitem {
display: flex;
align-items: center;
border: 0;
border-radius: 0;
margin: 0;
padding: 3px 24px;
width: 100%;
text-align: left;
background-color: transparent;
color: currentColor;
}

.app-menuitem:hover {
background-color: deepskyblue;
}

.app-menuitem:disabled {
opacity: 0.15;
background-color: transparent;
}

.app-menuitem-separator {
width: 100%;
height: 0;
margin: 6px 0;
border-top: solid 1px rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: light) {
.app-menuitem-separator {
border-top: solid 1px rgba(0, 0, 0, 0.2);
}
}

.app-menuitem-label {
user-select: none;
flex-grow: 1;
}

.app-menuitem-keys {
flex-grow: 0;
margin-left: 12px;
text-transform: capitalize;
}

.app-menuitem-icon {
width: 18px;
height: 18px;
margin-right: 12px;
}
1 change: 1 addition & 0 deletions pkg/app/gen/scripts.go
Expand Up @@ -38,6 +38,7 @@ func main() {
{Var: "appWorkerJS", Filename: "gen/app-worker.js"},
{Var: "manifestJSON", Filename: "gen/manifest.json"},
{Var: "appCSS", Filename: "gen/app.css"},
{Var: "appLightCSS", Filename: "gen/app.light.css"},
}

fmt.Fprintln(f, "const(")
Expand Down
10 changes: 9 additions & 1 deletion pkg/app/http.go
Expand Up @@ -100,6 +100,10 @@ type Handler struct {
// The page title.
Title string

// UseMinimalDefaultStyles makes app.css to adopt a minimal implementation
// that does not style the default HTML elements.
UseMinimalDefaultStyles bool

// The version number. This is used in order to update the PWA application
// in the browser. It must be set when deployed on a live system in order to
// prevent recurring updates.
Expand Down Expand Up @@ -389,7 +393,11 @@ func (h *Handler) initManifestJSON() {
}

func (h *Handler) initAppCSS() {
h.appCSS = []byte(appCSS)
css := appCSS
if h.UseMinimalDefaultStyles {
css = appLightCSS
}
h.appCSS = []byte(css)
}

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/scripts.go

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

0 comments on commit 43815bc

Please sign in to comment.