pattern-lab / patternlab-php

The PHP version of Pattern Lab
http://patternlab.io
MIT License
3.06k stars 456 forks source link

Code View on Pattern Detail Page #23

Closed bradfrost closed 10 years ago

bradfrost commented 10 years ago

Code view is currently available on the view all page, but isn't functional on pattern detail pages.

Code view will include the markup, and will present all CSS affecting the module.

dmolsen commented 10 years ago

I created a feature branch for this this morning. Good news and bad news. The good news is that I integrated CSS Rule Saver quickly... the bad news is that it takes two seconds to generate PL when saving the CSS rules. Waiting two seconds for a simple refresh when using the watcher seems like a bad idea if the CSS output isn't going to be used.

So I was thinking that we'd have a default code view that was lineage and mark-up. If someone needed the rules they could set a flag that caused PL to generate that as well and it would then get put into code view. I figure this would only happen near the end of a project.

A useful feature but a performance hog.

I was also thinking of using prism.js in the pop-up window for styling.

bradfrost commented 10 years ago

Yeah, I think at the end of the day we have to be mindful of performance more than anything. I like the idea of having it as a feature flag, but honestly I'm happy to punt on this as there are a lot of other ways to inspect styles.

Another thing I remember was someone talking about commenting CSS, and using that as a flag to spit out into the pattern. So something like:

/* PL Pattern: molecule-tabs */
.tabs {  ... }
/* End molecule-tabs */

Pattern Lab would then associate whatever's in between those comments with the appropriate molecule/organism/whatver.

Again, I say we defer this for a later date, but definitely good to think about how this could be accomplished.

dmolsen commented 10 years ago

Ok, I'll focus on the other. The use case I had in mind was a code repository (came up here) where we'd want to make assets easily copy-able. Not just for inspecting.

The commenting CSS idea sounds really fragile.

bradfrost commented 10 years ago

I get a little nervous having Pattern Lab become a code repository. There are lots of other tools that do that sort of thing way better, and I feel like if we were to go down that route, it would be a whole lot of work.

I've seen companies using JS Bin internally to manage their production code modules, and that seems to work pretty well. I don't think it makes logistical sense for Pattern Lab to try to do double duty in that respect.

dmolsen commented 10 years ago

Code view on the list views and pattern detail view is now sort of working in dev branch. I plugged the data I had into the areas you had noted on the list view. Fairly painless. I've also built out the pattern detail view but it isn't styled at all and doesn't "shut off". I'm assuming that's a style issue. I basically created a new mark-up structure for it and you can play with it as much as you want. Some things to note:

I didn't test this overly much. Just make sure to clear your cache and generate your PL site. The header pattern is probably the best use case when testing.

dmolsen commented 10 years ago

Tried to tackle the linking. Works on list view. Can't really test on the pattern detail view.

dmolsen commented 10 years ago

Feature is live.