today_ai_weather/app/views/cities/show.html.erb

129 lines
5.9 KiB
Plaintext
Raw Normal View History

<div class="min-h-screen bg-base-200">
<!-- 城市头部信息 -->
<section class="relative h-[50vh] overflow-hidden">
<% if @city.latest_weather_art&.image&.attached? %>
<%= image_tag @city.latest_weather_art.image,
class: "w-full h-full object-cover" %>
<div class="absolute inset-0 bg-gradient-to-t from-base-100 via-base-100/60 to-transparent"></div>
<% end %>
<div class="absolute inset-0 flex items-center">
<div class="container mx-auto px-4">
<div class="max-w-4xl">
<div class="flex items-center space-x-4 mb-6">
<%= link_to cities_path,
class: "btn btn-ghost btn-circle bg-base-100/50 backdrop-blur-sm hover:bg-base-100/70" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
<% end %>
<div>
<h1 class="text-4xl md:text-5xl font-display font-bold mb-2"><%= @city.localized_name %></h1>
<p class="text-lg opacity-80">
<%= @city.country.name %>, <%= @city.region %>
<span class="mx-2">•</span>
<%= Time.current.in_time_zone(@city.timezone).strftime("%Y-%m-%d %H:%M") %>
</p>
</div>
</div>
<div class="stats bg-base-100/80 backdrop-blur-sm shadow-lg rounded-box">
<div class="stat">
<div class="stat-title">Latest Weather</div>
<div class="stat-value text-2xl">
<%= @city.latest_weather_art&.temperature %>°C
</div>
<div class="stat-desc">
<%= @city.latest_weather_art&.description %>
</div>
</div>
<div class="stat">
<div class="stat-title">Coordinates</div>
<div class="stat-value text-xl">
<%= @city.latitude %>°N, <%= @city.longitude %>°E
</div>
<div class="stat-desc">Geographical Location</div>
</div>
<div class="stat">
<div class="stat-title">Weather Records</div>
<div class="stat-value text-2xl"><%= @city.weather_arts.count %></div>
<div class="stat-desc">Total Entries</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- 天气艺术历史记录 -->
<section class="container mx-auto px-4 py-16">
<div class="space-y-8">
<div class="flex justify-between items-center">
<h2 class="text-3xl font-display font-bold">Weather Art History</h2>
<div class="stats shadow inline-flex">
<div class="stat">
<div class="stat-title">Last Updated</div>
<div class="stat-value text-primary text-lg">
<%= time_ago_in_words(@city.last_weather_fetch) if @city.last_weather_fetch %>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<% @city.weather_arts.order(weather_date: :desc).each do |art| %>
<div class="card bg-base-100 shadow-xl hover:shadow-2xl transition-all duration-300">
<figure class="relative aspect-video overflow-hidden">
<% if art.image.attached? %>
<%= image_tag art.image,
class: "w-full h-full object-cover transform hover:scale-105 transition-transform duration-500" %>
<% end %>
<div class="absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/70 to-transparent">
<div class="text-white">
<div class="flex items-center justify-between">
<div class="text-3xl font-bold"><%= art.temperature %>°C</div>
<div class="text-right">
<div class="text-sm font-semibold">
<%= art.weather_date.strftime("%H:%M") %>
</div>
<div class="text-xs opacity-80">
<%= art.weather_date.strftime("%B %d, %Y") %>
</div>
</div>
</div>
</div>
</div>
</figure>
<div class="card-body">
<h3 class="card-title font-display"><%= art.description %></h3>
<div class="grid grid-cols-2 gap-4 my-4 text-sm">
<div class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 opacity-70" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.5 14.7a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
<span>Humidity: <%= art.humidity %>%</span>
</div>
<div class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 opacity-70" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
</svg>
<span>Wind: <%= art.wind_scale %></span>
</div>
</div>
<%= link_to city_weather_art_path(@city, art),
class: "btn btn-primary btn-block" do %>
View Details
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
<% end %>
</div>
</div>
<% end %>
</div>
</div>
</section>
</div>