<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: disjfa</title>
    <description>The latest articles on DEV Community by disjfa (@disjfa).</description>
    <link>https://dev.to/disjfa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F189542%2F18ff2a06-b8bf-433c-8374-dc3b74013f8e.jpeg</url>
      <title>DEV Community: disjfa</title>
      <link>https://dev.to/disjfa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/disjfa"/>
    <language>en</language>
    <item>
      <title>Long live css4!</title>
      <dc:creator>disjfa</dc:creator>
      <pubDate>Tue, 03 Mar 2020 22:18:41 +0000</pubDate>
      <link>https://dev.to/disjfa/long-live-css4-4cak</link>
      <guid>https://dev.to/disjfa/long-live-css4-4cak</guid>
      <description>&lt;p&gt;So there is talk online about css4. There is no css4, lets see wat we can do without it. Maybe think of a way to help the argument. If you just want to skip to the end, i made a quick view on the status of css, you can check it &lt;a href="https://disjfa.github.io/css4/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;So where we started was checking what we can find on the internet. There are lots of discussions about css4, some nicely summed up on &lt;a href="https://css-tricks.com/css4-update/"&gt;this article on css-tricks&lt;/a&gt;. Nice! We are done. But not yet.&lt;/p&gt;

&lt;p&gt;Lets see what we can do now. If you develop we all know about the &lt;a href="https://caniuse.com/"&gt;caniuse website&lt;/a&gt;. The go to when we developers want to add something to our website. Also nice! But they have all their data open source. So we tested what we can do with that data. We found the &lt;a href="https://www.npmjs.com/package/caniuse-lite"&gt;caniuse-lite&lt;/a&gt; package. All the data we need, maybe we can do something with that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thoughts
&lt;/h2&gt;

&lt;p&gt;So next up we have read the articles, we have listened and maybe ignored all the people on the internet. So we have another opinion. We have the data, lets just sum up the features based on releases for all the data we can get from the caniuse-lite package.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules
&lt;/h2&gt;

&lt;p&gt;The rules, for now, are simple. Lets sum up every feature and sort them by release date. Release date meaning the date all the browsers have set the feature to fully supported. This can be a sort of release date for a feature on the internet. This is done in more places on the internet, in javascript we now have es2019, es2020 etc. So to create the basic specs we can just say we have releases x feature in x year. But for now just sum up the data.&lt;/p&gt;

&lt;h3&gt;
  
  
  The browsers
&lt;/h3&gt;

&lt;p&gt;We also need to use some browsers. For now we just made the rule we use the 4 major browsers. &lt;a href="https://www.google.com/chrome/"&gt;chrome&lt;/a&gt;, &lt;a href="https://www.microsoft.com/en-us/edge"&gt;edge&lt;/a&gt;, &lt;a href="https://www.mozilla.org/en-US/firefox/new/"&gt;firefox&lt;/a&gt; and &lt;a href="https://www.apple.com/safari/"&gt;safari&lt;/a&gt;. Maybe we can add the mobile versions, maybe not. If you have opinions, please share. The data can only get better moving forward.&lt;/p&gt;

&lt;p&gt;Just a thought as a reminder, the data we have is for css, html and javascript. So if there is a feature that is not just css, just keep in mind we just made a list of features. The css part is the part we can use for this article, the rest is just more information. Information we can also use. &lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;First we sum op the browsers by date. Just sum up to get the data, just as a reference. We have the list &lt;a href="https://disjfa.github.io/css4/browsers/index.html"&gt;here&lt;/a&gt;. Just list all browser by date, simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lite&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;caniuse-lite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;lite&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;agents&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next up, list all the features. All the features and setup a table adding some colors to show if a feature is supported, &lt;a href="https://disjfa.github.io/css4/features/index.html"&gt;check the list of features here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lite&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;caniuse-lite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;lite&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;features&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Cool, we have a sample. Lets play some more. We need a support table that can tell us what we can use from when. So next up we made a list of features. Checked if a feature is fully supported, and from there get the date of the last browser that supports the feature. Not hard, but it can be done. So to sup it all up, we added some functions and made that list! Based upon the latest data we have. The list can be found &lt;a href="https://disjfa.github.io/css4/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cool, data
&lt;/h2&gt;

