What is the equivalent of bootstrap spacing breakpoints in Material-UI? - material-ui

In Bootstrap I can control the spacing with screen-size dependent classes like so:
{property}{sides}-{breakpoint}-{size}
e.g. .p-sm-2 .p-xl-4 will set the padding on the small screen to 2 units and on a large screen to 4 units.
How would I achieve the same in Material-UI?

You can use Box component.
<Box p={{ xs: 2, lg: 4 }}>
</Box>

Related

Set Button half the window size in .NET Maui

I'd like to set the size of a button in .NET Maui to take up half of the window size, or some other fraction. I want to have some big buttons, and I can not lie. If I was doing this in html/css, I would set the width to 50%. In .NET Maui, I would think that I would set the widthrequest to 50%. There doesn't seem to be a way to do that because .WidthRequest only takes a double. So, I thought I would get the width of the current window. I try
var width = DeviceDisplay.Current.MainDisplayInfo.Width;
That only seems to return a zero when I try this in windows in debug mode. Googling doesn't seem to be much help. Is there a way to set a button to a width?
TIA
Maui has proportional sizing for grid row and columns. You don't explain where you want your button but you can use multiples of * proportional.
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/grid?view=net-maui-7.0
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
If you put a button in that middle row then it will be half the width of the grid and central.
Similarly, define 3 columns with * widths and you have a central cell half the width and half the height of the grid.
I test the code and it work well:
<Button                
x:Name="btn"                
Text="btn"/>
double width= DeviceDisplay.Current.MainDisplayInfo.Width/4;    
public MainPage()
{        
InitializeComponent();        
btn.WidthRequest=width; 
}

Can you set a responsive sx value for one breakpoint and not others?

Is it possible to use the sx property to set a value for one responsive breakpoint, but not touch that property for other breakpoints?
For example, I want a box with the color set to red on extra-small and small displays, and blue on medium and larger displays. I could do this:
<Box sx={{color: {xs:'red', md:'blue'}}}>
Hello, world
</Box>
But let's say I don't want blue on medium and larger displays. For those sizes, I want the box to behave as if I hadn't specified the property at all. Let the component pull that value from the theme or wherever it would normally get it from.
This doesn't work:
<Box sx={{color: {xs:'red', md:undefined}}}>
Hello, world
</Box>
Neither does md:null, or md:'initial'.
I'm not looking for a color specific solution, either. I'm trying to find the general pattern I could use for setting any sx property for a smaller breakpoint, without touching it for a larger one.

Can svg clip-path property be used on tspan element

Even after a lot of search I can't find any mention of this over the net. And When I tried to use clip-path on a tspan element, it didn't work for me. Am I doing something wrong or clip-path doesn't work for tspan elements that are nested inside a text element?
This is my svg code I am trying.
<svg width="500px" height="500px">
<defs>
<clipPath id="clipPath841">
<rect width="10" y="0" x="0" height="100%"></rect>
</clipPath>
</defs>
<text y="130" x="125" __internalID="internal281">
<tspan textLength="30" clip-path="url(#clipPath841)">
Hello world how are you what are you doing
</tspan>
</text>
</svg>
Per the SVG 1.1 specification you cannot set a clipPath on a tspan.
Applies to: container elements, graphics elements and ‘clipPath’
And tspan is not a graphics element.
The upcoming SVG 2 specification may change this.

GWT DockLayoutPanel with browser determining size of some subpanels?

It looks like you have to specify absolute sizes of all but one subpanel. For example, from the GWT docs:
DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
p.addNorth(new HTML("header"), 2);
p.addSouth(new HTML("footer"), 2);
p.addWest(new HTML("navigation"), 10);
p.add(new HTML(content));
But I want the north panel sized by the browser. I put some text or buttons in it and I don't know exactly what size it will be, I just know it is relatively thin and at the top of the page. And I want the content to take up the rest of the space, but no more, so there are no browser scroll bars. Is there a way to handle this with these newer layout panels?
Right now I'm using the older panels, and I have a handler attached with Window.addResizeHandler, which sets the height of the main content area so that everything fits within Window.getClientHeight
Update:
Thomas suggested a DockLayoutPanel inside a HeaderPanel, but this is not working for me:
<g:HeaderPanel>
<g:Label>Header top</g:Label>
<g:DockLayoutPanel unit='PX'>
<g:west size='300'>
<g:Label>West</g:Label>
</g:west>
<g:center>
<g:Label>Center</g:Label>
</g:center>
</g:DockLayoutPanel>
</g:HeaderPanel>
"Header top" is there, the rest invisible. It looks like inner divs are getting 0 height.
You should put a DockLayoutPanel (for the west and center regions, possibly the south one too if you don't want it to use its natural height) in a HeaderPanel (for the natural sizing of the north region)

How to change the background color of JasperReports chart

The default background color of JasperReports chart is sky blue.
I want to change that background color.
How to change it?
If you are using iReport select the charts properties and change the background property to the colour you desire.
If not in the XML for the chart there should be an xml tag called <itemLabel>.
Within this you can set the foreground and the background of the chart as seen bellow.
<itemLabel color="#000000" backgroundColor="#FFFFFF"/>
I had this problem. Contrary to even some of the official documentation, the itemLabel tag has no effect on the chart appearance.
Instead, to set the background colour of the entire chart area, create or change the backcolor attribute in the reportElement tag for your chart. E.g:
<barChart>
<chart>
<reportElement mode="Opaque" backcolor="#CCCCCC" x="0" y="0" width="400" height="400"/>
...
Note that the mode attribute must be set to "Opaque" for the colour to be rendered.
If you are using iReport, you can of course change the colour by using the properties tab.
If you want to set the background colour for only the actual chart (area within the axes where the data is displayed), set the backcolor attribute within the plot element of your chart. E.g:
<barChart>
...
<barPlot>
<plot backcolor="#CCCCCC"/>
...
This does not feature on the properties tab, so you will need to edit the xml directly.