<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Claus Straube on Medium]]></title>
        <description><![CDATA[Stories by Claus Straube on Medium]]></description>
        <link>https://medium.com/@claus.straube?source=rss-28320dd1ec66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*TD6WAuhXYn3d_Ci5.</url>
            <title>Stories by Claus Straube on Medium</title>
            <link>https://medium.com/@claus.straube?source=rss-28320dd1ec66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:15:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@claus.straube/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Responsive Web Apps with Vuetify]]></title>
            <link>https://medium.com/@claus.straube/responsive-web-apps-with-vuetify-80bd3959165f?source=rss-28320dd1ec66------2</link>
            <guid isPermaLink="false">https://medium.com/p/80bd3959165f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuetify]]></category>
            <dc:creator><![CDATA[Claus Straube]]></dc:creator>
            <pubDate>Mon, 11 May 2020 12:02:22 GMT</pubDate>
            <atom:updated>2020-05-12T10:13:10.887Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oE2aUqks7Um-uYXq0g1wg.png" /></figure><p><a href="https://vuetifyjs.com/">VuetifyJs</a> is a great <a href="https://material.io/">Material Design</a> Framework for <a href="https://vuejs.org/">VueJs</a>. It comes with a ton of ready to use components. A “hidden champion” is the build in responsive system. This is not a component, but a declarative feature in some of its components. I’ll show you in this article how to create responsive text, forms, images and nearly everything — latter by using the breakpoint object. So if you want to create a web application that fits to every viewport sizes, VuetifyJs and of course this article is for you ;)</p><p>I assume that you’ve a running VueJs project with VuetifyJs, so I skip that project creation stuff. If you want to try this tutorial in a fresh setup, please read the <a href="https://vuetifyjs.com/en/getting-started/quick-start/">Vuetify Quick Start tutorial</a>. Another point: I’m using typescript (and I can recommend this). If you’re using Javascript things might be slightly different in your component, but this article we have nearly no coding, so this should no problem.</p><h4>Breakpoints</h4><p>Breakpoints in responsive web applications represents different view sizes. Obviously has a smart phone an other size than a tablet, or a notebook, or a normal PC monitor or a ultra wide screen. We as web developers should create applications, that work on every screen size — at least. I think it should work and look great on every screen size. To make this, the Material Design Spec gave breakpoints to us. One for each device type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xZ0L7hA5BzQ_jQR8OapPA.png" /><figcaption>Material Design Viewport Breakpoints</figcaption></figure><p>The screenshot above shows the Material Design viewport breakpoints. This breakpoint system is heavily used by VuetifyJs. You can checkout the <a href="https://vuetifyjs.com/en/customization/breakpoints/">documentation</a> for further information.</p><h4>Responsive Text</h4><p>Some of the responsive text features come with Vuetify 2.3.0. So the one or other early bird has to use the beta version.</p><p>So what is responsive text? The text size depends on the screen size. If you have a headline on a ultra wide display, a font size of 80px may look better than 20px. On the other side — a 80px headline can smash the whole design on a tiny mobile phone. So responsive text makes definitely sense. Of course you can do this with css and media queries. But in VuetifyJs this is a ready to use declarative feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxe1I4k8ty71UI3_n4suTg.png" /><figcaption>Responsive text sample</figcaption></figure><p>The image above shows how a heading and even the text can change on the view size. In Vuetify you can get this behavior simply by declaring different classes on your textelement:</p><pre>&lt;template&gt;<br>  &lt;v-row class=&quot;pa-3&quot;&gt;<br>    &lt;h1 <br>      class=&quot;<br>        text-h4            [1]<br>        text-md-h2         [2]<br>        text-lg-h1         [2]<br>        text-xl-h1         [2] <br>        text-truncate&quot;     [3]<br>    &gt;This is my heading&lt;/h1&gt;<br>    &lt;p <br>      class=&quot;<br>        text--secondary <br>        text-caption <br>        text-sm-body-2 <br>        text-md-body-1 <br>        text-lg-body-1 <br>        text-xl-body-1 <br>        text-justify&quot;&gt; <br>      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut...<br>    &lt;/p&gt;<br>  &lt;/v-row&gt;<br>&lt;/template&gt;</pre><pre>/// @/components/ResponsiveText.vue</pre><p>You’ve always a default text size class [1] which also covers the smallest breakpoint (xs). The default can be overwritten by using breakpoint classes for each breakpoint [2] — if you want a different text size according to the default. The pattern is always text-[breakpoint]-[fontsize]. Especially in headings a great tool is text-truncate, which cuts off the text if it doesn’t fit in the outer element.</p><h4>Responsive Forms</h4><p>Another big issue in creating responsive web applications are forms. They should be arranged, depending on the view size. Here can the great grid system play out its strength. Of course the grid system is not only useful using forms, but it’s a common case for responsive web applications. So I used a forms sample — it works always the same, regardless what you want to put onto the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmVhdfwWHP4y1MiaC4b8Ag.png" /><figcaption>The grid system with a form</figcaption></figure><p>The grid system consists of rows and columns. Every “virtual” row has 12 “virtual” columns, which gives a grid of an arbitrary number of rows with 12 columns each. There’re two elements in vuetify — v-row and v-column. It’s important to understand, that you can place v-row and v-column into the grid system, but they doesn’t have to be equal to the static n to 12 grid.</p><p>The fields in the image above are all named with R(ow)[number]C(olumn)[number]. So you can see, how the fields move, in the grid system, on changing the view size. We can have a look on the first form row (R1C1, R1C2, R1C3) to make things more clear. On big screens, the first row (which is equal to the v-row element) holds three fields in three v-col elements. The first v-col spreads over 6 virtual columns, the other two over 3 each. So they spread over 12 virtual columns in total.</p><p>Let’s have a look on the left bottom screenshot. Same form, lower view size. The first v-col element spreads over 12 virtual columns, the other two over 6 each. So the v-row element needs two rows à 12 virtual columns. The right bottom screenshot shows the same form in a very small view. The v-row needs here three virtual rows and each v-col spreads over 12 columns.</p><p>The question is — how can I get this behavior from VuetifyJs? Luckily this is the easy part. Simply as writing the number of virtual columns into the breakpoint attribute:</p><pre>...<br>&lt;v-row&gt;<br>  &lt;v-col cols=&quot;12&quot; md=&quot;6&quot; lg=&quot;6&quot; xl=&quot;6&quot;&gt;<br>     &lt;v-text-field<br>        label=&quot;Field R1C1&quot;<br>     &gt;&lt;/v-text-field&gt;<br>   &lt;/v-col&gt;<br>   &lt;v-col cols=&quot;12&quot; sm=&quot;6&quot; md=&quot;3&quot; lg=&quot;3&quot; xl=&quot;3&quot;&gt;<br>     &lt;v-text-field<br>         label=&quot;Field R1C2&quot;<br>      &gt;&lt;/v-text-field&gt;<br>   &lt;/v-col&gt;<br>   &lt;v-col cols=&quot;12&quot; sm=&quot;6&quot; md=&quot;3&quot; lg=&quot;3&quot; xl=&quot;3&quot;&gt;<br>      &lt;v-text-field<br>         label=&quot;Field R1C3&quot;<br>      &gt;&lt;/v-text-field&gt;<br>   &lt;/v-col&gt;<br> &lt;/v-row&gt;<br>...</pre><pre>/// @/components/ResponsiveForm.vue</pre><p>There’s a breakpoint attribute for every Material Design breakpoint, except for xs. This one is covered by the default attribute cols. With the VuetifyJs grid system, you can create very powerful responsive layouts without any line of JavaScript code.</p><h4>Responsive image size</h4><p>The responsiveness of images comes from there ability to load the best image in size and quality for the device. For this the img element offers the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-srcset">scrset</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes">sizes</a> attributes. There’re tons of great articles out in the web, so I’m not going to write an other one. The message for the VuetifyJs users is: These two attributes are there in the v-img component as well. So you can use the standard responsive stuff with great features like lazy preload images or the <a href="https://dev.vuetifyjs.com/en/components/images/">contain</a> attribute.</p><pre>...<br>&lt;v-img <br> src=&quot;<a href="http://catify.de/.../village_1264.jpg">http://catify.de/.../village_1264.jpg</a>&quot;<br> lazy-src=&quot;<a href="http://catify.de/.../village_blur.jpg">http://catify.de/.../village_blur.jpg</a>&quot;<br> srcset=&quot;<a href="http://catify.de/.../village_600.jpg">http://catify.de/.../village_600.jpg</a> 600w,<br>   <a href="http://catify.de/.../village_960.jpg">http://catify.de/.../village_960.jpg</a> 960w,<br>   <a href="http://catify.de/.../village_1264.jpg">http://catify.de/.../village_1264.jpg</a> 1264w,<br>   <a href="http://catify.de/.../village_1904.jpg">http://catify.de/.../village_1904.jpg</a> 1904w,<br>   <a href="http://catify.de/.../village_2400.jpg">http://catify.de/.../village_2400.jpg</a> 2400w&quot;<br> width=&quot;100%&quot;<br>&gt;&lt;/v-img&gt;<br>...</pre><pre>/// @/components/ResponsiveImage.vue</pre><h4>Responsive Type- or JavaScript</h4><p>For every wish in responsiveness, that VuetifyJs not fulfills in a declarative way, they give a responsive breakpoint object to you. This can be used in computed properties, methods or nearly anywhere inside the VueJs context:</p><pre>this.$vuetify.breakpoint </pre><p>It supports you with information about the current breakpoint, conditionals, dimensions etc. You can check out the <a href="https://vuetifyjs.com/en/customization/breakpoints/#breakpoint-service-object">documentation</a> for more. In the sample I’ve used this object, to switch from many icons in the app bar to a burger icon, for opening a hidden menu. This is simply done in one line of code [1]:</p><pre>&lt;script lang=&quot;ts&quot;&gt;<br>import Vue from &#39;vue&#39;<br>import { Component } from &quot;vue-property-decorator&quot;</pre><pre><a href="http://twitter.com/Component">@Component</a><br>export default class ResponsiveActionIcons extends Vue {</pre><pre>get shrink() {<br>    return this.$vuetify.breakpoint.smAndDown  [1]<br>  }</pre><pre>show() {<br>    console.log(&quot;show menu...&quot;)<br>  }</pre><pre>}<br>&lt;/script&gt;</pre><pre>/// @/components/ResponsiveActionIcons.vue</pre><h4>The End</h4><p>You can find the sources of my responsive VuetifyJs sample on a <a href="https://github.com/xdoo/vuetify_responsive_sample">github repository</a>. I hope you have enjoyed this article. Please leave a comment if you have any question or would like to give feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80bd3959165f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drop and Click File Upload with VuetifyJs]]></title>
            <link>https://medium.com/swlh/drop-and-click-file-upload-with-vuetifyjs-f2c2a8357377?source=rss-28320dd1ec66------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2c2a8357377</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[material-design]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuetify]]></category>
            <dc:creator><![CDATA[Claus Straube]]></dc:creator>
            <pubDate>Fri, 24 Apr 2020 13:50:21 GMT</pubDate>
            <atom:updated>2020-04-25T10:16:08.933Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Sceenshot of the final drag &amp; drop &amp; click component." src="https://cdn-images-1.medium.com/max/854/1*LytSgVdaCDLi5Vnnwc7yvQ.png" /></figure><p><a href="https://vuetifyjs.com/">VuetifyJs</a> comes with a bunch of great <a href="https://material.io/">Material Design</a> components. The file upload component is like the standard HTML 5 component in Material Design style. It works, but you can’t use drag &amp; drop. If you need a drag &amp; drop file component and you want to use VuetifyJs (what you definitely should), this little blog post is exactly for you. After reading (and little bit of coding), you’ll end up with a shiny drag &amp; drop file component. Yours might be even prettier than mine.</p><p>I assume that you’ve a running VueJs project with VuetifyJs, so I skip that project creation stuff. If you want to try this tutorial in a fresh setup, please read the <a href="https://vuetifyjs.com/en/getting-started/quick-start/">Vuetify Quick Start tutorial</a>. Another point: I’m using typescript (and I can recommend this). If you’re using Javascript things might be slightly different in your component, but this should be doable.</p><h4>Basic design of the dropzone</h4><p>Ok — fist step. We need a new component:</p><pre>&lt;template&gt;</pre><pre>&lt;/template&gt;<br>&lt;script lang=&quot;ts&quot;&gt;<br>import Vue from &quot;vue&quot;<br>import { Component } from &quot;vue-property-decorator&quot;</pre><pre><a href="http://twitter.com/Component">@Component</a><br>export default class FileDrop extends Vue{<br>  <br>}<br>&lt;/script&gt;</pre><p>Next we have to add a vuetify component, that represents the dropzone. I’m using for this a v-sheet component, but you can use what ever you want.</p><pre>&lt;template&gt;   <br>    &lt;v-sheet<br>      tabindex=&quot;0&quot;                                [1]<br>      title=&quot;Click to grap a file from your PC!&quot;<br>      color=&quot;indigo lighten-4&quot;<br>      width=&quot;100%&quot;<br>      height=&quot;200&quot;<br>      class=&quot;pa-2&quot;<br>    &gt;<br>    &lt;/v-sheet&gt;<br>&lt;/template&gt;</pre><p>There’s nothing special about the v-sheet component. Be sure, that you provide a tabindex attribute [1]. This is not necessary for the base functionallity, but it makes the component accessible by keybord.</p><p>If you only want to drop files into the component, you’ve done so far. But in the heading I promised, that we’ll end with a drag and click dropzone. To add the click functionality, we can simply use the standard HTML 5 file input component.</p><pre>&lt;template&gt;   <br>    &lt;v-sheet<br>      tabindex=&quot;0&quot;<br>      title=&quot;Click to grap a file from your PC!&quot;<br>      color=&quot;indigo lighten-4&quot;<br>      width=&quot;100%&quot;<br>      height=&quot;200&quot;<br>      class=&quot;pa-2&quot;<br>    &gt;<br>      &lt;input <br>      type=&quot;file&quot;               [1]<br>      accept=&quot;text/xml&quot; <br>      style=&quot;display:none&quot;/&gt;    [2]<br>    &lt;/v-sheet&gt;<br>&lt;/template&gt;</pre><p>Simply place this inside the v-sheet component (or what ever component you’re using). Be sure, that it is of type “file” [1]. We don’t want to see, the component itself, but only borrow its functionallity. So we have to hide ist. This is done by display:none inside the style attribute [2].</p><p>We now have the visual base for our component. Let’s add it to the application. In a fresh demo project open the App.vue file and import our new drag &amp; drop component.</p><pre>&lt;template&gt;<br>  &lt;v-app&gt;<br>    ...<br>    &lt;v-content&gt;<br>      &lt;v-container fill-height&gt;      [1]<br>        &lt;v-row&gt;<br>          &lt;v-col cols=&quot;2&quot;&gt;&lt;/v-col&gt;<br>          &lt;v-col cols=&quot;8&quot;&gt;<br>            &lt;file-drop&gt;&lt;/file-drop&gt;  [2]<br>          &lt;/v-col&gt;<br>          &lt;v-col cols=&quot;2&quot;&gt;&lt;/v-col&gt;<br>        &lt;/v-row&gt;<br>      &lt;/v-container&gt;<br>    &lt;/v-content&gt;<br>  &lt;/v-app&gt;<br>&lt;/template&gt;</pre><pre>&lt;script lang=&quot;ts&quot;&gt;<br>import Vue from &quot;vue&quot;<br>import { Component } from &quot;vue-property-decorator&quot;</pre><pre>// components<br>import FileDrop from &quot;@/components/FileDrop.vue&quot; [3]</pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>  components: {<br>    FileDrop                                     [4]<br>  }<br>})<br>export default class App extends Vue {</pre><pre>}<br>&lt;/script&gt;</pre><ol><li>Stuff to beautify your screen :)</li><li>The file-drop component itself.</li><li>Import your component.</li><li>Register the component.</li></ol><p>If you’ll send npm run serve , you can see somethin like this on your screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*kiU9Zsqj9hx01LJl1eI2jw.png" /><figcaption>The blank dropzone.</figcaption></figure><h4>The drag &amp; drop functionallity</h4><p>A nice indigo colored dropzone with… absolutely no functionality. Ok — let’s change this. Head back to your component file. To create a working dropzone we have to register some event listeners. So the component can “see” and react on different user interactions. The listeners should registered as early as possible. But be aware that we must have access to the HTML components to register any listener. So mounted should be the perfect lifecycle phase for this.</p><pre>&lt;script lang=&quot;ts&quot;&gt;<br>...</pre><pre><a href="http://twitter.com/Component">@Component</a><br>export default class FileDrop extends Vue{<br>  <br>  mounted () {<br>    const dropzone = this.$el [1]<br>    const fileupload = this.$el.firstElementChild as HTMLElement [2]<br>  }<br>}<br>&lt;/script&gt;</pre><p>The dropzone itself (the v-sheet component) can be accessed by this.$el [1], the fileupload is simply the first element child [2]. Be aware, that this is also true after beautifying your component ;)</p><p>First of all, let’s implement the drop functionality. If we want to change a icon, color of the dropzone, or what ever, we need a status property [1]. The dragenter , dragover and dragleave events [2] will change this status on every move. If you don’t need this — leave the first three event listeners off. The last event listener [3] is crucial for the file drop functionality. So we need this one in every case.</p><pre><a href="http://twitter.com/Component">@Component</a><br>export default class FileDrop extends Vue{<br>  <br>  // internal properties<br>  dragover: boolean = false [1]<br>  <br>  mounted () {<br>    const dropzone = this.$el<br>    const fileupload = this.$el.firstElementChild as HTMLElement</pre><pre>    // register listeners on your dropzone / v-sheet<br>    if(dropzone) {<br>      // register all drag &amp; drop event listeners<br>      dropzone.addEventListener(&quot;dragenter&quot;, e =&gt; { [2]<br>        e.preventDefault()<br>        this.dragover = true<br>      })<br>      dropzone.addEventListener(&quot;dragleave&quot;, e =&gt; { [2]<br>        e.preventDefault()<br>        this.dragover = false<br>      })<br>      dropzone.addEventListener(&quot;dragover&quot;, e =&gt; { [2]<br>        e.preventDefault()<br>        this.dragover = true<br>      })<br>      dropzone.addEventListener(&quot;drop&quot;, e =&gt; { [3]<br>        e.preventDefault()<br>        const dragevent = e as DragEvent<br>        if(dragevent.dataTransfer) {<br>          // do something<br>        }<br>      })<br>    }<br>  }<br>}</pre><p>What should be done if the file has been dropped to the dropzone? Keeping in mind, that the drop &amp; click component should be reusable, we simply send an event (with all files in it) to the parent component.</p><pre><a href="http://twitter.com/Component">@Component</a><br>export default class FileDrop extends Vue{<br>  <br>  // internal properties<br>  dragover: boolean = false<br>  <br>  mounted () {</pre><pre>    const dropzone = this.$el</pre><pre>    // register listeners on your dropzone / v-sheet<br>    if(dropzone) {<br>      ...</pre><pre>      dropzone.addEventListener(&quot;drop&quot;, e =&gt; {<br>        e.preventDefault()<br>        const dragevent = e as DragEvent<br>        if(dragevent.dataTransfer) {   [1]<br>          this.filesSelected(dragevent.dataTransfer.files) <br>        }<br>      })<br>    }<br>  }</pre><pre><a href="http://twitter.com/Emit">  @Emit</a>()<br>  filesSelected(fileList: FileList) { [2]<br>      this.dragover = false<br>  }<br>}</pre><p>Of course this event [2] should contain the dropped files. It will be fired, if the drop event has a filled dataTransfer property [1]. The parent component can reach the drop event like this:</p><pre>&lt;file-drop v-on:files-selected=&quot;doSomething&quot;&gt;&lt;/file-drop&gt;</pre><p>Ok. Drag &amp; drop functionally — check!</p><h4>The click and key press functionallity</h4><p>If you want add the click and key press (focus by tab and press enter) behavior, you should read on ;)</p><p>Most of the work has already been done. Adding the additional functionality is as easy, as putting three event listeners to your code:</p><pre><a href="http://twitter.com/Component">@Component</a><br>export default class FileDrop extends Vue{<br>  <br>  // internal properties<br>  formUpload: boolean = false<br>  dragover: boolean = false</pre><pre>mounted () {<br>    // to register listeners, we have to know the <br>    // html elements<br>    const dropzone = this.$el<br>    const fileupload = this.$el.firstElementChild as HTMLElement</pre><pre>// register listeners on your dropzone / v-sheet<br>    if(dropzone) {<br>      ...<br>      dropzone.addEventListener(&quot;click&quot;, e =&gt; { [1]<br>        e.preventDefault()<br>        if(fileupload) {<br>          fileupload.click()<br>        }<br>      })<br>      dropzone.addEventListener(&quot;keypress&quot;, e =&gt; { [2]<br>        e.preventDefault()<br>        const keyEvent = e as KeyboardEvent<br>        if (keyEvent.key === &quot;Enter&quot;) {<br>          if(fileupload)<br>            fileupload.click()<br>        }<br>      })</pre><pre>      // register listeners on the file input<br>      if(fileupload) {<br>        fileupload.addEventListener(&quot;change&quot;, e =&gt; { [3]<br>          const target = (e.target as HTMLInputElement)<br>          if(target.files) {<br>            this.filesSelected(target.files)<br>          }<br>        })<br>      }<br>    }<br>  }</pre><pre><a href="http://twitter.com/Emit">  @Emit</a>()<br>  filesSelected(fileList: FileList) {<br>    this.dragover = false<br>  }<br>}</pre><p>The first one [1] is used to register click events on our dropzone. If someone clicks the dropzone, a virtual click will be triggered on the hidden input element, which opens the (browser) file select dialog. The second one [2] does the same as the click event listener, but on key press event. More precise — on pressing the enter key.</p><p>Finally we need an event listener on the file input component [3], that fires, if the user selects files over the browser dialog. This one checks, if files have been selected and if yes, filesSelected event will be triggered (the same as for drop events).</p><p>Ok. Press and click functionality — check!</p><h4>A more beautiful dropzone</h4><p>If you more purist — skip this section. A single colored dropzone is exact the perfect thing for you :)</p><pre>&lt;template&gt;   <br>    &lt;v-sheet<br>      id=&quot;dropzone&quot;<br>      ref=&quot;dzone&quot;<br>      tabindex=&quot;0&quot;<br>      title=&quot;Click to grap a file from your PC!&quot;<br>      color=&quot;indigo lighten-4&quot;<br>      width=&quot;100%&quot;<br>      style=&quot;cursor:pointer;&quot;<br>      height=&quot;200&quot;<br>      class=&quot;pa-2&quot;<br>    &gt;<br>      &lt;input <br>        ref=&quot;upload&quot;<br>        id=&quot;fileUpload&quot;<br>        type=&quot;file&quot; <br>        accept=&quot;text/xml&quot; <br>        style=&quot;display:none&quot;/&gt;<br>      &lt;v-row justify=&quot;center&quot;&gt;<br>        &lt;v-icon<br>          v-if=&quot;!dragover&quot; <br>          color=&quot;indigo darken-2&quot; <br>          size=&quot;75&quot;<br>        &gt;mdi-cloud-upload-outline&lt;/v-icon&gt;<br>        &lt;v-icon<br>          v-if=&quot;dragover&quot; <br>          color=&quot;indigo darken-2&quot; <br>          size=&quot;75&quot;<br>        &gt;mdi-book-plus&lt;/v-icon&gt;<br>      &lt;/v-row&gt;<br>      &lt;v-row justify=&quot;center&quot;&gt;<br>        &lt;span class=&quot;title indigo--text text--darken-2&quot;&gt;Drag&#39;n drop or click to upload file!&lt;/span&gt;<br>      &lt;/v-row&gt;<br>    &lt;/v-sheet&gt;<br>&lt;/template&gt;</pre><p>You can put into the dropzone what ever you want. But be aware, that the hidden input is always the first element inside the v-sheet component. Otherwise this</p><pre>const fileupload = this.$el.firstElementChild as HTMLElement</pre><p>won’t work anymore. Your final result should look like this (or more beautiful).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*B1mtlE7HE03Gs6AVkVp8Fw.png" /><figcaption>The final result :)</figcaption></figure><p>You can find the sources on a <a href="https://github.com/xdoo/vuetify_filedrop_sample">github repository</a>. I hope you have enjoyed this article. Please leave a comment if you have any question or would like to leave feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2c2a8357377" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/drop-and-click-file-upload-with-vuetifyjs-f2c2a8357377">Drop and Click File Upload with VuetifyJs</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Background Images withVuetify]]></title>
            <link>https://medium.com/swlh/background-images-withvuetify-3ce1dcc84123?source=rss-28320dd1ec66------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ce1dcc84123</guid>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vuetify]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Claus Straube]]></dc:creator>
            <pubDate>Tue, 04 Feb 2020 15:32:25 GMT</pubDate>
            <atom:updated>2020-03-20T08:25:14.561Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lazy loading Background Images</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WIElw1fPUMw6nVrKg5q8w.jpeg" /><figcaption>A really pretty background image for your app (47.479693, 10.958209). Ok — you can use your own, too ;)</figcaption></figure><p>You’re writing a app with VueJs / Vuetify and you want a background image that doesn’t scroll with the content and has lazy loading capabilities? Then this article is for you.</p><p>Of course you can use CSS for your background image. And of course you can do all things I’ll show in this article with CSS, too. If you’re a CSS expert… Or if you’re a Google search and copy &amp; paste expert. I’m more or less the latter one. So I thought to myself: “Can’t I do this background image thing with native <a href="https://vuetifyjs.com/">Vuetify</a> tools as well?” The short answer is — yes you can.</p><p>The customer wants a modern looking single page application with a background image. So far so good. The problem starts with content, that is higher than the screen. So you have to scroll. And if you scroll down very far, your beautiful background image will disappear on the top of your screen. An other issue with plain old background images is, that they’re potentially big if the quality is high. That’s bad for your lighthouse audit scores… and for the visitors with low bandwidth. So why not use the <a href="https://vuetifyjs.com/en/components/images">Vuetify image component</a>?</p><pre>&lt;v-img&gt;&lt;/v-img&gt;</pre><p>On of the coolest features of this component is the lazy loading image. Instead of loading the full blown high quality image, you can load first a small blurry picture and then the bigger one. So the page visitor sees something, before getting the end result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9jGWBzghRQ43Kd1ShkAelw.png" /><figcaption>v-img lazy loading image</figcaption></figure><p>To start with your Vuetify background image app, you can use the <a href="https://cli.vuejs.org/">VueJS CLI</a>. Go to your development folder, open a terminal and start typing:</p><pre>vue create my_bg_app<br>cd my_bg_app<br>vue add vuetify<br>npm run serve</pre><p>You can leave the defaults everywhere. I’m using Typescript, but this should not really make a big difference here. You will end up with a running VueJs / Vuetify demo application. I added a footer and painted the application bar black, but you can leave your app as it is.</p><p><strong>First step: Define the app frame</strong>. Switch to the <em>src</em> folder and open the <em>App.vue</em> file. You can find there an element called</p><pre>&lt;v-app-bar&gt;&lt;/v-app-bar&gt;</pre><p>It’s important to know the height of the app bar. So you should set the corresponding attribute <strong>[1]</strong>:</p><pre>&lt;v-app-bar<br> app<br> color=&quot;black&quot;<br> height=&quot;100&quot; [1]<br> dark<br>&gt;<br>...<br>&lt;/v-app-bar&gt;</pre><p>If you’ve added a footer you should set its height <strong>[1]</strong>, too:</p><pre>&lt;v-footer <br> app<br> color=&quot;black&quot;<br> height=&quot;47&quot; [1]<br>&gt;<br>...<br>&lt;/v-footer&gt;</pre><p><strong>Second step:</strong> <strong>Modify the content component.</strong> Go to the <em>components</em> folder and open <em>HelloWorld.vue</em>. You can delete everything inside the <em>template</em> element. You should end with something like this:</p><pre>&lt;template&gt;<br>&lt;/template&gt;</pre><pre>&lt;script lang=”ts”&gt;<br>import Vue from ‘vue’<br>import { Component } from ‘vue-property-decorator’</pre><pre><a href="http://twitter.com/Component">@Component</a><br>export default class Helloworld extends Vue {</pre><pre>}<br>&lt;/script&gt;</pre><p>If you don’t use Typescript, your <em>script</em> section looks different, but as I wrote above, that doesn’t really matter.</p><p><strong>Third step:</strong> <strong>Add the background image.</strong></p><pre>&lt;template&gt;<br>  &lt;v-container fluid class=”pa-0&quot;&gt; [1]<br>    &lt;v-img<br>      :src=”require(‘@/assets/bg_image.jpg’)” [2]<br>      :lazy-src=”require(‘@/assets/bg_image_blur.jpg’)” [3]<br>      :height=”bgHeight” [4]<br>    &gt; <br>    &lt;/v-img&gt;<br>  &lt;/v-container&gt;<br>&lt;/template&gt;<br>&lt;script lang=&quot;ts&quot;&gt;<br>import Vue from &#39;vue&#39;<br>import { Component } from &#39;vue-property-decorator&#39;</pre><pre><a href="http://twitter.com/Component">@Component</a><br>export default class Helloworld extends Vue {</pre><pre>  get bgHeight() {<br>    return this.$vuetify.breakpoint.height - 147 [5]<br>  }</pre><pre>}<br>&lt;/script&gt;</pre><p>First we’re filling our content section with a container <strong>[1]</strong>. The <a href="https://vuetifyjs.com/en/styles/spacing">pa-0 class</a> ensures, that this container has no padding. So it really fills the whole area with no space — if there is something in it, that is big enough. Inside the <em>v-container</em> we’ll place the <em>v-img</em> element. The <em>src</em> <strong>[2]</strong> and <em>lazy-src</em> <strong>[3]</strong> attributes are responsible to load the images. Of course the images must be dropped into the <em>assets</em> folder before saving. Now we need a flexible height. If the user changes the browser size, the background image should still fit. For this case Vuetify offers a breakpoint object <strong>[5]</strong>. You can use this inside a computed property (if you’re not using Typescript the script section is slightly different, but the return statement should be the same). You can reach the height of the screen with <em>this.$vuetify.breakpoint.height</em>. To get the image height, subtract the height of your app bar and footer (if you have one). In our case this is <em>100 (app-bar)+ 47 (footer) = 147</em>. finally we have to fill the height attribute dynamically with the calculated value of height <strong>[4]</strong>.</p><p><strong>Fourth step:</strong> <strong>Add a scroll container.</strong> E.g. a <em>v-sheet</em> element, but it should work with a <em>v-card</em>, too. Place this <em>v-sheet</em> inside the <em>v-img</em>.</p><pre>&lt;template&gt;<br>  &lt;v-container fluid class=”pa-0&quot;&gt;<br>    &lt;v-img<br>      ...<br>    &gt; <br>      &lt;v-sheet<br>        color=”transparent” [1]<br>        class=”overflow-y-auto” [2]<br>        :max-height=”bgHeight” [3]<br>      &gt;<br>      &lt;/v-sheet&gt;<br>    &lt;/v-img&gt;<br>  &lt;/v-container&gt;<br>&lt;/template&gt;</pre><p>We want to see the background image (of course), so we have to set the color attribute to <a href="https://vuetifyjs.com/en/styles/colors"><em>transparent</em></a> <strong>[1]</strong>. The class <em>overflow-y-auto</em> <strong>[2]</strong> adds the vertical scrolling ability to the component, if there is something inside that is higher than the maximum height. So it’s crucial to set the <em>max-height</em> attribute. To hold the background image in an absolute position, the maximum height must be identically to the image height. So we can use here the computed <em>bgHeight</em> property.</p><p><strong>Fifth step: Add really long content.</strong> We want to scroll. So we need something, that is for sure longer than the screen high. A <em>v-list</em> with 100 items should do that job. If you have an extraordinary high Monitor, set the number to 1000 <strong>[1]</strong>.</p><pre>&lt;template&gt;<br>  &lt;v-container fluid class=&quot;pa-0&quot;&gt;<br>    &lt;v-img<br>      ...<br>    &gt; <br>      &lt;v-sheet<br>        ...<br>      &gt;<br>        &lt;v-row no-gutters align=&quot;start&quot;&gt;<br>          &lt;v-col key=&quot;1&quot; cols=&quot;2&quot;&gt;&lt;/v-col&gt;<br>          &lt;v-col key=&quot;2&quot; cols=&quot;8&quot;&gt;<br>            &lt;v-card<br>              class=&quot;my-10&quot;<br>            &gt;<br>              &lt;v-toolbar ...&gt;...&lt;/v-toolbar&gt;<br>              &lt;v-toolbar ...&gt;...&lt;/v-toolbar&gt;</pre><pre>              &lt;!-- a really long list --&gt;<br>              &lt;v-list&gt;<br>                &lt;v-list-item<br>                  v-for=&quot;i in count&quot;<br>                  :key=&quot;i&quot;<br>                  dark<br>                &gt;<br>                  &lt;v-list-item-icon&gt;<br>                    &lt;v-icon class=&quot;black--text&quot;&gt;mdi-file&lt;/v-icon&gt;<br>                  &lt;/v-list-item-icon&gt;<br>                  &lt;v-list-item-content&gt;<br>                    &lt;v-list-item-title&gt;<br>                      Foo Item {{i}}<br>                    &lt;/v-list-item-title&gt;<br>                    &lt;v-list-item-subtitle&gt;<br>                      The subtitle for the... Foo<br>                    &lt;/v-list-item-subtitle&gt;<br>                  &lt;/v-list-item-content&gt;<br>                  &lt;v-list-item-action &gt;<br>                    &lt;v-icon&gt;mdi-cloud-download&lt;/v-icon&gt;<br>                  &lt;/v-list-item-action&gt;<br>                  &lt;/v-list-item&gt;<br>              &lt;/v-list&gt;<br>            &lt;/v-card&gt;<br>          &lt;/v-col&gt;<br>          &lt;v-col cols=&quot;2&quot; key=&quot;3&quot;&gt;&lt;/v-col&gt;<br>        &lt;/v-row&gt;<br>      &lt;/v-sheet&gt;<br>    &lt;/v-img&gt;<br>  &lt;/v-container&gt;<br>&lt;/template&gt;</pre><pre>&lt;script lang=&quot;ts&quot;&gt;<br>import Vue from &#39;vue&#39;<br>import { Component } from &#39;vue-property-decorator&#39;</pre><pre><a href="http://twitter.com/Component">@Component</a><br>export default class Helloworld extends Vue {<br>  // enter a lower number, to get a shorter list<br>  count: number = 100 [1]</pre><pre>  get bgHeight() {<br>    return this.$vuetify.breakpoint.height - 147<br>  }</pre><pre>}<br>&lt;/script&gt;</pre><p>Now you should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2EjHBBhMFhO_aochVsWIcw.png" /><figcaption>Really long content with absolute background image.</figcaption></figure><p>You can find the sources on a <a href="https://github.com/xdoo/vuetify_scrollbar_sample">github repository</a>. I hope you have enjoyed this article. Please leave a comment if you have any question or would like to leave feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ce1dcc84123" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/background-images-withvuetify-3ce1dcc84123">Background Images withVuetify</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>