dropzone

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dropzone implements drap & drop upload drop zones.

templ: version: v0.2.778

Index

Examples

Constants

View Source
const DefaultDragMessage = `<span class="font-semibold">Click to upload</span> or drag and drop`
View Source
const DefaultDropMessage = `Drop to upload`

Variables

This section is empty.

Functions

func C

func C(def D) templ.Component

Types

type D

type D struct {
	// ID is the input id (Name if not set).
	ID string
	// Name is the input name.
	Name     string
	Multiple bool
	// AllowedTypes is the list of allowed mime types
	AllowedTypes []string
	// Style defines the style (style.Default, Valid or Invalid).
	Style style.Style
	// Icon allows you to define a custom icon.
	Icon *icon.D
	// DropIcon sets the icon displayed when dragging a file over the drop zone.
	DropIcon *icon.D
	// IconSize defines the default icon size (ignored when using a custom icon).
	IconSize size.Size
	// DragMessage is the default label message (default: "Click to upload or drag and drop").
	DragMessage string
	// DropMessage is the label message displayed when dragging a file over the drop zone.
	DropMessage string
	// AllowedTypesMessage is the text that specifies allowed types, max size (e.g. "PNG, JPG or GIF (Max. 600x300px)")
	AllowedTypesMessage string
	// Message adds a validation message below the field.
	// Just add &message.D{} to add automatic validation.
	//playground:import:github.com/jfbus/templui/components/form/validation/message
	//playground:default:&message.D{Message: "Validation message"}
	Message *message.D
	// Disabled disables the input.
	Disabled bool
	// Invalid marks the input as invalid.
	Invalid bool
	// Loader displays a spinning loader when an HTMX action is triggered by the input.
	Loader bool
	// CustomStyle defines a custom style.
	CustomStyle style.Custom
	// Attributes stores additional attributes (e.g. HTMX attributes).
	Attributes templ.Attributes
}

D is the definition for input fields.

Example
package main

import (
	"context"
	"os"

	"github.com/jfbus/templui/components/dropzone"
)

func main() {
	c := dropzone.C(dropzone.D{
		Name: "upload",
	})
	c.Render(context.TODO(), os.Stdout)
}
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL