-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Liviu Ilea
committed
Aug 4, 2021
1 parent
e9cfa95
commit 4588684
Showing
14 changed files
with
7,884 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
node_modules | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
# go-alpine-tailwind-sample | ||
# go-alpine-tailwind-sample | ||
|
||
### Install & build frontend | ||
1. `npm i` | ||
2. `npm start` or `npm run build` | ||
|
||
### Run | ||
1. `go run main.go --dev=true` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"title": "Go AlpineJS TailwindCSS Sample", | ||
"backendName": "Backend", | ||
"backendLibName": "Fiber", | ||
"backendLibUrl": "https://gofiber.io", | ||
"frontendName": "Frontend", | ||
"frontendLib1Name": "TailwindCSS", | ||
"frontendLib1Url": "https://tailwindcss.com", | ||
"frontendLib2Name": "AlpineJS", | ||
"frontendLib2Url": "https://alpinejs.dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@import "tailwindcss/base"; | ||
@import "tailwindcss/components"; | ||
@import "tailwindcss/utilities"; | ||
|
||
/* your custom CSS here */ | ||
body { | ||
background: rgb(14, 165, 233); | ||
background: linear-gradient(0deg, rgba(14, 165, 233, 0.15028018043154767) 0%, rgba(215, 233, 241, 0.05504208519345233) 100%); | ||
} | ||
|
||
.blue-stripes-background { | ||
--stripes-color: rgba(14, 165, 233, 0.4); | ||
background-image: linear-gradient(45deg, var(--stripes-color) 12.5%, transparent 12.5%, transparent 50%, var(--stripes-color) 50%, var(--stripes-color) 62.5%, transparent 62.5%, transparent 100%); | ||
background-size: 5.66px 5.66px; | ||
} | ||
|
||
.yellow-stripes-background { | ||
--stripes-color: rgba(233, 196, 14, 0.85); | ||
background-image: linear-gradient(45deg, var(--stripes-color) 12.5%, transparent 12.5%, transparent 50%, var(--stripes-color) 50%, var(--stripes-color) 62.5%, transparent 62.5%, transparent 100%); | ||
background-size: 5.66px 5.66px; | ||
} | ||
|
||
h1 { | ||
color: white; | ||
width: fit-content; | ||
} | ||
|
||
.bg-light-blue { | ||
background-color: #0EA5E9; | ||
} | ||
|
||
.text-light-blue { | ||
color: #0EA5E9; | ||
} | ||
|
||
.bg-yellow { | ||
background-color: rgba(233, 196, 14, 0.85); | ||
} | ||
|
||
.bg-yellow-50 { | ||
background-color: rgba(233, 196, 14, 0.5); | ||
} | ||
|
||
.text-gold { | ||
color: rgba(112, 93, 0, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module github.com/sample/project | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/andybalholm/brotli v1.0.3 // indirect | ||
github.com/gofiber/fiber/v2 v2.15.0 // indirect | ||
github.com/gofiber/template v1.6.13 // indirect | ||
github.com/klauspost/compress v1.13.1 // indirect | ||
github.com/valyala/fasthttp v1.28.0 // indirect | ||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Alpine from 'alpinejs' | ||
import '../css/styles.css'; | ||
|
||
Alpine.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"flag" | ||
"fmt" | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/gofiber/fiber/v2/middleware/logger" | ||
"github.com/gofiber/template/html" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
) | ||
|
||
func main() { | ||
port := flag.String("port", "8080", "port to use") | ||
devMode := flag.Bool("dev", false, "enable dev mode") | ||
flag.Parse() | ||
|
||
templateEngine := html.New("./views", ".html") | ||
templateEngine.Reload(*devMode) | ||
|
||
app := fiber.New(fiber.Config{ | ||
Views: templateEngine, | ||
}) | ||
|
||
app.Use(logger.New()) | ||
|
||
setupRouting(app) | ||
|
||
log.Println(log.Ldate|log.Ltime|log.Lshortfile, fmt.Sprintf("Started service v1 on port: : %s. Dev mode is: %t", *port, *devMode)) | ||
log.Fatal(app.Listen(":" + *port)) | ||
} | ||
|
||
func setupRouting(app *fiber.App) { | ||
// => http://localhost:3000/static/js/script.js | ||
// => http://localhost:3000/static/css/style.css | ||
app.Static("/static", "./public") | ||
|
||
app.Get("/", func(c *fiber.Ctx) error { | ||
return c.Render("index", getContent("index")) | ||
}) | ||
} | ||
|
||
func getContent(name string) *fiber.Map { | ||
jsonFile, err := os.Open(fmt.Sprintf("content/%s.json", name)) | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
defer jsonFile.Close() | ||
|
||
byteValue, _ := ioutil.ReadAll(jsonFile) | ||
|
||
var result fiber.Map | ||
if err := json.Unmarshal(byteValue, &result); err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
return &result | ||
} |
Oops, something went wrong.