kalamuna / kalastatic

:electric_plug: Facilitate the front-end experience through Styleguides and Prototypes
https://kalamuna.github.io/kalastatic/
41 stars 14 forks source link

inherit resources from drupal in the prototype #197

Closed andrewmallis closed 8 years ago

andrewmallis commented 9 years ago

js and css comes in from the theme and affects the prototype. This is the context in which components will live and be affected.

We could provide a helper module that builds a bridge between the protoype and the theme.

a menu callback + template suggestion could see us provide a frame around the components. Once upon a time we did something like this:

https://github.com/kalamuna/ideograph_dev/blob/master/ideograph_dev.module#L55 https://github.com/kalamuna/ideograph_dev/blob/master/typography-test-page.tpl.php

This approach would call in the theme's html.html (instead of the prototype's) The prototype could spit out section-1.tpl.php section-2.tpl.php which we include on the dupal side. The above files need not contain any php; can just be html.

Our prototype menu patterns are somewhat dependable for now, but if they change, we would need to find a way to define them.

RobLoach commented 9 years ago

Drupal module to help with integration. Point to load "the things".

soniktrooth commented 9 years ago

It shall be called 'kalastatic_dot_module'.

andrewmallis commented 9 years ago

Initially in the first pass at the module, we're just going to pull the css and js the theme generates, then move on #208.

soniktrooth commented 9 years ago

Ok, @RobLoach and @madeofpeople do you want to check this oooot? https://github.com/kalamuna/kalatstic_dot_module

I have added a menu callback for the css and one for the js. Both return the json-ified output of drupal_add_css() and drupal_add_js() respectively. Let me know if this is too much stuff to be passing through but for the most part you should just be able to grab the urls and output style/script tags.

I have one more thing I think we need here and that's either a module weight or a module_implements_alter to make sure all the other modules have added their css and js before we grab them.

soniktrooth commented 9 years ago

We couldn't get away with a module_implements_alter so it had to be setting the module weight in an install hook.

soniktrooth commented 9 years ago

Ok, so, after discussion with @RobLoach we have two approaches, one bare minimum and one that is a little nicer.

I've added a new menu callback that returns a drupal page with two textareas—one for the css and js respectively. A Kalastatic user can visit this page and copy/paste the markup into their html.html and then continue about their merry way.

https://github.com/kalamuna/kalatstic_dot_module/commit/bd90885968645c88bd6837ea6fb1d8852f572456

A further improvement to this which @RobLoach is looking at is to pull the markup in automatically as metalsmith bulids and then add it to the html.html. The only complex part about this is that it needs a custom swig filter to decode the html entities.

Leaving it up to @RobLoach to decide how much work this is going to be and whether we need to push it back to a later sprint.

RobLoach commented 9 years ago

@soniktrooth Nice job on the form, looks like this should be good to go for now. It makes is easy for the user to load up the form, copy the CSS/JS into the template. I'd consider this good for now.

soniktrooth commented 9 years ago

@RobLoach wanna close this if you're happy?