Magento 2 Different Swatch Types in the Category and Product Page - magento2

Would it be possible to use 2 different Swatch Types in the Category and Product Page?
My view.xml as follows. I'd like to use the swatch_image in the Category Page and swatch_image_base in the Product page for the swatches.
<images module="Magento_Catalog">
<image id="swatch_image" type="swatch_image">
<width>30</width>
<height>30</height>
</image>
<image id="swatch_thumb" type="swatch_thumb">
<width>110</width>
<height>90</height>
</image>
<image id="swatch_image_base" type="swatch_image">
<width>60</width>
<height>60</height>
</image>
Is this possible to do?

Related

How to make cards in material Ui appear in a horizontal row?

Im implementing material Ui in my project.I have list of cards ..I want them to appear one by one in a horizontal row and then in the same pattern in the next row.But my cards are appearing one below the other.I have tried adding some custom css but it dosent work.Pls check out my code.There are like two cards. with the box im able to adding some margin to my cards .How to make them appear next to each other?
function Blogs(){
const [expanded, setExpanded] = React.useState(false);
const handleExpandClick = () => {
setExpanded(!expanded);
};
return (
<>
<Box m={6}>
<Card sx={{ maxWidth: 345 }}>
<CardHeader
title="It’s a cocktail o’clock."
subheader="May 14, 2021"
/>
<CardMedia
component="img"
height="194"
image="https://img.freepik.com/free-photo/selection-various-cocktails-table_140725-2909.jpg?w=2000"
alt="Paella dish"
/>
<CardContent>
<Typography variant="body2" color="text.secondary">
Beat The Heat With Chilled Cocktails At The Best Bars In New York.
</Typography>
</CardContent>
<CardActions disableSpacing>
<ExpandMore
expand={expanded}
onClick={handleExpandClick}
aria-expanded={expanded}
aria-label="show more"
>
<ExpandMoreIcon />
</ExpandMore>
</CardActions>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent>
<Typography paragraph>To a foodie, summer means one thing and one thing only – DRINKS!</Typography>
<Typography paragraph>
Yes people, we know it’s hot out there and the only way to quench your thirst is by guzzling down a bunch of ice-cold cocktails
</Typography>
<Typography paragraph>
<h4>1.The Bar Room at The Beekman</h4>
Visit the beautiful Bar Room in the historic Beekman Hotel for high-key romance that really wows.
Do try the whiskey sour.One of the best drinks available.
<h4>2.Dublin House</h4>
You can never go wrong with Sláinte! Margarita,Pot O'Gold, & Irish Old Fashioned
<h4>3.Russian Samovar</h4>
Alpensahne,Amarula Cream Liqueur, Caribou,Feni
</Typography>
</CardContent>
</Collapse>
</Card>
</Box>
<Box m={6}>
<Card sx={{ maxWidth: 345 }}>
<CardHeader
title="Winner Winner Pizza Dinner"
subheader="May 14, 2021"
/>
<CardMedia
component="img"
height="194"
image="https://cdn.shopify.com/s/files/1/0624/9853/articles/20220211142645-margherita-9920.jpg?crop=center&height=800&v=1660843558&width=800"
alt="Paella dish"
/>
<CardContent>
<Typography variant="body2" color="text.secondary">
Beat The Heat With Chilled Cocktails At The Best Bars In New York.
</Typography>
</CardContent>
<CardActions disableSpacing>
<ExpandMore
expand={expanded}
onClick={handleExpandClick}
aria-expanded={expanded}
aria-label="show more"
>
<ExpandMoreIcon />
</ExpandMore>
</CardActions>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent>
<Typography paragraph>To a foodie, summer means one thing and one thing only – DRINKS!</Typography>
<Typography paragraph>
Yes people, we know it’s hot out there and the only way to quench your thirst is by guzzling down a bunch of ice-cold cocktails
</Typography>
<Typography paragraph>
<h4>1.The Bar Room at The Beekman</h4>
Visit the beautiful Bar Room in the historic Beekman Hotel for high-key romance that really wows.
Do try the whiskey sour.One of the best drinks available.
<h4>2.Dublin House</h4>
You can never go wrong with Sláinte! Margarita,Pot O'Gold, & Irish Old Fashioned
<h4>3.Russian Samovar</h4>
Alpensahne,Amarula Cream Liqueur, Caribou,Feni
</Typography>
</CardContent>
</Collapse>
</Card>
</Box>
</>
);
}
export default Blogs;
Use MUI Grid for responsive layout and horizontal row
import { Grid } from "#mui/material"
<Grid container direction="row" justifyContent="center">
<Grid item xs={4}>
<Card> ..... </Card>
</Grid>
<Grid item xs={4}>
<Card> ..... </Card>
</Grid>
<Grid item xs={4}>
<Card> ..... </Card>
</Grid>
</Grid>
xs={4} will display 3 Cards in each row because 12/3 = 4 as MUI uses 12 columns grid system. You can also use md, sm, lg, xl for different screen sizes.

