Closed jensljungblad closed 6 years ago
@jimmynordlund Cool! I pushed some more markdown examples, I think one additional subheader and a blockquote. They're all on the style guide home page now. Some other feedback:
(Would prefer not to add sass if possible)
@jensljungblad Pushed some updated styling with a new, more muted colour scheme and and a nav that supports deeper nesting and clearly differentiates between what’s clickable and what’s not. There’s also a max-width on the main container now. Feels much better.
The only thing I’m not entirely sold on is the left alignment of the component preview in the iframe. I like it centred. I feel like the “misalignment” is a plus, that it’s its own thing, a preview of something that lives somewhere else and therefore should break the “flow” and just be aligned against its own container. It’s also not as jarring now that the max-width of the main container is capped. But, all in all, minor detail. I’m fine with either really.
@jimmynordlund Cool! Feels better with the max width, agreed. I fixed an issue with how the example code was being generated that made the padding a bit weird, and also added a markdown code example to the dummy home page. I tweaked some paddings and stuff in the css, and also moved the font declarations from the pre
to the code
tag, didn't seem to work on the pre
.
I also changed my mind about the Google Font dependency for now :P I have to think a bit if it's a good idea or not.. I added the native-stack from Bootstrap instead for now.
Perhaps it's good enough to test with the real style guide now, and then we can make further tweaks once we see how that looks!
This PR explores adding a style guide.
app/styleguide
?There are currently issues with both
redcarpet
androuge
, with them spitting out a lot of warnings. Hopefully new releases of both gems will fix those. There are also alternatives such askramdown
andcoderay
available.Original idea
When it comes to printing the code for rendering the component, my current idea is to do something like this: ```ruby class ExampleComponent has_many :examples do attribute :source end # override this method... def examples(value = nil, attributes = nil, &block) if block # i suppose this will be the value variable in fact, but still... attributes[:source] = block.source # capture the content of the block somehow... end super end end ``` Might need a gem to get the source of the block: https://github.com/banister/method_source. It's possible to do with `#source_location` as well but that means parsing the file, which seems a bit silly. Yet another solution would be to pass it as a string or something and then eval it but that sounds like a worse solution! **Update**: Unfortunately the gems available can't extract the source of an `erb` block, only pure Ruby blocks.. Another issue is that you can't print `erb` markdown blocks without them getting evaluated.The way examples are implemented is through markdown, similar to https://www.catalog.style. That is: