-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3385 from fjordllc/feature/tweet-learning_completion
プラクティス完了ツイート機能の実装
- Loading branch information
Showing
66 changed files
with
2,157 additions
and
115 deletions.
There are no files selected for viewing
1,522 changes: 1,522 additions & 0 deletions
1,522
app/assets/images/completion/completion_background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.a-completion-message | ||
background-color: $info | ||
+padding(vertical, .75rem) | ||
&:not(:last-child) | ||
margin-bottom: 1.25rem | ||
|
||
.a-completion-message__inner | ||
+media-breakpoint-up(md) | ||
display: flex | ||
justify-content: center | ||
align-items: center | ||
|
||
.a-completion-message__title | ||
+text-block(1em 1.45, center $reversal-text 600) | ||
+media-breakpoint-up(md) | ||
font-size: 1rem | ||
+media-breakpoint-down(sm) | ||
font-size: .8125rem | ||
|
||
.a-completion-message__actions-item | ||
+media-breakpoint-up(md) | ||
width: 10rem | ||
+media-breakpoint-down(sm) | ||
|
||
.a-completion-message__inner-end | ||
+media-breakpoint-up(md) | ||
margin-left: 1rem | ||
+media-breakpoint-down(sm) | ||
margin-top: .75rem |
22 changes: 22 additions & 0 deletions
22
app/assets/stylesheets/blocks/card/_congrats-card-body.sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.congrats-card-body__title | ||
+text-block(1.5rem 1.5, 700) | ||
+media-breakpoint-up(md) | ||
font-size: 1.5rem | ||
+media-breakpoint-down(sm) | ||
font-size: 1rem | ||
|
||
.congrats-card-body__image-container | ||
margin-top: 1.25rem | ||
|
||
.congrats-card-body__image-container | ||
width: 100% | ||
max-width: 28rem | ||
+margin(horizontal, auto) | ||
|
||
.congrats-card-body__image | ||
border-radius: .75rem | ||
border: solid .5rem $background | ||
|
||
.congrats-card-body | ||
.card-main-actions | ||
margin-top: 1.25rem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.page-tools | ||
.page-header + & | ||
border-top: solid 1px $border-more-shade | ||
& + .page-body | ||
border-top: solid 1px $border-more-shade |
2 changes: 2 additions & 0 deletions
2
app/assets/stylesheets/blocks/practice/_completion-massage.sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.completion-massage | ||
background-color: $success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import common-imports | ||
@import blocks/shared/flash | ||
@import blocks/shared/modal | ||
@import completion/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
$completion: #00a0dd | ||
|
||
body.is-completion | ||
background-color: $completion | ||
|
||
.completion-wrapper | ||
min-height: 100vh | ||
display: flex | ||
flex-direction: column | ||
&::before | ||
content: '' | ||
background-image: image_url('completion/completion_background.svg') | ||
background-repeat: repeat | ||
+position(fixed, left 0, top 0, right 0, bottom 0, 1) | ||
+size(100%) | ||
opacity: .075 | ||
+media-breakpoint-up(md) | ||
background-size: 16rem auto | ||
|
||
.completion-wrapper__start | ||
flex: 1 | ||
+position(relative, 2) | ||
|
||
.completion-wrapper__end | ||
+position(relative, 2) | ||
|
||
.complestion | ||
+padding(vertical, 4rem 2rem) | ||
|
||
.complestion__title | ||
+text-block(2rem 1.5, 800 center $reversal-text) | ||
font-family: YakuHanJP_Narrow,Hiragino Sans,Hiragino Kaku Gothic ProN,BIZ UDPGothic,Meiryo,sans-serif | ||
|
||
.complestion__body | ||
margin-top: 3rem | ||
|
||
.complestion__image | ||
border-radius: 1rem | ||
border: solid .75rem shade($completion, 30%) | ||
|
||
.welcome-footer | ||
+media-breakpoint-up(md) | ||
+padding(vertical, 3rem) | ||
+media-breakpoint-down(sm) | ||
padding-bottom: 1.5rem | ||
body.welcome & .container | ||
+padding(horizontal, 0) | ||
|
||
.welcome-footer__nav | ||
margin-bottom: 1.5rem | ||
|
||
.welcome-footer__nav-items | ||
+media-breakpoint-up(md) | ||
display: flex | ||
justify-content: center | ||
|
||
.welcome-footer__nav-item | ||
+media-breakpoint-up(md) | ||
+padding(horizontal, .5rem) | ||
|
||
.welcome-footer__nav-item-link | ||
+text-block(.875rem 1, $reversal-text) | ||
+media-breakpoint-up(md) | ||
+hover-link | ||
+media-breakpoint-down(sm) | ||
text-decoration: none | ||
display: flex | ||
align-items: center | ||
+padding(horizontal, 1rem) | ||
border-bottom: solid 1px $border | ||
+size(100% 2.75rem) | ||
|
||
.welcome-footer-copyright | ||
justify-content: center | ||
align-items: center | ||
+text-block(.875rem 1.45, flex $reversal-text) | ||
|
||
.welcome-footer-copyright__author | ||
display: block | ||
+margin(horizontal, .1em .5em) |
12 changes: 12 additions & 0 deletions
12
app/controllers/api/practices/learning/completion_message_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class API::Practices::Learning::CompletionMessageController < API::BaseController | ||
def update | ||
learning = current_user.learnings.find_by(practice_id: params[:practice_id]) | ||
if learning.update(completion_message_displayed: true) | ||
head :ok | ||
else | ||
head :bad_request | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class Practices::CompletionController < ApplicationController | ||
layout 'completion' | ||
|
||
def show | ||
@practice = Practice.find(params[:practice_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module LearningDecorator | ||
def should_display_message_automatically?(current_user:) | ||
user == current_user && complete? && !completion_message_displayed? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const modal = document.querySelector('#modal-learning_completion') | ||
if (!modal) { | ||
return null | ||
} | ||
|
||
const datasetNode = document.querySelector('#modal-learning_completion-data') | ||
|
||
if (datasetNode.dataset.shouldDisplayMessageAutomatically === 'true') { | ||
modal.checked = true | ||
} | ||
|
||
modal.addEventListener('change', () => { | ||
if (!modal.checked) { | ||
const practiceId = datasetNode.dataset.practiceId | ||
fetch(`/api/practices/${practiceId}/learning/completion_message`, { | ||
method: 'PATCH', | ||
headers: { | ||
'Content-Type': 'application/json; charset=utf-8', | ||
'X-Requested-With': 'XMLHttpRequest', | ||
'X-CSRF-Token': token() | ||
}, | ||
credentials: 'same-origin', | ||
redirect: 'manual' | ||
}).catch((error) => { | ||
console.warn('Failed to parsing', error) | ||
}) | ||
} | ||
}) | ||
|
||
function token() { | ||
const meta = document.querySelector('meta[name="csrf-token"]') | ||
return meta ? meta.getAttribute('content') : '' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.