From b3a43acd4d349445f0ba05fc568e6b57b46a0426 Mon Sep 17 00:00:00 2001 From: Kobe Date: Thu, 22 May 2025 22:56:46 +0200 Subject: [PATCH] lol --- app.py | 15 ++++++++---- static/css/tooltip.css | 53 ++++++++++++++++++++++++++++++++++++++++++ templates/base.html | 1 + templates/home.html | 21 +++++++++++------ templates/post.html | 21 +++++++++++------ 5 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 static/css/tooltip.css diff --git a/app.py b/app.py index f9cb611..30d5f06 100644 --- a/app.py +++ b/app.py @@ -183,8 +183,8 @@ def home(): query = query.filter(Plant.growth_rate_id == growth_rate_id) plants = query.order_by(Plant.date_added.desc()).all() - climates_dict = {c.id: {'name': c.name, 'icon': c.icon} for c in Climate.query.all()} - environments_dict = {e.id: {'name': e.name, 'icon': e.icon} for e in Environment.query.all()} + climates_dict = {c.id: {'name': c.name, 'icon': c.icon, 'description': c.description} for c in Climate.query.all()} + environments_dict = {e.id: {'name': e.name, 'icon': e.icon, 'description': e.description} for e in Environment.query.all()} products_dict = {p.id: p.name for p in Product.query.all()} display_plants = [] @@ -195,29 +195,36 @@ def home(): pid = pid.strip() if pid.isdigit() and int(pid) in products_dict: product_names.append(products_dict[int(pid)]) - climate_info = climates_dict.get(plant.climate_id, {'name': '', 'icon': None}) - environment_info = environments_dict.get(plant.environment_id, {'name': '', 'icon': None}) + climate_info = climates_dict.get(plant.climate_id, {'name': '', 'icon': None, 'description': ''}) + environment_info = environments_dict.get(plant.environment_id, {'name': '', 'icon': None, 'description': ''}) display_plants.append({ 'id': plant.id, 'name': plant.name, 'picture': plant.picture, 'climate': climate_info['name'], 'climate_icon': climate_info['icon'], + 'climate_description': climate_info['description'], 'environment': environment_info['name'], 'environment_icon': environment_info['icon'], + 'environment_description': environment_info['description'], 'products': ', '.join(product_names), 'description': plant.description, 'date_added': plant.date_added, 'light': plant.light.name if plant.light else '', 'light_icon': plant.light.icon if plant.light and plant.light.icon else None, + 'light_description': plant.light.description if plant.light else '', 'toxicity': plant.toxicity.name if plant.toxicity else '', 'toxicity_icon': plant.toxicity.icon if plant.toxicity and plant.toxicity.icon else None, + 'toxicity_description': plant.toxicity.description if plant.toxicity else '', 'size': plant.size.name if plant.size else '', 'size_icon': plant.size.icon if plant.size and plant.size.icon else None, + 'size_description': plant.size.description if plant.size else '', 'care_difficulty': plant.care_difficulty.name if plant.care_difficulty else '', 'care_difficulty_icon': plant.care_difficulty.icon if plant.care_difficulty and plant.care_difficulty.icon else None, + 'care_difficulty_description': plant.care_difficulty.description if plant.care_difficulty else '', 'growth_rate': plant.growth_rate.name if plant.growth_rate else '', 'growth_rate_icon': plant.growth_rate.icon if plant.growth_rate and plant.growth_rate.icon else None, + 'growth_rate_description': plant.growth_rate.description if plant.growth_rate else '', }) return render_template('home.html', diff --git a/static/css/tooltip.css b/static/css/tooltip.css new file mode 100644 index 0000000..f8624da --- /dev/null +++ b/static/css/tooltip.css @@ -0,0 +1,53 @@ +.tag-tooltip { + position: relative; + display: inline-flex; + align-items: center; +} + +.tag-tooltip .tooltip-text { + visibility: hidden; + width: 200px; + background-color: #4e6b50; + color: #fff; + text-align: center; + border-radius: 6px; + padding: 8px; + position: absolute; + z-index: 1; + bottom: 125%; + left: 50%; + transform: translateX(-50%); + opacity: 0; + transition: opacity 0.3s, visibility 0.3s; + font-size: 0.875rem; + line-height: 1.4; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} + +.tag-tooltip .tooltip-text::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #4e6b50 transparent transparent transparent; +} + +.tag-tooltip:hover .tooltip-text { + visibility: visible; + opacity: 1; +} + +/* Adjust tooltip position for tags at the top of the screen */ +.tag-tooltip.top .tooltip-text { + bottom: auto; + top: 125%; +} + +.tag-tooltip.top .tooltip-text::after { + top: auto; + bottom: 100%; + border-color: transparent transparent #4e6b50 transparent; +} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 29f0992..0f220c1 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,6 +7,7 @@ +