Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

日報フォロー機能のコメント通知を切り替えられるようにする #3227

Merged
merged 25 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e9f9309
Followingテーブルにwatchを追加
yana-gi Sep 5, 2021
4b348e8
watch=falseの場合、自動的にWatchしないようにした
yana-gi Sep 5, 2021
24867f0
Following.watchを切り替えられるようにした
yana-gi Sep 5, 2021
50a49ed
ビュー側でフォローできるようにした
yana-gi Sep 7, 2021
74ce810
コメントなしボタンを追加
yana-gi Sep 7, 2021
2eceba3
フォローしないボタンを追加
yana-gi Sep 7, 2021
767538a
usersにクエリパラメータにwatchを追加
yana-gi Sep 13, 2021
d23dae6
文言・デザイン仮追加
yana-gi Sep 13, 2021
665f94e
フォローボタンの表示を変更
yana-gi Sep 14, 2021
ef101c8
usersの「フォロー中」の階層を1段階あげた
yana-gi Sep 14, 2021
7fb7975
フォローボタンのデザイン、タブ周りの色調整
machida Sep 17, 2021
df2fb34
モデルテスト追加
yana-gi Sep 19, 2021
455966a
システムテスト追加
yana-gi Sep 19, 2021
15f0768
テストデータ追加
yana-gi Sep 19, 2021
3b2d9a7
エラー発生時の文言を修正
yana-gi Sep 21, 2021
9cc96eb
lint修正
yana-gi Sep 21, 2021
bb32343
User#followにキーワード引数を設定した
yana-gi Sep 22, 2021
3f3f97f
User#change_watching の更新処理を update! から update に変更
yana-gi Sep 22, 2021
774512e
User#following_list の処理変更
yana-gi Sep 22, 2021
329e103
User#auto_watching? の名前を watching? に変更
yana-gi Sep 22, 2021
fa8a40a
boolean属性の指定に?を付与
yana-gi Sep 22, 2021
4546e9e
不要なファイルを削除
yana-gi Sep 22, 2021
ca9b433
User#follow の処理を変更
yana-gi Sep 22, 2021
c18e8c2
フォローの説明が消えてしまっていたのを修正、通知のデザインファイルを消してしまっていたのを戻した
machida Sep 27, 2021
995a47a
「フォロー中」のタブのアクティブ状態を修正
yana-gi Sep 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/assets/stylesheets/atoms/_a-dropdown.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.a-dropdown
overflow: hidden
background-color: $base
border: solid 1px $border-shade
box-shadow: rgba(black, .2) 0 0 .375rem
border-radius: .25rem

.a-dropdown__item
&:not(:last-child)
border-bottom: solid 1px $border
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.header-notification-icon
+text-block(1.25rem 1, center)
+media-breakpoint-down(sm)
+text-block(1.125rem 1)
.has-count &
color: $default-text

.header-notification-count
background-color: $badge-color
+text-block(.625rem 1, center $reversal-text flex)
align-items: center
justify-content: center
border-radius: 1rem
position: absolute
+media-breakpoint-up(md)
+size(1.25rem .875rem)
+position(right .25rem, top .25rem)
+media-breakpoint-down(sm)
+size(1.125rem .75rem)
+position(right .125rem, top .125rem)

.header-notifications-item__body
width: 100%
+media-breakpoint-up(md)
color: $default-text
+media-breakpoint-down(sm)
color: $reversal-text

.header-notifications-item__user-icon
float: left
+size(2rem)
margin-right: .5rem
margin-bottom: .25rem

.header-notifications-item__message
p
line-height: 1.45
margin-bottom: .375em
+media-breakpoint-up(md)
font-size: .8125rem
+media-breakpoint-down(sm)
font-size: .75rem

.header-notifications-item__created-at
text-align: right
display: block
+media-breakpoint-up(md)
font-size: .75rem
+media-breakpoint-down(sm)
font-size: .625rem
119 changes: 0 additions & 119 deletions app/assets/stylesheets/blocks/header/_header-drop-down.sass

This file was deleted.

4 changes: 2 additions & 2 deletions app/assets/stylesheets/blocks/header/_header-dropdown.sass
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

.header-dropdown__inner
+media-breakpoint-up(md)
background-color: $base
+position(absolute, right 0, top 100%, 2)
background-color: $base
border: solid 1px $border-shade
width: 14rem
box-shadow: rgba(black, .2) 0 0 .375rem
Expand Down Expand Up @@ -63,7 +63,7 @@
.header-dropdown__item:not(:last-child) &
border-bottom: solid 1px $background
&:hover
background-color: $background-more-tint
background-color: $hover-background
+media-breakpoint-down(sm)
color: $reversal-text
border-bottom: solid 1px $side-border
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/blocks/page/_page-tabs.sass
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