&lt;p&gt;So now we have the data. We have the list based on dates supported. Now we can tell by a simple list  what has been supported, by date. This is very handy, we can see when we can use features. By date. Also we can just read the entire list to see what we didn't know even existed. Or just to have a log of items to see and learn. There is a date in the list in january 2020 when edge moved over to chromium when a lot released. So january 2020 is a date to remember for support.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next
&lt;/h2&gt;

&lt;p&gt;Next is just to make the web more awesome! We know what we can use, we know how to make it more awesome. If you have thoughts on the data, please let us know. If you do not agree on a step we used here, feel free to check the source and do you. We just made a list of open data to show the things we like and want to see.&lt;/p&gt;

&lt;p&gt;Just make cool stuff.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://disjfa.github.io/css/2020/03/03/long-live-css4.html"&gt;Original article&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@morganharpernichols?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Morgan Harper Nichols&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mailing with symfony, what can we do!</title>
      <dc:creator>disjfa</dc:creator>
      <pubDate>Mon, 02 Dec 2019 21:38:53 +0000</pubDate>
      <link>https://dev.to/disjfa/mailing-with-symfony-what-can-we-do-1nl1</link>
      <guid>https://dev.to/disjfa/mailing-with-symfony-what-can-we-do-1nl1</guid>
      <description>&lt;p&gt;Ok so symfony created a new &lt;a href="https://symfony.com/doc/current/components/mime.html"&gt;mime&lt;/a&gt; component to create emails, and a new &lt;a href="https://symfony.com/doc/current/mailer.html"&gt;mailer&lt;/a&gt; component to send those. Let's bundle them up and see what we end up with!&lt;/p&gt;

&lt;p&gt;If you prefer to skip to the end, just install the &lt;a href="https://packagist.org/packages/disjfa/mail-bundle"&gt;bundle&lt;/a&gt; we made and enjoy!&lt;/p&gt;

&lt;h3&gt;
  
  
  Why?
&lt;/h3&gt;

&lt;p&gt;Why we started this. We made a lot of symfony apps and in every app we started a new mail system, awesome they were. But after the third or fourth we knew the basics. But as is in every project we forgot to make a bundle and kept copy pasting the data missing stuff or re-create the methods over and over again. Se lets make a bundle that can be used and re-used.&lt;/p&gt;

&lt;p&gt;This will be a setup for the core data of the bundle, so code.  &lt;/p&gt;

&lt;h3&gt;
  
  
  History
&lt;/h3&gt;

&lt;p&gt;So first up, a bit of history in my words. So probably none is true, but i like it. The guys (guys as in plural men and women of course) from symfony used a old package swiftmailer, so they ended up maintaining it. This could be cleaner and nicer, so they made that with the mime component, decoupling the sending in the mailer component. In the way making the components they set it up in a way to make it fancier and add magic. Awesome, now lets get into the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;This article will talk about the setup, opinionated and the way we would set things up. We will have ideas and opinions. And if you differ from those, you will hopefully learn a thing or two to get you on your own way.&lt;/p&gt;

&lt;p&gt;But the basic setup is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;make it easy to set up emails in your symfony application.&lt;/li&gt;
&lt;li&gt;make use of a database, so you can manage and your clients can tinker.&lt;/li&gt;
&lt;li&gt;generate emails using the &lt;a href="https://dev.toInlining%20CSS%20Styles"&gt;Inlining CSS Styles&lt;/a&gt; and &lt;a href="https://symfony.com/doc/current/mailer.html#inky-email-templating-language"&gt;Inky Email Templating Language&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;add a way to test and see what we are actually doing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Let's go
&lt;/h3&gt;

&lt;p&gt;You can install the bundle by just installing it in your symfony application. This will setup everything you need to start emailing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;composer require disjfa/mail-bundle&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the basic setup you can just add your own email, An email should have a name, subject and content. You do need one &lt;code&gt;.env&lt;/code&gt; variable named &lt;code&gt;DISJFA_MAIL_FROM&lt;/code&gt; for the from email address.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create an email
&lt;/h3&gt;

