mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 15:44:20 +01:00
refactor: unify button styles across sidebars using IconButton
- Convert HighlightsPanel buttons to use IconButton component - Add style prop support to IconButton for custom styling - Remove redundant CSS for old button classes (level-toggle-btn, refresh-highlights-btn, etc.) - Keep only highlight-level-toggles container styling - Consistent button appearance across left and right sidebars - DRY: Single IconButton component handles all sidebar buttons
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
||||||
import { faChevronRight, faEye, faEyeSlash, faRotate, faUser, faUserGroup, faNetworkWired } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronRight, faEye, faEyeSlash, faRotate, faUser, faUserGroup, faNetworkWired } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { HighlightVisibility } from '../HighlightsPanel'
|
import { HighlightVisibility } from '../HighlightsPanel'
|
||||||
|
import IconButton from '../IconButton'
|
||||||
|
|
||||||
interface HighlightsPanelHeaderProps {
|
interface HighlightsPanelHeaderProps {
|
||||||
loading: boolean
|
loading: boolean
|
||||||
@@ -32,76 +32,72 @@ const HighlightsPanelHeader: React.FC<HighlightsPanelHeaderProps> = ({
|
|||||||
<div className="highlights-actions-left">
|
<div className="highlights-actions-left">
|
||||||
{onHighlightVisibilityChange && (
|
{onHighlightVisibilityChange && (
|
||||||
<div className="highlight-level-toggles">
|
<div className="highlight-level-toggles">
|
||||||
<button
|
<IconButton
|
||||||
|
icon={faNetworkWired}
|
||||||
onClick={() => onHighlightVisibilityChange({
|
onClick={() => onHighlightVisibilityChange({
|
||||||
...highlightVisibility,
|
...highlightVisibility,
|
||||||
nostrverse: !highlightVisibility.nostrverse
|
nostrverse: !highlightVisibility.nostrverse
|
||||||
})}
|
})}
|
||||||
className={`level-toggle-btn ${highlightVisibility.nostrverse ? 'active' : ''}`}
|
|
||||||
title="Toggle nostrverse highlights"
|
title="Toggle nostrverse highlights"
|
||||||
aria-label="Toggle nostrverse highlights"
|
ariaLabel="Toggle nostrverse highlights"
|
||||||
|
variant={highlightVisibility.nostrverse ? 'primary' : 'ghost'}
|
||||||
style={{ color: highlightVisibility.nostrverse ? 'var(--highlight-color-nostrverse, #9333ea)' : undefined }}
|
style={{ color: highlightVisibility.nostrverse ? 'var(--highlight-color-nostrverse, #9333ea)' : undefined }}
|
||||||
>
|
/>
|
||||||
<FontAwesomeIcon icon={faNetworkWired} />
|
<IconButton
|
||||||
</button>
|
icon={faUserGroup}
|
||||||
<button
|
|
||||||
onClick={() => onHighlightVisibilityChange({
|
onClick={() => onHighlightVisibilityChange({
|
||||||
...highlightVisibility,
|
...highlightVisibility,
|
||||||
friends: !highlightVisibility.friends
|
friends: !highlightVisibility.friends
|
||||||
})}
|
})}
|
||||||
className={`level-toggle-btn ${highlightVisibility.friends ? 'active' : ''}`}
|
|
||||||
title={currentUserPubkey ? "Toggle friends highlights" : "Login to see friends highlights"}
|
title={currentUserPubkey ? "Toggle friends highlights" : "Login to see friends highlights"}
|
||||||
aria-label="Toggle friends highlights"
|
ariaLabel="Toggle friends highlights"
|
||||||
style={{ color: highlightVisibility.friends ? 'var(--highlight-color-friends, #f97316)' : undefined }}
|
variant={highlightVisibility.friends ? 'primary' : 'ghost'}
|
||||||
disabled={!currentUserPubkey}
|
disabled={!currentUserPubkey}
|
||||||
>
|
style={{ color: highlightVisibility.friends ? 'var(--highlight-color-friends, #f97316)' : undefined }}
|
||||||
<FontAwesomeIcon icon={faUserGroup} />
|
/>
|
||||||
</button>
|
<IconButton
|
||||||
<button
|
icon={faUser}
|
||||||
onClick={() => onHighlightVisibilityChange({
|
onClick={() => onHighlightVisibilityChange({
|
||||||
...highlightVisibility,
|
...highlightVisibility,
|
||||||
mine: !highlightVisibility.mine
|
mine: !highlightVisibility.mine
|
||||||
})}
|
})}
|
||||||
className={`level-toggle-btn ${highlightVisibility.mine ? 'active' : ''}`}
|
|
||||||
title={currentUserPubkey ? "Toggle my highlights" : "Login to see your highlights"}
|
title={currentUserPubkey ? "Toggle my highlights" : "Login to see your highlights"}
|
||||||
aria-label="Toggle my highlights"
|
ariaLabel="Toggle my highlights"
|
||||||
style={{ color: highlightVisibility.mine ? 'var(--highlight-color-mine, #eab308)' : undefined }}
|
variant={highlightVisibility.mine ? 'primary' : 'ghost'}
|
||||||
disabled={!currentUserPubkey}
|
disabled={!currentUserPubkey}
|
||||||
>
|
style={{ color: highlightVisibility.mine ? 'var(--highlight-color-mine, #eab308)' : undefined }}
|
||||||
<FontAwesomeIcon icon={faUser} />
|
/>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{onRefresh && (
|
{onRefresh && (
|
||||||
<button
|
<IconButton
|
||||||
|
icon={faRotate}
|
||||||
onClick={onRefresh}
|
onClick={onRefresh}
|
||||||
className="refresh-highlights-btn"
|
|
||||||
title="Refresh highlights"
|
title="Refresh highlights"
|
||||||
aria-label="Refresh highlights"
|
ariaLabel="Refresh highlights"
|
||||||
|
variant="ghost"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
spin={loading}
|
||||||
<FontAwesomeIcon icon={faRotate} spin={loading} />
|
/>
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
{hasHighlights && (
|
{hasHighlights && (
|
||||||
<button
|
<IconButton
|
||||||
|
icon={showHighlights ? faEye : faEyeSlash}
|
||||||
onClick={onToggleHighlights}
|
onClick={onToggleHighlights}
|
||||||
className="toggle-highlight-display-btn"
|
|
||||||
title={showHighlights ? 'Hide highlights' : 'Show highlights'}
|
title={showHighlights ? 'Hide highlights' : 'Show highlights'}
|
||||||
aria-label={showHighlights ? 'Hide highlights' : 'Show highlights'}
|
ariaLabel={showHighlights ? 'Hide highlights' : 'Show highlights'}
|
||||||
>
|
variant="ghost"
|
||||||
<FontAwesomeIcon icon={showHighlights ? faEye : faEyeSlash} />
|
/>
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<IconButton
|
||||||
|
icon={faChevronRight}
|
||||||
onClick={onToggleCollapse}
|
onClick={onToggleCollapse}
|
||||||
className="toggle-highlights-btn"
|
|
||||||
title="Collapse highlights panel"
|
title="Collapse highlights panel"
|
||||||
aria-label="Collapse highlights panel"
|
ariaLabel="Collapse highlights panel"
|
||||||
>
|
variant="ghost"
|
||||||
<FontAwesomeIcon icon={faChevronRight} rotation={180} />
|
style={{ transform: 'rotate(180deg)' }}
|
||||||
</button>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ interface IconButtonProps {
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
spin?: boolean
|
spin?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
|
style?: React.CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
const IconButton: React.FC<IconButtonProps> = ({
|
const IconButton: React.FC<IconButtonProps> = ({
|
||||||
@@ -23,7 +24,8 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|||||||
size = 33,
|
size = 33,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
spin = false,
|
spin = false,
|
||||||
className = ''
|
className = '',
|
||||||
|
style
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@@ -31,7 +33,7 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
title={title}
|
title={title}
|
||||||
aria-label={ariaLabel || title}
|
aria-label={ariaLabel || title}
|
||||||
style={{ width: size, height: size }}
|
style={{ width: size, height: size, ...style }}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={icon} spin={spin} />
|
<FontAwesomeIcon icon={icon} spin={spin} />
|
||||||
|
|||||||
@@ -74,38 +74,6 @@
|
|||||||
|
|
||||||
/* Three-level highlight toggles */
|
/* Three-level highlight toggles */
|
||||||
.highlight-level-toggles { display: flex; gap: 0.25rem; padding: 0.25rem; background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
|
.highlight-level-toggles { display: flex; gap: 0.25rem; padding: 0.25rem; background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
|
||||||
.highlight-level-toggles .level-toggle-btn { background: none; border: none; color: rgb(161 161 170); /* zinc-400 */ cursor: pointer; padding: 0.375rem 0.5rem; border-radius: 3px; transition: all 0.2s; font-size: 0.9rem; }
|
|
||||||
.highlight-level-toggles .level-toggle-btn:hover { background: rgba(255, 255, 255, 0.1); }
|
|
||||||
.highlight-level-toggles .level-toggle-btn.active { background: rgba(255, 255, 255, 0.1); opacity: 1; }
|
|
||||||
.highlight-level-toggles .level-toggle-btn:not(.active) { opacity: 0.4; }
|
|
||||||
.highlight-level-toggles .level-toggle-btn:disabled { opacity: 0.3; cursor: not-allowed; }
|
|
||||||
.highlight-level-toggles .level-toggle-btn:disabled:hover { background: none; }
|
|
||||||
|
|
||||||
.refresh-highlights-btn,
|
|
||||||
.toggle-highlight-display-btn,
|
|
||||||
.toggle-highlights-btn {
|
|
||||||
background: transparent;
|
|
||||||
color: rgb(228 228 231); /* zinc-200 */
|
|
||||||
border: 1px solid rgb(82 82 91); /* zinc-600 */
|
|
||||||
padding: 0;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refresh-highlights-btn:hover,
|
|
||||||
.toggle-highlight-display-btn:hover,
|
|
||||||
.toggle-highlights-btn:hover { background: rgb(39 39 42); /* zinc-800 */ color: rgb(255 255 255); /* white */ }
|
|
||||||
.refresh-highlights-btn:active,
|
|
||||||
.toggle-highlight-display-btn:active,
|
|
||||||
.toggle-highlights-btn:active { transform: translateY(1px); }
|
|
||||||
.refresh-highlights-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
||||||
.refresh-highlights-btn:disabled:hover { background: transparent; color: rgb(228 228 231); /* zinc-200 */ }
|
|
||||||
|
|
||||||
.highlights-loading,
|
.highlights-loading,
|
||||||
.highlights-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; color: rgb(161 161 170); /* zinc-400 */ text-align: center; gap: 0.5rem; }
|
.highlights-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; color: rgb(161 161 170); /* zinc-400 */ text-align: center; gap: 0.5rem; }
|
||||||
|
|||||||
Reference in New Issue
Block a user