<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Frameworks &#8211; Filip Raiper34 Gulan</title>
	<atom:link href="https://gulan.eu/category/frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>https://gulan.eu</link>
	<description>Senior frontend developer</description>
	<lastBuildDate>Fri, 07 Jul 2023 21:11:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Material Design Icons in the Phaser game</title>
		<link>https://gulan.eu/material-design-icons-in-the-phaser-game/</link>
					<comments>https://gulan.eu/material-design-icons-in-the-phaser-game/#respond</comments>
		
		<dc:creator><![CDATA[Raiper34]]></dc:creator>
		<pubDate>Fri, 07 Jul 2023 14:24:33 +0000</pubDate>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Game development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Phaserjs]]></category>
		<category><![CDATA[Typescript]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[google font icons]]></category>
		<category><![CDATA[google font icons in Phaser]]></category>
		<category><![CDATA[google font icons in Phaser3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[phaser]]></category>
		<category><![CDATA[phaser3]]></category>
		<category><![CDATA[phaserjs]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://gulan.eu/?p=311</guid>

					<description><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 3</span> <span class="rt-label rt-postfix">minutes</span></span>During my upcoming game development, I have realized that paying a graphic designer for every single thing is quite time-consuming and also a bit expensive. I needed a simple button for a fullscreen toggle. Some time ago, I needed to rework all buttons in my game. All buttons have got text inside the image, but [&#8230;]]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 3</span> <span class="rt-label rt-postfix">minutes</span></span>
<p>During my upcoming game development, I have realized that paying a graphic designer for every single thing is quite time-consuming and also a bit expensive. I needed a simple button for a fullscreen toggle. Some time ago, I needed to rework all buttons in my game. All buttons have got text inside the image, but I needed to separate it, because of localization. So I separated all text from image graphics and create <strong>JSON i18n</strong> files for every language that I wanted to include in the game. Ok well, but what about icons? Do I need to pay every time to the graphic designer when I need a new button? I have a button image (background), I need only an icon. Yes, I can create icons on my own. Or? Hmmm, There is another approach. What about using some web icon fonts like FontAwesome, Google Material Design Icons, or similar? Yes, that way exists!</p>



<p>Let&#8217;s say, we have a working Phaser 3 project. First download <strong>.tff</strong> font from the original Material Design Icons repository <a rel="noreferrer noopener" href="https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.ttf" target="_blank">https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.ttf</a>. Add font inside your project, I put it into the <strong>assets </strong>folder. Now we need to load font to be able to use it inside the Phaser project. We can load it in a CSS file and then create a fake HTML element, but there is a better newer approach called <a rel="noreferrer noopener" href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API" data-type="URL" data-id="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API" target="_blank">CSS Font loading API</a>. Thanks to this API, we can dynamically load fonts in Javascript. So we load font. </p>



<pre class="wp-block-code"><code lang="typescript" class="language-typescript line-numbers">const font = new FontFace("Icons", "url('./assets//MaterialIcons-Regular.ttf')");
(document.fonts as any).add(font);
font.load();

document.fonts.ready.then(() =&gt; {
      // Use your font here
});</code></pre>



<p></p>



<p>The first argument of <strong>FontFace</strong> is font name, it is user-defined, and you can use your own idea. The second argument is the path to your downloaded font, as I said, I put it into the assets folder. Then you need to add it into document fonts and load it. Font loading is an asynchronous operation, so we can not use it immediately, but need to wait for the font to be loaded. We can use our font in <strong>ready</strong> promise, or we can load it in some preload state during assets loading. </p>



<p>Now we can pick our desired icon on <a rel="noreferrer noopener" href="https://fonts.google.com/icons?selected=Material+Icons+Outlined:home:&amp;icon.style=Outlined" target="_blank">https://fonts.google.com/icons?selected=Material+Icons+Outlined:home:&amp;icon.style=Outlined</a> and copy th<strong>e Code point</strong>. </p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1025" height="685" src="https://gulan.eu/wp-content/uploads/2023/07/google-font-icons.png" alt="" class="wp-image-316" srcset="https://gulan.eu/wp-content/uploads/2023/07/google-font-icons.png 1025w, https://gulan.eu/wp-content/uploads/2023/07/google-font-icons-300x200.png 300w, https://gulan.eu/wp-content/uploads/2023/07/google-font-icons-768x513.png 768w" sizes="(max-width: 1025px) 100vw, 1025px" /></figure>



<p>Finally, we can create our material icon in Phaser.</p>



<pre class="wp-block-code"><code lang="typescript" class="language-typescript line-numbers">const text = this.add.text(0, 0, '\ue8b8', {color: '#6002EE', fontSize: '50px', fontFamily: 'Icons', padding: {left: 5, right: 5, top: 5, bottom: 5}});</code></pre>



<p>Important here is the content of the text (3rd argument), which is copied <strong>code point</strong> with <strong>\u</strong> prefix, which means Unicode. Also, we need to specify, that text uses our font, see font family, with our defined font name. Almost everything is good, but sometimes some icons got their top cut off. I do not understand why, but we can fix it using padding, and try to experiment with this property. I used 5px. </p>



<p>That was not so hard, and I think, I will use this approach more often. The good part is, I can combine it with the button background image and style icon in Phaser and avoid the need for a graphic designer. Pretty cool, isn&#8217;t it? You do not need to use only Material design icons, but any font icons on the web,  like Font Awesome&#8230; Just care font license!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gulan.eu/material-design-icons-in-the-phaser-game/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Vue3 Router params in Class component</title>
		<link>https://gulan.eu/vue3-router-params-in-class-component/</link>
					<comments>https://gulan.eu/vue3-router-params-in-class-component/#respond</comments>
		
		<dc:creator><![CDATA[Raiper34]]></dc:creator>
		<pubDate>Sat, 15 Jan 2022 14:50:39 +0000</pubDate>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Typescript]]></category>
		<category><![CDATA[Vue]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[typescript]]></category>
		<category><![CDATA[vue]]></category>
		<category><![CDATA[vue class component]]></category>
		<category><![CDATA[vue router params]]></category>
		<category><![CDATA[vue3]]></category>
		<category><![CDATA[vue3 router params in class component]]></category>
		<category><![CDATA[vuejs]]></category>
		<guid isPermaLink="false">https://gulan.eu/?p=241</guid>

					<description><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 2</span> <span class="rt-label rt-postfix">minutes</span></span>Recently I started to learn and program some simple demo applications (advertisement portal) in Vuejs. As an Angular developer, I am surprised by the number of ways Vue offers to achieve the desired goal. I think it is sometimes good, sometimes bad, to have multiple possibilities. Vue offers multiple approaches how to making components. Recently [&#8230;]]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 2</span> <span class="rt-label rt-postfix">minutes</span></span>
<p class="has-text-align-left">Recently I started to learn and program some simple demo applications (advertisement portal) in Vuejs. As an Angular developer, I am surprised by the number of ways Vue offers to achieve the desired goal. I think it is sometimes good, sometimes bad, to have multiple possibilities. Vue offers multiple approaches how to making components. Recently Vue developers add a new feature called the Vue <strong><a rel="noreferrer noopener" href="https://class-component.vuejs.org/" target="_blank">Class component</a></strong>. It is the approach how to making Vue components using ES6 classes, it means using inheritance, methods, properties, and all OOP principles. It is great for me, It is more intuitive for me than plain Javascript composition API or options API. </p>



<p class="has-text-align-left">However, when there is the great <strong>Class component</strong> feature, documentation and guides are still written using old principles and it is hard for newcomers to join principles together. At least it was hard for me. I was completely lost on how to access router params of the <strong><a rel="noreferrer noopener" href="https://router.vuejs.org/" data-type="URL" data-id="https://router.vuejs.org/" target="_blank">Vue router</a></strong> in the <strong>Class component</strong> and how to define these params. I needed to experiment a bit because I was unable to find a solution that fits me. I mean Vue3 application using Typescript, Vue class component, and Vue router.</p>



<h2 class="wp-block-heading">Router params in class component simple solution</h2>



<p>Yes, it was hard for me, but the completed solution is quite simple. We need to define a route as follows: </p>



<pre class="wp-block-code"><code lang="typescript" class="language-typescript">{path: '/edit-advertisement/:id', name: 'Edit Advertisement', component: EditAdvertisement, props: true}</code></pre>



<p>We defined route param placeholder in the path using <strong>:id</strong> and also it is important to set <strong>props</strong> property to <strong>true</strong>. <strong>Props</strong> property means that the router parameter will be passed to the Vue component as a property (surprisingly). Then in your Vue class component, you can access it: </p>



<pre class="wp-block-code"><code lang="typescript" class="language-typescript">import { Options, Vue } from 'vue-class-component';

@Options({
  props: {
    id: String
  }
})
export default class EditAdvertisement extends Vue {

  mounted() {
    console.log(this.id);
  }
}</code></pre>



<p>We defined <strong>id</strong> prop in <strong>Options</strong> decorator. If you do this, you can access this router param in this class using <strong>this</strong> keyword. Exactly the same as normal component props. So if you type <strong>&lt;APP_URL&gt;/edit-advertisement/1</strong> you get <strong>1</strong> in your component.</p>



<p>As you can see, it was quite a simple solution, but when I started to learn Vue3 I was unable to do it because there were solutions on the internet and StackOverflow without the <strong>Vue class component</strong> and, to be honest, I was confused from the number of possibilities that did not work together.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gulan.eu/vue3-router-params-in-class-component/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
