Vue.js Digest 🇷🇺 🇺🇸
39 subscribers
389 photos
745 links
Дайджест новостей из мира vuejs
Download Telegram
How to attempt Coding-Assignments, for job applications

https://javascript.plainenglish.io/how-to-attempt-coding-assignments-for-job-applications-5cbbc5d06521?source=rss------vuejs-5
Show-off your skills in a tasteful mannerContinue reading on JavaScript in Plain English »
Web Weekly — Issue #1

https://blog.canopas.com/web-weekly-issue-1-4bb08558fb9c?source=rss------vuejs-5
Welcome to Web weekly — a weekly newsletter on new development and updates of Web universe curated by Canopas team, delivered every Monday.Continue reading on Canopas Software »
Quasar admin CRM with Quasar 2!

https://dev.to/mayank091193/quasar-admin-crm-with-quasar-2-5c78
I have migrated my Quasar Admin CRM template to Quasar 2! I am offering it at the cheap price of $49! If you want to purchase, please send me an email at [email protected]
Live demo:



https://next-quasar-admin-crm.netlify.app/

Do let me know in case of any questions.
Prevent Form Submission in Vue.js

https://dev.to/hirajatamil/prevent-form-submission-in-vuejs-3ncj
In this article, I’m going to cover two different ways on how to prevent default form submission behaviour using vue.js.
Let’s say you have a sign-up form that you do not want to submit to the server directly.
As you know, the default behaviour of the form element is to send the form input data via GET request when the submit button is pressed.



<form class="ui large form">
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="text" placeholder="Username or Email"/>
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input type="password" placeholder="Password"/>
</div>
</div>
<button class="ui fluid pink button big" >SIGN IN</button>
</form>



form {
width:400px;
margin:20px auto;
}



To prevent that, what we want is to handle the form submission via an AJAX call of some sort.
There are two main ways you can prevent form submission in vue.js.



Invoke preventDefault Method

Attach a click event with a callback function signInButtonPressed to the submit button.



<button class="ui fluid pink button big" @click="signInButtonPressed">SIGN IN</button>


Then, declare the signInButtonPressed function inside the methods object.



methods: {
signInButtonPressed() {
console.log("sign in button is pressed");
}
}


When you hit the sign in button at this stage, you can see the message quickly in the browser console and then it disappears as the page gets reloaded.
Also notice the question (?) mark added to the URL that indicates the form is trying to send data via GET request.
Continue Reading...
how to add Tailwind CSS to your Vue 2 project easily [in one command]

https://dev.to/slimpython/how-to-add-tailwind-css-to-your-vue-2-project-easily-in-one-command-1db0
In this video, I have explained how to add Tailwind CSS to your Vue 2 project easily, this video can be very helpful for those are trying the old fashion way and getting lot's of errors like tailwindcss postcss plugin tailwindcss requires postcss 8 etc
Nuxt Fetch - A renderless component

https://dev.to/elmatella/nuxt-fetch-a-renderless-component-3hdn
Hey, I'm writing my first blog post here to talk about a simple renderless component I wrote for NuxtJS that I use everyday.
It's a renderless component for NuxtJS that allows me to take advantage of VueJS slots to write less logic when fetching remote data.
Here is a basic copy/paste of the README:



Installation


yarn add @hammerbot/nuxt-fetch





Usage


<template>
<div>
<nuxt-fetch :fetch-fn="fetchFn">
<template #default="{ data, fetching, error }">
<p>
{{ data }} - {{ fetching }} - {{ error }}
</p>
</template>
<template #fetching>
Fetching for the first time
</template>
<template #error="{ error }">
Error handling {{ error }}
</template>
</nuxt-fetch>
</div>
</template>
<script >
import NuxtFetch from '@hammerbot/nuxt-fetch'
export default {
components: {
NuxtFetch
},
methods: {
async fetchFn () {
const { data } = await this.$api.get('/foo')
return data
}
}
}
</script>


