1564798608
You can see the code for my entire portfolio on github, created from this starting point, here: https://github.com/markjohnson303/portfolio
A finished example is at hellomark.dev, but it is a work in progress and you may see some things that are different from what is described here.
Vue.js: I chose Vue for this project because it's the framework that I'm most familiar with. Some might say that it's overkill for a small project like this, and for you, it might be. It works well for me because it's comfortable and flexible enough for what I might do with it in the future. It's also what I'm hoping to use in my next role, so why not!
Bulma: I haven't used Bulma before this project, but I wanted something that would allow me to get the site up quickly, then improve the styling easily over time. Bulma is simple to learn, but easy to build upon. It doesn't have the world's largest library of components, but what it does have is solidly built.
Airtable: I've been wanting to use Airtable in a project for a while now. According to Airtable, it's "Part spreadsheet, part database", and was made to be flexible for all sorts of uses. I used it here as a CMS because it's really easy to use and has an awesome API with great documentation (that's customized to your database). Now that it's set up, I can use it across the site for all sorts of fun things. And it's free!
The first thing you need to do is set up your Vue project. We're going to use the Vue CLI to scaffold the project. Make sure you have vue and the Vue CLI installed:
$ npm install -g vue
$ npm install -g @vue/cli
Then create your project:
$ vue create portfolio
And fire it up:
$ npm run serve
Vue CLI gives you a very helpful starting point with a lot of the files and folders that we need. We're going to build off of this.
Let's also add our CSS framework, Bulma, now.
$ npm install --s bulma
And add the Sass stylesheet to our App.vue
file
<style lang="sass"> @import "~bulma/bulma.sass" </style>
You can make any adjustments to the Bulma defaults here, above the import.
We'll install Axios (for working with our Airtable API)
$ npm install --s axios
We need VueSimpleMarkdown so we can compose and style our posts with markdown.
$ npm install -s vue-simple-markdown
And in main.js
we'll put:
import VueSimpleMarkdown from 'vue-simple-markdown' import 'vue-simple-markdown/dist/vue-simple-markdown.css'Vue.use(VueSimpleMarkdown)
We’re going to have 5 main routes for this site: About, Contact, Home, Project, and Projects. Let’s set those up in In src/router.js
.
import Vue from “vue”;
import Router from “vue-router”;
import Home from “./views/Home.vue”;
import About from “./views/About.vue”;
import Contacts from “./views/Contact.vue”;
import Projects from “./views/Projects.vue”
import Project from “./views/Project.vue”Vue.use(Router);
export default new Router({
mode: “history”,
base: process.env.BASE_URL,
routes: [
{
path: “/”,
name: “home”,
component: Home
},
{
path: “/about”,
name: “about”,
component: About
},
{
path: “/contact”,
name: “contact”,
component: Contact
},
{
path: “/projects”,
name: “projects”,
component: Projects
},
{
path: “/project/:slug”,
name: “project”,
component: Project
}
]
});
}
The odd one out is path: “/project/:slug”
. We’re going to use this route to display a single project from Airtable based on the slug later.
We’re also going to make an empty component for each one in src/views
, here’s the empty Contact.vue
for example. We’ll fill these in later.
<template>
<div></div>
</template><script>
export default {
name: “contact”,
};</script>
Let’s add our header (with navigation) and footer, a little bit of styling, and a touch of Vue magic to make it work on mobile. We’ll put this code in App.vue
so that it will show up on every view.
<template>
<div id=“app”>
<meta name=“viewport” content=“width=device-width, initial-scale=1”>
<nav class=“navbar” role=“navigation” aria-label=“main navigation”>
<div class=“navbar-brand”>
<router-link class=“navbar-item” to=“/”>
<img src=“./assets/name-mark.jpg” width=“112” height=“28”>
</router-link><a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample" :class="{ 'is-active': showNav }" @click="showNav = !showNav"> <span aria-hidden="true"></span> <span aria-hidden="true"></span> <span aria-hidden="true"></span> </a> </div> <div id="navbarBasicExample" class="navbar-menu" :class="{ 'is-active': showNav }"> <div class="navbar-start"> </div> <div class="navbar-end"> <router-link to="/" class="navbar-item"> Home </router-link> <router-link to="/about" class="navbar-item"> About </router-link> <router-link to="/projects" class="navbar-item"> Projects </router-link> <router-link to="/contact" class="navbar-item"> Contact </router-link> </div> </div>
</nav>
<router-view />
<footer class=“footer”>
<div class=“content has-text-centered”>
<p>
Built by Mark Johnson with Vue.js, Bulma, and Airtable.
</p>
</div>
</footer>
</div>
</template><script>
export default {
name: “App”,
data() {
return{
showNav: false
}
},
};
</script><style type=“text/css”>
#app {
min-height: 100vh;
overflow: hidden;
display: block;
position: relative;
padding-bottom: 168px; /* height of your footer */
}
footer {
position: absolute;
bottom: 0;
width: 100%;
}
</style><style lang=“sass”>
@import “~bulma/bulma.sass”
</style>
The About, Home, and Contact pages don’t have any dynamic content on them, so feel free to add whatever content you like. Here’s what I did with the homepage, for example. I kept it very simple here, but you can embellish it however you like.
<template>
<div>
<div class=“hero is-cover is-relative is-fullheight-with-navbar is-primary”>
<div class=“hero-body”>
<div class=“container”>
<h1 class=“title is-1”>Hello, I’m Mark.</h1>
<h2 class=“subtitle is-3”>A customer focused, entrepreneurially minded web developer.</h2>
</div>
</div>
</div>
</div>
</template><script>
export default {
name: “home”,
};
</script>
The projects page is where things start to get interesting. We’re going to be pulling our information in from Airtable and displaying a summary card for each project.
Create a new base on Airtable called “Projects”. Create the following fields: “Title” (single line text), “slug” (single line text), “Body”(long text), “Image”(attachment), “Date Published” (date), “Published” (checkbox), “Excerpt” (single line text).
Voila! You have a simple CMS! Fill it in with a few rows of dummy data so you can see what you’re working with. Make sure the “slug” is unique! We’ll use this to build our url in a later step.
We’re going to create a component to display our project summary. It’s also reusable so that you could create a blog with the same thing later!
In src/components
create a new file called PostCard.vue
. Fill it in as follows:
<template>
<div class=“post-card”>
<div class=“card”>
<div class=“card-image”>
<figure class=“image is-square”>
<img :src=“image” alt=“Placeholder image”>
</figure>
</div>
<div class=“card-content”>
<div class=“media”>
<div class=“media-content”>
<p class=“title is-4”>{{title}}</p>
<p class=“subtitle is-6”>{{date}}</p>
</div>
</div>
<div class=“content”>
<p>{{snippet}}</p>
<router-link :to=“‘/project/’+slug” class=“button is-fullwidth”>View Project</router-link>
</div>
</div>
</div>
</div>
</template><script>
export default {
name: “PostCard”,
props: {
title: String,
date: String,
snippet: String,
image: String,
slug: String
}
};
</script>
We’re going to bring in the props from the Projects page after we get the projects from Airtable’s API. They’ll fill in the template with content and a link to the full project view.
Let’s set up the connection to the Airtable API. Make a directory at src/services
, and in it, put a file called ProjectsService.js
.
In the projects service, we’re going to use Axios to call the Airtable API and get all of the projects. Your file should look like this:
import axios from ‘axios’const Axios = axios.create({
baseURL: “https://api.airtable.com/v0/[YOUR APP ID]/Projects”
});Axios.defaults.headers.common = {‘Authorization’:
Bearer
+ process.env.VUE_APP_AIRTABLEKEY}export default{
getProjects() {
return Axios.get()
}
}
You’ll need to set up the baseURL
with the ID of your Airtable base. Find it in the URL from Airtable.
You’ll also need to add your API key from Airtable. I put mine in a file called .env.local
in the root directory of the Vue project. This file is listed in .gitignore so you don’t risk exposing it. All that’s in the file is this: VUE_APP_AIRTABLEKEY=[YOUR API KEY]
.
Finally, we’re exporting a function that calls get on the API endpoint in the baseURL.
We’re going to display the cards for our projects on the Projects view. In your Projects.vue
template:
<template>
<div>
<section class=“hero is-medium is-primary is-bold”>
<div class=“hero-body”>
<div class=“container”>
<h1 class=“title is-2”>
Projects that I have built
</h1>
</div>
</div>
</section>
<section class=“section”>
<div class=“container is-fluid”>
<div class=“columns is-multiline”>
<div class=“column is-one-third” v-for=“project in projects”>
<post-card v-bind=“project”></post-card>
</div>
</div>
</div>
</section>
</div>
</template>
The thing to note here is v-for=“project in projects”
where we’re creating an instance of post-card
for every project and passing in the project details with v-bind
.
The script section of the template looks like this:
<script>
import ProjectsService from ‘@/services/ProjectsService’
import PostCard from ‘@/components/PostCard’
export default {
name: “projects”,
components: {
PostCard
},
data() {
return{
airtableResponse: []
}
},
mounted: function () {
let self = this
async function getProjects() {
try{
const response = await ProjectsService.getProjects()
console.log(response)
self.airtableResponse = response.data.records}catch(err){ console.log(err) } } getProjects() }, computed: { projects(){ let self = this let projectList = [] for (var i = 0; i < self.airtableResponse.length; i++) { if (self.airtableResponse[i].fields.Published){ let project = { title: self.airtableResponse[i].fields.Title, date: self.airtableResponse[i].fields["Date Published"], snippet: self.airtableResponse[i].fields.Excerpt, image: self.airtableResponse[i].fields.Image[0].url, slug: self.airtableResponse[i].fields.slug } projectList.push(project) } } return projectList } } };
</script>
From the top, here’s what happening:
If all went well, you should be able to load /projects
and see each project you created in Airtable in a grid
Remember this bit of code from our router setup?
{
path: “/project/:slug”,
name: “project”,
component: Project
}
It’s going to make it so we can access the slug in our Project component and pass it into our Projects Service so we can retrieve all of the information for the item with that slug Airtable.
Let’s add a call for that in ProjectsService.js
:
getProject(slug) {
return Axios.get(“?filterByFormula={Slug}='” + slug + “'”)
}
We’re using the features of Airtable’s API here to search for the post that contains the slug and return it.
Now let’s create our Project view template:
<template>
<div>
<section class=“hero is-medium is-primary is-bold”>
<div class=“hero-body”>
<div class=“container”>
<h1 class=“title is-2”>
{{project.title}}
</h1>
<h2 class=“subtitle is-4”>
{{project.snippet}}
</h2>
</div>
</div>
</section>
<section class=“section”>
<div class=“container is-fluid”>
<div class=“columns”>
<div class=“column is-two-thirds”>
<vue-simple-markdown :source=“project.body”></vue-simple-markdown>
</div>
<div class=“column is-one-third”>
<div class=“columns is-multiline”>
<div class=“column is-full” v-for=“image in project.images”>
<img :src=“image.url”/>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</template>
This template is using the VueSimpleMarkdown plugin that we installed earlier. That means you can use markdown in the body field on Airtable to style your project. We’re displaying the body in a column on the left, and all of the images from the item on the right.
Finally, the script section of the project component:
<script>
import ProjectsService from ‘@/services/ProjectsService’
import PostCard from ‘@/components/PostCard’
export default {
name: “project”,
components: {
PostCard
},
data() {
return{
airtableResponse: []
}
},
mounted: function () {
let self = this
console.log(“here 1”)
async function getProject() {
try{
const response = await ProjectsService.getProject(self.$route.params.slug)
console.log(response)
self.airtableResponse = response.data.records}catch(err){ console.log(err) } } getProject() }, computed: { project(){ let self = this if (self.airtableResponse[0]){ let thisProject = { title: self.airtableResponse[0].fields.Title, snippet: self.airtableResponse[0].fields.Excerpt, images: self.airtableResponse[0].fields.Image, body: self.airtableResponse[0].fields.Body } return thisProject } } } };
</script>
Similar to the Projects view, but this time we’re passing the slug into the getProject
call. We should only get one response if the slug is unique.
Go to /projects/[your-slug] to see your project live!
Whew. That was a lot! Now that we’re done, we have a simple CMS displaying live data on a site built in Vue and styled with Bulma. Pretty cool!
Thanks For Visiting, Keep Visiting
☞ The Complete JavaScript Course 2019: Build Real Projects!
☞ Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
☞ Nuxt.js - Vue.js on Steroids
☞ Best JavaScript Frameworks, Libraries and Tools to Use in 2019
☞ Build a Progressive Web App In VueJs
☞ Build a CMS with Laravel and Vue
☞ Hands-on Vue.js for Beginners
☞ Top 3 Mistakes That Vue.js Developers Make and Should be Avoided
☞ Microfrontends — Connecting JavaScript frameworks together (React, Angular, Vue etc)
☞ Ember.js vs Vue.js - Which is JavaScript Framework Works Better for You
☞ Vue.js Tutorial: Zero to Sixty
This post was originally published here
#vue-js #web-development
1600583123
In this article, we are going to list out the most popular websites using Vue JS as their frontend framework.
Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.
This framework was created by Evan You and still it is maintained by his private team members. Vue is of course an open-source framework which is based on MVVM concept (Model-view view-Model) and used extensively in building sublime user-interfaces and also considered a prime choice for developing single-page heavy applications.
Released in February 2014, Vue JS has gained 64,828 stars on Github, making it very popular in recent times.
Evan used Angular JS on many operations while working for Google and integrated many features in Vue to cover the flaws of Angular.
“I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight." - Evan You
#vuejs #vue #vue-with-laravel #vue-top-story #vue-3 #build-vue-frontend #vue-in-laravel #vue.js
1598685221
In this tutorial, I will show you how to upload a file in Vue using vue-dropzone library. For this example, I am using Vue.js 3.0. First, we will install the Vue.js using Vue CLI, and then we install the vue-dropzone library. Then configure it, and we are ready to accept the file. DropzoneJS is an open source library that provides drag and drops file uploads with image previews. DropzoneJS is lightweight doesn’t depend on any other library (like jQuery) and is highly customizable. The vue-dropzone is a vue component implemented on top of Dropzone.js. Let us start Vue File Upload Using vue-dropzone Tutorial.
Dropzone.js is an open-source library providing drag-and-drop file uploads with image previews. DropzoneJS is lightweight, doesn’t depend on any other library (like jQuery), and is highly customizable.
The vue-dropzone is a vue component implemented on top of Dropzone.js.
First, install the Vue using Vue CLI.
Go to your terminal and hit the following command.
npm install -g @vue/cli
or
yarn global add @vue/cli
If you face any error, try running the command as an administrator.
Now, we need to generate the necessary scaffold. So type the following command.
vue create vuedropzone
It will install the scaffold.
Open the project in your favorite editor. Mine is Visual Studio Code.
cd vuedropzone
code .
I am using the Yarn package manager. So let’s install using Yarn. You can use NPM, also. It does not matter.
yarn add vue2-dropzone
or
npm install vue2-dropzone
Okay, now we need to add one css file with the above package. Now, vue cli uses css loader, so we can directly import in the src >> main.js entry file.
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App)
}).$mount('#app')
import 'vue2-dropzone/dist/vue2Dropzone.css'
If importing css is not working for you, then you need to install that CSS file manually.
Copy this vue2Dropzone.css file’s content.
Create one file inside the src >> assets folder, create one css file called vuedropzone.css and paste the content there.
Import this css file inside src >> App.vue file.
<style lang="css">
@import './assets/vuedropzone.css';
</style>
Now, it should include in our application.
Our primary boilerplate has one ready-made component called HelloWorld.vue inside src >> components folder. Now, create one more file called FileUpload.vue.
Add the following code to FileUpload.vue file.
// FileUpload.vue
<template>
<div id="app">
<vue-dropzone id="upload" :options="config"></vue-dropzone>
</div>
</template>
<script>
import vueDropzone from "vue2-dropzone";
export default {
data: () => ({
config: {
url: "https://appdividend.com"
}
}),
components: {
vueDropzone
}
};
</script>
Here, our API endpoint is https://appdividend.com. It is the point where we will hit the POST route and store our image, but it is my blog’s homepage, so it will not work anyway. But let me import this file into App.vue component and see what happens.
// App.vue
<template>
<div id="app">
<FileUpload />
</div>
</template>
<script>
import FileUpload from './components/FileUpload.vue'
export default {
name: 'app',
components: {
FileUpload
}
}
</script>
<style lang="css">
@import './assets/vuedropzone.css';
</style>
Now, start the development server using the following command. It will open up URL: http://localhost:8080.
npm run serve
Now, after uploading the image, we can see that the image upload is failed due to the wrong POST request endpoint.
Install the Laravel.
After that, we configure the database in the .env file and use MySQL database.
We need to create one model and migration file to store the image. So let us install the following command inside the Laravel project.
php artisan make:model Image -m
It will create both the Image model and create_images_table.php migrations file.
Now, open the migrations file and add the schema to it.
// create_images_table.php
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->increments('id');
$table->string('image_name');
$table->timestamps();
});
}
Now, migrate the database table using the following command.
php artisan migrate
It creates the table in the database.
Now, we need to add a laravel-cors package to prevent cross-site-allow-origin errors. Go to the Laravel root and enter the following command to install it.
composer require barryvdh/laravel-cors
Configure it in the config >> app.php file.
Barryvdh\Cors\ServiceProvider::class,
Add the middleware inside app >> Http >> Kernel.php file.
// Kernel.php
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\Barryvdh\Cors\HandleCors::class,
];
First, create an ImageController.php file using the following command.
php artisan make:controller ImageController
Define the store method. Also, create one images folder inside the public directory because we will store an image inside it.
Right now, I have written the store function that handles one image at a time. So do not upload multiple photos at a time; otherwise, it will break.
// ImageController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Image;
class ImageController extends Controller
{
public function store(Request $request)
{
if($request->file('file'))
{
$image = $request->file('file');
$name = time().$image->getClientOriginalName();
$image->move(public_path().'/images/', $name);
}
$image= new Image();
$image->image_name = $name;
$image->save();
return response()->json(['success' => 'You have successfully uploaded an image'], 200);
}
}
Go to the routes >> api.php file and add the following route.
// api.php
Route::post('image', 'ImageController@store');
We need to add the correct Post request API endpoint in FileUpload.vue component.
// FileUpload.vue
<template>
<div id="app">
<vue-dropzone id="drop1" :options="config" @vdropzone-complete="afterComplete"></vue-dropzone>
</div>
</template>
<script>
import vueDropzone from "vue2-dropzone";
export default {
data: () => ({
config: {
url: "http://localhost:8000/api/image",
}
}),
components: {
vueDropzone
},
methods: {
afterComplete(file) {
console.log(file);
}
}
};
</script>
Now, save the file and try to upload an image. If everything is okay, then you will be able to save the image on the Laravel web server as well as save the name in the database as well.
You can also verify on the server side by checking the database entry and the images folder in which we have saved the image.
The only required options are url, but there are many more you can use.
For example, let’s say you want:
export default {
data: () => ({
dropOptions: {
url: "https://httpbin.org/post",
maxFilesize: 5, // MB
maxFiles: 5,
chunking: true,
chunkSize: 400, // Bytes
thumbnailWidth: 100, // px
thumbnailHeight: 100,
addRemoveLinks: true
}
})
// ...
}
Happy Coding !!!
Originally published at https://appdividend.com
#vue #vue-dropzone #vue.js #dropzone.js #dropzonejs #vue cli
1603374000
Evan You is an independent software developer and the creator of the open source JavaScript framework Vue.js. We had a chance to speak to Evan about the release of Vue 3, his opinion on no-backend & fullstack approaches, Vue.js use cases and the work-life balance of the creator of the technology.
The Interview
Evrone: Hey Evan, it’s great having you here today! Let’s start our interview with such a question: your Patreon-funded full-time job position is quite unique. How do you organize your work-life balance and avoid burnouts?
Evan: I try to follow a fixed schedule every day even though I’m self-employed and working from home. Having kids actually helps a lot in this regard because I get to (and have to) spend time with family whenever I’m not working. Another important thing is that I take long breaks (several weeks) whenever I feel I need to — which is probably harder to do if I’m a full time employee at a company.
Evrone: Great!Vue 3 release is around the corner. Will you take a break after it or do you already have plans for the next version of the new Vite build system?
Evan: I always have a long backlog. For Vite, the current goal is actually just making it more stable — it’s a new system and people are trying to use it in scenarios that I didn’t initially design for, so we will give it some time to see where it should evolve next. There are also already ideas lined up for Vue 3.1. But I will definitely take a break, it’s important to recharge!
#vuejs #vue #vue-3 #vue.js #build-vue-frontend #angular
1578589885
A Vue mobile UI toolkit, based on Vue.js 2, designed for financial scenarios
You can scan the following QR code to access the examples:
New project can be initialized and integrated with mand-mobile by vue-cli-2 with mand-mobile-template.
vue init mand-mobile/mand-mobile-template my-project
New project can be initialized and integrated with mand-mobile by vue-cli with vue-cli-plugin-mand.
vue create my-project
cd my-project
npm install --save-dev vue-cli-plugin-mand
vue invoke mand
npm install mand-mobile --save
import { Button } from 'mand-mobile'
import Button from 'mand-mobile/lib/button'
import Vue from 'vue'
import mandMobile from 'mand-mobile'
import 'mand-mobile/lib/mand-mobile.css'
Vue.use(mandMobile)
Select the components you need to build your webapp. Find more details in Quick Start.
git clone git@github.com:didi/mand-mobile.git
cd mand-mobile
npm install
npm run dev
Open your browser and visit http://127.0.0.1:4000. Find more details in Development Guide.
#vue #vue-mobile #vue-mobile-ui #vue-js
1618639156
Demo: https://cutt.ly/TvxhH2T
#portfolio website html css #personal portfolio website tutorial #portfolio website #responsive personal portfolio website #portfolio website html css javascript #responsive portfolio website html css javascript