Skip to content

Commit 7c6187d

Browse files
committed
questions#show styling
1 parent 753e6d4 commit 7c6187d

7 files changed

Lines changed: 59 additions & 20 deletions

File tree

app/assets/stylesheets/layout.css.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ header .topbar-inner {
4040

4141
.two-column {
4242
#content {
43-
@include columns(13);
43+
@include columns(11);
4444
}
4545

4646
#sidebar {
47-
@include columns(3, true);
47+
@include columns(5, true);
4848
}
4949

5050
}

app/assets/stylesheets/lib/bootstrap/patterns.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ a.menu:after,
403403
footer {
404404
margin-top: $baseline - 1;
405405
padding-top: $baseline - 1;
406-
border-top: 1px solid #eee;
406+
border-top: 1px solid #ddd;
407407
}
408408

409409

app/assets/stylesheets/questions.css.scss

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
.questions, .question {
2+
h1 {
3+
line-height: 1.1;
4+
margin-bottom: 0.15em;
5+
}
26
.meta {
7+
a {
8+
font-style: italic;
9+
}
310
font-style: italic;
411
padding-bottom: 0.75em;
512
}
@@ -11,7 +18,7 @@
1118
@include clearfix;
1219
list-style-type: none;
1320
padding-bottom: 1em;
14-
border-bottom: 1px solid #eee;
21+
border-bottom: 1px solid #ddd;
1522
margin-bottom: 1em;
1623

1724
.answer-count {
@@ -33,7 +40,7 @@
3340
}
3441

3542
.summary {
36-
@include columns(11, last);
43+
@include columns(9, last);
3744

3845
h2 {
3946
line-height: 1;
@@ -47,7 +54,36 @@
4754
}
4855

4956
.question {
57+
color: #555;
58+
p {
59+
font-size: 1.15em;
60+
line-height: 1.5;
61+
margin-bottom: 1.25em;
62+
}
63+
64+
h2 {
65+
margin-top: 0.5em;
66+
padding-bottom: 0.5em;
67+
border-bottom: 1px solid #bbb;
68+
}
69+
70+
.answers {
71+
margin: 0;
72+
.answer {
73+
position: relative;
74+
list-style-type: none;
75+
padding: 1em 1em 0;
76+
border-bottom: 1px solid #ddd;
77+
margin-bottom: 1em;
78+
79+
.links {
80+
position: absolute;
81+
top: 1em;
82+
right: 1em;
83+
}
84+
}
85+
}
5086
.selected-answer{
51-
background-color:yellow;
87+
background: #ffc;
5288
}
5389
}

app/models/question.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class Question
88

99
belongs_to :user
1010
many :answers
11-
12-
one :answer, :in => :solution_id
1311

1412
validates_presence_of :title, :description
1513

app/views/answers/_list.html.haml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
%li.answer{:class => list.id == @question.solution_id && 'selected-answer'}
2-
.author
3-
Answered by #{list.user.username if list.user}
2+
- if list.user
3+
.meta
4+
#{link_to list.user.username, ""} says
45
.description
5-
= list.description
6+
!= RDiscount.new(list.description).to_html
67

7-
- if can? :update, list
8-
= link_to 'Edit', edit_question_answer_path(@question, list)
9-
- if can? :destroy, list
10-
= link_to 'Delete', question_answer_path(@question, list), :confirm => 'Are you sure?', :method => :delete
11-
- if can? :update, @question
8+
.links
9+
- if can? :update, list
10+
= link_to 'Edit', edit_question_answer_path(@question, list)
11+
- if can? :destroy, list
12+
= link_to 'Delete', question_answer_path(@question, list), :confirm => 'Are you sure?', :method => :delete
13+
14+
- if can?(:update, @question) && (@question.solution_id != list.id)
1215
= simple_form_for(@question, :url => question_path(@question)) do |f|
1316
= f.hidden_field :solution_id, :value => list.id
14-
= f.button :submit, :value => "This answer is correct", :class => "primary btn"
17+
= f.button :submit, :value => "This answers my question!", :class => "primary btn"

app/views/questions/_list.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
%span.date= time_ago_in_words(list.created_at)
1212
ago
13-
.description= truncate(list.description, :length => 200)
13+
.description= truncate(list.description, :length => 150)

app/views/questions/show.html.haml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
= resource.title
44

55
- content_for :sidebar do
6+
 
67
- if can? :update, resource
78
= link_to 'Edit', edit_resource_path
89
- if can? :destroy, resource
@@ -21,8 +22,9 @@
2122
.description
2223
!= RDiscount.new(resource.description).to_html
2324

24-
%h2 Answers
25+
%h2= resource.answers.count == 1 ? "1 response" : "#{resource.answers.count} responses"
2526
%ul.answers
2627
= render :partial => "answers/list", :collection => resource.answers
2728

28-
= render :partial => "answers/form"
29+
- if can? :create, Answer
30+
= render :partial => "answers/form"

0 commit comments

Comments
 (0)