Documentation
¶
Overview ¶
Package sitelook lets a website worker SEE pages: a reference the user pointed at, or the site it is building. Capture scrolls through a rendered page one viewport at a time (so scroll-triggered reveals play, as they do for a visitor) and returns each screen as an image; Inspect measures the rendered page's design system (type scale, palette, layout rhythm, sections, motion) from computed styles, which is what a designer reads off a page and what grepping its HTML and CSS can't recover.
Both run memcode's own fixed scripts in an ephemeral headless Chrome; no model-written code runs in the page.
Index ¶
Constants ¶
const MaxScreens = 8
MaxScreens bounds one capture.
Variables ¶
var Viewports = []Viewport{ {Name: "desktop", Width: 1440, Height: 900}, {Name: "laptop", Width: 1280, Height: 800}, {Name: "tablet", Width: 834, Height: 1112, Mobile: true}, {Name: "mobile", Width: 390, Height: 844, Mobile: true}, }
Viewports are the sizes a site is judged at.
Functions ¶
This section is empty.
Types ¶
type Browser ¶
type Browser interface {
Emulate(ctx context.Context, width, height int, mobile bool) error
Eval(ctx context.Context, js string) (string, error)
Screenshot(ctx context.Context, fullPage bool) ([]byte, string, error)
ClearConsole()
Console(level string) []string
}
Browser is the slice of browser.Session this package drives.
type Layout ¶
type Layout struct {
ContentWidth int `json:"contentWidth"`
Gutter int `json:"gutter"`
SectionPad []string `json:"sectionPad"`
ButtonRadius string `json:"buttonRadius"`
CardRadius string `json:"cardRadius"`
Buttons []string `json:"buttons"`
Borders string `json:"borders"`
Shadows int `json:"shadows"`
StickyHeader bool `json:"stickyHeader"`
HeaderHeight int `json:"headerHeight"`
FullBleedImgs int `json:"fullBleed"`
}
Layout is the page's spatial system.
type Look ¶
type Look struct {
URL string
Title string
Viewport Viewport
PageHeight int
Screens []Screen
Errors []string // console errors and uncaught exceptions while loading
}
Look is a captured page.
type Media ¶
type Media struct {
Images int `json:"img"`
Videos int `json:"video"`
SVGs int `json:"svg"`
Canvas int `json:"canvas"`
BGImgs int `json:"bgimg"`
}
Media is the page's imagery.
type Motion ¶
type Motion struct {
Libraries []string `json:"libs"`
Animated int `json:"animated"` // elements carrying scroll/reveal markers
Transitions int `json:"transitions"` // elements with CSS transitions
Running int `json:"running"` // Web Animations running now
Autoplay int `json:"autoplay"` // autoplaying videos
SmoothScroll bool `json:"smoothScroll"` // a smooth-scroll library or CSS
Markers []string `json:"markers"` // attribute names used for reveals
}
Motion is how the page moves.
type Report ¶
type Report struct {
URL string `json:"-"`
Viewport Viewport `json:"-"`
Title string `json:"title"`
Height int `json:"height"`
Fonts []string `json:"fonts"`
Type []TypeStyle `json:"type"`
Surfaces []Share `json:"surfaces"`
Text []Share `json:"text"`
Accents []Share `json:"accents"`
Layout Layout `json:"layout"`
Sections []Section `json:"sections"`
Motion Motion `json:"motion"`
Media Media `json:"media"`
Errors []string `json:"-"`
}
Report is a page's measured design system.
type Screen ¶
type Screen struct {
Top int // page offset (CSS px) of the screen's top edge
Image []byte
Mime string
}
Screen is one viewport-sized capture.
type Section ¶
type Section struct {
Top int `json:"top"`
Height int `json:"height"`
BG string `json:"bg"`
Heading string `json:"heading"`
Size int `json:"size"`
Cols int `json:"cols"`
Media string `json:"media"`
Tag string `json:"tag"`
}
Section is one band of the page, top to bottom.
type TypeStyle ¶
type TypeStyle struct {
Tag string `json:"tag"`
Family string `json:"family"`
Size float64 `json:"size"`
Weight string `json:"weight"`
Line float64 `json:"line"` // line-height ÷ size (0 = normal)
Track float64 `json:"track"` // letter-spacing in em
Case string `json:"case"` // text-transform when not none
Italic bool `json:"italic"` // font-style italic
Color string `json:"color"`
Chars int `json:"chars"`
Sample string `json:"sample"`
MaxWidth int `json:"measure"` // widest line box seen, px
Alignment string `json:"align"`
}
TypeStyle is one distinct text style in use.