carbon

package module
v0.0.0-...-6ac86a7 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

carbon-go

https://carbon-go.io

every component implements the carbon.Component interface:

type Component interface {
	Render(w io.Writer)
	Attr(name, value string) Component
}

so, you can use it to write to anything that implements io.Writer. use in a server like this:

type foo struct {}

func (f *foo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	carbon.Button("Hello world!").Render(w)
}

put HTMX tags on your component like this:

carbon.Button("Hello world!").Attr("hx-get", "https://example.com").Attr("hx-swap", "outerHTML").Render(w)

currently documentation sucks. just look at the docs for carbon design svelte. i've tried to keep it as similar as possible. moving forward, we should try to keep upstream with the react version when possible. i just didn't want to comb through react code.

will be adding doc comments.

TODO:

  • implement the rest of the components (copy button, textarea, etc...)
  • implement client side javascript for a few components
  • import icons on the fly and cache them server side instead of hardcoding them
  • automated testing against the react implemention to ensure markup generation parity
  • make every single component respect class Addr

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseCss string
View Source
var BaseFontCss string

Functions

func Accordion

func Accordion(cs ...*accordionItem) *accordion

func AccordionItem

func AccordionItem() *accordionItem

func Add

func Add() *iconComponent

func AspectRatio

func AspectRatio(cs ...Component) *aspectRatio
func Breadcrumb(children ...*breadcrumbItem) *breadcrumb
func BreadcrumbItem(children ...any) *breadcrumbItem

func Breakpoint

func Breakpoint(sm ...any) *breakpoint

func Button

func Button(children ...any) *button

func ButtonSet

func ButtonSet(children ...*button) *buttonSet

func Checkbox

func Checkbox() *checkbox

func Checkmark

func Checkmark() *iconComponent

func ChevronDown

func ChevronDown() *iconComponent

func ChevronRight

func ChevronRight() *iconComponent

func ClickableTile

func ClickableTile(children ...any) *clickableTile

func Column

func Column(c ...*row) *column

func Content

func Content(a ...any) *content

func ContentSwitcher

func ContentSwitcher(cs ...*switch_) *contentSwitcher

func Copy

func Copy() *iconComponent

func Delete

func Delete() *iconComponent

func Div

func Div(a ...any) *div

func EditOff

func EditOff() *iconComponent

func Escaped

func Escaped(s string) string

func GitHub

func GitHub() *iconComponent

func Grid

func Grid(c ...*column) *grid
func Header() *header

func Html

func Html() *html_

func InlineScript

func InlineScript(href string) *script

func InlineStyle

func InlineStyle(href string) *style
func Link(children ...any) *link

func ListItem

func ListItem(children ...any) *listItem

func OrderedList

func OrderedList(children ...any) *orderedList

func P

func P(a ...any) *p

func PasswordInput

func PasswordInput(labelText string) *passwordInput

func Row

func Row(a ...any) *row

func Script

func Script(s string) *script

func Section

func Section(a ...any) *section

func Select

func Select(s ...*selectItem) *select_

func SelectItem

func SelectItem() *selectItem

func Style

func Style(s string) *style

func Switch

func Switch(text string) *switch_

func TextInput

func TextInput(labelText string) *textInput

func Toggle

func Toggle() *toggle

func UnorderedList

func UnorderedList(children ...any) *unorderedList

func View

func View() *iconComponent

func ViewOff

func ViewOff() *iconComponent

func WarningAltFilled

func WarningAltFilled() *iconComponent

func WarningFilled

func WarningFilled() *iconComponent

Types

type Attr

type Attr struct {
	Name  string
	Value string
}

type Component

type Component interface {
	Render(w io.Writer)
}

Jump to

Keyboard shortcuts

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