&lt;p&gt;So now you need to create your own email. There is an interface for that! If you implement the interface the system will auto register the email so you are done. Lets check it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Disjfa\MailBundle\Mail&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;MailInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getSubject&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getContent&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So your class will look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="nx"&gt;namespace&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;Disjfa\MailBundle\Mail\MailInterface&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExampleMail&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;MailInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'app.example'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getSubject&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'subject'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'content'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will just generate an email with the subject &lt;code&gt;subject&lt;/code&gt; and the content &lt;code&gt;content&lt;/code&gt;. You can just extend the class and &lt;a href="https://symfony.com/doc/current/service_container/autowiring.html"&gt;autowire&lt;/a&gt; a twig environment into that to make life easier or a translator. Example in the &lt;a href="https://github.com/disjfa/mail-bundle/blob/master/Example/ExampleMail.php"&gt;example&lt;/a&gt; folder.&lt;/p&gt;

&lt;p&gt;This will generate the default email when sent.&lt;/p&gt;

&lt;p&gt;The original email must have curly braces which will parsed and used for parameters. So in the subject and the content it should look like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight twig"&gt;&lt;code&gt;This is the email &lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;email&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you do create a template using twig, please note that you cannot add twig tags directly. So escape them!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight twig"&gt;&lt;code&gt;This is the email &lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="s1"&gt;'{{'&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt; email &lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="s1"&gt;'}}'&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will be read and checked for parameters. Only parameters made in the original content will be remembered in the system. For now we can also not implement fancy things like loops and extra stuff. The idea is to pre render data which you want to use and set those up as 'simple' parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Designing emails
&lt;/h3&gt;

&lt;p&gt;So there is a thing called &lt;a href="https://foundation.zurb.com/emails.html"&gt;Foundation for Emails&lt;/a&gt;. Those guys made a thing for making hard email structures easy to set up. So there is a twig extension for &lt;a href="https://github.com/twigphp/inky-extra"&gt;that&lt;/a&gt;. Also somebody mage a way to inline css styling so we can make styling emails a bit easier on the eye. So there is a twig extension for &lt;a href="https://github.com/twigphp/cssinliner-extra"&gt;that&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So they made live wonderful for people that do not like emails. If you create an email that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- a simplified example of the Inky syntax --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;container&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;row&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;columns&amp;gt;&lt;/span&gt;This is the email {{ email }}.&lt;span class="nt"&gt;&amp;lt;/columns&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/row&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/container&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It will be rendered and generated into something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;garbage of table and data structure, what will look awesome in email clients!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The last item we did not render, it will be generated. We will let you check that in the console.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cool, email setup. Send them.
&lt;/h3&gt;

&lt;p&gt;Next up, it is up to you to send the emails. You have to tell your application to send an email wich you names. But we have made that simple. Lets check that out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;Disjfa\MailBundle\Mail\MailFactory&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;Disjfa\MailBundle\Mail\MailService&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MailFactory&lt;/span&gt; &lt;span class="nv"&gt;$mailFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MailService&lt;/span&gt; &lt;span class="nv"&gt;$mailService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$mail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$mailFactory&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;findByName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'app.example'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$mailService&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$mail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
         &lt;span class="s1"&gt;'param1'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="s1"&gt;'param2'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;'info@example.com'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And done, add this in a function you use and inject the correct data to send them. You can place this wherever. You can even setup the mailer to start sending the emails &lt;a href="https://symfony.com/doc/current/mailer.html#sending-messages-async"&gt;async&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Checking the emails
&lt;/h3&gt;

