Skip to content

Commit

Permalink
a bit more stylish (#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Gaudin <[email protected]>
  • Loading branch information
Letiste and nymous authored Mar 26, 2023
1 parent 1f1ce79 commit a6aaf04
Show file tree
Hide file tree
Showing 47 changed files with 414 additions and 115 deletions.
10 changes: 9 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ Minitest/MultipleAssertions:
Max: 10

Metrics/MethodLength:
Max: 12
Max: 15

Metrics/AbcSize:
Max: 20

Rails/HelperInstanceVariable:
Enabled: false

# TODO: enable these rules when starting doing i18n

Rails/I18nLocaleTexts:
Enabled: false

I18n/RailsI18n/DecorateString:
Enabled: false
12 changes: 12 additions & 0 deletions app/assets/images/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions app/assets/stylesheets/layouts/_header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
header {
background-color: var(--primary-700);
padding: var(--padding-md);
width: 100%;
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: var(--padding-md);
}

nav ul {
list-style: none;
}

nav li {
display: inline-block;
}

nav a {
text-decoration: none;
color: var(--primary-200);
font-size: var(--text-md);
}

.logo {
font-weight: var(--font-bold);
margin-right: calc(2 * var(--padding-md));
}

.login_button {
background-color: var(--primary-600);
color: var(--primary-200);
border-radius: var(--rounded-lg);
letter-spacing: var(--spacing-lg);
font-size: var(--text-sm);
text-transform: uppercase;
border: none;
font-weight: var(--font-bold);
padding: var(--padding-xs) var(--padding-md);
}

.logout_button {
background-color: transparent;
color: var(--primary-200);
border-radius: var(--rounded-lg);
letter-spacing: var(--spacing-lg);
font-size: var(--text-sm);
text-transform: uppercase;
border: none;
box-shadow: inset 0px 0px 0px 2px var(--primary-200);
font-weight: var(--font-bold);
padding: var(--padding-xs) var(--padding-md);
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/subscriptions/_subscription.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.subscription {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-columns: auto auto;
column-gap: calc(var(--padding-md)*2);
}

Expand Down
32 changes: 32 additions & 0 deletions app/assets/stylesheets/theme/alert.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.alert {
border-radius: var(--rounded-lg);
border: 2px solid;
padding: var(--padding-sm) var(--padding-md);
margin: var(--padding-md) 0;
display: flex;
align-items: center;
}

.alert svg {
padding-right: var(--padding-sm);
}

.alert-success {
border-color: var(--green-300);
background-color: var(--green-50);
color: var(--green-900);
}

.alert-success svg {
fill: var(--green-700);
}

.alert-error {
border-color: var(--red-300);
background-color: var(--red-50);
color: var(--red-900);
}

.alert-error svg {
fill: var(--red-700);
}
8 changes: 8 additions & 0 deletions app/assets/stylesheets/theme/constants.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@
--gray-700: rgb(55 65 81);
--gray-800: rgb(31 41 55);
--gray-900: rgb(17 24 39);
--green-50: #e8f5e9;
--green-300: #81c784;
--green-700: #388e3c;
--green-900: #1b5e20;
--red-50: #ffebee;
--red-300: #e57373;
--red-700: #d32f2f;
--red-900: #b71c1c;
}
41 changes: 41 additions & 0 deletions app/assets/stylesheets/theme/form.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.form {
display: flex;
flex-direction: column;
font-size: var(--text-md);
margin-top: var(--padding-md);
}

.form div {
display: flex;
flex-direction: column;
margin-bottom: var(--padding-md);
}

.form label {
font-weight: var(--font-medium);
}

.form input {
border: 2px solid var(--primary-500);
border-radius: var(--rounded-lg);
font-size: var(--text-md);
padding: var(--padding-xs);
background-color: var(--primary-50);
}

.form input:focus {
border-color: var(--primary-800);
}

.form div:last-child input[type="submit"] {
background-color: var(--primary-600);
color: var(--primary-50);
border-radius: var(--rounded-lg);
letter-spacing: var(--spacing-lg);
font-size: var(--text-sm);
text-transform: uppercase;
border: none;
font-weight: var(--font-bold);
padding: var(--padding-sm) 0;
cursor: pointer;
}
8 changes: 8 additions & 0 deletions app/assets/stylesheets/users/_user.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.user {
display: grid;
grid-template-columns: max(20ch) 1fr 1fr auto;
column-gap: var(--padding-md);
align-items: center;
text-decoration: none;
color: var(--black);
}
14 changes: 14 additions & 0 deletions app/assets/stylesheets/users/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.users {
list-style: none;
font-size: var(--text-md);
color: var(--gray-800);
font-weight: var(--font-medium);
display: grid;
row-gap: var(--padding-md);
margin-top: var(--padding-md);
}

.users > * + * {
border-top: solid var(--primary-200) 2px;
padding-top: var(--padding-md);
}
6 changes: 2 additions & 4 deletions app/assets/stylesheets/users/show.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

.container {
display: grid;
grid-template-columns: repeat(3,1fr);
grid-template-rows: repeat(2, auto);
}

.divider {
Expand Down Expand Up @@ -36,7 +34,7 @@
}

.card-content {
grid-column: 2 / 4;
grid-column: 2 / 3;
display: flex;
flex-direction: row;
padding-left: 0;
Expand Down Expand Up @@ -74,10 +72,10 @@
grid-template-columns: 1fr 1fr;
grid-template-rows: repeat(3, 1fr);
row-gap: var(--padding-xs);
column-gap: var(--padding-md);
font-size: var(--text-md);
color: var(--gray-800);
font-weight: var(--font-medium);
grid-column: 2 / 3;
}

.card-machines {
Expand Down
15 changes: 15 additions & 0 deletions app/assets/stylesheets/utils/_error_messages.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.error_messages {
list-style: none;
}

.form .field_with_errors {
margin: 0;
}

.field_with_errors label {
color: var(--red-900);
}

.field_with_errors input {
border-color: var(--red-300);
}
3 changes: 3 additions & 0 deletions app/controllers/free_accesses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def create
@free_access = @owner.free_accesses.new(free_access_params)
authorize! :create, @free_access
if @free_access.save
flash[:success] = 'Free access added!'
redirect_to @owner
else
render 'new', status: :unprocessable_entity
Expand All @@ -27,6 +28,7 @@ def update
authorize! :update, @free_access
owner = @free_access.user
if @free_access.update(free_access_params)
flash[:success] = 'Free access updated!'
redirect_to owner
else
render 'edit', status: :unprocessable_entity
Expand All @@ -37,6 +39,7 @@ def destroy
authorize! :destroy, @free_access
owner = @free_access.user
@free_access.destroy
flash[:success] = 'Free access deleted!'
redirect_to owner
end

Expand Down
15 changes: 12 additions & 3 deletions app/controllers/machines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def create
authorize! :create, @machine
respond_to do |format|
if @machine.save
format.html { redirect_to @owner }
format.html do
flash[:success] = 'Machine added!'
redirect_to @owner
end
format.json { render 'show', status: :created, location: @machine }
else
format.html { render 'new', status: :unprocessable_entity }
Expand All @@ -38,7 +41,10 @@ def update
owner = @machine.user
respond_to do |format|
if @machine.update(machine_params)
format.html { redirect_to owner }
format.html do
flash[:success] = 'Machine updated!'
redirect_to owner
end
format.json { render 'show', status: :ok, location: @machine }
else
format.html { render 'edit', status: :unprocessable_entity }
Expand All @@ -52,7 +58,10 @@ def destroy
owner = @machine.user
@machine.destroy
respond_to do |format|
format.html { redirect_to owner }
format.html do
flash[:success] = 'Machine deleted!'
redirect_to owner
end
format.json { head :no_content }
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ class SessionsController < ApplicationController
def create
user = User.upsert_from_auth_hash(request.env['omniauth.auth'])
log_in user
flash[:success] = 'You are now logged in!'
redirect_to user_path user
end

def destroy
log_out
redirect_to users_path
flash[:success] = 'You are now logged out!'
redirect_to root_path
end
end
5 changes: 5 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class StaticPagesController < ApplicationController
def home; end
end
2 changes: 2 additions & 0 deletions app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def create
@subscription = @owner.extend_subscription(duration: Integer(subscription_params[:duration]))
authorize! :create, @subscription
if @subscription.save
flash[:success] = 'New subscription added!'
redirect_to @owner
else
render 'new', status: :unprocessable_entity
Expand All @@ -21,6 +22,7 @@ def create
def destroy
authorize! :destroy, @owner.current_subscription
owner.cancel_current_subscription!
flash[:success] = 'Last subscription cancelled!'
redirect_to owner
end

Expand Down
15 changes: 12 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def create
authorize! :create, @user
respond_to do |format|
if @user.save
format.html { redirect_to @user }
format.html do
flash[:success] = 'User created!'
redirect_to @user
end
format.json { render 'show', status: :created, location: @user }
else
format.html { render 'new', status: :unprocessable_entity }
Expand All @@ -44,7 +47,10 @@ def update
authorize! :update, @user
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to @user }
format.html do
flash[:success] = 'User updated!'
redirect_to @user
end
format.json { render 'show', status: :ok, location: @user }
else
format.html { render 'edit', status: :unprocessable_entity }
Expand All @@ -58,7 +64,10 @@ def destroy
authorize! :destroy, @user
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.html do
flash[:success] = 'User deleted!'
redirect_to users_url
end
format.json { head :no_content }
end
end
Expand Down
Loading

0 comments on commit a6aaf04

Please sign in to comment.