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

Upload component #81

Merged
merged 4 commits into from
Nov 19, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
lint:
name: golangci-lint
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
id: go

- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
30 changes: 30 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
run:
timeout: "120s"

output:
formats:
- format: "colored-line-number"

linters:
enable:
- "gocyclo"
- "unconvert"
- "goimports"
- "govet"
- "misspell"
- "nakedret"
- "revive"
- "goconst"
- "unparam"
- "gofmt"
- "errname"
- "zerologlint"

linters-settings:
staticcheck:
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: ["all"]

issues:
exclude-use-default: false
34 changes: 34 additions & 0 deletions go/alpine/upload.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package alpine

import (
popui "github.com/invopop/popui/go"
"github.com/invopop/popui/go/classes"
"github.com/invopop/popui/go/props"
)

templ UploadFile(p props.UploadFile) {
<div class={ classes.UploadFile }>
<img class={ classes.UploadFileImg } x-show={ p.XModel } :src={ p.XModel }/>
<div x-show={ "!" + p.XModel } class={ classes.UploadFilePlaceholder }></div>
<span class={ classes.UploadFileText } x-text={ p.Loading + " ? 'Uploading...' : 'Select logo'" }></span>
@popui.Button(props.Button{
Variant: "primary",
Small: true,
Attrs: templ.Attributes{
"@click": p.OnSelect,
":disabled": p.Loading,
},
}) {
Upload
}
@popui.Button(props.Button{
Small: true,
Attrs: templ.Attributes{
"@click": p.OnRemove,
":disabled": p.Loading + " || !" + p.XModel,
},
}) {
Remove
}
</div>
}
238 changes: 238 additions & 0 deletions go/alpine/upload_templ.go

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

2 changes: 2 additions & 0 deletions go/classes/avatar.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package classes

// AvatarBase is the default class used for Avatar component
const AvatarBase = "popui-avatar"

// AvatarInitial is the default class used for the initial of the Avatar component
const AvatarInitial = "popui-avatar--initial"
4 changes: 4 additions & 0 deletions go/classes/button.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package classes

// ButtonBase is the default class used for the Button component
const ButtonBase = "popui-button"

// ButtonDanger is the default class used for the danger variant of the Button component
const ButtonDanger = "popui-button--danger"

// ButtonPrimary is the default class used for the primary variant of the Button component
const ButtonPrimary = "popui-button--primary"

// ButtonSmall is the default class used for the small version of the Button component
const ButtonSmall = "popui-button--small"
3 changes: 3 additions & 0 deletions go/classes/checkbox.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package classes

// CheckboxWrapper is the default class used for the wrapper of the Checkbox component
const CheckboxWrapper = "popui-checkbox-wrapper"

// CheckboxInput is the default class used for the input of the Checkbox component
const CheckboxInput = "popui-checkbox-input"

// CheckboxLabel is the default class used for the label of the Checkbox component
const CheckboxLabel = "popui-checkbox-label"
1 change: 1 addition & 0 deletions go/classes/classes.go
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// Package classes contains the available default css classes for components.
package classes
1 change: 1 addition & 0 deletions go/classes/containers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package classes

// PopupConfigContainer is the default class used for the wrapper of the config popup layout
const PopupConfigContainer = "popui-container-config"
1 change: 1 addition & 0 deletions go/classes/image.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package classes

// Image is the default class used for the Image component
const Image = "popui-image"
5 changes: 5 additions & 0 deletions go/classes/input.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package classes

// InputTextWrapper is the default class used for the wrapper of the InputText component
const InputTextWrapper = "popui-input-wrapper"

// InputTextBase is the default class used for the InputText component
const InputTextBase = "popui-input"

// InputTextError is the default class used for the error state of the InputText component
const InputTextError = "popui-input--error"

// Label is the default class used for the label of the InputText component
const Label = "popui-label"

// Error is the default class used for the error text of the InputText component
const Error = "popui-error"
Loading
Loading