Merge pull request #9 from bumi/setup-application-layout

Add application layout styling
This commit is contained in:
bumi 2020-04-09 18:29:48 +02:00 committed by GitHub
commit 3042f422f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 122 additions and 27 deletions

View File

@ -14,18 +14,26 @@
*= require_self
*/
@import "bulma/sass/utilities/initial-variables";
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Lobster&family=Comfortaa:wght@400;500;600;700&display=swap');
$family-sans-serif: "Helvetica",
"Arial",
sans-serif;
// https://coolors.co/06aed5-086788-f0c808-fff1d0-dd1c1a
$blue: #083d77;
$red: #dd1c1a;
$orange: #ee964b;
$yellow: #f4d35e;
$light: #f5fafe; // #ebebd3;
$primary: $blue;
$green: #007932; // hsl(141, 53%, 53%);
$footer-background-color: $light;
$family-sans-serif: 'Roboto', sans-serif;
$family-secondary: 'Comfortaa', cursive;
// // https://coolors.co/06aed5-086788-f0c808-fff1d0-dd1c1a
// $blue: #083d77;
// $red: #dd1c1a;
// $orange: #ee964b;
// $yellow: #f4d35e;
// $light: #f5fafe; // #ebebd3;
// $primary: $blue;
// $green: #007932; // hsl(141, 53%, 53%);
// $footer-background-color: $light;
@import 'bulma/bulma';
@import 'bulma/bulma';
.is-font-logo {
font-family: 'Lobster', cursive;
}
body {
min-height: 100vh;
}

View File

@ -1,4 +1,5 @@
class ApplicationController < ActionController::Base
helper_method :current_user, :logged_in?
def require_login
redirect_to login_url unless current_user.present?

View File

@ -15,3 +15,30 @@ require("channels")
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
document.addEventListener('DOMContentLoaded', () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});

View File

@ -1,3 +1,12 @@
<h1>Welcome</h1>
<%= link_to "Login", login_url %>
<section class="hero is-medium is-dark is-bold">
<div class="hero-body">
<div class="container">
<h1 class="title is-family-secondary has-text-weight-bold">
Welcome
</h1>
<p class="subtitle is-size-6 has-text-white">
Generate forms instantly
</p>
</div>
</div>
</section>

View File

@ -1,15 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<title>Tinyform</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<head>
<title>Tinyform</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<body>
<%= yield %>
</body>
</html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body class="has-background-white-bis">
<!-- Wrapper -->
<div id="wrapper" class="has-text-centered-mobile">
<!-- Hero -->
<section class="hero is-medium">
<div class="hero-head">
<div class="container">
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item is-size-4 has-text-black has-text-weight-bold is-font-logo" href="/">
TinyForms
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
data-target="navbar">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbar" class="navbar-menu">
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<% if !logged_in? -%>
<%= link_to "Login", login_url, { :class => "button is-primary"} %>
<% else -%>
<%= link_to "Logout", logout_url, { :class => "button is-light"} %>
<% end -%>
</div>
</div>
</div>
</div>
</nav>
</div>
</section>
<main>
<%= yield %>
</main>
</div>
</body>
</html>

View File

@ -7,6 +7,7 @@
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.2.2",
"bulma": "^0.8.1",
"bulma-helpers": "^0.3.10",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",

View File

@ -1540,6 +1540,11 @@ builtin-status-codes@^3.0.0:
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=
bulma-helpers@^0.3.10:
version "0.3.10"
resolved "https://registry.yarnpkg.com/bulma-helpers/-/bulma-helpers-0.3.10.tgz#a0ab518b44343bb708339ade721f7355d159a547"
integrity sha512-dgJB8LreVzAHJfcbYUUONA0oo/cdWxhFt1b/DlmTLaukYTjkdM5GP9A7DRyssjuRhcozIqzTm//BLLR313Xw3Q==
bulma@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.8.1.tgz#a5feacb703b73a87fdeae4f0d12317d62fc1d301"