How to add style class and icon to TabContainerItem in openui5 - sapui5

How to add style class and icon to the TabContainerItem in openui5?
In TabContainerItem documentation there is no addStyleClass and icon properties which is possible in tabstrip by using tab title.
but I need to use TabContainerItem because it is having tabs menu which is useful in mobile device.
Can any one please help me
oTabContainer = new sap.m.TabContainer("tabContainer", {
items:
[
new sap.m.TabContainerItem({name: "tab1",
content: [
new sap.ui.core.mvc.JSView({id:"tab1",viewName:"oui5mvc.tab1"})
]}),
new sap.m.TabContainerItem({name: "tab2",
content: [
new sap.ui.core.mvc.JSView({id:"tab2",viewName:"oui5mvc.home"})
]}),
]
}).placeAt("content").addStyleClass("tabContainer");
Here is an example that i have tried.

Since sap.m.TabContainerItem inherits from Element directly and not from Control it does not offer addStyleClass.
However, you can still apply custom CSS to the TabContainerItem by adding a style class to the sap.m.TabContainer which targets its TabContainerItem children, like:
/* class tabContainer as your custom class added to the TabContainer */
/* custom TabContainerItem (selected) */
.tabContainer
.sapMTabStrip
.sapMTSTabsContainer
.sapMTSTabs
.sapMTabStripItem.sapMTabStripItemSelected {
color : green;
background : yellow;
}
/* custom TabContainerItem (unselected) */
.tabContainer
.sapMTabStrip
.sapMTSTabsContainer
.sapMTSTabs
.sapMTabStripItem {
color : white;
background : grey;
}
Here`s your adapted example. You can adjust this to your needs with basic CSS rules, then.
As far as I know, it is currently not supported to add an icon/image to the TabContainerItem. You can create a feature request for that on the issue tracker of the OpenUI5 project with the enhancement label or contribute it by yourself.

Related

Case Study for Card Development Using Pseudo-Classes

While developing a card, I used a pseudo-class for a component to implement a color changing effect. However, the color cannot be restored.
For example, the original background color of a picture was yellow.See Image
This figure shows the new background color after using the pseudo-class. It is red now.
See Image
In normal cases, the card’s background color is changed upon tapping, and will return to the original color when you lift your finger. So how to achieve this?
Simply add a tap event to the component using the pseudo-class. No logic processing is needed.
Sample code:
<div class="sitetype_box" widgetid="8e4bf1ca-f716-46f8-8614-16d1b35002c5" onclick="test">
</div>
CSS style:
.sitetype_box {
flex-direction: column;
background-color:#FFBF00;
padding: dpConvert(0) dpConvert($elementsMarginHorizontalL) dpConvert(0) dpConvert($elementsMarginHorizontalL);
}
/** Pseudo-class */
.sitetype_box :active{
background-color: #E40078;
}
Method:
test(){
console.log("message");
}
For Details,check Pseudo-classes for quick apps

What's the difference between withStyle and withTheme in material ui?

I am new to the web development, and I am trying to use material-ui. I saw some demo codes use withStyle and some others use withTheme. Are there any differences between them? Thanks a lot!
I think the accepted answer is not well-explained, to be more clear:
1) withStyles also provides the theme object when creating css styles; the signature of creating function is like:
const styles = theme => ({
root: {
maxWidth: 600,
},
tabs: {
borderTopWidth: 1,
borderTopStyle: 'solid',
borderColor: theme.palette.divider,
width: '100%',
},
});
As one can see theme and everything inside it like theme.palette can be accessed. Official documentation and examples are everywhere so I just randomly picked this one. (Press this button to show the source codes: "< >")
2) The purpose of withTheme is to inject theme into props, so it could also be accessed inside component functions like render, sometimes it's useful. Official documentation here.
withStyles overrides the style of a specific component.
withTheme overrides the style of a specific component while also giving you access to the theme so that your style can be based on the theme's colors, typography, spacing, etc.
It can be confusing because you have to create a new component using these higher-order functions:
const MyCustomBottom = withStyles(styles)(Button);
const MyCustomThemeBasedButton = withTheme(theme)(Button);

How to change layout of sap.uxap.ObjectPage Blocks

Demo
I have 2 + 5 blocks here, in small screen, each panel in blocks are in full width.
But in large screen, blocks are in 3:3:3 or 6:3. I want them all in a single row.
each section is contained in <div class="sapUiRespGridSpanL4 sapUiRespGridSpanM6 sapUiRespGridSpanS12 sapUiRespGridSpanXL3">
How to change it to class="sapUiRespGridSpanL12 sapUiRespGridSpanM12 sapUiRespGridSpanS12 sapUiRespGridSpanXL12" ?
I've tried to add layout in Panel, but not working.
Refrence:
sap.uxap.ObjectPageLayout Documentation
layout of blocks, blocks are in the same color, hard to specify
Finally after 1.5 hours figured out
Reason: Blocks will have to be extended from BlockBase to apply columnLayout.
Extending the BlockBase:
sap.ui.define(["sap/uxap/BlockBase"], function (BlockBase) {
"use strict";
var BlockPanel = BlockBase.extend("sap.uxap.sample.ObjectPageSubSectionSized.blocks.BlockPanel", {
metadata: {
/* no additional views provided */
}
});
return BlockPanel;
});
Then create a view and controller using the above new ui5 extended control. Use that in your page with columnLayout
xmlns:sample="sap.uxap.sample.ObjectPageSubSectionSized.blocks"
...
...
<uxap:blocks>
<sample:BlockPanel columnLayout="4"/>
</uxap:blocks>
columnLayout can't be applied if you don't extend block base. (which is really pathetic design). Nevertheless, values range from 1-4 and "auto".
Created working plnkr here
How to build custom SAPUI control?
You can wrap the target controls up with sap.uxap.BlockBase[API]. BlockBase controls are intended to be used inside sap.uxap.ObjectPageSubSection (hence the name <blocks>) and support customizing the grid spans with the property columnLayout.
Here is a demo: https://embed.plnkr.co/lSrDk9/?show=view%2FHome.view.xml,preview
<uxap:ObjectPageSubSection>
<block:MyBlock columnLayout="4"/>
<block:MyBlock columnLayout="4"/>
</uxap:ObjectPageSubSection>
Provide a not elegant, but very fast way: Overwrite CSS
<uxap:ObjectPageSubSection class="fullWidthPanel">
/* CSS specificity */
.fullWidthPanel .sapUiRespGrid.sapUiRespGridHSpace1 > div {
width: 98.88888889%;
width: -webkit-calc(100% - 1rem);
width: calc(100% - 1rem)
}

How to user custom Drag Appearance in smart gwt

I am trying to user Custom Drag appearance in smart gwt. how can i implement it.
Current when using DragAppearance.TRACKER its show on 10px square i want a lable with caption Drag to Lineup.
vLayout1.setDragAppearance(DragAppearance.TRACKER);
vLayout1.setCanHover(true);
vLayout1.setCursor(Cursor.HAND);
I hope, the following links will help you
https://github.com/moravianlibrary/MEditor/blob/master/editor-editation/src/main/java/cz/mzk/editor/client/view/ModifyView.java#L1100:L1104
https://github.com/moravianlibrary/MEditor/blob/master/editor-common/editor-common-client/src/main/java/cz/mzk/editor/client/view/other/EditorDragMoveHandler.java
Override BaseWidget.setDragTracker and provide required content using EventHandler.setDragTracker.
VLayout vLayout1 = new VLayout() {
#Override
protected boolean setDragTracker() {
EventHandler.setDragTracker("<pre>Drag to Lineup</pre>");
return false;
}
};
vLayout1.setCanDrop(true);
vLayout1.setCanDrag(true);
vLayout1.setDragAppearance(DragAppearance.TRACKER);
EventHandler.setDragTracker accepts any valid html code and <pre/> tags were used above to avoid word wrap.
Check following sample in SmartGWT showcase:
http://www.smartclient.com/smartgwt/showcase/#effects_dd_tracker

Bing map hover waypoint pushpin icons

i'm developing a web application with bing map. I used this method to change the waypoint pushpin icon:
directionsManager.setRenderOptions({
itineraryContainer: document.getElementById('itineraryDiv'),
waypointPushpinOptions: {
icon: "/images/citta-nascosta/blue-pushpin.png",
height:29,
width:25,
draggable:false,
textOffset:new Microsoft.Maps.Point(-1,3)
}
});
Then i render the map with:
directionsManager.calculateDirections();
In the site i see the pushpin with my custom icons, but i also want to change the icon in hover (actually i see the hover standard icon, the blue flag).
Someone know how to set a custom hover waypoint pushpin icon? Or prevent the mousehover event?
Try using hoverIcon inside waypointPushPinOptions like so:
directionsManager.setRenderOptions({
itineraryContainer: document.getElementById('itineraryDiv'),
waypointPushpinOptions: {
icon: "/images/citta-nascosta/blue-pushpin.png",
hoverIcon: "/images/citta-nascosta/blue-pushpin-hover.png",
height:29,
width:25,
draggable:false,
textOffset:new Microsoft.Maps.Point(-1,3)
}
});
This property is undocumented. If Microsoft wants to get their map API adopted more, they should really get their act together instead of paying companies to use it. Very sloppy!
You can set the typeName property on the options object when creating the pushpin. This gets set as a the class name of the containing the pushpin.
Example - if you set typeName to 'waypoint', then in your css you could have:
div.waypoint {
/* normal settings */
}
div.waypoint:hover {
/* hover settings */
}
Alternatively you could subscribe to the mouse events on the pushpin and in response change the typeName property on the pushpin and have different css rules apply (if the :hover pseudo class doesn't work)
Hope that helps.