jrief / djangocms-cascade

Build Single Page Applications using the Django-CMS plugin system
MIT License
165 stars 85 forks source link

Feature: Should let users define arbitrary style classes for Simple Wrapper plugin #34

Closed georgema1982 closed 9 years ago

georgema1982 commented 10 years ago

Right now it seems to me that Simple Wrappe can only have divs with thumbnail and jumbotron classes. I feel its functionalities pretty restricted by such hardcoding. I suggest that users should be able to either predefine some classes in settings.py so that they can choose from a list of styles (similar to this plugin: https://github.com/divio/djangocms-style) or they can enter wildcard class names when using this plugin.

electroniceagle commented 10 years ago

Agree with that. I don't think it would be that difficult to add an inline_classes option to the base class.

jrief commented 10 years ago

Can you please do me a favor in order to speed up development: I need a way to write unit tests for DjangoCMS Plugins. Unfortunately nobody answered yet on this https://github.com/divio/django-cms/issues/3473 and I haven't found any CMSPlugins which do unit testing the way it should be.

If I get a working example for a unit testing CMS Plugins, we can talk about new features.

electroniceagle commented 10 years ago

screen shot 2014-10-01 at 4 06 32 pm I have a working inline_classes test. See issue: https://github.com/jrief/djangocms-cascade/issues/28

jrief commented 9 years ago

The current dev version (0.4.0 branch) has a feature to let add extra fields for CSS classes and inline styles to any kind of Plugin. Currently this is implemented for the SimpleWrapperPlugin.

How does it work: In the admin section below Cmsplugin_Cascade Add Custom CSS classes and styles. Select Bootstrap Simple Wrapper and your site. In the admin form, and add extra CSS classes and enable fields for extra inline styles.

Now inside Structure View select a "Simple Wrapper Plugin". Here you should see the possible extra input fields. Please test this, also from the point of view of usability. In my opinion it should add the required flexibility to this Plugin.

electroniceagle commented 9 years ago

Will give it a try!

electroniceagle commented 9 years ago

I'm getting this, maybe shouldn't have started with a comma-separated list.

TypeError
TypeError: can only concatenate tuple (not "list") to tuple
...
File "/Users/bschott/Source/djangocms-cascade/cmsplugin_cascade/mixins.py", line 44, in __init__
widget = widgets.Select(choices=((None, _("Select CSS")),) + choices)
[console ready]
>>> choices
[(u'pull-left', u'pull-left')]
>>> 
jrief commented 9 years ago

can you please explain me how I can reproduce this.

electroniceagle commented 9 years ago

Will try to reproduce from the demo app.

On Nov 19, 2014, at 1:40 AM, Jacob Rief notifications@github.com wrote:

can you please explain me how I can reproduce this.

— Reply to this email directly or view it on GitHub https://github.com/jrief/djangocms-cascade/issues/34#issuecomment-63598889.

oldskool73 commented 9 years ago

I get the same error if I don't select the 'Allow multiple' checkbox. Changing line 44 of mixins.py to : widget = widgets.Select(choices=[(None, _("Select CSS"),)] + choices) appears to fix it.

Edit : this appears to fix the error, but every time I apply a singular style (without 'allow multiple' selected) I get <div class="f o o"> instead of <div class="foo">, so still not quite working properly.

electroniceagle commented 9 years ago

I get the idea and was able to see it work in practice, However, I don't think this is the use case I had in mind. I'm really looking for a way to a) use bootstrap helper classes like pull-left, pull-right, center-block etc. and b) add my own classes like make-this-panel-green. I think Jumbotron and Thumbnail and other bootstrap components (http://getbootstrap.com/components/) should rather have explicit named plugins in the structure dropdown.

screen shot 2014-12-04 at 2 19 21 pm screen shot 2014-12-04 at 2 18 31 pm screen shot 2014-12-04 at 2 18 19 pm

jrief commented 9 years ago

@oldskool73 The problem with <div class="f o o"> has been fixed yesterday.

@electroniceagle The intention of ExtraFieldsMixin class is to allow classes like make-this-panel-green. On the other side, I'd rather prefer to only allow CSS classes to Bootstrap elements which are officially documented on the http://getbootstrap.com/ website. Where for instance would you allow pull-right or pull-left?

electroniceagle commented 9 years ago

The ExtraFieldsMixin might be the way to go for all of the bootstrap classes, which is what @oldskool73 has done. There are lots of helper classes (http://getbootstrap.com/css/#helper-classes). I'd use pull-left or pull-right on an image or thumbnail in the same column as text. I'd use block-center, pull-left, pull-right on an image in a column to control the justification of the content.

jrief commented 8 years ago

Hi Brian, I now added a fully working Jumbotron plugin to the Cascade library. Please peer review this branch https://github.com/jrief/djangocms-cascade/tree/jumbotron-plugin and tell me about your experience. In https://github.com/jrief/djangocms-cascade/blob/jumbotron-plugin/docs/source/bootstrap3/other-components.rst there is some documentation.