webstyle

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webstyle writes NSGo's styles as CSS, for the backends that draw with a browser's engine: the web and WeChat mini programs, whose render layer is a web view. It is plain Go, so it is tested on any host.

Lengths are CSS pixels, which are points; what is at CSS's initial value comes back empty, so callers leave the property out.

Index

Constants

This section is empty.

Variables

View Source
var DecorationStyles = map[driver.TextDecorationStyle]string{
	0: "solid", driver.DecorationSolid: "solid", driver.DecorationDouble: "double", driver.DecorationDotted: "dotted",
	driver.DecorationDashed: "dashed", driver.DecorationWavy: "wavy",
}

DecorationStyles are the CSS of the decoration styles.

Functions

func AnimatedInline

func AnimatedInline(base driver.ViewStyle, vals driver.AnimatedValues) map[string]string

AnimatedInline returns the inline CSS properties for a view with base style base and bound animated values vals. Only properties driven by vals are set inline; unbound properties stay empty so the view's class and its CSS transitions own them. When vals binds properties listed in base.Transition, transition is narrowed to the unbound ones (or "none" when none remain).

func Color

func Color(c driver.Color) string

Color is c as CSS.

func CustomCursorDeclarations

func CustomCursorDeclarations(named driver.Cursor, custom *driver.CustomCursor, url1x, url2x string, dpr float32) []string

CustomCursorDeclarations returns the CSS cursor property values for a view's named and custom cursors, in progressive-enhancement order: a universal url() declaration followed by -webkit-image-set() and image-set() when a 2x representation is present so HiDPI displays select it automatically. Returns nil when no cursor property should be emitted.

func DataURL

func DataURL(data []byte) string

DataURL encodes image bytes into a data: URL with the sniffed media type (SVG, PNG, JPEG, GIF, WebP, defaulting to image/png).

func Decoration

func Decoration(d driver.TextDecoration) string

Decoration is CSS's text-decoration-line of d, "none" for none.

func Easing

func Easing(c driver.Curve) string

Easing is the CSS timing function of a curve, linear for none.

func Fill

func Fill(c driver.Color) string

Fill is the CSS of a background or border color, "" for none.

func Filter

func Filter(filters []driver.Filter) string

Filter is CSS's filter of filters, or "" for none.

func GlassBoxTransform

func GlassBoxTransform(lx, ly, w, h float64, vs *driver.ViewStyle) (x, y, sw, sh float64, ok bool)

GlassBoxTransform checks whether vs's transform keeps the glass box upright (axis-aligned, flat, no rotation/skew/perspective/matrix) and returns its transformed CSS bounds (x, y, sw, sh) from layout origin (lx, ly) and layout size (w, h).

func GlassFallbackBackdrop

func GlassFallbackBackdrop(vs *driver.ViewStyle) string

GlassFallbackBackdrop returns the CSS backdrop-filter for a glass view when the glass shader is unavailable: the style's own BackdropFilters when set, else a material blur matching GlassEffect.

func GlassFallbackRim

func GlassFallbackRim(vs *driver.ViewStyle, dark bool) string

GlassFallbackRim returns a subtle inset specular rim box-shadow for a glass view falling back to CSS, or "" when vs has no glass effect.

func GlassFallbackTint

func GlassFallbackTint(vs *driver.ViewStyle, dark bool) string

GlassFallbackTint returns the CSS background-color for a glass view falling back to CSS: the view's own Background when set, else a subtle translucent tint matching GlassEffect and appearance.

func GlassUnsafeAncestor

func GlassUnsafeAncestor(vs *driver.ViewStyle) bool

GlassUnsafeAncestor reports whether an ancestor view with style vs makes placing a nested HTML-in-Canvas drawable inside it unsafe: Chrome hangs when a nested drawable sits under blend/mask/translucent backdrop layers, and nesting glass inside glass risks recursive capture.

func Gradient

func Gradient(p *driver.GradientPaint, size driver.Size) string

Gradient is the CSS gradient of p on a box of size.

func LineStyle

func LineStyle(s driver.BorderStyle) string

LineStyle is the CSS of a border or outline style.

func Opacity

func Opacity(o float32) string

Opacity is the CSS of an opacity, "" for opaque.

func Px

func Px(p driver.Points) string

Px is p in CSS pixels.

func Radius

func Radius(vs *driver.ViewStyle) string

Radius is the border-radius of vs, which the browser fits.

func Shadow

func Shadow(vs *driver.ViewStyle) string

Shadow is the box-shadow of vs: its layers, then React Native's shadow under them.

func TextShadow

func TextShadow(s driver.TextShadow) string

TextShadow is the CSS of a text shadow.

func Transform

func Transform(t driver.Transform) string

Transform is t around the view's transform origin, in its order: perspective, translate, rotate, rotateX, rotateY, rotateZ, skew, then scale.

func Transition

func Transition(t driver.Transition) string

Transition animates the listed properties from what the view shows to what the same style change sets.

func TransitionFor

func TransitionFor(t driver.Transition, bound uint16) string

TransitionFor returns the CSS transition of t excluding the CSS properties currently driven by bound (AnimatedValues.Set), so unbound properties keep transitioning alongside animated values.

Types

type GlassUniforms

type GlassUniforms struct {
	Rect  [4]float32 // x, y, width, height in output pixels
	Radii [4]float32 // fitted corner radii in pixels: top-left, top-right, bottom-right, bottom-left
	P0    [4]float32 // bezel, refraction, rim, rim width (pixels / factors)
	P1    [4]float32 // straight RGBA tint
	P2    [4]float32 // low, high, curve, saturation
	P3    [4]float32 // light direction (x, y, 0, 0)
	Blur  float32    // backdrop blur sigma in CSS points
}

GlassUniforms holds the shader parameters for Liquid Glass, matching Windows' glass shader (internal/platform/windows/glass.go) and MyGo's glass material measurements of macOS 27's NSGlassEffectView.

func ComputeGlassUniforms

func ComputeGlassUniforms(vs *driver.ViewStyle, w, h, scale float32, dark bool) (GlassUniforms, bool)

ComputeGlassUniforms computes the Liquid Glass shader parameters for a box of w by h CSS points at device pixel scale. It returns false when vs has no glass effect or the box has no area.

Jump to

Keyboard shortcuts

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