Skip to content

Commit

Permalink
Merge pull request #149 from chasefleming/cf/pseudo-constants-and-docs
Browse files Browse the repository at this point in the history
Add pseudo element constants and docs
chasefleming authored Sep 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 274ffa4 + a2120ce commit e4938a3
Showing 2 changed files with 37 additions and 2 deletions.
20 changes: 20 additions & 0 deletions styles/STYLEMANAGER.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
- [Creating a StyleManager](#creating-a-stylemanager)
- [Adding Styles](#adding-styles)
- [Pseudo-Classes](#pseudo-classes)
- [Pseudo-Elements](#pseudo-elements)
- [Animations](#animations)
- [Media Queries](#media-queries)
- [Features](#features)
@@ -102,6 +103,25 @@ link := elem.A(
)
```

### Pseudo-Elements

Define styles with pseudo-elements to insert content or style specific parts of an element:

```go
compositeClassName := styleMgr.AddCompositeStyle(styles.CompositeStyle{
Default: styles.Props{
styles.Position: "relative"
},
PseudoElements: map[string]styles.Props{
styles.PseudoBefore: {
styles.Content: "'Before Text'"
},
},
})
```

In this example, the `::before` pseudo-element will insert the text "Before Text" before the content of the element.

### Animations

Create animations and apply them to styles with the returned animation name:
19 changes: 17 additions & 2 deletions styles/constants.go
Original file line number Diff line number Diff line change
@@ -214,6 +214,21 @@ const (
PseudoPaused = ":paused"

// Content pseudo-elements
PseudoBefore = "::before"
PseudoAfter = "::after"
PseudoBefore = "::before"
PseudoAfter = "::after"
PseudoFirstLine = "::first-line"
PseudoFirstLetter = "::first-letter"
PseudoSelection = "::selection"
PseudoBackdrop = "::backdrop"
PseudoPlaceholder = "::placeholder"
PseudoMarker = "::marker"
PseudoCues = "::cues"
PseudoCueRegion = "::cue-region"
PseudoResizer = "::resizer"
PseudoScrollbar = "::scrollbar"
PseudoScrollbarThumb = "::scrollbar-thumb"
PseudoScrollbarTrack = "::scrollbar-track"
PseudoScrollbarTrackPiece = "::scrollbar-track-piece"
PseudoScrollbarButton = "::scrollbar-button"
PseudoScrollbarCorner = "::scrollbar-corner"
)

0 comments on commit e4938a3

Please sign in to comment.