-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wicket 10.x bootstrap 5.x panel style (#1016)
* Align background classes with Bootstrap 5.3 * Add PanelStyle feature - text and background is set to the same combination as in BS doc: https://getbootstrap.com/docs/5.3/utilities/background/ - border uses same color as background - samples show panel styles - added PanelTypesPanel References #1006 * Add PanelType parameter to the constructor
- Loading branch information
Showing
7 changed files
with
225 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...-core/src/main/java/de/agilecoders/wicket/core/markup/html/bootstrap/panel/PanelType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.agilecoders.wicket.core.markup.html.bootstrap.panel; | ||
|
||
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BackgroundColorBehavior; | ||
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BorderBehavior; | ||
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.BorderBehavior.Color; | ||
import de.agilecoders.wicket.core.markup.html.bootstrap.utilities.ColorBehavior; | ||
|
||
/** | ||
* Automatically sets panel's header background and border. | ||
*/ | ||
public enum PanelType | ||
{ | ||
Default(null, null, null), | ||
Primary(BackgroundColorBehavior.Color.Primary, ColorBehavior.Color.White, BorderBehavior.Color.Primary), | ||
Primary_subtle(BackgroundColorBehavior.Color.Primary_subtle, ColorBehavior.Color.Primary_emphasis, BorderBehavior.Color.Primary_subtle), | ||
Secondary(BackgroundColorBehavior.Color.Secondary, ColorBehavior.Color.White, BorderBehavior.Color.Secondary), | ||
Secondary_subtle(BackgroundColorBehavior.Color.Secondary_subtle, ColorBehavior.Color.Secondary_emphasis, BorderBehavior.Color.Secondary_subtle), | ||
Success(BackgroundColorBehavior.Color.Success, ColorBehavior.Color.White, BorderBehavior.Color.Success), | ||
Success_subtle(BackgroundColorBehavior.Color.Success_subtle, ColorBehavior.Color.Success_emphasis, BorderBehavior.Color.Success_subtle), | ||
Danger(BackgroundColorBehavior.Color.Danger, ColorBehavior.Color.White, BorderBehavior.Color.Danger), | ||
Danger_subtle(BackgroundColorBehavior.Color.Danger_subtle, ColorBehavior.Color.Danger_emphasis, BorderBehavior.Color.Danger_subtle), | ||
Warning(BackgroundColorBehavior.Color.Warning, ColorBehavior.Color.Black, BorderBehavior.Color.Warning), | ||
Warning_subtle(BackgroundColorBehavior.Color.Warning_subtle, ColorBehavior.Color.Warning_emphasis, BorderBehavior.Color.Warning_subtle), | ||
Info(BackgroundColorBehavior.Color.Info, ColorBehavior.Color.White, BorderBehavior.Color.Info), | ||
Info_subtle(BackgroundColorBehavior.Color.Info_subtle, ColorBehavior.Color.Info_emphasis, BorderBehavior.Color.Info_subtle), | ||
Light(BackgroundColorBehavior.Color.Light, ColorBehavior.Color.Black, BorderBehavior.Color.Light), | ||
Light_subtle(BackgroundColorBehavior.Color.Light_subtle, ColorBehavior.Color.Light_emphasis, BorderBehavior.Color.Light_subtle), | ||
Dark(BackgroundColorBehavior.Color.Dark, ColorBehavior.Color.White, BorderBehavior.Color.Dark), | ||
Dark_subtle(BackgroundColorBehavior.Color.Dark_subtle, ColorBehavior.Color.Dark_emphasis, BorderBehavior.Color.Dark_subtle), | ||
Body_secondary(BackgroundColorBehavior.Color.Body_secondary, null, BorderBehavior.Color.Primary), | ||
Body_tertiary(BackgroundColorBehavior.Color.Body_tertiary, null, BorderBehavior.Color.Primary), | ||
Body(BackgroundColorBehavior.Color.Body, ColorBehavior.Color.Body, BorderBehavior.Color.Primary), | ||
Black(BackgroundColorBehavior.Color.Black, ColorBehavior.Color.White, BorderBehavior.Color.Black), | ||
White(BackgroundColorBehavior.Color.White, ColorBehavior.Color.Black, BorderBehavior.Color.White), | ||
Transparent(BackgroundColorBehavior.Color.Transparent, ColorBehavior.Color.Body, null); | ||
|
||
|
||
private BackgroundColorBehavior.Color backgroundColor; | ||
private ColorBehavior.Color textColor; | ||
private BorderBehavior.Color borderColor; | ||
|
||
private PanelType(BackgroundColorBehavior.Color backgroundColor, ColorBehavior.Color textColor, Color borderColor) { | ||
this.backgroundColor = backgroundColor; | ||
this.textColor = textColor; | ||
this.borderColor = borderColor; | ||
} | ||
|
||
/** | ||
* @return the backgroundColor | ||
*/ | ||
public BackgroundColorBehavior.Color getBackgroundColor() { | ||
return backgroundColor; | ||
} | ||
|
||
/** | ||
* @return the textColor | ||
*/ | ||
public ColorBehavior.Color getTextColor() { | ||
return textColor; | ||
} | ||
|
||
/** | ||
* @return the borderColor | ||
*/ | ||
public BorderBehavior.Color getBorderColor() { | ||
return borderColor; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
bootstrap-samples/src/main/java/de/agilecoders/wicket/samples/panels/PanelTypesPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org"> | ||
<body> | ||
<wicket:panel> | ||
<div class="row"> | ||
<div wicket:id="panelTypes" class="col-lg-4 mt-3"> | ||
<h4 wicket:id="panelType"></h4> | ||
<div wicket:id="panel"></div> | ||
</div> | ||
</div> | ||
</wicket:panel> | ||
</body> | ||
</html> |
40 changes: 40 additions & 0 deletions
40
bootstrap-samples/src/main/java/de/agilecoders/wicket/samples/panels/PanelTypesPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.agilecoders.wicket.samples.panels; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.html.image.ExternalImage; | ||
import org.apache.wicket.markup.html.link.Link; | ||
import org.apache.wicket.markup.html.list.ListItem; | ||
import org.apache.wicket.markup.html.list.PropertyListView; | ||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.model.Model; | ||
|
||
import de.agilecoders.wicket.core.markup.html.bootstrap.button.BootstrapButton; | ||
import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons; | ||
import de.agilecoders.wicket.core.markup.html.bootstrap.panel.PanelType; | ||
|
||
/** | ||
* @author Jan Ferko | ||
*/ | ||
public class PanelTypesPanel extends Panel { | ||
|
||
public PanelTypesPanel(String id) { | ||
super(id); | ||
} | ||
|
||
@Override | ||
protected void onInitialize() { | ||
super.onInitialize(); | ||
|
||
add(new PropertyListView<PanelType>("panelTypes", Arrays.asList(PanelType.values())) { | ||
@Override | ||
protected void populateItem(ListItem<PanelType> item) { | ||
item.add(new Label("panelType", item.getModelObject().name())); | ||
item.add(new SimpleCard("panel").withPanelType(item.getModelObject())); | ||
} | ||
}); | ||
} | ||
} |