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

Added missing caret for BootstrapSelectFilter. Improved ColorBehaviors #1027

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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.ComponentTag;

import de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapBaseBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BackgroundColorBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BackgroundColorBehavior.BackgroundColor;
import de.agilecoders.wicket.core.util.Attributes;
import de.agilecoders.wicket.core.util.Components;

Expand All @@ -15,22 +14,23 @@
* @author miha
*/
public class BadgeBehavior extends Behavior {

private static final long serialVersionUID = 1L;

private BackgroundColorBehavior.Color color;
private BackgroundColor backgroundColor;

private boolean isPill;

public BadgeBehavior() {
this(BackgroundColorBehavior.Color.Secondary, false);
this(BackgroundColor.Secondary, false);
}

public BadgeBehavior(BackgroundColorBehavior.Color color) {
this(color, false);
public BadgeBehavior(BackgroundColor backgroundColor) {
this(backgroundColor, false);
}

public BadgeBehavior(BackgroundColorBehavior.Color color, boolean isPill) {
this.color = color;
public BadgeBehavior(BackgroundColor backgroundColor, boolean isPill) {
this.backgroundColor = backgroundColor;
this.isPill = isPill;
}

Expand All @@ -39,7 +39,7 @@ public void onComponentTag(final Component component, final ComponentTag tag) {
super.onComponentTag(component, tag);

Components.assertTag(component, tag, "span", "a");
Attributes.addClass(tag, className(), color.cssClassName());
Attributes.addClass(tag, className(), backgroundColor.cssClassName());
if (isPill) {
Attributes.addClass(tag, pillClassName());
}
Expand All @@ -60,7 +60,7 @@ public void unbind(final Component component) {
}

protected String pillClassName() {
return "rounded-pill";
return "rounded-pill";
}

protected String className() {
Expand All @@ -73,9 +73,8 @@ public BadgeBehavior pill(boolean isPill) {
return this;
}

public BadgeBehavior color(BackgroundColorBehavior.Color color) {
this.color = color;

public BadgeBehavior color(BackgroundColor color) {
this.backgroundColor = backgroundColor;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package de.agilecoders.wicket.core.markup.html.bootstrap.badge;

import java.io.Serializable;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BackgroundColorBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BackgroundColorBehavior.BackgroundColor;

/**
* Badges are our small count and labeling components.
Expand All @@ -21,34 +19,34 @@
* <span class="badge bg-info">Info</span>
* <span class="badge bg-danger">Danger</span>
* </pre>
*
* @author Jan Ferko
*/
public class BootstrapBadge extends Label {

private static final long serialVersionUID = 1L;
private BadgeBehavior badgeBehavior;

public BootstrapBadge(String id, BackgroundColorBehavior.Color color) {
this(id, null, color);
public BootstrapBadge(String id, BackgroundColor backgroundColor) {
this(id, null, backgroundColor);
}

public BootstrapBadge(String id, Serializable label, BackgroundColorBehavior.Color color) {
this(id, Model.of(label), color);
public BootstrapBadge(String id, Serializable label, BackgroundColor backgroundColor) {
this(id, Model.of(label), backgroundColor);
}

public BootstrapBadge(String id, IModel<?> model, BackgroundColorBehavior.Color color) {
public BootstrapBadge(String id, IModel<?> model, BackgroundColor backgroundColor) {
super(id, model);
add(this.badgeBehavior = new BadgeBehavior(color));
add(this.badgeBehavior = new BadgeBehavior(backgroundColor));
}

public BootstrapBadge setType(BackgroundColorBehavior.Color color) {
badgeBehavior.color(color);

public BootstrapBadge setType(BackgroundColor backgroundColor) {
badgeBehavior.color(backgroundColor);
return this;
}

public BootstrapBadge setPill(boolean isPill) {
badgeBehavior.pill(isPill);

return this;
}
}
Loading