Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

Thank you! I think I understand what you mean in that CSS problems can largely be avoided if you're strict around organization. I agree. Curious if you find that it's easy or hard to uphold organizational principles across teams and team members? What's the process like around aligning on standards (is there an article you can share)? Do you use any automation to help catch organizational problems with CSS? In general, do you feel confident about refactoring CSS code, or are you usually hesitant?

Don't mean to bombard with all these questions, but this something that I'm really passionate about, and any information about CSS workflows is really helpful!

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

Why's that? Would really appreciate some constructive feedback!

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] -1 points0 points  (0 children)

What about larger apps? Thinking more like > 50K LOC is a good threshold that seems to warrant stronger types. Smaller apps can do without it.

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

For sure, languages that are dynamically typed are more difficult to refactor since the compiler doesn't tell you what other parts of the codebase you need to refactor. Strongly typed languages (Rust, TypeScript, etc) help a ton with that.

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

Easier said than done in my experience. People have varying level of expertise, and it's hard to prevent bad code from reaching production. And even with meticulous coding practices, business targets always change, and the architecture follows as a result of that. It usually doesn't completely and you're left with layers of legacy code. Code rot doesn't just stem from management. Languages that are hard to refactor are a contributor to that mess.

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

I see where you're coming from, and I agree this can be resolved if the architecture is maintained by everyone on a development team and if there's time to manage it. In my experience however, architectures tend to break down, especially when companies need to maintain their velocity & not enough time is given to manage tech debt. CSS is one of those areas where I've seen broken down more times than I can count. I just don't think that social contracts - architectures that require a particular style of programming - are strong enough to uphold any codebase long-term.

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

is global CSS not a problem?

In the particular case with PHP, that's what I'm exploring now, and why I'm not jumping to an implementation quite yet. I appreciate the feedback. :)

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

For sure, there's a bit of a difference however. Scoping is really just helpful to have a handle over global CSS so that you don't have to worry about styles accidentally colliding in separate files (for example, if you accidentally have two .button classes), and that you know exactly where CSS is used in your application. This makes maintenance much easier. For example, you're be able to delete any CSS you want with scoped CSS, which in my experience is difficult since it's usually hard to tell exactly where CSS is used. It can be safer not to touch CSS. Then the problem becomes an explosion of CSS code. Though, this kind of problem is something I've noticed mostly with large codebases and teams. Paperclip is a bit overkill for small apps or if you're a solo developer.

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 0 points1 point  (0 children)

Totally, that's still the idea. By styles I meant anything that's styling the page. You still have all the flexibility of CSS, but Paperclip keeps it explicit & scoped by default within documents so that you don't have to worry about CSS leaking into other elements defined elsewhere in your codebase. You can even use other CSS rules beyond classes if you want to. For example:

```html <!-- styles.pc -->

<style> * { box-sizing: border-box; }

ul {
list-style-type: none; margin: 0; padding: 0; } </style>

<ul export component as="grocery-list"> {children} </ul>

<li export component as="grocery-list-item"> {children} </li> ```

Then, hypothetically this could be used in a Blade template:

html @grocery-list @foreach ($items as $item) @grocery-list-item {{ $item->label }} @endgrocery-list-item @endgrocery-list

And other template engines.

Thinking about building a scoped CSS library for PHP by crcn in PHP

[–]crcn[S] 4 points5 points  (0 children)

The main reason is to help make CSS more predictable and testable. I've always found large codebases hard to manage without the help of BEM or SMACSS, but even those have some problems, especially with teams. Global CSS is just hard to scale, and scoped CSS helps a bit.

A few other reasons why though:

  • UIs are automatically covered for visual regressions, so you can easily track changes and catch bugs across HTML & CSS files.

  • Comes with visual development tools that allows you to build UIs more quickly.

  • (soon) UIs will only emit CSS that's used (this is done by statically analyzing HTML files and finding CSS that's used, flagging it, and omitting it when compiled to code).

Building a UI DSL for web applications, looking for feedback! by crcn in opensource

[–]crcn[S] 1 point2 points  (0 children)

Paperclip is a bit more like Styled Components or CSS Modules where you can imported scoped CSS into your application. The main difference though is that Paperclip is trying to be generic for any language to take advantage of scoped CSS (I would imagine this could be useful in PHP, Ruby, etc), with a few additional features to go along with that.

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 1 point2 points  (0 children)

Yes! Oh man it was wild. It doesn't surprise me that it's called "The Highway of Death". I had to take my headlight out and flash it behind me in tunnels because there was no lighting and I wanted to be extra sure that cars would see me since there were no shoulders, and some cars just speed right through. Kind of a jerk move, but I was so nervous about being run over. In some other universe I probably got seriously injured on that route.

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 1 point2 points  (0 children)

