elem-go icon indicating copy to clipboard operation
elem-go copied to clipboard

Support for Pseudo-Elements

Open rxdps93 opened this issue 1 year ago • 3 comments

I've been able to make good use of the pseudo class support within stylemanager, however I'm finding myself needing to use pseudo elements (specifically ::before) and it doesn't seem like there is support for these yet.

If they are actually implemented and I'm just missing it I'd love to know, but if not I don't mind seeing if I can implement it myself.

rxdps93 avatar Jun 14 '24 17:06 rxdps93

Good catch, yeah it looks like constants like ::before and ::after need to be added to the constants list. If there are any issues with the double colon, it would probably require a change here, but any changes are probably minor. Most of the support should be there. If you want to take a shot at adding in support that would be great, thanks so much!

chasefleming avatar Jun 18 '24 13:06 chasefleming

Accidentally closed the issue sorry about that. I did get it working just by passing them into the pseudo class, and there were no issues. The complexity came in when trying to chain them together with pseudo-classes, as the most recent css spec (IIRC) has some restrictions around order and different combinations.

If you're fine with them just being added as constants and ignoring the more advanced use cases I'll go ahead and add them to the constants file.

rxdps93 avatar Jun 19 '24 03:06 rxdps93

So you're just appending the elements to the class? Yeah, I guess that would work. We could also do something like adding this to the CompositeStyle:

type CompositeStyle struct {
    Default        Props
    PseudoClasses  map[string]Props
    PseudoElements map[string]Props // Add this line
    MediaQueries   map[string]Props
}

Usage might look like this:

compositeClassName := styleMgr.AddCompositeStyle(CompositeStyle{
    Default: Props{
        Color: "black",
    },
    PseudoClasses: map[string]Props{
        PseudoHover: {Color: "blue"},
    },
    PseudoElements: map[string]Props{
        PseudoBefore: {
            Content:         `" "`,
            Display:         "block",
            Height:          "100%",
            Width:           "100%",
            BackgroundColor: "yellow",
        },
    },
})

chasefleming avatar Jun 30 '24 21:06 chasefleming

Hi @chasefleming and @rxdps93, please check out PR #148 for pseudo elements support.

whisk avatar Sep 14 '24 07:09 whisk

Awesome @whisk , thank you for taking this! Will check it out.

chasefleming avatar Sep 17 '24 01:09 chasefleming

Closing this issue as its been resolved with #148

chasefleming avatar Sep 18 '24 18:09 chasefleming