nextjs image into svg - reactjs

How can I import a png image into a nextJS svg component.
This is the sample code I'm working with.
<Page title="Logo Designer" className="max-w-xl">
<div>
<svg id="logoDesigner" width={700} height={600} style={{ backgroundColor: 'lightgray' }}>
<rect class="draggable" x="4" y="5" width="80" height="100" fill="#007bff" />
<rect class="draggable" x="18" y="5" width="80" height="400" fill="#888" />
</svg>
</div>
</Page>

you can use the image tag
<image
width="100"
height="100"
xlink:href="my-logo.png"
/>
make sure to change the width height and xlink:href based on your need

Related

Make placeholder loading responsive

I'm using create-content-loader package for creating placeholder loading but can't make it responsive.
How to make svg fill parent content. I don't want to set width hardcoded 1060px. I tried with viewbox property too.
<ContentLoader
height={40}
width={1060}
speed={2}
primaryColor="#d9d9d9"
secondaryColor="#ecebeb"
>
<rect x="10" y="40" rx="0" ry="0" width="75" height="10" />
<rect x="10" y="60" rx="0" ry="0" width="75" height="10" />
<rect x="10" y="100" rx="0" ry="0" width="75" height="10" />
<rect x="10" y="80" rx="0" ry="0" width="75" height="10" />
<rect x="10" y="120" rx="0" ry="0" width="75" height="10" />
<rect x="110" y="40" rx="0" ry="0" width="370" height="125" />
<rect x="275" y="63" rx="0" ry="0" width="72" height="4" />
<rect x="430" y="5" rx="5" ry="5" width="75" height="20" />
<rect x="110" y="10" rx="0" ry="0" width="200" height="15" />
<rect x="10" y="5" rx="4" ry="4" width="75" height="20" />
<circle cx="493" cy="54" r="2" />
<circle cx="497" cy="47" r="7" />
<circle cx="497" cy="77" r="7" />
<circle cx="497" cy="107" r="7" />
</ContentLoader>```
ContentLoader uses html5 canvas for rendering, so viewbox won't work. What I would do is:
add ref to container element (which holds ContentLoader).
get that element width by using ref
pass that value to the ContentLoader width prop.
Keep in mind that on the first render ref.current will be null or undefined
Update:
Also you can try to extract svg from create-content-loader example and turn it into your component. Just change svg attributes to match rect related svg props. Than set css class on svg to have these properties:
.responsive-svg {
width: 100%;
height: auto;
}
Svg (before you turn it into react component) might look something like this:
<svg
role="img"
width="400"
height="160"
aria-labelledby="loading-aria"
viewBox="0 0 400 160"
preserveAspectRatio="none"
>
<title id="loading-aria">Loading...</title>
<rect
x="0"
y="0"
width="100%"
height="100%"
clip-path="url(#clip-path)"
style='fill: url("#fill");'
></rect>
<defs>
<clipPath id="clip-path">
<rect x="48" y="8" rx="3" ry="3" width="88" height="6" />
<rect x="48" y="26" rx="3" ry="3" width="52" height="6" />
<rect x="0" y="56" rx="3" ry="3" width="410" height="6" />
<rect x="0" y="72" rx="3" ry="3" width="380" height="6" />
<rect x="0" y="88" rx="3" ry="3" width="178" height="6" />
<circle cx="20" cy="20" r="20" />
</clipPath>
<linearGradient id="fill">
<stop
offset="0.599964"
stop-color="#f3f3f3"
stop-opacity="1"
>
<animate
attributeName="offset"
values="-2; -2; 1"
keyTimes="0; 0.25; 1"
dur="2s"
repeatCount="indefinite"
></animate>
</stop>
<stop
offset="1.59996"
stop-color="#ecebeb"
stop-opacity="1"
>
<animate
attributeName="offset"
values="-1; -1; 2"
keyTimes="0; 0.25; 1"
dur="2s"
repeatCount="indefinite"
></animate>
</stop>
<stop
offset="2.59996"
stop-color="#f3f3f3"
stop-opacity="1"
>
<animate
attributeName="offset"
values="0; 0; 3"
keyTimes="0; 0.25; 1"
dur="2s"
repeatCount="indefinite"
></animate>
</stop>
</linearGradient>
</defs>
</svg>

Using xPath find all elements where text contains 'en':

<svg width="400" height="550">
<g style="enable-background:new">
<rect x="40" y="20" width="300" height="450" style="fill:url(#MyGradient)" /> <g style="font-size:75px;fill:#888888;fill-opacity:.6">
<text x="50" y="90" filter="url(#normal)">Normal</text>
<text x="50" y="180" filter="url(#multiply)">Multiply</text>
<text x="50" y="270" filter="url(#screen)">Screen</text>
<text x="50" y="360" filter="url(#darken)">Darken</text>
<text x="50" y="450" filter="url(#lighten)">Lighten</text>
</g>
</g>
</svg>
//text[contains(text(), 'en')]
This xpath gives me the following result.
'<text filter="url(#screen)" x="50" y="270">Screen</text>'
'<text filter="url(#darken)" x="50" y="360">Darken</text>'
'<text filter="url(#lighten)" x="50" y="450">Lighten</text>'

How to Replace Default icon in Visual Studio 2013 apache cordova application for ipad/iphone

I tried in different ways to replace default app icon but its not working for me.i added custom icons res/icons/ios in this path. when I build my cordova app on remote device(ipad) its always showing default app icon.if anyone help me to solve my problem? I also added following lines into my config.xml file.
*
<platform name="android">
<!--
ldpi : 36x36 px
mdpi : 48x48 px
hdpi : 72x72 px
xhdpi : 96x96 px
xxhdpi : 144x144 px
xxxhdpi : 192x192 px
-->
<icon src="res/android/ldpi.png" density="ldpi" />
<icon src="res/android/mdpi.png" density="mdpi" />
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
<icon src="res/android/xxhdpi.png" density="xxhdpi" />
<icon src="res/android/xxxhdpi.png" density="xxxhdpi" />
</platform>
<platform name="ios">
<!-- iOS 8.0+ -->
<!-- iPhone 6 Plus -->
<icon src="res/ios/icon-60-3x.png" width="180" height="180" />
<!-- iOS 7.0+ -->
<!-- iPhone / iPod Touch -->
<icon src="res/ios/icon-60.png" width="60" height="60" />
<icon src="res/ios/icon-60-2x.png" width="120" height="120" />
<!-- iPad -->
<icon src="res/ios/icon-76.png" width="76" height="76" />
<icon src="res/ios/icon-60-2x.png" width="152" height="152" />
<!-- iOS 6.1 -->
<!-- Spotlight Icon -->
<icon src="res/ios/icon-40.png" width="40" height="40" />
<icon src="res/ios/icon-40-2x.png" width="80" height="80" />
<!-- iPhone / iPod Touch -->
<icon src="res/ios/icon.png" width="60" height="60" />
<icon src="res/ios/icon-2x.png" width="120" height="120" />
<!-- iPad -->
<icon src="res/ios/icon-72.png" width="72" height="72" />
<icon src="res/ios/icon-72-2x.png" width="144" height="144" />
<!-- iPhone Spotlight and Settings Icon -->
<icon src="res/ios/icon-small.png" width="29" height="29" />
<icon src="res/ios/icon-small-2x.png" width="58" height="58" />
<!-- iPad Spotlight and Settings Icon -->
<icon src="res/ios/icon-50.png" width="50" height="50" />
<icon src="res/ios/icon-50-2x.png" width="100" height="100" />
</platform>
You need to open your project in xcode and find the Resources folder -> images.xsassets
http://ticons.fokkezb.nl/
above link is useful for create your icon and splash-screen for your ios application.
once that downloaded you drag and drop icons in appicon and splashscreen in lanchimage
I hope this work for you.

how to create AngularJs svg directive

I'm trying to create an angular (1.5.5) directive where the template is an svg element. I read this answer, and several others, but I'm not able to get my simple svg element to show.
I have tried to simplify it as much as possible. So this simple directive should draw a circle when used inside a svg element, at least that is what I'm trying to achieve.
app.directive("svg01", () => {
return {
templateNamespace: "svg",
template: `
<circle cx="50" cy="50" r="40" stroke="blue" stroke-width="4" fill="green" />
`
//template: `
// <svg width="100" height="100">
// <circle cx="50" cy="50" r="40" stroke="blue" stroke-width="4" fill="white" />
// </svg>
//`
}
});
This does not show the circle with this html
<div style="height: 100px; background-color: lightgreen">
<svg width="100" height="100">
<svg01></svg01>
</svg>
</div>
if instead I change the directive to include the svg element, then it shows (since this is now an html element I assume)
app.directive("svg01", () => {
return {
templateNamespace: "svg",
//template: `
// <circle cx="50" cy="50" r="40" stroke="blue" stroke-width="4" fill="green" />
//`
template: `
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="blue" stroke-width="4" fill="white" />
</svg>
`
}
});
<div style="height: 100px; background-color: lightgreen">
<svg01></svg01>
</div>
And it doesn't matter if I set the templateNamespace to "html" or "svg". It shows in either case.
Is it not possible to define an svg template in a directive, and instead I need to add it programmatically as suggested in this answer
What am I missing ?
Thanks
Ahh - I found the problem, and I will post this as an answer instead of modifying my question, adding replace: true and the shape is shown
app.directive("svg01", () => {
return {
replace: true,
templateNamespace: "svg",
template: `
<circle cx="50" cy="50" r="40" stroke="blue" stroke-width="4" fill="yellow" />
`

What is the exact difference between ToolBarPanel and ToolBarTray in wpf?

What is the exact difference between ToolBarPanel and ToolBarTray in WPF?
Here you are
The ToolBar uses a ToolBarPanel and a ToolBarOverflowPanel in its ControlTemplate. The ToolBarPanel is responsible for the layout of the items on the toolbar. The ToolBarOverflowPanel is responsible for the layout of the items that do not fit on the ToolBar. For an example of a ControlTemplate for a ToolBar, see
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/toolbar-overview?view=netframeworkdesktop-4.8
ToolBarPanel Class
XAML
<ToolBarTray Background="White">
<ToolBar Band="1" BandIndex="1">
<Button>
<Image Source="toolbargraphics\cut.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\copy.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\paste.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\undo.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\redo.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\paint.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\spell.bmp" />
</Button>
<Separator/>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\save.bmp" />
</Button>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\open.bmp" />
</Button>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\print.bmp" />
</Button>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\preview.bmp" />
</Button>
</ToolBar>
</ToolBarTray>

Resources