<?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>Bogdan | Bogdan's blog</title>
	<atom:link href="https://blog.bogdancarpean.com/author/bogdan/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.bogdancarpean.com</link>
	<description>Code and anything else.</description>
	<lastBuildDate>Sat, 24 Dec 2022 02:14:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://blog.bogdancarpean.com/wp-content/uploads/2022/12/icons8-pencil-drawing-96.png</url>
	<title>Bogdan | Bogdan's blog</title>
	<link>https://blog.bogdancarpean.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Simple disable mode using only CSS</title>
		<link>https://blog.bogdancarpean.com/simple-disable-mode-using-only-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-disable-mode-using-only-css</link>
					<comments>https://blog.bogdancarpean.com/simple-disable-mode-using-only-css/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Sat, 24 Dec 2022 02:14:57 +0000</pubDate>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[web dev]]></category>
		<guid isPermaLink="false">https://blog.bogdancarpean.com/?p=451</guid>

					<description><![CDATA[<p>Photo by AVI on Unsplash There is a simple way to add a visual disable state to an HTML element. We just have to add the following CSS class to the parent HTML element we want to disable: .disabled { cursor: initial; pointer-events: none; opacity: 0.5; } Caveats of this method: disabling the elements using [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/simple-disable-mode-using-only-css/">Simple disable mode using only CSS</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<pre>Photo by <a href="https://unsplash.com/ja/@ravali?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">AVI</a> on <a href="https://unsplash.com/photos/_9ag8c_oOJU?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></pre>
<p>There is a simple way to add a visual disable state to an HTML element.</p>
<p>We just have to add the following CSS class to the parent HTML element we want to disable:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">
.disabled {
    cursor: initial;
    pointer-events: none;
    opacity: 0.5;
}
</pre>
<p>Caveats of this method: disabling the elements using CSS only does not disable the keyboard tab focusing. At the time of writing, there is no viable CSS only solution to disable the tab navigation. For this, a tabindex=&#8221;-1&#8243; property should be used on the HTML element. To dynamically switch the tabindex we need to use JavaScript to find the element and change the value.</p>The post <a href="https://blog.bogdancarpean.com/simple-disable-mode-using-only-css/">Simple disable mode using only CSS</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/simple-disable-mode-using-only-css/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Vue 3 is out &#8211; what should I do next?</title>
		<link>https://blog.bogdancarpean.com/vue-3-is-out-what-should-i-do-next/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vue-3-is-out-what-should-i-do-next</link>
					<comments>https://blog.bogdancarpean.com/vue-3-is-out-what-should-i-do-next/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Thu, 24 Sep 2020 03:00:34 +0000</pubDate>
				<category><![CDATA[vuejs]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Typescript]]></category>
		<category><![CDATA[vue 3]]></category>
		<category><![CDATA[vue next]]></category>
		<guid isPermaLink="false">https://blog.bogdancarpean.com/?p=389</guid>

					<description><![CDATA[<p>Long-awaited version 3 of the popular Vue framework is finally released (after 6 months in beta and release candidate), packed with interesting new things for Vue developers. Named &#8220;One Piece&#8221; and hosted in a separate repo, vue-next, for a period of time (to avoid being confused with 2.x and also not to be picked by [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/vue-3-is-out-what-should-i-do-next/">Vue 3 is out – what should I do next?</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<p>Long-awaited version 3 of the popular Vue framework is finally released (after 6 months in beta and release candidate), packed with interesting new things for Vue developers.</p>
<p>Named &#8220;One Piece&#8221; and hosted in a separate repo, <a href="https://github.com/vuejs/vue-next" target="_blank" rel="nofollow noopener noreferrer">vue-next</a>, for a period of time (to avoid being confused with 2.x and also not to be picked by <em>npm install </em>as @latest), the new version promises increased performance, smaller bundle size, and interesting new features to at least intriguing us for discovering more.</p>
<p>Let&#8217;s take a first look at what&#8217;s new to decide if we go all-in with the new version or wait for the moment.</p>
<p>Vue 3 introduces the <strong>Composition API</strong>, which addresses the biggest problem (*personal opinion) of Vue, the use of mixins. Mixins are a good way of abstracting code to make it more reusable, but they have some flaws: they hide the code &#8211; at some point, a method defined in the mixin is called into the component, but that method is nowhere to be found inside the component. So you start digging up, losing time tracing the method to debug. In the extreme case of mixins nested in other mixins, this job increases in complexity. Other downsides are possible namespace clash (when you define a method in your component with the same name as one in the mixin) and have side effects hard to trace and the possibility of adding too much code in the mixin that is only partly used in a component at the time, this way incorporating to much bloat in components. The new Composition API in Vue 3 is giving us a new way of defining reusable code in Composables, which are more concise and clear as structure, then import these building blocks to construct our components.</p>
<p>Vue 3 promises to be <strong>faster </strong>and to have a <strong>smaller bundle size</strong>. On Vue 2, one way of gaining performance was to transform stateful components in functional ones when you have a lot of them in the DOM, to save lost time on register/unregister when re-rendering. On Vue 3, the functional prop was taken out from components (only render functions from now on), but the difference in performance between functional components and stateful ones became negligible, so we are advised to use only stateful components (for the part of us that does not like to use render functions).</p>
<p>Another point that will increase the performance of a Vue 3 application is compiler-informed Virtual DOM. This means that at compile-time, the resulting render functions that go into the bundle are flagged when they contain runtime dynamically changing elements. This way, at runtime, the Virtual DOM is aware of the elements to look for changes and not waste time on watching static ones.</p>
<p>In Vue 3, tree-shaking of Vue internals has been added at compile time. This is a step further in the &#8220;progressive framework&#8221; approach, allowing us to transport in the bundle only the Vue internals we are actually using. More than this, we have the possibility to manually flag the compiler for the parts it can&#8217;t detect automatically for tree-shake.</p>
<p>The new proxy-based reactivity system will speed even further the runtime of our application (check the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" target="_blank" rel="nofollow noopener noreferrer">MDN docs on proxies</a> to find more on this interesting topic).</p>
<p>Some other interesting <strong>new</strong> <strong>features</strong> can be found in Vue 3.</p>
<p>The new <strong>&lt;teleport&gt;</strong> component allows us to render a part of the component template somewhere else in the DOM than the containing component place. Very useful for triggering a modal or a spinner from inside of a component to a more generic point in the DOM (e.g. &lt;body&gt;). Or, when you have a hamburger button on a mobile collapsed layout header to be able to trigger the navigation list outside that layout component.</p>
<p><strong>&lt;suspense&gt;</strong> is another component that acts as a wrapper for our component, allowing it to have an alternate template displayed until async operations are executed. Simply put, it allows us to show a loading template until the actual template is loaded and hydrated.</p>
<p>The new Vue 3 now supports <strong>multiple elements</strong> in the root of the <strong>&lt;template&gt;</strong>. This means no more wrapping all the elements in the template in one big &lt;div&gt; to avoid an error. Nice addition!!!</p>
<p><strong>&lt;v-model&gt;</strong> has a <strong>new API</strong> in the form of &lt;component v-model:key=&#8221;binding&#8221;&gt;. This allows us to pass multiple v-model binding for the same component. Multiple two-way bindings on one component. Nice!!!</p>
<p><strong>Filters</strong> have been <strong>removed</strong> from Vue 3 (these are the pipes for those coming, like myself, from the Angular world). From now on, to avoid confusion, only direct method binding {{ convertToCelsius (degrees) }}.</p>
<p>Some additions have been made to the Single File Components syntax. One is the new <strong>&lt;script setup&gt;</strong>, which is a shorthand to use instead of returning the setup function for the Composition API. The other interesting one is <strong>&lt;style vars&gt;</strong>, which allows us to pass CSS variables to the style sheet and this way to control dynamically the style at runtime.</p>
<p>For those of you wanting to tweak the framework or even to use parts of Vue to build their own framework, new <strong>modular internals</strong> of Vue 3 are here, replacing the monolith core of Vue from former versions.</p>
<p>Lastly, the wide use of <strong>TypeScript</strong> in Vue 3 allows you to have on the fly type inference in your component when you instantiate a variable. And if you already declare the type of your props, you&#8217;re already there.</p>
<p>The last thing to mention is that Vue 3 will stay on @next tag until somewhere the end of 2020 when a coordinated switch of all components to @latest will be made. Also, a minor release of Vue 2.7 is scheduled for Q1/2021, having all the 3.x backward compatible features included and the migration build for 3.x. At that point, 2.7 will enter LTS for 18 months.</p>
<p>Now that we have a clearer picture of what Vue 3 brings to the table, we ask ourselves <strong>what to do next</strong>? And as usual, there are few different answers to this question, depending on the current state of your application.</p>
<p>If you have a small application(s) that work fine and have no benefit from using the above-mentioned changes, just keep them on 2.x.</p>
<p>If you start a new application with Vue, start it directly on Vue 3, this way you have all the new benefits of the framework and your application is future proof for what&#8217;s to come for a longer period of time. The only drawback in this situation is that some of the submodules are not yet on stable releases, but I think most are stable enough (beta or RC) to be usable and soon stable.</p>
<p>If your application is a complex one and you were already thinking of some refactoring, could be the time to start architecting for the transition to Vue 3 and by the time you figure it out, hopefully, all the pieces will be in place for a fast migration and the benefits brought by Vue 3.</p>
<p>Else, if you have a complex application that is working fine now, you will want to wait a bit for the migration build to be in place and do a two-step migration to Vue 3 using this build as an intermediary step.</p>
<p>Either way, hope you will enjoy the new iteration of the framework and happy coding!</p>
<p>&nbsp;</p>The post <a href="https://blog.bogdancarpean.com/vue-3-is-out-what-should-i-do-next/">Vue 3 is out – what should I do next?</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/vue-3-is-out-what-should-i-do-next/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Javascript for of index</title>
		<link>https://blog.bogdancarpean.com/javascript-for-of-index/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-for-of-index</link>
					<comments>https://blog.bogdancarpean.com/javascript-for-of-index/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Mon, 01 Jun 2020 16:36:25 +0000</pubDate>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[for of]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[iterable]]></category>
		<category><![CDATA[js]]></category>
		<guid isPermaLink="false">https://blog.bogdancarpean.com/?p=376</guid>

					<description><![CDATA[<p>Starting with ECMA 6 we have a new loop iterating statement in the form of for&#8230;of. This helps us to loop thru an iterable object (array, string, map, set&#8230;) in a simpler fashion than the classic for loop. To achieve this, we are going to use the entries() method of the Array: for (const [index, [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/javascript-for-of-index/">Javascript for of index</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<p>Starting with ECMA 6 we have a new loop iterating statement in the form of <strong>for&#8230;of</strong>. This helps us to loop thru an iterable object (array, string, map, set&#8230;) in a simpler fashion than the classic <strong>for</strong> loop.</p>
<p>To achieve this, we are going to use the <strong>entries()</strong> method of the Array:</p>
<pre>for (const [index, element] of myArray.entries()) {
  console.log(index, element)
}</pre>The post <a href="https://blog.bogdancarpean.com/javascript-for-of-index/">Javascript for of index</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/javascript-for-of-index/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Vuetify upgrade to 2</title>
		<link>https://blog.bogdancarpean.com/vuetify-upgrade-to-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vuetify-upgrade-to-2</link>
					<comments>https://blog.bogdancarpean.com/vuetify-upgrade-to-2/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Thu, 22 Aug 2019 20:52:20 +0000</pubDate>
				<category><![CDATA[vuejs]]></category>
		<category><![CDATA[Vuetify]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[vue]]></category>
		<category><![CDATA[vuetify]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=324</guid>

					<description><![CDATA[<p>This article shows you how to update Vuetify on your existing project built with Vuetify 1 to the newly released Vuetify 2. This assumes that you have a Vue project using the Vuetify components library. Since Vuetify 2 is adopting the new Google Material Design 2, please check after the update all your components for [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/vuetify-upgrade-to-2/">Vuetify upgrade to 2</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<p>This article shows you how to update Vuetify on your existing project built with Vuetify 1 to the newly released Vuetify 2. This assumes that you have a Vue project using the Vuetify components library.</p>
<p>Since Vuetify 2 is adopting the new Google Material Design 2, please check after the update all your components for style changes and adjust where needed.</p>
<p>First, two commands to remove the Vuetify 1 lib from your project and to add Vuetify 2 to your node_modules:</p>
<pre class="theme:github line-height:19 nums:false lang:default decode:true">npm remove --save vuetify</pre>
<pre class="theme:github line-height:19 nums:false lang:js decode:true">npm install --save vuetify@latest</pre>
<p>If you try to build your project at this point, you will likely get the following error:</p>
<pre class="theme:github line-height:19 nums:false lang:default decode:true">This dependency is not found:

* vuetify/src/stylus/app.styl in ./src/plugins/vuetify.js</pre>
<p>That is because Vuetify changed the style language from Stylus in Vuetify 1 to Sass in Vuetify 2. Find your <em>vuetify.js </em>config file (mine is in /src/plugins/vuetify.js) and do the following changes:</p>
<pre class="theme:github line-height:19 nums:false lang:default decode:true" title="vuetify.js">* Delete import 'vuetify/src/stylus/app.styl'

Replace with

import 'vuetify/dist/vuetify.min.css'</pre>
<p>In my Vuetify 1 project, I also had a custom primary color. This is how the instantiation of Vuetify changes on vuetify.js:</p>
<pre class="theme:github line-height:19 nums:false lang:default decode:true " title="vuetify.js">Before
======

Vue.use( Vuetify, {
           theme: {
             primary:'#01884e'
           }
        })

After
=====

Vue.use( Vuetify )

export default new Vuetify({
                     theme: {
                       themes: {
                         light: {
                           primary: '#01884e'
                         }
                       }
                     }
                   })
</pre>
<p>The only thing left is to add Vuetify in your Vue instance. This is done in main.js file:</p>
<pre class="theme:github line-height:19 nums:false lang:default decode:true " title="main.js">import Vuetify from '@/plugins/vuetify' //your path to vuetify.js file could be different

//then we add Vuetify to our Vue instance

new Vue({
      Vuetify
}).$mount('#app')</pre>
<p>Hoping this Vuetify 2 upgrade guide has helped you on how to update Vuetify without hassle, I wish you happy coding.</p>The post <a href="https://blog.bogdancarpean.com/vuetify-upgrade-to-2/">Vuetify upgrade to 2</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/vuetify-upgrade-to-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fetch data needed on component&#8217;s template in Vue before render</title>
		<link>https://blog.bogdancarpean.com/fetch-data-needed-on-components-template-in-vue-before-render/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fetch-data-needed-on-components-template-in-vue-before-render</link>
					<comments>https://blog.bogdancarpean.com/fetch-data-needed-on-components-template-in-vue-before-render/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Thu, 01 Aug 2019 06:00:10 +0000</pubDate>
				<category><![CDATA[vuejs]]></category>
		<category><![CDATA[fetch data]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[router]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=311</guid>

					<description><![CDATA[<p>Let&#8217;s say in your Vue app you have a component that needs to fetch some data in order to display it on the template. This component needs this data on creation in order to be able to bind it on the template. Let&#8217;s take the following example: &#60;template&#62; &#60;div class="container"&#62; &#60;p&#62;Name: {{name}}&#60;/p&#62; &#60;p&#62;Age: {{age}}&#60;/p&#62; &#60;/div&#62; [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/fetch-data-needed-on-components-template-in-vue-before-render/">Fetch data needed on component’s template in Vue before render</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<p>Let&#8217;s say in your Vue app you have a component that needs to fetch some data in order to display it on the template. This component needs this data on creation in order to be able to bind it on the template.</p>
<p>Let&#8217;s take the following example:</p>
<pre class="lang:default decode:true">&lt;template&gt;
  &lt;div class="container"&gt;
    &lt;p&gt;Name: {{name}}&lt;/p&gt;
    &lt;p&gt;Age: {{age}}&lt;/p&gt;
  &lt;/div&gt;
&lt;/template&gt;
&lt;script&gt;
data():{
  return{
    name: null
    age: null
  }
}

created():{
  fetchUser().
    then(res =&gt; {
     this.name = res.data.name
     this.age = res.data.age 
    }
    )
}
&lt;/script&gt;</pre>
<p>In this example, we have a Vue Component that needs to fetch the user name and age before being able to create the template and display them. We use the lifecycle hook&nbsp;<em>created()&nbsp;</em>to fetch the data in the component. This will finally work, because of the reactive nature of Vue, but we are going to have an error in the console telling us that&nbsp;<em>name&nbsp;</em>is undefined. This happens because when we navigate to the component and this one gets rendered, the value of the variables is not yet fetched, the component rendering first the template, then executing the script. So we get the error on the console, then the script is run, data is fetched and displayed.</p>
<p>Let&#8217;s see how to do that without having the error on the console:</p>
<pre class="lang:default decode:true ">&lt;template&gt;
 &lt;div class="container" v-if="dataFetched"&gt;
   &lt;p&gt;Name: {{name}}&lt;/p&gt;
   &lt;p&gt;Age: {{age}}&lt;/p&gt;
 &lt;/div&gt;
&lt;/template&gt;
&lt;script&gt;
data: {
  return {
    name: null
    age: null
    dataFetched: false
  }
},

beforeRouteEnter(to, from, next) {
  fetchUser().
    then(res =&gt; {
      next(vm =&gt; vm.setUser(res.data)
    })
},

methods: {
  setUser(user){
    this.name = user.name
    this.age = user.age
    this.dataFetched = true
  }
}
&lt;/script&gt;</pre>
<p>To achieve this, we first use the&nbsp;<em>beforeRouteEnter()&nbsp;</em>guard of the Vue Router that is called before the Router navigates to our component route. This guard has three parameters: to, from and next. From is an object containing the information about the route we are navigating from, also the parameters passed by route, to is the information about the route we are navigating to, next() is the function we call after we executed all we need on the guard to pursue the navigation.</p>
<p>But moving the fetch logic from the lifecycle hook to the guard alone won&#8217;t solve our problem because fetch is an asynchronous operation that will start on the guard, then next is called, leading to template rendering before data being fetched and virtually the same error on console.</p>
<p>To achieve this, we use a trick. We declare a boolean in the component, let&#8217;s say&nbsp;<em>dataFetched,&nbsp;</em>that we instantiate to false and we use it to trigger with&nbsp;<em>v-if&nbsp;</em>the render of the container div only when the data is fetched. We set the variable to true in the setUser method in the component after data is fetched, this way preventing the render of the template and the error on the console.</p>
<p>Happy coding!!!</p>The post <a href="https://blog.bogdancarpean.com/fetch-data-needed-on-components-template-in-vue-before-render/">Fetch data needed on component’s template in Vue before render</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/fetch-data-needed-on-components-template-in-vue-before-render/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to @extend sass classes or use sass global variables in Vue components</title>
		<link>https://blog.bogdancarpean.com/how-to-extend-sass-classes-or-use-sass-global-variables-in-vue-components/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-extend-sass-classes-or-use-sass-global-variables-in-vue-components</link>
					<comments>https://blog.bogdancarpean.com/how-to-extend-sass-classes-or-use-sass-global-variables-in-vue-components/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Wed, 20 Mar 2019 04:16:21 +0000</pubDate>
				<category><![CDATA[css]]></category>
		<category><![CDATA[vuejs]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[sass]]></category>
		<category><![CDATA[vue]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=274</guid>

					<description><![CDATA[<p>Extend classes and use of variables are two of the sass most powerful tools. But using them in a VueJS application could be a little bit tricky. In this article, I will show you a way of using these two on components without the need for importing the sheet containing them at each usage. Let&#8217;s [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/how-to-extend-sass-classes-or-use-sass-global-variables-in-vue-components/">How to @extend sass classes or use sass global variables in Vue components</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-image"><figcaption>Extend classes and use of variables are two of the sass most powerful tools. But using them in a VueJS application could be a little bit tricky. In this article, I will show you a way of using these two on components without the need for importing the sheet containing them at each usage.</p>
<p style="text-align: left;">Let&#8217;s assume that you have a class that you want to extend</p>
<pre class="EnlighterJSRAW" data-enlighter-language="css" data-enlighter-theme="classic">src/styles/style.scss

.my_class_to_extend {
  backgroud-color: aqua;
}</pre>
<p style="text-align: left;">Assuming you generated your project with @vue/cli, you have to add the following statement to vue.config.js in order to have file visibility throughout your application</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">module.exports = {
  css: {
    loaderOptions: {
      sass: {
        data: `@import "@/styles/style.scss";`
      }
    }
  }
}</pre>
<p style="text-align: left;">Then, you can use @extend on which component you want</p>
<pre class="EnlighterJSRAW" data-enlighter-language="html">&lt;style lang="scss" scoped&gt;
.my_extended_class {
  @extend .my_class_to_extend;
}
&lt;/style&gt;</pre>
<p style="text-align: left;">Remember that you have to use sass in both extended and extender sheets for this to work.</p>
</figcaption></figure>The post <a href="https://blog.bogdancarpean.com/how-to-extend-sass-classes-or-use-sass-global-variables-in-vue-components/">How to @extend sass classes or use sass global variables in Vue components</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/how-to-extend-sass-classes-or-use-sass-global-variables-in-vue-components/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>New ng lint syntax on Angular 6</title>
		<link>https://blog.bogdancarpean.com/new-ng-lint-syntax-on-angular-6/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-ng-lint-syntax-on-angular-6</link>
					<comments>https://blog.bogdancarpean.com/new-ng-lint-syntax-on-angular-6/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Tue, 19 Jun 2018 22:50:36 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Angular 2]]></category>
		<category><![CDATA[TypeScript]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[angular/cli]]></category>
		<category><![CDATA[lint]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=251</guid>

					<description><![CDATA[<p>Let&#8217;s say you had a syntax like ng lint --format stylish on your package.json before Angular 6. Running this after you update to Angular 6 will result in the following error: Architect command with multiple targets cannot specify overrides. This error is not much of help when you know that before update the linting worked fine. For this [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/new-ng-lint-syntax-on-angular-6/">New ng lint syntax on Angular 6</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<div style="text-align: left;">Let&#8217;s say you had a syntax like <code>ng lint --format stylish</code> on your <code>package.json</code> before Angular 6.</div>
<p>Running this after you update to Angular 6 will result in the following error: <code>Architect command with multiple targets cannot specify overrides.</code> This error is not much of help when you know that before update the linting worked fine.</p>
<p>For this to work, we have to add the name of the application after the <code>ng lint</code> command: <code>ng lint your_app_name --format stylish</code></p>The post <a href="https://blog.bogdancarpean.com/new-ng-lint-syntax-on-angular-6/">New ng lint syntax on Angular 6</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/new-ng-lint-syntax-on-angular-6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Create custom color theme on Angular Material</title>
		<link>https://blog.bogdancarpean.com/create-custom-color-theme-on-angular-material/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-custom-color-theme-on-angular-material</link>
					<comments>https://blog.bogdancarpean.com/create-custom-color-theme-on-angular-material/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Thu, 01 Feb 2018 02:04:34 +0000</pubDate>
				<category><![CDATA[Angular Material]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[custom color]]></category>
		<category><![CDATA[custom theme]]></category>
		<category><![CDATA[material]]></category>
		<category><![CDATA[material design]]></category>
		<category><![CDATA[sass]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=197</guid>

					<description><![CDATA[<p>Most of the time when building an Angular Material application, you will need to customize your color palette, so that you adapt the look of your application to your client&#8217;s brand. In this article, we are going to do that customization for an Angular app that uses Angular Material. When you add Angular Material to [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/create-custom-color-theme-on-angular-material/">Create custom color theme on Angular Material</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<div style="position: relative;">Most of the time when building an Angular Material application, you will need to customize your color palette, so that you adapt the look of your application to your client&#8217;s brand. In this article, we are going to do that customization for an Angular app that uses Angular Material.</div>
<div style="position: relative;">When you add Angular Material to your app, you have the choice of four pre-built themes: deeppurple-amber, indigo-pink, pink-bluegrey or purple-green.</div>
<div>An Angular Material theme is based on five color palettes, each palette being just a collection of nuances generated from one main color: the primary palette (the main color used across the application), the accent palette (color used for floating action button and interactive elements), the warn palette (used for all error displays), the foreground palette (used for text and icons) and the background palette (used for element backgrounds).</div>
<div></div>
<div>Let&#8217;s say we are going to define a custom theme using three colors: the primary color, the accent (or the contrast) color and the warn color. For the first two, we are going to generate custom palettes, for the third, we are going to use the <code>material red</code> predefined palette.</div>
<div></div>
<div>First, we are going to generate a scss file, let&#8217;s call it <code>your-theme.scss</code>, in a common zone folder, let&#8217;s say <code>app/common/themes</code>.</div>
<div>Into this file, we are going to <code>@import</code> the theming file from Angular Material which contains the <code>mat-core()</code> mixin, containing all the common styles used by material components. (<code>mat-core()</code> should only be included once in your app to not duplicate the common styles).</div>
<div></div>
<div>
<pre class="EnlighterJSRAW" data-enlighter-language="css">@import '../node_modules/@angular/material/theming';

@include mat-core();</pre>
<p>Next, we need to generate the material palettes for our two custom colors (primary and accent). An excellent site to do this is <a href="http://mcg.mbitson.com" target="_blank" rel="noopener noreferrer">mcg.mbitson.com</a>. In our example, we are going to use <code>#008a00</code> as the primary custom color and <code>#ca5d1e</code> as the accent color. On the generator, enter the name you want for your color variable, click on the arrow on the right of the color box on the header and enter the color code in the input field under the color picker. Click choose and you will see the material nuances generated from your custom color. To export the palette, click on the clipboard icon on the header, then choose <code>output format</code> Angular JS 2 (Material 2). Copy the generated code in our <code>your-theme.scss</code> file. Do the same for the accent color. We will end up having the two custom color material palettes:</p>
</div>
<pre class="EnlighterJSRAW" data-enlighter-language="null">@import '../node_modules/@angular/material/theming'; @include mat-core();

@include mat-core();

$my-primary: (
    50 : #e0f1e0,
    100 : #b3dcb3,
    200 : #80c580,
    300 : #4dad4d,
    400 : #269c26,
    500 : #008a00,
    600 : #008200,
    700 : #007700,
    800 : #006d00,
    900 : #005a00,
    A100 : #8bff8b,
    A200 : #58ff58,
    A400 : #25ff25,
    A700 : #0cff0c,
    contrast: (
        50 : #000000,
        100 : #000000,
        200 : #000000,
        300 : #000000,
        400 : #ffffff,
        500 : #ffffff,
        600 : #ffffff,
        700 : #ffffff,
        800 : #ffffff,
        900 : #ffffff,
        A100 : #000000,
        A200 : #000000,
        A400 : #000000,
        A700 : #000000,
    )
);

$my-accent: (
    50 : #f9ece4,
    100 : #efcebc,
    200 : #e5ae8f,
    300 : #da8e62,
    400 : #d27540,
    500 : #ca5d1e,
    600 : #c5551a,
    700 : #bd4b16,
    800 : #b74112,
    900 : #ab300a,
    A100 : #ffdfd7,
    A200 : #ffb5a4,
    A400 : #ff8c71,
    A700 : #ff7858,
    contrast: (
        50 : #000000,
        100 : #000000,
        200 : #000000,
        300 : #000000,
        400 : #000000,
        500 : #ffffff,
        600 : #ffffff,
        700 : #ffffff,
        800 : #ffffff,
        900 : #ffffff,
        A100 : #000000,
        A200 : #000000,
        A400 : #000000,
        A700 : #000000,
    )
);</pre>
<p>Now, all we have left to do is to declare the three palettes, declare the new theme using the three palettes and then add the newly created theme into the material themes.</p>
<div style="position: relative;">
<pre class="EnlighterJSRAW" data-enlighter-language="css">@import '../node_modules/@angular/material/theming';

@include mat-core();


$my-primary: (
    50 : #e0f1e0,
    100 : #b3dcb3,
    200 : #80c580,
    300 : #4dad4d,
    400 : #269c26,
    500 : #008a00,
    600 : #008200,
    700 : #007700,
    800 : #006d00,
    900 : #005a00,
    A100 : #8bff8b,
    A200 : #58ff58,
    A400 : #25ff25,
    A700 : #0cff0c,
    contrast: (
        50 : #000000,
        100 : #000000,
        200 : #000000,
        300 : #000000,
        400 : #ffffff,
        500 : #ffffff,
        600 : #ffffff,
        700 : #ffffff,
        800 : #ffffff,
        900 : #ffffff,
        A100 : #000000,
        A200 : #000000,
        A400 : #000000,
        A700 : #000000,
    )
);

$my-accent: (
    50 : #f9ece4,
    100 : #efcebc,
    200 : #e5ae8f,
    300 : #da8e62,
    400 : #d27540,
    500 : #ca5d1e,
    600 : #c5551a,
    700 : #bd4b16,
    800 : #b74112,
    900 : #ab300a,
    A100 : #ffdfd7,
    A200 : #ffb5a4,
    A400 : #ff8c71,
    A700 : #ff7858,
    contrast: (
        50 : #000000,
        100 : #000000,
        200 : #000000,
        300 : #000000,
        400 : #000000,
        500 : #ffffff,
        600 : #ffffff,
        700 : #ffffff,
        800 : #ffffff,
        900 : #ffffff,
        A100 : #000000,
        A200 : #000000,
        A400 : #000000,
        A700 : #000000,
    )
);

//the first two are the custom palettes we declared above
$my-theme-primary: mat-palette($my-primary);
$my-theme-accent: mat-palette($my-accent);
//the third, for the warn color, is the predefined material red palette
$my-theme-warn: mat-palette($mat-red);

$my-theme: mat-light-theme($my-theme-primary, $my-theme-accent, $my-theme-warn);

@include angular-material-theme($my-theme);</pre>
<p>The only one thing left to do is to import the generated theme file into the <code>styles.scss</code> file found in the root of your application</p>
</div>
<pre class="EnlighterJSRAW" data-enlighter-language="css">@import "./path/to/your-theme.scss"</pre>
<p><em>If you&#8217;re in Montreal and passionate about Angular, come meet at <a href="https://www.meetup.com/Angular-Montreal">Angular Montreal Meetup</a></em></p>The post <a href="https://blog.bogdancarpean.com/create-custom-color-theme-on-angular-material/">Create custom color theme on Angular Material</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/create-custom-color-theme-on-angular-material/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Deepcopy of JavaScript Objects and Arrays using lodash&#8217;s cloneDeep method</title>
		<link>https://blog.bogdancarpean.com/deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method</link>
					<comments>https://blog.bogdancarpean.com/deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Fri, 12 Jan 2018 14:08:06 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[cloneDeep]]></category>
		<category><![CDATA[copy objects]]></category>
		<category><![CDATA[deep clone]]></category>
		<category><![CDATA[deep copy]]></category>
		<category><![CDATA[lodash]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=182</guid>

					<description><![CDATA[<p>While developing JavaScript applications, often we need to make copies of Objects or Arrays containing Objects. Then we want to work with those copies without affecting the original objects. In a common scenario, we are going to deal with a simple, one level Object (an Object without other Objects nested inside), like in the following [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method/">Deepcopy of JavaScript Objects and Arrays using lodash’s cloneDeep method</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<div style="position: relative;">While developing JavaScript applications, often we need to make copies of Objects or Arrays containing Objects. Then we want to work with those copies without affecting the original objects.<br />
In a common scenario, we are going to deal with a simple, one level Object (an Object without other Objects nested inside), like in the following example:</div>
<pre class="EnlighterJSRAW" data-enlighter-language="js">let originalObject = {name: 'Bunt', type: 'dog'};</pre>
<p>Then, we want to make a copy of the <code>originalObject</code>. In <code>ES6</code>, we are going to do something like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">let copiedObject = Object.assign({}, originalObject);</pre>
<p>This will create the <code>copiedObject</code> with all the properties and respective values of the <code>originalObject</code>. Now, if we want to change a value in the <code>copiedObject</code>, this will not change also the value into the <code>originalObject:</code></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">copiedObject.type = 'cat';

console.log(originalObject.type); // will print 'dog'
console.log(copiedObject.type); // will print 'cat'</pre>
<p>Now, what is going to happen if we have a nested Object inside our Object, doing the same operations?</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">let originalObject = {name: 'Bunt', details: {type: 'dog', color: 'brown'}};

let copiedObject = Object.assign({}, originalObject);

copiedObject.details.type = 'cat'; 

console.log(originalObject.details.type); // will print 'cat' 
console.log(copiedObject.details.type); // will print 'cat'</pre>
<p>As you can see, when you change the value of a property in the nested Object of <code>copiedObject</code>, that change is perpetuated to the same property of the nested Object in <code>originalObject</code>. You&#8217;ll ask why that happened? Because JavaScript passes the primitive values (string, number, etc.) as <code>value-copy</code> and the compound values (Objects, Arrays, Functions) as <code>reference-copy</code> to the value of the primitives on that Object. This way, when we copied the Object containing the nested Object, we have created a <code>shallow copy</code> of that object, meaning that the primitives found at the first level of the Object have values that are copied, thus when we change them into the <code>copiedObject</code>, they are not going to change in the <code>originalObject</code> while all other property found in a nested object will have the value passed as a <code>reference</code> to the same property value into the nested Object of <code>originalObject</code>, thus when we change its value, we actually change the value of the reference, resulting on both nested Objects having the modified property value.</p>
<p>Now, what&#8217;s the solution to <code>deep copy</code> an Object or Array, meaning that we want to have a copy free of references at all nested levels so we can change the values inside without the fear of breaking the original?</p>
<p>The first solution you are going to find is to serialize the Object to a JSON, then parse back that JSON to a JavaScript Object, practically passing the Object thru a string that will clean up the Object tree from the references nested inside by recreating a new Object with copied properties and values from the original one.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">let copiedObject = JSON.parse(JSON.stringify(originalObject));</pre>
<p>But this is a controversial solution. Why? Because this is going to work fine as long as your Objects and the nested Objects only contains primitives, but if you have objects containing <code>functions</code>, this won&#8217;t work. Neither for <code>Date</code>.</p>
<p>So, what&#8217;s the working solution? We are going to use <a href="https://lodash.com/">lodash&#8217;s</a> <a href="https://lodash.com/docs/4.17.4#cloneDeep">cloneDeep</a> method to <code>deep copy</code> the Object. Lodash is an excellent JavaScript utility library for those not knowing it yet. The <code>cloneDeep</code> method will iterate all levels of the original Object and recursively copying all properties found.</p>
<p>The example I will give here is in Angular. Since we don&#8217;t want to carry all the bundle of <code>lodash</code> to the client, we are going only to import the cloneDeep method.</p>
<p>First, let&#8217;s install <code>lodash</code>into our project:</p>
<p><code>yarn add lodash</code> or <code>npm install lodash</code></p>
<p>Once installed, we are going to use in our component:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">import * as cloneDeep from 'lodash/cloneDeep';

...

clonedObject = cloneDeep(originalObject);</pre>
<p>Importing <code>cloneDeep</code> will add to your build 18kb, a fair price to pay in order to have a reliable <code>deep copy</code> solution for you Objects.</p>
<p>I added a demo app on Github <a href="https://github.com/bogdancar/demo-angular-object-deep-copy">here</a>.</p>
<p><em>Interested in Angular? Join our <a href="https://www.meetup.com/Angular-Montreal/">Angular Montreal Meetup</a>.</em></p>The post <a href="https://blog.bogdancarpean.com/deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method/">Deepcopy of JavaScript Objects and Arrays using lodash’s cloneDeep method</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to run Angular tests on CI Docker Container with Chrome</title>
		<link>https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-run-angular-tests-on-ci-docker-container-with-chrome</link>
					<comments>https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Sat, 06 Jan 2018 05:31:33 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[angular tests]]></category>
		<category><![CDATA[angular/cli]]></category>
		<category><![CDATA[atlassian bitbucket pipelines]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[node]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=171</guid>

					<description><![CDATA[<p>In this article, we are going to learn how to run the tests of an Angular solution generated with @angular/cli into a Docker Container without changing any of the initial configuration generated by @angular/cli. This is very important in the context of Continuous Integration workflow when you want to run your tests as you commit [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/">How to run Angular tests on CI Docker Container with Chrome</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<div style="position: relative;">In this article, we are going to learn how to run the tests of an Angular solution generated with <a href="https://cli.angular.io/" target="_blank" rel="noopener noreferrer"><code>@angular/cli</code></a> into a Docker Container without changing any of the initial configuration generated by <a href="https://cli.angular.io/" target="_blank" rel="noopener noreferrer"><code>@angular/cli</code></a>. This is very important in the context of Continuous Integration workflow when you want to run your tests as you commit to the repo.</div>
<p>For this example I&#8217;m gonna use the <a href="https://bitbucket.org/product" target="_blank" rel="noopener noreferrer">Atlassian Bitbucket Pipelines</a> for continuous integration, but is not limited to it, you can use it in any other environment that is using a <a href="https://www.docker.com/" target="_blank" rel="noopener noreferrer">Docker Container</a>, like Bitbucket, to test and build your Angular app.</p>
<p>To be able to test the Angular solution generated with <a href="https://cli.angular.io/" target="_blank" rel="noopener noreferrer"><code>@angular/cli</code></a>, we need a <a href="https://www.docker.com/" target="_blank" rel="noopener noreferrer">Docker Container</a> with <a href="https://nodejs.org/en/" target="_blank" rel="noopener noreferrer">Node</a> to run <code>npm install</code> in order to install the dependencies and then we need an instance of <a href="https://www.google.com/chrome/browser/desktop/index.html" target="_blank" rel="noopener noreferrer"><code>chrome</code></a> to run the tests.</p>
<p>For this, we have two solutions. I prefer the first one in which we take the official Node Docker Container, for the time being, 6.9.4, we install the <code>chrome</code> browser, then run <code>npm install</code> to fetch the dependencies of the project, then finally run our tests.</p>
<p>For Atlassian Bitbucket Pipelines, we are going to use the following code in the commit <code>bitbucket-pipelines.yml</code> file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="ini">image: node:6.9.4

pipelines:
  default:
    - step:
        caches:
          - node
        script:
          - apt-get update; apt-get install -y gettext-base;
          - echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' &gt; /etc/apt/sources.list.d/chrome.list
          - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
          - set -x &amp;&amp; apt-get update &amp;&amp; apt-get install -y xvfb google-chrome-stable
          - wget -q -O /usr/bin/xvfb-chrome https://bitbucket.org/atlassian/docker-node-chrome-firefox/raw/ff180e2f16ea8639d4ca4a3abb0017ee23c2836c/scripts/xvfb-chrome
          - ln -sf /usr/bin/xvfb-chrome /usr/bin/google-chrome
          - chmod 755 /usr/bin/google-chrome
          - npm install
          - ./node_modules/@angular/cli/bin/ng -v
          - ./node_modules/@angular/cli/bin/ng test --watch=false</pre>
<p>Please take into consideration that this is the code for a <code>debian linux</code> machine inside the Docker Container, so you have to adapt if you have a different machine.</p>
<p>I said that this solution is my preferred one because I want to test my app against the newest <code>chrome</code> version and I achieve this by installing the latest on each commit I make.</p>
<p>The downside of this solution is that it has to fetch all the updates for the <code>linux</code> machine and install <code>chrome</code> and it will take between 2 and 3 minutes to accomplish so this can become costly if you have a time limit on your Bitbucket account.</p>
<p>The second solution is to take a container from <a href="https://hub.docker.com/" target="_blank" rel="noopener noreferrer">Docker Container Hub</a> containing already Node and Chrome and to run the code starting from <code>npm install</code>. This way you cut in half the runtime, but you are going to test against the version of <code>chrome</code> installed into the Docker Container.</p>
<p>Have fun!</p>The post <a href="https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/">How to run Angular tests on CI Docker Container with Chrome</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