&lt;p&gt;For checking the emails there is a command!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;bin/console disjfa:mail:preview-mail&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will result in a question, and list all the emails found in the application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;Please select an email&lt;/span&gt;
  &lt;span class="s"&gt;[0] disjfa_mail.example&lt;/span&gt;
  &lt;span class="s"&gt;[1] ... your email setup&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next up, what to do?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;What to do?&lt;/span&gt;
  &lt;span class="s"&gt;[0] preview&lt;/span&gt;
  &lt;span class="s"&gt;[1] preview raw&lt;/span&gt;
  &lt;span class="s"&gt;[2] send email&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Preview will just dump the base html. Preview raw will ask for all the parameters in the email and render it out dumping a pile of garbage of table and data structure, which should look awesome in an email application. The last will also ask for an email address and it will send out a test.&lt;/p&gt;

&lt;p&gt;Nice! Now you can make, create and test the emails.&lt;/p&gt;

&lt;h3&gt;
  
  
  Edit them
&lt;/h3&gt;

&lt;p&gt;So now we have setup the emails, are able to make new email templates to use in your app. Now you just want to tweak them, they are never right for everyone. And anyone has their own opinion. So lets just edit them.&lt;/p&gt;

&lt;p&gt;You can add the routes in a &lt;code&gt;config/routes/disjfa_mail.yaml&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;disjfa_mail&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;resource&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;@DisjfaMailBundle/Controller/'&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;annotation&lt;/span&gt;
    &lt;span class="na"&gt;prefix&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/admin'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example the routes are annotated and mapped to the &lt;code&gt;/admin&lt;/code&gt; folder, just as an example. This should end up in your application. So now you can open up the location. As an example on a localhost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://localhost:8000/admin/mail-template"&gt;https://localhost:8000/admin/mail-template&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an overview of all emails in the system again! Cool. Here you can edit or preview them. If you edit one of them there will be subject and content edit area. And from the original html all the parameters are rendered and added as reference for your new template. Check it out in action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SakkP4DH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cl8ktwsile21yy3i7zr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SakkP4DH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cl8ktwsile21yy3i7zr0.png" alt="Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  As for the templates
&lt;/h3&gt;

&lt;p&gt;For the template. There is just a basic layout adding some &lt;a href="https://getbootstrap.com/"&gt;bootstrap&lt;/a&gt; and there is some &lt;a href="https://clipboardjs.com/"&gt;clipboardjs&lt;/a&gt; added so it can be used. If you want to add the templates in your own you can just override the existing &lt;code&gt;layout.html.twig&lt;/code&gt;. You can just add your own in &lt;code&gt;templates/bundles/DisjfaMailBundle/layout.html.twig&lt;/code&gt;, just keep in mind to add the blocks needed.&lt;/p&gt;

&lt;p&gt;The same is for the base email, but in this path &lt;code&gt;templates/bundles/DisjfaMailBundle/mail/email.html.twig&lt;/code&gt;. Again, keep in mind the original blocks to implement. But here you can also just add your logo and other data you want to add.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cool, now what?
&lt;/h3&gt;

&lt;p&gt;Now what? You can add your own and add custom emails in your applications. Send them as you like! Lets check what to do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a class implementing &lt;code&gt;MailInterface&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add some templates as needed.&lt;/li&gt;
&lt;li&gt;Add some translations as needed.&lt;/li&gt;
&lt;li&gt;Create a place in your application to send the emails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And done. You just created your first email and you did not even need to know much html to get them sending. It sounded like a lot, but in the end it was easy.&lt;/p&gt;

&lt;p&gt;Now get on your way and create some awesome emails, and don't forget to send them!&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@mathyaskurmann?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Mathyas Kurmann&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://disjfa.github.io/symfony/php/2019/12/02/mailing-with-symfony.html"&gt;Original article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>symfony</category>
    </item>
    <item>
      <title>Bootstrap carousel using animate.css</title>
      <dc:creator>disjfa</dc:creator>
      <pubDate>Tue, 20 Aug 2019 21:01:13 +0000</pubDate>
      <link>https://dev.to/disjfa/bootstrap-carousel-using-animate-css-36a4</link>
      <guid>https://dev.to/disjfa/bootstrap-carousel-using-animate-css-36a4</guid>
      <description>&lt;p&gt;The premise is that we know how to &lt;a href="https://getbootstrap.com"&gt;bootstrap&lt;/a&gt;, we know how to &lt;a href="https://daneden.github.io/animate.css/"&gt;Animate.css&lt;/a&gt;. Now in bootstrap there is a thing like a carousel. We want to make the animations some more fancy! Lets try.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does this work?
