💄 Modifie l'apparence avec tabler.io

Pour #5
This commit is contained in:
cdesmidt 2019-10-01 16:15:50 +02:00
parent b4c9714202
commit c23baa8684
5 changed files with 250 additions and 85 deletions

View File

@ -32,7 +32,13 @@ class HomeController extends Controller
setlocale(LC_TIME, 'fr_FR.utf8');
$today = new DateTime();
$user_id = Auth::user()->getAuthIdentifier();
$posts = Post::where('user_id', $user_id)->orderBy('date_post', 'DESC')->get();
$all_counts = Post::where('user_id', $user_id)->count();
$year_counts = Post::where('user_id', $user_id)->count();
$month_counts = Post::where('user_id', $user_id)
->whereYear('date_post', $today->format('Y'))
->whereMonth('date_post', $today->format('m'))->count();
$image_counts = 0; // TODO #4
$posts = Post::where('user_id', $user_id)->orderBy('date_post', 'DESC')->limit(9)->get();
$today_post = Post::whereDate('date_post', '=', $today->format('Y-m-d'))
->where('user_id', $user_id)
->count();
@ -44,6 +50,10 @@ class HomeController extends Controller
return view('home', [
'already' => $already,
'all_counts' => $all_counts,
'year_counts' => $year_counts,
'month_counts' => $month_counts,
'image_counts' => $image_counts,
'today' => $today,
'posts' => $posts,
]);

View File

@ -24,6 +24,7 @@
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"tabler-ui": "^0.0.34",
"textarea-caret": "^3.1.0"
}
}

13
resources/js/app.js vendored
View File

@ -6,6 +6,8 @@
require('./bootstrap');
require('tabler-ui/src/assets/scss/bundle.scss');
window.Vue = require('vue');
/**
@ -30,6 +32,17 @@ window.Vue = require('vue');
import App from './components/App.vue';
Vue.config.productionTip = false;
/** Function for collapse card */
document.querySelectorAll('[data-toggle="card-collapse"]').forEach(function(card){
card.addEventListener('click', function(evt) {
let $card = this.parentElement.parentElement.parentElement;
$card.classList.toggle('card-collapsed');
evt.preventDefault();
return false;
});
});
const app = new Vue({
render: h => h(App),
}).$mount('#app');

View File

@ -4,50 +4,125 @@
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Dashboard') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
<h1>{{ strftime('%B %G', $today->format('U')) }}</h1>
@if($already)
<div class="alert alert-info" role="alert">L'activité du jour a été entrée.</div>
@else
<form action="{{ url('store') }}" method="post" accept-charset="utf-8">
@csrf
<div class="contact-form">
<div class="form-group">
<label class="control-label col-sm-5" for="message">Quoi de neuf aujourd'hui ?</label>
<div class="col-sm-10">
<div id="app">
</div>
<span class="text-danger">{{ $errors->first('message') }}</span>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">J'enregistre ma journée</button>
</div>
</div>
</div>
</form>
@endif
@foreach($posts as $post)
<div class="post">
<p>{{ \Carbon\Carbon::instance($post->date_post)->diffForHumans() }}</p>
<p>{!! $tag_detector->linkTagFrom($post->content) !!}</p>
</div>
@endforeach
<div class="page-header">
<h1 class="page-title">
{{ __('Dashboard') }}
</h1>
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
</div>
<div class="row flex-fill">
<div class="col-sm-6 col-lg-3">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-blue mr-3">
<i class="fe fe-activity"></i>
</span>
<div>
<h4 class="m-0">{{ $all_counts }}</h4>
<small class="text-muted">{{ __('Jours Écrits') }}</small>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-3">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-green mr-3">
<i class="fe fe-calendar"></i>
</span>
<div>
<h4 class="m-0">{{ $year_counts }}</h4>
<small class="text-muted">{{ __('Cette Année') }}</small>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-3">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-red mr-3">
<i class="fe fe-grid"></i>
</span>
<div>
<h4 class="m-0">{{ $month_counts }}</h4>
<small class="text-muted">{{ __('Ce Mois') }}</small>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-3">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-yellow mr-3">
<i class="fe fe-image"></i>
</span>
<div>
<h4 class="m-0">{{ $image_counts }}</h4>
<small class="text-muted">{{ __('Images Envoyées') }}</small>
</div>
</div>
</div>
</div>
<div class="col-md-12">
@if($already)
<div class="alert alert-primary">L'activité du jour a déjà été entrée.</div>
@else
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">{{ strftime('%B %G', $today->format('U')) }}</h3>
</div>
<div class="card-body">
<form action="{{ url('store') }}" method="post" accept-charset="utf-8">
@csrf
<div class="contact-form">
<div class="form-group">
<label class="control-label col-sm-5" for="message">Quoi de neuf aujourd'hui ?</label>
<div class="col-sm-10">
<div id="app">
</div>
<span class="text-danger">{{ $errors->first('message') }}</span>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary ml-auto">J'enregistre ma journée</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
@endif
</div>
@foreach($posts as $post)
<div class="col-md-6 col-xl-4">
<div class="card">
<div class="card-status bg-blue"></div>
<div class="card-header">
<h3 class="card-title">{{ ucfirst(\Carbon\Carbon::instance($post->date_post)->diffForHumans()) }}</h3>
<div class="card-options">
<a href="#" class="card-options-collapse" data-toggle="card-collapse"><i class="fe fe-chevron-up"></i></a>
<a href="#" class="card-options-remove" data-toggle="card-remove"><i class="fe fe-x"></i></a>
</div>
</div>
<div class="card-body">
{!! $tag_detector->linkTagFrom($post->content) !!}
</div>
<div class="card-footer">
{{ \Carbon\Carbon::instance($post->date_post)->format('d F Y') }}
</div>
</div>
</div>
@endforeach
</div>
</div>
@endsection