As you can see in the example, I don't need to use any v-if statement or anything. I'm just using slots here and I find it much less verbose.
Tell me if you like it! I will write a better documentation if someone in this world uses it.
Cheers and happy new year!
PS: If you like it, leave me a star on Github! If you don't.. Tell me why in the comments!
https://github.com/ElMatella/nuxt-fetch
Create a Beautiful To-Do List App With Vuetify: Deleting Tasks

https://javascript.plainenglish.io/create-a-beautiful-to-do-list-app-with-vuetify-deleting-tasks-3b7bc2bc301f?source=rss------vuejs-5
Use the Vuetify hover component and an icon button to add task deletion functionality to the app.Continue reading on JavaScript in Plain English »
Javascript Array methods, a simpler way!

https://medium.com/@rajukhunt/javascript-array-methods-a-simpler-way-92f4c2a23cb3?source=rss------vuejs-5
I know how long it takes before this knowledge sticks up in our minds, so here is a quick recap!Continue reading on Medium »
Best VueJs Development Company in New York| VueJs Services New York

https://itriangletechnolabs.medium.com/best-vuejs-development-company-in-new-york-vuejs-services-new-york-7476d364b34d?source=rss------vuejs-5
iTriangle Technolabs is the best VueJs Development company in New York with a development center located in India.Continue reading on Medium »
💡 Vue Typescript State Management : We can do better than “isLoading” in 2022

https://dev.to/monisnap/vue-typescript-state-management-we-can-do-better-than-isloading-in-2022-2n5d
Sorry for the clickbait title, but I needed your attention 👀 
Have you ever encountered code like this one :



new Vue({
el: '#app',
data () {
return {
info: null,
loading: true,
errored: false
}
},
filters: {
currencydecimal (value) {
return value.toFixed(2)
}
},
mounted () {
axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => {
this.info = response.data.bpi
})
.catch(error => {
console.log(error)
this.errored = true
})
.finally(() => this.loading = false)
}
})
...
<div id="app">
<h1>Bitcoin Price Index</h1>
<section v-if="errored">
<p>We're sorry, we're not able to retrieve this information at the moment, please try back later</p>
</section>
<section v-else>
<div v-if="loading">Loading...</div>
<div
v-else
v-for="currency in info"
class="currency"
>
{{ currency.description }}:
<span class="lighten">
<span v-html="currency.symbol"></span>{{ currency.rate_float | currencydecimal }}
</span>
</div>
</section>
</div>


It’s an example I found in the Vue documentation here https://vuejs.org/v2/cookbook/using-axios-to-consume-apis.html#Dealing-with-Errors
What if you have multiple things that could load, do you add a loading2 variable ? 👀
To solve this issue, you can use a variable for each async actions you have with this 4 “states” :

IDLE : the user didn’t trigger the action yet
WAITING : the action is ongoing
ERROR : there was an error
DONE : The action succeeded

Using an enum with the different states, and better naming, the code can be rewritten like this :



enum AsyncState {
IDLE = 'IDLE',
WAITING = 'WAITING',
ERROR = 'ERROR',
DONE = 'DONE',
}
new Vue({
el: '#app',
data () {
return {
info: null,
AsyncState,
currentPriceLoadState: AsyncState.WAITING,
}
},
filters: {
currencydecimal (value) {
return value.toFixed(2)
}
},
mounted () {
axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => {
this.info = response.data.bpi
this.currentPriceLoadState = AsyncState.DONE
})
.catch(error => {
console.log(error)
this.currentPriceLoadState = AsyncState.ERROR
})
}
})
...
<div id="app">
<h1>Bitcoin Price Index</h1>
<div v-if="currentPriceLoadState === AsyncState.WAITING">Loading...</div>
<section v-else-if="currentPriceLoadState === AsyncState.ERROR">
<p>We're sorry, we're not able to retrieve this information at the moment, please try back later</p>
</section>
<section v-else>
<div v-for="currency in info" class="currency">
{{ currency.description }}:
<span class="lighten">
<span v-html="currency.symbol"></span>{{ currency.rate_float | currencydecimal }}
</span>
</div>
</section>
</div>


With better naming and this simple enum, you can almost cover all the use cases where you need to load one or multiple things and manage errors
If you want to manage different error messages, you can add another variable with an enum type like this :



enum CurrentPriceLoadErrors {
INVALID_CURRENCY = 'INVALID_CURRENCY',
API_LIMIT_REACHED = 'API_LIMIT_REACHED',
DEFAULT = 'DEFAULT',
}


Tell me in the comment section if you like this trick or not, and if you have an even better technique !
And don’t forget to like and share this post if you liked it 💙
Vue + SSR + AMP — как подружить SPA с гугл страницами

https://habr.com/ru/post/599301/?utm_campaign=599301&utm_source=habrahabr&utm_medium=rss
Привет, хабрист!Довольно давненько подружил свои приложения с гуглом.Основная идея была - не создавая новых шаблонов, получить все страницы сайта AMP-friendly и, вообще, сделать ядро приложения AMP-ready.Тут нас поджидает серьезная переработка стилей CSS и структуры приложения путем добавления дубликатов забаненных гуглом компонентов, таких как картинки, карусели, менюхи и прочее.Я буду вещать на примере самого простого - картинок. Все прочее аналогично, хоть и посложнее на практике.Объявим зависимости Читать далее
Code: Views-driven router paths, instead of a hardcoded mess — VueJS

https://andrewwinnicki.medium.com/code-views-driven-router-paths-instead-of-a-hardcoded-mess-vuejs-b3f0d257c553?source=rss------vuejs-5
Router configuration paths are defined in one massive file sitting in the index.js file, where all the magic happens. That has to change!Continue reading on Medium »
Dockerizing Vue App With NodeJS Backend — Typescript Version

https://medium.com/bb-tutorials-and-thoughts/dockerizing-vue-app-with-nodejs-backend-typescript-version-3244573b6a02?source=rss------vuejs-5
Both Vue and NodeJS are in TypescriptContinue reading on Bachina Labs »
20+ Useful Vue JS Components 2022

https://medium.com/js-dojo/20-useful-vue-js-components-2022-3bf9fbe5b556?source=rss------vuejs-5
Want to make your vuejs based app’s interface unique and appealing? Then here is the collection of Vue js Components that you can use for…Continue reading on Vue.js Developers »
Webpack5 + vue3

https://dev.to/vadim/webpack5-vue3-g0n
Nevertheless you can create a simple vue app by
npm install --save-dev @vue/cli

vue create vue3-project
but it is too simple. Sometimes we need to be close to bare metal - then we need a custom build with our own webpack.config.js. Reasons you might need that:

you are a skilled webpack user
you have a proven webpack config from a previous project
you want to integrate with some third parties

Here a simple proven webpack.config.js which allows using Single File Components (SFC). Here is a project structure we are going to use:

Features included:

CSS modules
extract node_modules to a separate file (or chunk, or bundle)

webpack.config.js:



const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const { VueLoaderPlugin } = require("vue-loader");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const src = path.resolve(__dirname, 'src');
const dist = path.resolve(__dirname, 'dist');
module.exports = (env, argv) => {
const IS_PRODUCTION = argv.mode === 'production';
const config = {
entry: './src/index.js',
output: {
path: dist,
filename: "[name]-[contenthash].js",
},
resolve: {
alias: {
"@": src
}
},
mode: argv.mode,
devServer: {
static: dist
},
plugins: [
new HtmlWebpackPlugin(),
new VueLoaderPlugin(),
new CleanWebpackPlugin(),
],
module: {
rules: [{
test: /\.vue$/,
loader: "vue-loader",
exclude: /node_modules/
}, {
test: /\.css$/,
use: [
IS_PRODUCTION ? MiniCssExtractPlugin.loader : "style-loader",
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[local]--[hash:base64:6]",
},
}
}
]
}, {
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/
}, {
test: /\.(png|jpe?g|gif|webm|mp4|svg)$/,
loader: "file-loader",
options: {
outputPath: "assets"
}
}]
},
optimization: {
minimizer: [
// extend default plugins
`...`,
// HTML and JS are minified by default if config.mode === production.
// But for CSS we need to add this:
new CssMinimizerPlugin()
],
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'node_modules',
chunks: 'all',
},
},
},
}
};
if (IS_PRODUCTION) {
// put all CSS files to a single <link rel="stylesheet" href="...">
config.plugins.push(new MiniCssExtractPlugin({
filename: "[contenthash].css"
}));
} else {
// config.devtool = "inline-source-map";
}
return config;
}


