Verschillende staten (tekst en icoon) voor niet-geaccepteerde en geaccepteerde antwoorden

I’m adding a css solution in case this is found helpful.

With pseudo elements, at least the behavior for the text portion can be mimicked:

CleanShot 2023-12-08 at 18.56.34

This code is a bit semantically nested, but it works. The text alignment would need to be changed or the button’s width fixed so that the target doesn’t jump around on hover.

css
nav.post-controls .actions button {
    &:after {
        margin-left: 0.5em;
    }
    
    &.unaccepted {
        &:after {
            content: "Mark as solution";
        }
        &:hover {
            &:after {
                content: "Select solution";
            }
        }
        
    }
    
    &.accepted {
        &, .d-icon {
            color: var(--tertiary);
        }
        &:after {
            content: "Selected Solution"; 
        }
        &:hover {
            &, .d-icon {
                color: var(--primary);
            }
            &:after {
                content: "Deselect Solution";
            }
        }
    }
}

It’s also possible to do this, which would result in the text “Select if this reply solves the problem,” which is too long but should respect language translations.

&:after {
    content: attr(title);
}

Ideally, I would change the actual html to support translations, instead of using pseudo elements;
Except for the title attribute (if it was shorter), can be better than having a js hover listener.

3 likes