Fix: Implement proper link scrolling in groups using ExpandableGroup component
Some checks failed
continuous-integration/drone/push Build is failing

- Replace all hardcoded group.links.slice(0, 5) with ExpandableGroup component
- Updated renderGridLayout, renderCardsLayout, renderCompactLayout, renderSidebarLayout
- Fixed icon display in ExpandableGroup component
- Improved styling for button-style links
- All group layouts now support expandable link lists with 'Show X more links' functionality
This commit is contained in:
2025-11-09 12:08:35 +09:00
parent 90ac03663f
commit cefd884172
3 changed files with 58 additions and 104 deletions

View File

@@ -303,33 +303,19 @@ export default function UserPage({
</p> </p>
)} )}
<div className="d-grid gap-2"> <div className="d-grid gap-2">
{group.links.slice(0, 5).map((link) => ( <ExpandableGroup
<Link links={group.links.map(link => ({
key={link.id} id: link.id,
href={link.url} title: link.title,
target="_blank" url: link.url,
rel="noopener noreferrer" description: link.description,
className="btn btn-outline-primary btn-sm d-flex align-items-center justify-content-start" image: designSettings.show_link_icons ? link.icon_url : undefined
style={{ }))}
borderColor: designSettings.theme_color, layout="grid"
color: designSettings.link_text_color || designSettings.theme_color initialShowCount={5}
}} className=""
> linkClassName="btn btn-outline-primary btn-sm d-flex align-items-center justify-content-start"
{designSettings.show_link_icons && link.icon_url && ( />
<img
src={link.icon_url}
width={16}
height={16}
className="me-2 rounded"
alt={link.title}
/>
)}
<span className="text-truncate">{link.title}</span>
</Link>
))}
{group.links.length > 5 && (
<small className="text-muted text-center">+{group.links.length - 5} еще...</small>
)}
</div> </div>
</div> </div>
</div> </div>
@@ -476,35 +462,19 @@ export default function UserPage({
<i className="bi bi-star-fill text-warning ms-2"></i> <i className="bi bi-star-fill text-warning ms-2"></i>
)} )}
</div> </div>
<div className="row"> <ExpandableGroup
{group.links.map((link) => ( links={group.links.map(link => ({
<div key={link.id} className="col-auto mb-1"> id: link.id,
<Link title: link.title,
href={link.url} url: link.url,
target="_blank" description: link.description,
rel="noopener noreferrer" image: designSettings.show_link_icons ? link.icon_url : undefined
className="btn btn-outline-secondary btn-sm d-flex align-items-center" }))}
style={{ layout="cards"
borderColor: designSettings.theme_color + '60', initialShowCount={10}
color: designSettings.link_text_color || designSettings.theme_color className="row"
}} linkClassName="col-auto mb-1"
> />
{designSettings.show_link_icons && link.icon && (
<img
src={link.icon}
alt=""
width={16}
height={16}
className="me-1 rounded"
/>
)}
<small className="text-truncate" style={{ color: designSettings.link_text_color || designSettings.theme_color }}>
{link.title}
</small>
</Link>
</div>
))}
</div>
</div> </div>
</div> </div>
))} ))}
@@ -572,39 +542,19 @@ export default function UserPage({
backgroundPosition: 'center' backgroundPosition: 'center'
}} }}
> >
<div className="row"> <ExpandableGroup
{group.links.map((link) => ( links={group.links.map(link => ({
<div key={link.id} className="col-12 col-md-6 col-lg-4 mb-3"> id: link.id,
<Link title: link.title,
href={link.url} url: link.url,
target="_blank" description: link.description,
rel="noopener noreferrer" image: designSettings.show_link_icons ? link.icon_url : undefined
className="card h-100 text-decoration-none border" }))}
style={{ borderColor: designSettings.theme_color + '40' }} layout="cards"
> initialShowCount={6}
<div className="card-body d-flex align-items-center"> className="row"
{designSettings.show_link_icons && link.icon && ( linkClassName="col-12 col-md-6 col-lg-4 mb-3"
<img />
src={link.icon}
alt=""
width={24}
height={24}
className="me-2 rounded"
/>
)}
<div>
<h6 className="mb-1" style={{ color: designSettings.link_text_color || designSettings.theme_color }}>
{link.title}
</h6>
{link.description && (
<small className="text-muted">{link.description}</small>
)}
</div>
</div>
</Link>
</div>
))}
</div>
</div> </div>
</div> </div>
))} ))}

View File

@@ -41,6 +41,10 @@
position: relative; position: relative;
overflow: hidden; overflow: hidden;
border-radius: 10px; border-radius: 10px;
border: none;
background: white;
width: 100%;
text-align: left;
&:hover { &:hover {
text-decoration: none; text-decoration: none;
@@ -53,20 +57,19 @@
.linkInner { .linkInner {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 1rem; padding: 0.75rem;
background: white;
border-radius: 10px; border-radius: 10px;
border: 1px solid #e9ecef;
position: relative; position: relative;
z-index: 1; z-index: 1;
width: 100%;
} }
.linkIcon { .linkIcon {
width: 40px; width: 20px;
height: 40px; height: 20px;
object-fit: cover; object-fit: cover;
border-radius: 8px; border-radius: 4px;
margin-right: 1rem; margin-right: 0.75rem;
flex-shrink: 0; flex-shrink: 0;
} }
@@ -76,17 +79,18 @@
} }
.linkTitle { .linkTitle {
margin: 0 0 0.25rem 0; margin: 0;
font-size: 1rem; font-size: 0.875rem;
font-weight: 600; font-weight: 500;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
color: inherit;
} }
.linkDescription { .linkDescription {
margin: 0; margin: 0.25rem 0 0 0;
font-size: 0.875rem; font-size: 0.75rem;
color: #6c757d; color: #6c757d;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;

View File

@@ -117,7 +117,7 @@ function LinkItem({ link, layout, className = '', overlayColor, overlayOpacity }
href={link.url} href={link.url}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className={`${styles.linkContent} link-item ${layout}-link`} className={`${styles.linkContent} link-item ${layout}-link btn btn-outline-primary btn-sm d-flex align-items-center justify-content-start`}
> >
<div className={styles.linkInner}> <div className={styles.linkInner}>
{link.image && ( {link.image && (
@@ -128,9 +128,9 @@ function LinkItem({ link, layout, className = '', overlayColor, overlayOpacity }
/> />
)} )}
<div className={styles.linkInfo}> <div className={styles.linkInfo}>
<h6 className={styles.linkTitle}>{link.title}</h6> <span className={styles.linkTitle}>{link.title}</span>
{link.description && ( {link.description && (
<p className={styles.linkDescription}>{link.description}</p> <small className={styles.linkDescription}>{link.description}</small>
)} )}
</div> </div>
</div> </div>