package.json:



"scripts": {
"start": "webpack serve --open --mode=development",
"build": "webpack --mode=production --progress",
"dist-clean": "rm -fr dist/*"
},


Full project https://github.com/vinogradov/webpack-templates/tree/main/webpack5-simple-vue. Thanks!
Vue.js Interview Challenge — #11— Direction Arrow — Solution

https://medium.com/js-dojo/vue-js-interview-challenge-11-direction-arrow-solution-fb79b4b180d6?source=rss------vuejs-5
SolutionContinue reading on Vue.js Developers »
Vue.js Interview Challenge — #11 — Direction Arrow

https://medium.com/js-dojo/vue-js-interview-challenge-11-direction-arrow-c3d12ccbb00c?source=rss------vuejs-5
Problem statementContinue reading on Vue.js Developers »
Getting rid of NgModule in Angular. Javascript

https://dev.to/antmik/getting-rid-of-ngmodule-in-angular-javascript-2gcc
Working many years with angular I found it hard to create the structure of a project. The main reason for that struggle lay behind the way Angular interacts with components and modules. The following article explains what is the issue with NgModule and whether is going to change in the foreseeable future.



Builtin lazy loading mechanisms

Angular has NgModule based architecture. In other words, each application has at least one NgModule which connects all the components and routes together. It is a practical approach for applications structure. An application has a central unit that contains all the declarations. That’s right when we are talking about small web apps.
When working with large Single Page Applications performance becomes a critical pain point. It is a time to start thinking about optimization. One of the ways to reduce loading times is to minify application size on the first load. This goal can be achieved with lazy loading. The technique is supported by angular routing mechanisms.
The technique allows loading specific parts of an application only when needed. Here is the full documentation on how to implement lazy loading within Angular framework.



What is wrong with NgModules?

Up to now, all seems correct, right? Let’s zoom in to see whether potential issues could pop up.
For instance, we will take the Angular Material UI. The framework should comply with best practices because it is built and maintained by the Angular team. Looking at the components provided you may mention that each of them has its own NgModule. It is done to allow importing of a single component without grabbing all them and overloading the application.
What does all that mean for me as a developer? Practically you will need to create a NgModule for each of the components. Thus double action on each component creation.
For newbies, the concept may appear quite painful. To be honest for me to work in this way is still frustrating.



VueJs components interaction

When I started to work with VueJs I didn’t feel any discomfort. Just after some period of time mentioned I am doing fewer actions to achieve the same component interactions than I was doing in Angular. “How could it be?” I thought. Just after side by side comparison, figured out what was missing through all the development process with VueJs. The answer was “modules”.
In VueJs all is based on components. Do you want to create a page? Make a component. Do you want to create a reusable UI piece of code? Make component! Nothing more. Just that easy.
Aren’t modules making a more coherent structure? Correct me if I am wrong, but I didn’t mention any practical benefit of this additional architecture layer yet.



Is it going to change?

Yes, the Angular roadmap gives all Angular developers a ray of hope. The proposal was explained and discussed in this “[Complete] RFC: Standalone components, directives and pipes — making Angular’s NgModules optional”.
Yet, pay attention to this statement:

This proposal is not trying to remove the concept of a NgModule from Angular — it is rather making it optional for typical application development tasks.

At the same time we believe that it paves the path towards greatly reducing the role of NgModule for typical development scenarios — to the point that some time in the future it would be possible and reasonable for us to consider removing it altogether.




To conclude

Getting rid of modules is the first step towards Angular architecture simplification. So far I see only benefits in that act.
Who knows maybe in the future Angular will adopt a functional components approach as React did instead of classes.
Getting rid of NgModule in Angular. Javascript

https://medium.com/@antmihlin/getting-rid-of-ngmodule-in-angular-javascript-43fd510779bc?source=rss------vuejs-5
Working many years with angular I found it hard to create the structure of a project. The main reason for that struggle lay behind the way…Continue reading on Medium »