Skip to content

Commit

Permalink
refactor about and contact pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Wood committed Apr 5, 2024
1 parent 5801b5d commit d1dc661
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 116 deletions.
3 changes: 1 addition & 2 deletions app/controllers/contact_messages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class ContactMessagesController < ApplicationController
def new
@contact_message = ContactMessage.new
@about = About.first
end

def create
Expand Down Expand Up @@ -55,4 +54,4 @@ def recaptcha_valid?
flash[:alert].push('reCaptcha failed, please try again')
false
end
end
end
1 change: 1 addition & 0 deletions app/frontend/packs/styles/base/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Desktop 1100px => ~

$breakpoints: (
'mobile' : ( max-width: 766px ),
'tablet' : ( min-width: 767px ),
'desktop': ( min-width: 1100px ),
'extra-wide': ( min-width: 2560px )
Expand Down
1 change: 1 addition & 0 deletions app/frontend/packs/styles/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
@include respond-to(tablet) {
align-items: center;
flex-direction: row;
justify-content: space-between;
margin: 20px 0;
}

Expand Down
77 changes: 14 additions & 63 deletions app/frontend/packs/styles/custom/about.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
@use '../base/mixins' as *;
@use '../base/typography';

.about-contact-container {
.profile-image-container {
display: flex;
flex-wrap: wrap;
max-width: 550px;
justify-content: center;
position: relative;
width: 100%;

Expand All @@ -19,76 +19,27 @@
}

.profile-image {
width: 50%;
margin-bottom: 0.5em;
margin-top: 1.4em;
max-width: 300px;
width: 100%;

@include respond-to(tablet) {
width: 100%;
}
}
}

.about-contact-details-container {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
padding-left: 20px;
position: relative;
width: 50%;

@include respond-to(tablet) {
margin-top: 10px;
padding-left: 0;
width: 100%;

.name {
font-size: 1.3em;
}

.location {
font-size: 1.1em;
}
}

.name {
font-size: 1.3em;
font-weight: 400;
margin-bottom: 10px;
.about-about-me-container {
@include respond-to(mobile) {
display: flex;
justify-content: center;
}

.location {
font-size: 1em;
}

}


.about-contact-links-section {
align-items: center;
box-sizing: border-box;
display: flex;
flex-direction: row;
margin-top: 10px;
position: relative;
width: 100%;

a {
display: inline;
line-height: 1em;
padding: 5px;

+ * {
margin-left: 10px;
}
}

.about-contact-link {
flex: 0 1 50%;
height: fit-content;
padding: 15px 0;

+ * {
margin-left: 20px;
.markdown {
@include respond-to(mobile) {
max-width: 50ch;
text-align: justify;
}
}
}
17 changes: 15 additions & 2 deletions app/frontend/packs/styles/custom/contact.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
@use '../base/mixins' as *;
@use '../base/typography';

.item-content.contact-messages-container {
align-content: center;
align-items: center;
flex-direction: column;
}

.contact-details-container {
margin-top: 10px;
Expand All @@ -19,6 +24,11 @@

.contact-form-container {
flex: 0 1 600px;
width: 100%;

@include respond-to(tablet) {
width: 450px;
}
}

.embedded-text-area.contact {
Expand Down Expand Up @@ -57,7 +67,10 @@

#contact-messages-new-form {
padding: 0;
@include respond-to(tablet) {
padding-left: 20px;

.embedded-input-box {
@include respond-to(tablet) {
width: 75%;
}
}
}
6 changes: 3 additions & 3 deletions app/views/abouts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<section class='reading-pane' itemscope itemtype="http://schema.org/AboutPage">
<%= render partial: 'partials/admin_toolbar', locals: { model: @about, singular: true } %>

<%= render partial: 'partials/contact_details', locals: { model: @about, contact_link: true } %>
<%= render partial: 'partials/profile_image', locals: { model: @about, contact_link: true } %>

<div itemprop="mainContentOfPage">
<div class='about-about-me-container' itemprop="mainContentOfPage">
<%= markdown_admin(@about.about_me) %>
</div>
</section>
</section>
6 changes: 2 additions & 4 deletions app/views/contact_messages/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
Talk to me
<% end %>

<div class='item-content' itemscope itemtype="https://schema.org/ContactPage">
<div class='contact-details-container' >
<%= render partial: 'partials/contact_details', locals: { model: @about, contact_link: false } %>
</div>
<div class='item-content contact-messages-container' itemscope itemtype="https://schema.org/ContactPage">
<h2>👋 Send me a message</h2>

<%= render partial: 'contact_messages/new_form', locals: {contact_message: @contact_message} %>
</div>
25 changes: 0 additions & 25 deletions app/views/partials/_contact_details.html.erb

This file was deleted.

3 changes: 3 additions & 0 deletions app/views/partials/_profile_image.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class='profile-image-container'>
<%= image_tag(image_path_helper(image_model: model.profile_image), class: 'profile-image about', alt: 'profile image') %>
</div>
4 changes: 1 addition & 3 deletions spec/feature/about_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ def some(code)
expect(page).to have_content('Contact email updated!')
click_on('Return')
expect(page).to have_content('new section name')
expect(page).to have_content('new about name')
expect(page).to have_content('new about location')
expect(page.html).to match('<h1>new about me text in markdown</h1>')
expect(page).to have_selector('code')
expect(page).to have_selector('img.profile-image')
end
end
end
end
3 changes: 1 addition & 2 deletions spec/feature/contact_message_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
visit('/')
click_on('CONTACT')
expect(page).to have_current_path('/contact')
expect(page).to have_content(@about.name)
fill_in('contact_message[from]', with: 'new from name')
fill_in('contact_message[email]', with: '[email protected]')
fill_in('contact_message[subject]', with: 'new message')
Expand All @@ -20,4 +19,4 @@
expect(page).to have_content('Message sent! You should receive a confirmation email shortly.')
end
end
end
end
7 changes: 1 addition & 6 deletions spec/views/abouts/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
render template: 'abouts/show'

expect(rendered).to match(about.about_me)
expect(rendered).to match(about.linkedin_link)
expect(rendered).to match(about.github_link)
expect(rendered).to match(about.name)
expect(rendered).to match(about.location)
expect(rendered).to match(contact_path)
expect(rendered).not_to match('toolbar-container')
end

Expand All @@ -27,4 +22,4 @@
expect(rendered).to match('toolbar-container')
end
end
end
end
7 changes: 1 addition & 6 deletions spec/views/contact_messages/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
expect(rendered).to match('contact_message_content')
expect(rendered).to match(contact_messages_path)
end

it 'it renders about details' do
expect(rendered).to match(about.name)
expect(rendered).to match(about.location)
end
end
end
end
end

0 comments on commit d1dc661

Please sign in to comment.