&lt;/h3&gt;

&lt;p&gt;First up, we need to figure out how we can use the bootstrap classes for a &lt;a href="https://getbootstrap.com/docs/4.3/components/carousel/"&gt;carousel&lt;/a&gt;. When we inspect the elements and test and try we see a quick &lt;code&gt;.carousel-item-left&lt;/code&gt; and &lt;code&gt;.carousel-item-right&lt;/code&gt; class on the main element. Also there is an &lt;code&gt;.active&lt;/code&gt; class. Lets puzzle, well i already puzzled so i'll just explain.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;.active&lt;/code&gt; item moves away or fades out on the carousel so that will be used for the animating out classes. So a simple overview.&lt;/p&gt;

&lt;h3&gt;
  
  
  Animate out classes
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.carousel-item-left.active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-item-right.active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Animate in classes
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.carousel-item-left&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-item-right&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Simple, left and right
&lt;/h3&gt;

&lt;p&gt;So now we know how to check and manipulate the in and out. Next we need to setup a main carousel and remove the deafult animation. Let's set up a default carousel. Keep the &lt;code&gt;.slide&lt;/code&gt; class for a base animatin and add a custom &lt;code&gt;.carousel-...&lt;/code&gt; class we can use to hook into the action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"carousel-zoom"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"carousel slide carousel-animation bg-dark"&lt;/span&gt; &lt;span class="na"&gt;data-ride=&lt;/span&gt;&lt;span class="s"&gt;"carousel"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  ...
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Reset some css
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item-left.active&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item-right.active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will just reset all the animations. Reverts the sliding. So now we can start. &lt;/p&gt;

&lt;p&gt;We can keep it simple and use some animations from &lt;a href="https://daneden.github.io/animate.css/"&gt;Animate.css&lt;/a&gt;. If you want you can create whatever you like. For now we use the bounceIn and bounceOut animations. Let's just put it all together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item-left&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bounceInRight&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;.65s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item-left.active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bounceOutLeft&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item-right&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bounceInLeft&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;.65s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.carousel-animation&lt;/span&gt; &lt;span class="nc"&gt;.carousel-item-right.active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bounceOutRight&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  And thats it!
&lt;/h3&gt;

&lt;p&gt;Cool, now we are done. We bounce in from the right, aka go to the left to enter and bounce out to the left on exiting. And the other way around if we click to the right.&lt;/p&gt;

&lt;p&gt;You can just play around with all the options Animate.css gives you. Also if you want to see a working example, check &lt;a href="https://disjfa.github.io/bootstrap-tricks/animate-carousel-2/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next up?
&lt;/h3&gt;

&lt;p&gt;Next up! Enjoy! Make awesome stuff and be awesome. You can animate the inners when the inital animation is done. After the the &lt;code&gt;.active&lt;/code&gt; class gets put on the new inner item. Check &lt;a href="https://disjfa.github.io/bootstrap-tricks/animate-carousel/"&gt;this example&lt;/a&gt; to get started with that.&lt;/p&gt;

&lt;p&gt;And don't forget to have fun.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://disjfa.github.io/bootstrap/css/2019/08/20/bootstrap-carousel-using-animate.css.html"&gt;original article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Share!</title>
      <dc:creator>disjfa</dc:creator>
      <pubDate>Tue, 02 Jul 2019 21:03:29 +0000</pubDate>
      <link>https://dev.to/disjfa/share-4gb</link>
      <guid>https://dev.to/disjfa/share-4gb</guid>
      <description>&lt;p&gt;On the internet we share stuff, Facebook, twitter, email, other socials, and so on. We use some links to custom share links and build it up ourselves. When i built some apps i also  share, usually there is a share functionality. Now what if we want to implement share on a simple way, lets see where we can go with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Share api.