.page-tabs__item-link
+flex-link
+text-block(.825rem 1, $default-text 600)
+text-block(.825rem 1, $semi-muted-text 600)
align-items: center
justify-content: center
height: 2.75rem
Expand Down
6 changes: 3 additions & 3 deletions app/assets/stylesheets/blocks/shared/_tab-nav.sass
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

.tab-nav__item-link
+block-link
+text-block(.75rem 2.3, $muted-text center nowrap)
+text-block(.75rem 2.3, $semi-muted-text center nowrap)
background-color: $background-shade
border-radius: 20rem
width: 7rem
transition: all.2s ease-out
&:hover
background-color: shade($background-shade, 10%)
color: $main-text
color: $default-text
&.is-active
background-color: $accent
color: $main-text
color: $default-text
32 changes: 32 additions & 0 deletions app/assets/stylesheets/blocks/user/_following.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.following
position: relative

.following__dropdown
+position(absolute, 2)
width: 18.75rem

.following-option
cursor: pointer
width: 100%
padding: .75rem
display: block
text-align: left
transition: all .2s ease-out
&:hover
background-color: $hover-background

.following-option__inner
position: relative
padding-left: 1.5rem
.following-option.is-active &::before
+fa(fas '\f00c')
+position(absolute, left 0, top 0)

.following-option__label
+text-block(.875rem 1.4, 600 $semi-muted-text)
.following-option.is-active &
color: $default-text

.following-option__desciption
+text-block(.75rem 1.5, $muted-text)
margin-top: .125rem
3 changes: 2 additions & 1 deletion app/assets/stylesheets/initializers/_reset.sass
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ hr
border: none

details,
details *
details *,
summary
box-sizing: border-box
2 changes: 1 addition & 1 deletion app/assets/stylesheets/mixins/_button.sass
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
&.is-block
display: flex
width: 100%
max-width: 100%
&.is-select
+margin(horizontal, 0)
&:focus
Expand All @@ -30,7 +31,6 @@
margin-right: .35em
margin-top: .02em
font-size: 1.07em
font-weight: normal
&.is-icon
i
+text-block(1.3em 1)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/variables/_colors.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ $background: #ececec
$background-shade: #d6d6d6
$background-tint: #eceeef
$background-more-tint: #f7f7f9
$hover-background: $background-more-tint


$default-text: #403f47
$reversal-text: white
Expand Down
13 changes: 12 additions & 1 deletion app/controllers/api/followings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ class API::FollowingsController < API::BaseController

def create
user = User.find(params[:id])
if current_user.follow(user)
watch = params[:watch] == 'true'
if current_user.follow(user, watch: watch)
render json: { id: user.id }
else
head :bad_request
end
end

def update
user = User.find(params[:id])
watch = params[:watch] == 'true'
if current_user.change_watching(user, watch)
head :no_content
else
head :bad_request
end
end

def destroy
user = User.find(params[:id])
if current_user.unfollow(user)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def index
@tag = params[:tag]
@target = params[:target]
@target = 'student_and_trainee' unless target_allowlist.include?(@target)
@watch = params[:watch]

target_users =
if @target == 'followings'
followings = Following.where(follower_id: current_user.id).select('followed_id')
User.where(id: followings)
current_user.following_list(watch: @watch)
elsif params[:tag]
User.tagged_with(params[:tag])
else
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class UsersController < ApplicationController
def index
@target = params[:target]
@target = 'student_and_trainee' unless target_allowlist.include?(@target)
@watch = params[:watch]

target_users =
if @target == 'followings'
followings = Following.where(follower_id: current_user.id).select('followed_id')
User.where(id: followings)
current_user.following_list(watch: @watch)
elsif params[:tag]
User.tagged_with(params[:tag])
else
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/following.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ document.addEventListener('DOMContentLoaded', () => {
const following = followings[i]
const isFollowing = following.getAttribute('data-is-following')
const userId = following.getAttribute('data-user-id')
const isWatching = following.getAttribute('data-is-watching')

new Vue({
render: (h) =>
h(Following, {
props: {
isFollowing: isFollowing === 'true',
userId: Number(userId)
userId: Number(userId),
isWatching: isWatching === 'true'
}
})
}).$mount('.js-following')
Expand Down
Loading