-
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 #7443 from fjordllc/chore/niconico-calendar-non-vu…
…e-conversion ニコニコカレンダーを非Vue化
- Loading branch information
Showing
19 changed files
with
223 additions
and
301 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
app/components/calendar/nico_nico_calendar_component.html.slim
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,55 @@ | ||
.a-card | ||
header.card-header.is-sm | ||
h2.card-header__title | ||
| ニコニコカレンダー | ||
hr.a-border-tint | ||
.card-body | ||
.card__description | ||
.niconico-calendar-nav | ||
- if prev_month?(current_date) | ||
= link_to prev_month_path do | ||
.niconico-calendar-nav__previous | ||
i.fa-solid.fa-angle-left | ||
- else | ||
.niconico-calendar-nav__next.is-blank | ||
.niconico-calendar-nav__year--month | ||
= "#{current_date.year}年#{current_date.month}月" | ||
- if next_month?(current_date) | ||
= link_to next_month_path do | ||
.niconico-calendar-nav__next | ||
i.fa-solid.fa-angle-right | ||
- else | ||
.niconico-calendar-nav__next.is-blank | ||
table.niconico-calendar | ||
thead.niconico-calendar__header | ||
tr | ||
th.niconico-calendar__header-day.is-sunday 日 | ||
th.niconico-calendar__header-day 月 | ||
th.niconico-calendar__header-day 火 | ||
th.niconico-calendar__header-day 水 | ||
th.niconico-calendar__header-day 木 | ||
th.niconico-calendar__header-day 金 | ||
th.niconico-calendar__header-day.is-saturday 土 | ||
tbody.niconico-calendar__body | ||
- user.niconico_calendar(current_calendar).each do |week| | ||
tr.niconico-calendar__week | ||
- week.each do |set| | ||
- day_css_class = frame_and_background(set[:date], set[:emotion]) | ||
- day_label_html = capture do | ||
.niconico-calendar__day-label | ||
= set[:date]&.day | ||
.niconico-calendar__day-value | ||
- if set[:emotion] | ||
img.niconico-calendar__emotion-image src="/images/emotion/#{set[:emotion]}.svg" alt="#{set[:emotion]}" | ||
- elsif set[:date] | ||
i.fa-solid.fa-minus | ||
td.niconico-calendar__day class=day_css_class | ||
- if set[:report] | ||
= link_to report_path(set[:report]), class: 'niconico-calendar__day-inner' do | ||
= day_label_html | ||
- elsif set[:date] && !set[:date].future? | ||
= link_to new_report_path(reported_on: set[:date]), class: 'niconico-calendar__day-inner' do | ||
= day_label_html | ||
- else | ||
.niconico-calendar__day-inner | ||
= day_label_html |
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,36 @@ | ||
# frozen_string_literal: true | ||
|
||
class Calendar::NicoNicoCalendarComponent < ViewComponent::Base | ||
def initialize(user:, path:, current_date:, current_calendar:) | ||
@user = user | ||
@path = path | ||
@current_date = current_date | ||
@current_calendar = current_calendar | ||
end | ||
|
||
def prev_month?(month) | ||
month.beginning_of_month > user.created_at.to_date.beginning_of_month | ||
end | ||
|
||
def prev_month_path | ||
send(path, niconico_calendar: current_date.prev_month.strftime('%Y-%m')) | ||
end | ||
|
||
def frame_and_background(date, emotion) | ||
day_class = emotion ? "is-#{emotion}" : 'is-blank' | ||
day_class += ' is-today' if date&.today? | ||
day_class | ||
end | ||
|
||
def next_month?(month) | ||
month.beginning_of_month < Time.zone.today.to_date.beginning_of_month | ||
end | ||
|
||
def next_month_path | ||
send(path, niconico_calendar: current_date.next_month.strftime('%Y-%m')) | ||
end | ||
|
||
private | ||
|
||
attr_reader :user, :path, :current_date, :current_calendar | ||
end |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.