Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created August 31, 2019 03:56
Show Gist options
  • Save jsdecena/17a2bbd0879dd8f42d3c57b1c2b24899 to your computer and use it in GitHub Desktop.
Save jsdecena/17a2bbd0879dd8f42d3c57b1c2b24899 to your computer and use it in GitHub Desktop.
Post Create Vue template
<template>
<div id="main">
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Electron CMS</a>
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
<ul class="navbar-nav px-3">
<li class="nav-item text-nowrap">
<a class="nav-link" href="#">Sign out</a>
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">
<span data-feather="home"></span>
Posts <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="home"></span>
Pages <span class="sr-only"></span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="home"></span>
Users <span class="sr-only"></span>
</a>
</li>
</ul>
</div>
</nav>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
</div>
<h2>Add a Post</h2>
<div class="table-responsive">
<form class="form-horizontal" v-on:submit.prevent="onSubmit()">
<div class="form-group">
<label for="title">Title</label>
<input v-model="title" type="text" id="title" class="form-control" placeholder="Post title">
</div>
<div class="form-group">
<label for="body">Content</label>
<textarea placeholder="Content" v-model="body" name="body" id="body" cols="30" rows="10" class="form-control"></textarea>
</div>
<router-link to="/" class="btn btn-sm btn-warning text-white">Go back</router-link>
<button type="submit" class="btn btn-sm btn-primary">Add this post</button>
</form>
</div>
</main>
</div>
</div>
</div>
</template>
<script>
import SystemInformation from './LandingPage/SystemInformation'
export default {
name: 'post-create',
components: { SystemInformation },
data () {
return {
title: null,
body: null
}
},
methods: {
open (link) {
this.$electron.shell.openExternal(link)
},
onSubmit () {
const posts = JSON.parse(localStorage.getItem('posts'))
posts.push({
id: Math.floor(Math.random() * 10000 + 1),
title: this.title,
body: this.body
})
localStorage.setItem('posts', JSON.stringify(posts))
this.$router.push({ name: 'landing-page' })
}
}
}
</script>
<style>
@import url('https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css');
body {
font-size: .875rem;
}
.feather {
width: 16px;
height: 16px;
vertical-align: text-bottom;
}
/*
* Sidebar
*/
.sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
z-index: 100; /* Behind the navbar */
padding: 0;
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}
.sidebar-sticky {
position: -webkit-sticky;
position: sticky;
top: 48px; /* Height of navbar */
height: calc(100vh - 48px);
padding-top: .5rem;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
}
.sidebar .nav-link {
font-weight: 500;
color: #333;
}
.sidebar .nav-link .feather {
margin-right: 4px;
color: #999;
}
.sidebar .nav-link.active {
color: #007bff;
}
.sidebar .nav-link:hover .feather,
.sidebar .nav-link.active .feather {
color: inherit;
}
.sidebar-heading {
font-size: .75rem;
text-transform: uppercase;
}
/*
* Navbar
*/
.navbar-brand {
padding-top: .75rem;
padding-bottom: .75rem;
font-size: 1rem;
background-color: rgba(0, 0, 0, .25);
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}
.navbar .form-control {
padding: .75rem 1rem;
border-width: 0;
border-radius: 0;
}
.form-control-dark {
color: #fff;
background-color: rgba(255, 255, 255, .1);
border-color: rgba(255, 255, 255, .1);
}
.form-control-dark:focus {
border-color: transparent;
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}
/*
* Utilities
*/
.border-top { border-top: 1px solid #e5e5e5; }
.border-bottom { border-bottom: 1px solid #e5e5e5; }
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment