feat: Добавлены шаблоны дизайна и управление большими группами
Some checks failed
continuous-integration/drone/push Build is failing

- Система готовых шаблонов (8 шт): Minimalist, Dark, Corporate, Creative, Nature, Retro, Neon, Soft
- Компонент ExpandableGroup для автоматического сворачивания больших списков ссылок
- Визуальный селектор шаблонов с превью в CustomizationPanel
- Поддержка во всех макетах (timeline, masonry, magazine, cards)
- CSS модули для улучшенной стилизации
- Настраиваемые лимиты отображения для разных макетов (5, 8, 3-5 ссылок)
- Полная интеграция с overlay системой и кастомными шрифтами
This commit is contained in:
2025-11-09 10:53:45 +09:00
parent 5ddc30fe0e
commit 644a0487e1
8 changed files with 1011 additions and 91 deletions

View File

@@ -1,6 +1,8 @@
'use client'
import React, { useState, useEffect } from 'react'
import { TemplatesSelector } from './TemplatesSelector'
import { designTemplates, DesignTemplate } from '../constants/designTemplates'
interface DesignSettings {
id?: number
@@ -51,7 +53,7 @@ export function CustomizationPanel({ isOpen, onClose, onSettingsUpdate }: Custom
header_text_color: '#000000'
})
const [loading, setLoading] = useState(false)
const [activeTab, setActiveTab] = useState<'layout' | 'colors' | 'groups' | 'advanced'>('layout')
const [activeTab, setActiveTab] = useState<'layout' | 'colors' | 'groups' | 'templates' | 'advanced'>('templates')
const [backgroundImageFile, setBackgroundImageFile] = useState<File | null>(null)
useEffect(() => {
@@ -189,6 +191,14 @@ export function CustomizationPanel({ isOpen, onClose, onSettingsUpdate }: Custom
}))
}
const handleTemplateSelect = (template: DesignTemplate) => {
setSettings(prev => ({
...prev,
...template.settings,
id: prev.id // Сохраняем оригинальный ID
}))
}
if (!isOpen) return null
return (
@@ -237,6 +247,15 @@ export function CustomizationPanel({ isOpen, onClose, onSettingsUpdate }: Custom
Группы
</button>
</li>
<li className="nav-item">
<button
className={`nav-link ${activeTab === 'templates' ? 'active' : ''}`}
onClick={() => setActiveTab('templates')}
>
<i className="bi bi-palette me-1"></i>
Шаблоны
</button>
</li>
<li className="nav-item">
<button
className={`nav-link ${activeTab === 'advanced' ? 'active' : ''}`}
@@ -659,6 +678,16 @@ export function CustomizationPanel({ isOpen, onClose, onSettingsUpdate }: Custom
</div>
)}
{/* Вкладка: Шаблоны */}
{activeTab === 'templates' && (
<div className="tab-pane fade show active">
<TemplatesSelector
onTemplateSelect={handleTemplateSelect}
currentTemplate={undefined} // Можно добавить определение текущего шаблона
/>
</div>
)}
{/* Вкладка: Дополнительно */}
{activeTab === 'advanced' && (
<div className="tab-pane fade show active">

View File

@@ -0,0 +1,163 @@
.expandToggle {
margin-top: 1rem;
position: relative;
}
.expandButton {
display: flex;
align-items: center;
justify-content: center;
min-height: 50px;
font-weight: 500;
transition: all 0.2s ease;
border-radius: 10px;
&:hover {
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
}
.expandOverlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 10px;
pointer-events: none;
}
.linkItem {
position: relative;
margin-bottom: 0.75rem;
}
.linkContent {
display: block;
text-decoration: none;
color: inherit;
transition: all 0.2s ease;
position: relative;
overflow: hidden;
border-radius: 10px;
&:hover {
text-decoration: none;
color: inherit;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
}
.linkInner {
display: flex;
align-items: center;
padding: 1rem;
background: white;
border-radius: 10px;
border: 1px solid #e9ecef;
position: relative;
z-index: 1;
}
.linkIcon {
width: 40px;
height: 40px;
object-fit: cover;
border-radius: 8px;
margin-right: 1rem;
flex-shrink: 0;
}
.linkInfo {
flex: 1;
min-width: 0;
}
.linkTitle {
margin: 0 0 0.25rem 0;
font-size: 1rem;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.linkDescription {
margin: 0;
font-size: 0.875rem;
color: #6c757d;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.linkOverlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
border-radius: 10px;
z-index: 2;
}
/* Layout-specific styles */
.linkItem :global(.grid-link) {
.linkInner {
flex-direction: column;
text-align: center;
padding: 1.5rem;
}
.linkIcon {
width: 60px;
height: 60px;
margin-right: 0;
margin-bottom: 1rem;
}
.linkTitle, .linkDescription {
white-space: normal;
text-align: center;
}
}
.linkItem :global(.cards-link) {
.linkInner {
padding: 1.25rem;
}
.linkIcon {
width: 50px;
height: 50px;
}
}
.linkItem :global(.timeline-link) {
.linkInner {
padding: 1rem 1.25rem;
border-left: 4px solid var(--theme-color, #007bff);
}
}
.linkItem :global(.magazine-link) {
.linkInner {
flex-direction: column;
padding: 1.5rem;
}
.linkIcon {
width: 80px;
height: 80px;
margin-right: 0;
margin-bottom: 1rem;
}
.linkTitle, .linkDescription {
white-space: normal;
text-align: center;
}
}

View File

@@ -0,0 +1,145 @@
'use client'
import React, { useState } from 'react'
import styles from './ExpandableGroup.module.css'
interface Link {
id: number
title: string
url: string
description?: string
image?: string
}
interface ExpandableGroupProps {
links: Link[]
layout: 'grid' | 'cards' | 'timeline' | 'magazine'
initialShowCount?: number
className?: string
linkClassName?: string
overlayColor?: string
overlayOpacity?: number
}
export function ExpandableGroup({
links,
layout,
initialShowCount = 5,
className = '',
linkClassName = '',
overlayColor,
overlayOpacity
}: ExpandableGroupProps) {
const [isExpanded, setIsExpanded] = useState(false)
const overlayStyles = overlayColor && overlayOpacity ? {
backgroundColor: overlayColor,
opacity: overlayOpacity
} : undefined
if (links.length <= initialShowCount) {
return (
<div className={className}>
{links.map((link) => (
<LinkItem
key={link.id}
link={link}
layout={layout}
className={linkClassName}
overlayColor={overlayColor}
overlayOpacity={overlayOpacity}
/>
))}
</div>
)
}
const visibleLinks = isExpanded ? links : links.slice(0, initialShowCount)
const hiddenCount = links.length - initialShowCount
return (
<div className={className}>
{visibleLinks.map((link) => (
<LinkItem
key={link.id}
link={link}
layout={layout}
className={linkClassName}
overlayColor={overlayColor}
overlayOpacity={overlayOpacity}
/>
))}
{hiddenCount > 0 && (
<div className={`${styles.expandToggle} ${linkClassName}`}>
<button
className={`${styles.expandButton} btn btn-outline-secondary w-100`}
onClick={() => setIsExpanded(!isExpanded)}
>
{isExpanded ? (
<>
<i className="bi bi-chevron-up me-2"></i>
Скрыть ({hiddenCount} ссылок)
</>
) : (
<>
<i className="bi bi-chevron-down me-2"></i>
Показать еще {hiddenCount} ссылок
</>
)}
</button>
{overlayStyles && (
<div className={styles.expandOverlay} style={overlayStyles}></div>
)}
</div>
)}
</div>
)
}
interface LinkItemProps {
link: Link
layout: string
className?: string
overlayColor?: string
overlayOpacity?: number
}
function LinkItem({ link, layout, className = '', overlayColor, overlayOpacity }: LinkItemProps) {
const overlayStyles = overlayColor && overlayOpacity ? {
backgroundColor: overlayColor,
opacity: overlayOpacity
} : undefined
return (
<div className={`${styles.linkItem} ${className}`}>
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
className={`${styles.linkContent} link-item ${layout}-link`}
>
<div className={styles.linkInner}>
{link.image && (
<img
src={link.image}
alt={link.title}
className={styles.linkIcon}
/>
)}
<div className={styles.linkInfo}>
<h6 className={styles.linkTitle}>{link.title}</h6>
{link.description && (
<p className={styles.linkDescription}>{link.description}</p>
)}
</div>
</div>
{overlayStyles && (
<div className={styles.linkOverlay} style={overlayStyles}></div>
)}
</a>
</div>
)
}
export default ExpandableGroup

View File

@@ -0,0 +1,69 @@
.template-selector {
.template-card {
cursor: pointer;
transition: all 0.2s ease;
&:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
&.selected {
border-color: var(--bs-primary) !important;
box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}
}
.template-preview {
height: 120px;
border-radius: 0.375rem 0.375rem 0 0;
position: relative;
overflow: hidden;
}
.preview-content {
padding: 1rem;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.preview-header {
height: 20px;
border-radius: 4px;
opacity: 0.8;
width: 70%;
margin-bottom: 0.5rem;
}
.preview-subtitle {
height: 12px;
border-radius: 2px;
opacity: 0.6;
width: 50%;
margin-bottom: 0.5rem;
}
.preview-button {
height: 24px;
border-radius: 6px;
width: 80%;
margin-bottom: 0.25rem;
}
.preview-text {
height: 8px;
border-radius: 2px;
opacity: 0.5;
width: 60%;
}
.overlay-demo {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}

View File

@@ -0,0 +1,122 @@
'use client'
import React from 'react'
import { designTemplates, DesignTemplate } from '../constants/designTemplates'
import styles from './TemplatesSelector.module.css'
interface TemplatesSelectorProps {
onTemplateSelect: (template: DesignTemplate) => void
currentTemplate?: string
}
export function TemplatesSelector({ onTemplateSelect, currentTemplate }: TemplatesSelectorProps) {
return (
<div className={styles.templateSelector}>
<h6 className="mb-3">
<i className="bi bi-palette me-2"></i>
Готовые шаблоны
</h6>
<div className="row g-3">
{designTemplates.map((template) => (
<div key={template.id} className="col-md-6 col-lg-4">
<div
className={`${styles.templateCard} card h-100 ${currentTemplate === template.id ? `${styles.selected} border-primary` : 'border-secondary'}`}
onClick={() => onTemplateSelect(template)}
>
<div
className={styles.templatePreview}
style={{
background: template.settings.background_color,
}}
>
{/* Мини-превью дизайна */}
<div className={styles.previewContent}>
<div>
<div
className={styles.previewHeader}
style={{
backgroundColor: template.settings.header_text_color,
}}
></div>
<div
className={styles.previewSubtitle}
style={{
backgroundColor: template.settings.group_text_color,
}}
></div>
</div>
<div>
<div
className={styles.previewButton}
style={{
backgroundColor: template.settings.theme_color,
}}
></div>
<div
className={styles.previewText}
style={{
backgroundColor: template.settings.link_text_color,
}}
></div>
</div>
</div>
{/* Overlay для демонстрации */}
{template.settings.group_overlay_enabled && (
<div
className={styles.overlayDemo}
style={{
backgroundColor: template.settings.group_overlay_color || '#000000',
opacity: template.settings.group_overlay_opacity || 0.3,
}}
></div>
)}
</div>
<div className="card-body p-3">
<h6
className="card-title mb-2"
style={{
fontFamily: template.settings.heading_font_family || template.settings.font_family,
color: template.settings.header_text_color
}}
>
{template.name}
</h6>
<p
className="card-text small mb-0"
style={{
fontFamily: template.settings.body_font_family || template.settings.font_family,
color: template.settings.group_description_text_color
}}
>
{template.description}
</p>
{currentTemplate === template.id && (
<div className="mt-2">
<span className="badge bg-primary">
<i className="bi bi-check-lg me-1"></i>
Выбран
</span>
</div>
)}
</div>
</div>
</div>
))}
</div>
<div className="mt-3">
<div className="alert alert-info">
<i className="bi bi-info-circle me-2"></i>
<small>
<strong>Совет:</strong> После выбора шаблона вы можете дополнительно настроить цвета, шрифты и другие параметры во вкладках выше.
</small>
</div>
</div>
</div>
)
}
export default TemplatesSelector