&lt;/h3&gt;

&lt;p&gt;As usual, the people of the internet have thought of this already. When i searched for a share api there is one, off course. The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share"&gt;Navigator.share&lt;/a&gt; api. Awesome.&lt;/p&gt;

&lt;p&gt;This sets us up to share the link using the default share slider you see on phones, where you only have the share types you have set up on your phone or device. Useful and clean! &lt;/p&gt;

&lt;h3&gt;
  
  
  Lets implement.
&lt;/h3&gt;

&lt;p&gt;Next up, a simple implementation. Next we need a button on a page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-outline-secondary js-share"&lt;/span&gt; &lt;span class="na"&gt;data-title=&lt;/span&gt;&lt;span class="s"&gt;"This is a title"&lt;/span&gt; &lt;span class="na"&gt;data-text=&lt;/span&gt;&lt;span class="s"&gt;"This is a text"&lt;/span&gt; &lt;span class="na"&gt;aria-label=&lt;/span&gt;&lt;span class="s"&gt;"Share this page"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;i&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"fa fa-share-alt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/i&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Cool, share button using some font awesome share icon! Lets add some JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;share&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;closest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.js-share&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Made a default click listener that listens to a &lt;code&gt;.js-share&lt;/code&gt; class that should be clicked. Note that this uses a &lt;code&gt;.closest&lt;/code&gt; function that can be pesky. More explanations and where i learned about this can be found &lt;a href="https://gomakethings.com/checking-event-target-selectors-with-event-bubbling-in-vanilla-javascript/"&gt;here on Chris Ferdinandi's site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And run the code! I was on a desktop and clicked frantically to see how it all worked. But it did little. Sad.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we use that!
&lt;/h3&gt;

&lt;p&gt;So the next step was to ask the internet if we could use that. &lt;a href="https://caniuse.com/#feat=web-share"&gt;Can i use web share api&lt;/a&gt;. The answer is no, not yet. Not as built in out of the box. As i said earlier, the share api uses the share dialog as used on phones. And the diagram on &lt;a href="https://caniuse.com"&gt;caniuse.com&lt;/a&gt; shows mobile browsers only at this point. I read somewhere that macos may be implementing something some time. But not yet. So should we use this, YES!&lt;/p&gt;

&lt;h3&gt;
  
  
  Lets poly fill.
&lt;/h3&gt;

&lt;p&gt;Asking the internet some more i found out more people wanted to implement this. So i stumbled upon the &lt;a href="https://github.com/NascHQ/share-api-polyfill"&gt;share-api-polyfill&lt;/a&gt;. This will add a fallback as we are used on desktops, and implements the same structure as above. So just import the JavaScript to your site and you are good to go.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/share-api-polyfill/dist/share-min.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Or install using npm and build it in your JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;npm install share-api-polyfill --save&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Done!
&lt;/h3&gt;

&lt;p&gt;Nice! Now we have a functionality that gives every type of browsing your app a nice way to share. And while the browsers will implement the api sharing will be nicer than ever. In the share poly fill you can also set up some stuff, for your own leisure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next up
&lt;/h3&gt;

&lt;p&gt;Next up. As on the example of the poly fill the share api returns a promise. So you can also extend it to add more to the share functionality. Thank the person that shares or log in your data collection efforts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Yay, you shared it :)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oh noh! You couldn&lt;/span&gt;&lt;span class="se"&gt;\'&lt;/span&gt;&lt;span class="s1"&gt;t share it! :&lt;/span&gt;&lt;span class="se"&gt;\'&lt;/span&gt;&lt;span class="s1"&gt;(&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Google is also on a way of sharing files this way, you can check that out on the &lt;a href="https://developers.google.com/web/updates/2019/05/web-share-files"&gt;Share files with Web Share&lt;/a&gt; post on googles page. Could be awesome to share a file to a image editing website as an idea!&lt;/p&gt;

&lt;p&gt;Next up is whatever we want it to be.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@kylejglenn?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Kyle Glenn&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://disjfa.github.io/javascript/2019/07/02/share.html"&gt;Original article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