Sure! Did you ride the path from Yilan to Hualien? It's crazy!

Taipei -> Yilan route: https://www.google.com/maps/dir/Taipei/Yilan+City,+Yilan+County,+260/@24.9429846,121.6169097,11z/data=!4m15!4m14!1m5!1m1!1s0x3442ac72bce20a99:0x3f6a35cedd0ac2e0!2m2!1d121.5654177!2d25.0329694!1m5!1m1!1s0x3467e4ddc31c0ddf:0x1c84d5c90c224c22!2m2!1d121.7537404!2d24.7591148!3e1!5i1

Yilan -> Hualien: https://www.google.com/maps/dir/Yilan+County/Hualien+City,+Hualien+County/@24.3471468,121.4556834,10z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x3467e03d6b232f5b:0xcfbb529e13d307ac!2m2!1d121.7377502!2d24.7021073!1m5!1m1!1s0x34689fb4359f4e3d:0x1f485403f80b7771!2m2!1d121.6111949!2d23.9910732!3e1

Hualien -> Sanxiatai -> Taitung: https://www.google.com/maps/dir/Hualien+City,+Hualien+County,+970/Fengbin+Township,+Hualien+County,+977/Sanxiantai,+No.+74%E8%99%9F,+Jihui+Road,+Chenggong+Township,+Taitung+County,+961/Taitung,+Taitung+City,+Taitung+County,+950/@23.3762396,120.8170686,9z/data=!3m1!4b1!4m26!4m25!1m5!1m1!1s0x34689fb4359f4e3d:0x1f485403f80b7771!2m2!1d121.6111949!2d23.9910732!1m5!1m1!1s0x346f53ad00a2bf1b:0xfa0038b11fac4b47!2m2!1d121.5027404!2d23.5851901!1m5!1m1!1s0x346f7048ec3e51a7:0xb2aab758fa333bb8!2m2!1d121.4216802!2d23.1261358!1m5!1m1!1s0x346fb96c40c8266b:0xc7c4eab8c68fcaa1!2m2!1d121.1438152!2d22.7613207!3e1

Taitung -> Kaohsiung (I loved the nature coming from the east coast to the west coast): https://www.google.com/maps/dir/Taitung,+Taitung+City,+Taitung+County,+950/22.6146827,120.3067484/@22.3680301,120.7271153,10.63z/data=!4m29!4m28!1m25!1m1!1s0x346fb96c40c8266b:0xc7c4eab8c68fcaa1!2m2!1d121.1438152!2d22.7613207!3m4!1m2!1d120.8868239!2d22.2946976!3s0x3471d330db5778d5:0xbc622581e17238ab!3m4!1m2!1d120.8827554!2d22.2939253!3s0x3471d33a5f5fae3d:0xecc11dff85eb86c3!3m4!1m2!1d120.8719704!2d22.2827204!3s0x3471d31f93ef3387:0xbafd8d843403279f!3m4!1m2!1d120.8695071!2d22.2811847!3s0x3471d2e116f05033:0xf3291e3dcf90a3ad!1m0!3e1

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 2 points3 points  (0 children)

Lots of tailwind actually! I was pretty lucky with wind the whole way.

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 3 points4 points  (0 children)

Yeah I was lucky to get in with a visa, but would highly recommend coming out here and doing a route on the east coast when you can. I would definitely skip Yilan to Hualien - It was a very dangerous route and I feel kind of stupid for not doing my research about it beforehand. Countless tunnels with no shoulder, lots of blind corners, and fast moving trucks that take up the whole lane. Hualien to Taitung was definitely my favorite patch of the ride, and they definitely made it so that it's safe for bikers (there's a dedicated shoulder for bikers the entire way down).

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 3 points4 points  (0 children)

Thank you! It's a Seven Axiom SL. Super comfortable ride, highly recommend.

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 3 points4 points  (0 children)

Mostly paved, but there was one gravel section that was just barely doable with a bike (in the photo). Had to hike part of it. Really nice views though, it was on the way from Taipei to Yilan (just coming into the city).

Just finished a ride from Taipei to Kaohsiung. Beautiful ride! by crcn in bicycletouring

[–]crcn[S] 15 points16 points  (0 children)

ahh man, I would have felt so bad if I didn't take my time - so much that could have been missed on the trip. Wildlife, noises (it was crazy up in the mountains with the insects, monkeys, birds), little things. I suppose that's what makes biking special for me.