Xamarin Forms: How to make each Carousel Page a different Color

I created Carousel view that contains a Collection of Slides. Each slide contains and image, message, and Color. It is stored in an ObservableCollection. I have three colors in the collection. The first slide/page should be yellow, second should be Red, and third should be blue. The issue I have is, when the app initiates all of the slides are blue in the carousel. I need each slide/page to have different colors.
Carousel.ItemsSource = slides = new ObservableCollection<Slides>(new[]
{
new Slides("money", "Some Description", BackgroundColor = Color.Yellow),
new Slides("money", "Some Description2", BackgroundColor = Color.Red),
new Slides("money", "Some Description3",BackgroundColor = Color.Blue)});
<Control:CarouselViewControl x:Name="Carousel"
ShowIndicators="True"
BackgroundColor="{Binding Color}"
CurrentPageIndicatorTintColor="Black">
<Control:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ContentView Grid.Row="0" Padding="60,30,60,0">
<Image Source="{Binding Image}" Aspect="AspectFit"/>
</ContentView>
<ContentView Grid.Row="1" Padding="20,50,20,0">
<Label Text="{Binding Message}" TextColor="black"
HorizontalOptions="CenterAndExpand"
FontSize="Large"/>
</ContentView>
</Grid>
</DataTemplate>
</Control:CarouselViewControl.ItemTemplate>
</Control:CarouselViewControl>
I expect each page to have different colors.
You are binding the BackgroundColor for the CarouselViewControl, which will set it for the whole view, not the distinct slides.
Furthermore, the items stored in ItemsSource do not represent any views in the CarouselViewControl, but rather data objects. Just because an object in the ItemsSource collection has a value BackgroundColor, the BackgroundColor of the respective view in the CarouselViewControl ain't set automagically.
To set the background of the pages you'll have to operate from within the DataTemplate and bind the BackgroundColor property of the Grid to the respective property of Slide.
<DataTemplate>
<Grid BackgroundColor="{Binding BackgroundColor}"> <!-- Bind the grids BackgroundColor to the one of the Slide -->
<!-- the grids content -->
</Grid>
</DataTemplate>

Obtain bounding box of <use> with external reference

I am writing an application that uses D3 to make some SVG charts. This application renders a number of annotations onto the charts.
The annotations appear as icons, so I have made an external XML file containing the icons defined within a <defs> section, and reference them by inserting a <use> element something like this:
<use x="100" y="50" xlink:href="defs.xml#iconname" />
I want to lay out the icons so that they are not overlapping and obscuring each other. In order to find out if they are overlapping, I attempt to obtain their bounding boxes.
My problem is that when I try to obtain the bounding boxes, using either getBBox() or getBoundingClientRect(), the returned rectangles have zero width and zero height.
The following sample illustrates the problem:
a.html:
<?xml version="1.0" standalone="no"?>
<html>
<head></head>
<body>
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<use id="used_icon" x="100" y="100" xlink:href="b.xml#test_icon" />
</svg>
<script>
var u = document.getElementById("used_icon");
var rect = u.getBoundingClientRect();
console.log("getBoundingClientRect = %d,%d - %d,%d", rect.left, rect.top, rect.right, rect.bottom);
var box = u.getBBox();
console.log("getBBox = x=%d,y=%d - w=%d,h=%d", box.x, box.y, box.width, box.height);
</script>
</body>
</html>
b.xml
<?xml version="1.0" standalone="no"?>
<svg width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<g id="test_icon">
<rect width="50" height="50" />
</g>
</defs>
</svg>
The output of this, in both Firefox is:
getBoundingClientRect = 8,8 - 8,8
getBBox = x=0,y=0 - w=0,h=0
and Chrome:
getBoundingClientRect = 107,107 - 107,107
getBBox = x=0,y=0 - w=0,h=0
If I place the <defs> inline in the same document, this does not occur and I get correct width and height (although incorrect x & y in Chrome due to this bug). But I would prefer not to have them in the same document, so that I can centralize the definition of all my icons.
I assume the reason for this is the asynchronous nature of referencing externally definitions - the browser may have to fetch them. Note that the page is constructed dynamically so it is not just a case of waiting until onLoad or similar event is emitted.
Is there any way I can get a callback when the external references have been loaded?

