Cookies Psst! Do you accept cookies?

We use cookies to enhance and personalise your experience.
Please accept our cookies. Checkout our Cookie Policy for more information.

Catpaw v3

Hello r/PHP,

It's been a while.

I've been busy at work and I've also been working on some new features and improved type safety for catpaw.

The latest release is v3, you can find it here.

I'm implementing an idea I've had some time ago, which i think can pay off well when it comes to faster UI development in PHP.

I call this feature Superstyle... because it's just style sheets, but with super powers.

I'll try to explain myself.

I've always found it a bit awkward and slow to write html and markup separately.

I've recently realized, since CSS's new nesting features, that html itself might have become a bit redundant in most cases, if not all.

I know it's a bold claim, but hear me out.

HTML is a declarative domain specific language that we use to describe our DOM tree, it doesn't do much more than that, and that's why it is great, it just does one thing and it does it well.

<div class="container"> <span class="info">Some text</span> </div> 

But of course I'm not saying anything new here.

Whenever we want to give our document some style we use CSS, another domain specific language.

But I've wondered if CSS can actually also describe a DOM tree by itself... and I think it can.

div.container { /* Some css rules */ span.info { /* More css rules */ content: "Some text"; } } 

Does the structure look familiar?

It technically describes the same tree as the HTML example above: a div with a "container" class, which contains a span with an "info" class and the text "Some text".

Well that's what Superstyle is, a feature that takes CSS content in and outputs the same CSS content and its HTML representation, with some optimizations added.

But what could the advantage be?

For starters I believe it to be less redundant, I can describe both the style of the document and the document itself at the same time.

There is potential for more advanced syntax in the future.

And third, I think it encourages more usage of CSS and less usage of JS, which in my book is a good thing.

That's all I've got for now.

Optimizations and improvements will come in the near future, in the mean time it would be nice to get some thoughts, possibly on the github discussion https://github.com/tncrazvan/catpaw/discussions/5.

Documentation and example can be found here.

Have a nice day.

submitted by /u/loopcake
[link] [comments]

Last Stories

What's your thoughts?

Please Register or Login to your account to be able to submit your comment.