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

refactor(cli): optimize default templates #1214

Merged
merged 7 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ func (a *App) shutdown(ctx context.Context) {

// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s!", name)
return fmt.Sprintf("Hello %s, It's show time!", name)
}

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/main.css" />
</head>

<head>
<link rel="stylesheet" href="/main.css">
</head>

<body data-wails-drag>
<div class="logo"></div>
<div class="result" id="result">Please enter your name below 👇</div>
<div class="input-box" id="input" data-wails-no-drag>
<input class="input" id="name" type="text" autocomplete="off">
<button class="btn" onclick="greet()">Greet</button>
</div>

<script src="/main.js"></script>
</body>

</html>
<body>
<div id="app" class="app">
<div class="logo"></div>
<div class="result" id="result">Please enter your name below 👇</div>
<div class="input-box" id="input">
<input class="input" id="name" type="text" autocomplete="off" />
<button class="btn" onclick="greet()">Greet</button>
</div>
</div>
<script src="/main.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
html {
background-color: rgba(33, 37, 43, 1);
background-color: rgba(27, 38, 54, 1);
text-align: center;
color: white;
}
Expand All @@ -20,15 +20,22 @@ body {
url("assets/fonts/nunito-v16-latin-regular.woff2") format("woff2");
}

#app {
height: 100vh;
text-align: center;
}

.logo {
display: block;
width: 35%;
height: 35%;
width: 50%;
height: 50%;
margin: auto;
padding: 15% 0 0;
padding: 10% 0 0;
background-position: center;
background-repeat: no-repeat;
background-image: url("./assets/images/logo-dark.svg");
background-image: url("./assets/images/logo-universal.png");
background-size: 100% 100%;
background-origin: content-box;
}
.result {
height: 20px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ nameElement.focus();

// Setup the greet function
window.greet = function () {

// Get name
let name = nameElement.value;

// Check if the input is empty
if (name === "") return;

// Call App.Greet(name)
window.go.main.App.Greet(name).then((result) => {
// Update result with data back from App.Greet()
document.getElementById("result").innerText = result;
});
try {
window.go.main.App.Greet(name)
.then((result) => {
// Update result with data back from App.Greet()
document.getElementById("result").innerText = result;
})
.catch((err) => {
console.error(err);
});
} catch (err) {
console.error(err);
}
};

nameElement.onkeydown = function (e) {
console.log(e)
if (e.keyCode == 13) {
window.greet()
window.greet();
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func main() {

// Create application with options
err := wails.Run(&options.App{
Title: "{{.ProjectName}}",
Width: 1024,
Height: 768,
MinWidth: 1024,
MinHeight: 768,
// MaxWidth: 1280,
// MaxHeight: 740,
Title: "{{.ProjectName}}",
Width: 1024,
Height: 768,
MinWidth: 1024,
MinHeight: 768,
MaxWidth: 1280,
MaxHeight: 800,
DisableResize: false,
Fullscreen: false,
Frameless: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
)

// App application struct
// App struct
type App struct {
ctx context.Context
}
Expand All @@ -16,22 +16,29 @@ func NewApp() *App {
}

// startup is called at application startup
func (b *App) startup(ctx context.Context) {
func (a *App) startup(ctx context.Context) {
// Perform your setup here
b.ctx = ctx
a.ctx = ctx
}

// domReady is called after the front-end dom has been loaded
func (b *App) domReady(ctx context.Context) {
func (a App) domReady(ctx context.Context) {
// Add your action here
}

// beforeClose is called when the application is about to quit,
// either by clicking the window close button or calling runtime.Quit.
// Returning true will cause the application to continue, false will continue shutdown as normal.
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
return false
}

// shutdown is called at application termination
func (b *App) shutdown(ctx context.Context) {
func (a *App) shutdown(ctx context.Context) {
// Perform your teardown here
}

// Greet returns a greeting for the given name
func (b *App) Greet(name string) string {
return fmt.Sprintf("Hello %s!", name)
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
/node_modules/
/dist/build/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["svelte.svelte-vscode"]
}
Loading