Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pseudo element constants and docs #149

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions styles/STYLEMANAGER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 17 additions & 2 deletions styles/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Loading