Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Navbar plugins #329

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmsplugin_cascade/bootstrap4/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_instance(cls):

class BootstrapButtonMixin(IconPluginMixin):
require_parent = True
parent_classes = ('BootstrapColumnPlugin', 'SimpleWrapperPlugin',)
parent_classes = ('BootstrapColumnPlugin', 'SimpleWrapperPlugin', 'NavbarNavItemsPlugin')
render_template = 'cascade/bootstrap4/button.html'
allow_children = False
default_css_class = 'btn'
Expand Down Expand Up @@ -188,6 +188,8 @@ def get_form(self, request, obj=None, **kwargs):
@classmethod
def get_css_classes(cls, obj):
css_classes = cls.super(BootstrapButtonPlugin, cls).get_css_classes(obj)
if obj.parent.plugin_type == 'NavbarNavItemsPlugin':
css_classes.insert(0,'nav-link text-left')
if obj.glossary.get('stretched_link'):
css_classes.append('stretched_link')
return css_classes
Expand Down
1 change: 1 addition & 0 deletions cmsplugin_cascade/bootstrap4/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def render(self, context, instance, placeholder):
try:
tags = get_image_tags(instance)
except Exception as exc:
tags = None
logger.warning("Unable generate image tags. Reason: {}".format(exc))
tags = tags if tags else {}
if 'extra_styles' in tags:
Expand Down
67 changes: 67 additions & 0 deletions cmsplugin_cascade/bootstrap4/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,73 @@ def paddings(cls):
return glossary_fields

@property
def flex_directions(cls):
glossary_fields = []
choices_format = [
('flex-{}row', _("horizontal")),
('flex-{}row-reverse', _("horizontal reverse")),
('flex-{}column', _("Vertical")),
('flex-{}column-reverse', _("Vertical reverse")),
]
for bp in Breakpoint.range(Breakpoint.xs, Breakpoint.xl):
if bp == Breakpoint.xs:
choices = [(c.format(''), l ) for c, l in choices_format]
choices.insert(0, ('', _("No Flex Directions")))
else:
choices = [(c.format(bp.name + '-'), l) for c, l in choices_format ]
choices.insert(0, ('', _("Inherit from above")))
glossary_fields.append(GlossaryField(
widgets.Select(choices=choices),
label=format_lazy(_("Flex Directions for {breakpoint}"), breakpoint=bp.label),
name='Flex_{}'.format(bp.name),
initial=''
))
return glossary_fields

@property
def display_propertys(cls):
glossary_fields = []
choices_format = [
('d-{}{}', _("horizontal")),
]
notation = ['none', 'inline', 'inline-block', 'block', 'table', 'table-cell', 'table-row', 'flex', 'inline-flex']
for bp in Breakpoint.range(Breakpoint.xs, Breakpoint.xl):
if bp == Breakpoint.xs:
choices = [(c.format('', n), c.format('', n)) for c, l in choices_format for n in notation]
choices.insert(0, ('', _("No Flex Directions")))
else:
choices = [(c.format(bp.name + '-', n),
c.format('', n)) for c, l in choices_format for n in notation]
choices.insert(0, ('', _("Inherit from above")))
glossary_fields.append(GlossaryField(
widgets.Select(choices=choices),
label=format_lazy(_("Flex Directions for {breakpoint}"), breakpoint=bp.label),
name='Flex_{}'.format(bp.name),
))
return glossary_fields

@property
def justify_content(cls):
glossary_fields = []
choices_format = [
('justify-content-{}{}', _("Justify Content")),
]
notation = [ 'start', 'end', 'center', 'between', 'around']
for bp in Breakpoint.range(Breakpoint.xs, Breakpoint.xl):
if bp == Breakpoint.xs:
choices = [(c.format('', n), c.format('', n)) for c, l in choices_format for n in notation]
choices.insert(0, ('', _("No Justify content")))
else:
choices = [(c.format(bp.name + '-', n),
c.format(bp.name + '-', n)) for c, l in choices_format for n in notation]
choices.insert(0, ('', _("Inherit from above")))
glossary_fields.append(GlossaryField(
widgets.Select(choices=choices),
label=format_lazy(_("Justify Content for {breakpoint}"), breakpoint=bp.label),
name='Justify_content_{}'.format(bp.name),
))
return glossary_fields

def floats(cls):
glossary_fields = []
choices_format = [
Expand Down
Loading