View File

@ -2,79 +2,145 @@
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Content-Language" content="{{ str_replace('_', '-', app()->getLocale()) }}" />
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<title>{{ config('app.name', 'Journal Intime') }}</title>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div>
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="page">
<div class="header py-4">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav mr-auto">
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Authentication Links -->
<div class="d-flex">
<a class="header-brand" href="{{ url('/') }}">
{{-- <img src="./demo/brand/tabler.svg" class="header-brand-img" alt="tabler logo">--}}
{{ config('app.name', 'Journal Intime') }}
</a>
<div class="d-flex order-lg-2 ml-auto">
@guest
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
<div class="nav-item d-none d-md-flex">
<a href="{{ route('login') }}" class="btn btn-sm btn-outline-primary">{{ __('Login') }}</a>
</div>
@if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
<div class="nav-item d-none d-md-flex">
<a href="{{ route('register') }}" class="btn btn-sm btn-outline-primary">{{ __('Register') }}</a>
</div>
@endif
@else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span>
<div class="dropdown d-none d-md-flex">
<a class="nav-link icon" data-toggle="dropdown">
<i class="fe fe-bell"></i>
<span class="nav-unread"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<!--<a href="#" class="dropdown-item d-flex">
<span class="avatar mr-3 align-self-center" style="background-image: url(demo/faces/male/41.jpg)"></span>
<div>
<strong>Nathan</strong> pushed new commit: Fix page load performance issue.
<div class="small text-muted">10 minutes ago</div>
</div>
</a>-->
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item text-center">Mark all as read</a>
</div>
</div>
<div class="dropdown">
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
<span class="avatar">{{ substr(Auth::user()->name, 0, 1) }}</span>
<span class="ml-2 d-none d-lg-block">
<span class="text-default">{{ Auth::user()->name }}</span>
<small class="text-muted d-block mt-1"></small>
</span>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item" href="#">
<i class="dropdown-icon fe fe-user"></i> Profile
</a>
<a class="dropdown-item" href="#">
<i class="dropdown-icon fe fe-settings"></i> Settings
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
document.getElementById('logout-form').submit();">
<i class="dropdown-icon fe fe-log-out"></i> {{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
</div>
</li>
</div>
</div>
@endguest
</ul>
<a href="#" class="header-toggler d-lg-none ml-3 ml-lg-0" data-toggle="collapse" data-target="#headerMenuCollapse">
<span class="header-toggler-icon"></span>
</a>
</div>
</div>
</nav>
</div>
<div class="header collapse d-lg-flex p-0" id="headerMenuCollapse">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-3 ml-auto">
<form class="input-icon my-3 my-lg-0">
<input type="search" class="form-control header-search" placeholder="Search…" tabindex="1">
<div class="input-icon-addon">
<i class="fe fe-search"></i>
</div>
</form>
</div>
<div class="col-lg order-lg-first">
<ul class="nav nav-tabs border-0 flex-column flex-lg-row">
<li class="nav-item">
<a href="./" class="nav-link active"><i class="fe fe-home"></i> {{ __('Accueil') }}</a>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link"><i class="fe fe-trending-up"></i> {{ __('Mes statistiques') }}</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link"><i class="fe fe-image"></i> {{ __('Ma gallerie') }}</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<main class="py-4">
<main class="my-3 my-md-5 flex-fill">
@yield('content')
</main>
<footer class="footer">
<div class="container">
<div class="row align-items-center flex-row-reverse">
<div class="col-auto ml-lg-auto">
<div class="row align-items-center">
<div class="col-auto">
<ul class="list-inline list-inline-dots mb-0">
<li class="list-inline-item"><a href="./docs/index.html">Documentation</a></li>
<li class="list-inline-item"><a href="./faq.html">FAQ</a></li>
</ul>
</div>
<div class="col-auto">
<a href="https://github.com/tabler/tabler" class="btn btn-outline-primary btn-sm">Source code</a>
</div>
</div>
</div>
<div class="col-12 col-lg-auto mt-3 mt-lg-0 text-center">
Copyright © 2019 <a href="{{ config('app.url') }}">{{ config('app.name') }}</a>. Thème par <a href="https://codecalm.net" target="_blank">codecalm.net</a>
</div>
</div>
</div>
</footer>
</div>
</body>
</html>