My autogenerated columns do not show in Datagrid

Most posts regarding DataGrid AutoGenerateColumns seem to deal with how to circumvent default behavior. Unfortunately the default is what I am struggling with.
I have several database tables created with Entity Framework 6.0, and would like to display them in my View using one and the same Datagrid for all tables, and AutoGenerating the Columns. Desired outcome: for the class-specific Viewmodel bound at run-time, display the columns with headers and at least one row.
XAML of the View's user control:
<UserControl.Resources>
<DataTemplate x:Key="TableDataTemplate">
<DataGrid
AutoGenerateColumns="True"
GridLinesVisibility="All"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible">
</DataGrid>
</DataTemplate>
</UserControl.Resources>
<StackPanel Height="720" Width="980">
<!-- shows user which menu item was chosen -->
<TextBlock Text="{Binding DisplayName}"/>
<!-- defines the Input data grid for adding to DB table -->
<Grid Height="80" MaxHeight="200">
<ItemsControl
ItemsSource="{Binding CurrentDataTable}"
ItemTemplate="{StaticResource TableDataTemplate}">
</ItemsControl>
</Grid>
The user control is bound to a class-specific 'Class'TableViewModel, implemented for all Database Tables. One example:
class ClientsAdminTableViewModel : TableViewModel
{
// the Property the view binds to
private IList<Client> currentDataTable;
public ObservableCollection<Client> CurrentDataTable
{
get { return CollectionExtensions.ToObservableCollection<Client>(currentDataTable); }
set { currentDataTable = value; OnPropertyChanged("CurrentDataTable")}
}
public ClientsAdminTableViewModel()
{
DisplayName = Strings.ClientAdminDisplayName;
currentDataTable = context.Clients.ToList<Client>();
}
When bound to {Binding CurrentDataTable} this code produces a UI, where I can see a grey body (probably the rows) surrounded by horizontal and vertical scrollbars, on top of which one long line (which must be the header line), but no columns.
Any help is appreciated.
your datagrid needs to have its itemsource set
try adding
ItemsSource="{Binding CurrentDataTable}"
to the datagrid declaration. Also, do you get any binding errors in the output window?
This code now works (Thank you J. King!) The trick was to get rid of the data template, create the data grid right in the grid with the exact same binding statements.
<StackPanel Height="720" Width="980">
<!-- shows user which menu item was chosen -->
<TextBlock Text="{Binding DisplayName}"/>
<!-- defines the Input data grid for adding to DB table -->
<Grid Height="200" MaxHeight="400">
<DataGrid
ItemsSource="{Binding CurrentDataTableNew}"
AutoGenerateColumns="True"
GridLinesVisibility="All"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible" >
</DataGrid>
</Grid>
</userControl>

Text filed of jasper report alignment issue in IE8

I am using iReport to create JR reports, and I would like to know if there is a way to set the text alignment for IE8. I have already set textAlignment="Left" but it does not work for IE8. Right now in IE8 it display at the center of total size of text field.
My text field is located at Is it any other property Page Footer band. Is it any different property present for IE? Is any other property present so that my text field automatically resize with respect to total text present in text box?
Following is my code:
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="413" height="30">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<box leftPadding="10"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA["Created By: "+ $P{CREATED_BY}]]></textFieldExpression>
</textField>
I solved ii by some jquery trick. it is not a exact solution but it works for me
Alter jasper report render on jsp page. it structure like this
<td>
<p>
<span> Created By:
</span>
</p>
</td>
Using jquery I have find out specific span for "Created by" text. then parent of span i.e and apply text align property left.
<script type="text/javascript">
$(function(){
$('span').each(function() {
//alert($(this).html());
if($(this).html().indexOf("Created By") == 0)
{
$(this).parent().css("text-align","left");
}
});
});
</script>