This is really so simple. You could have a statue which flips or pivots or anything you want, but I chose a book. Here’s how it works:
The books around it have no purpose other than to keep the hinged book company, they are loose and just sit there.
I had to add a block of wood to stop the gate latch from going too far back or it wouldn’t close automatically. It’s not the prettiest but it works beautifully. I first tried to add a bracket on top as a stopper, but it had no effect at all. The book has a tiny hinge attached.