mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +08:00
refactor(styles): update CitationTooltip and CitationsList components for improved UI consistency and layout
This commit is contained in:
parent
6d6a554fd3
commit
2fe2ae797b
@ -54,9 +54,10 @@ const CitationTooltip: React.FC<CitationTooltipProps> = ({ children, citation })
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
arrow={false}
|
||||||
overlay={tooltipContent}
|
overlay={tooltipContent}
|
||||||
placement="top"
|
placement="top"
|
||||||
color="var(--color-background-mute)"
|
color="var(--color-background)"
|
||||||
styles={{
|
styles={{
|
||||||
body: {
|
body: {
|
||||||
border: '1px solid var(--color-border)',
|
border: '1px solid var(--color-border)',
|
||||||
|
|||||||
@ -56,13 +56,13 @@ const CitationsList: React.FC<CitationsListProps> = ({ citations }) => {
|
|||||||
const popoverContent = (
|
const popoverContent = (
|
||||||
<PopoverContent>
|
<PopoverContent>
|
||||||
{citations.map((citation) => (
|
{citations.map((citation) => (
|
||||||
<div key={citation.url || citation.number}>
|
<PopoverContentItem key={citation.url || citation.number}>
|
||||||
{citation.type === 'websearch' ? (
|
{citation.type === 'websearch' ? (
|
||||||
<WebSearchCitation citation={citation} />
|
<WebSearchCitation citation={citation} />
|
||||||
) : (
|
) : (
|
||||||
<KnowledgeCitation citation={citation} />
|
<KnowledgeCitation citation={citation} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</PopoverContentItem>
|
||||||
))}
|
))}
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
)
|
)
|
||||||
@ -72,7 +72,17 @@ const CitationsList: React.FC<CitationsListProps> = ({ citations }) => {
|
|||||||
<Popover
|
<Popover
|
||||||
arrow={false}
|
arrow={false}
|
||||||
content={popoverContent}
|
content={popoverContent}
|
||||||
title={<div style={{ padding: '8px 12px 0', fontWeight: 'bold' }}>{t('message.citations')}</div>}
|
title={
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
padding: '8px 12px 8px',
|
||||||
|
marginBottom: -8,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
borderBottom: '0.5px solid var(--color-border)'
|
||||||
|
}}>
|
||||||
|
{t('message.citations')}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
placement="right"
|
placement="right"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
styles={{
|
styles={{
|
||||||
@ -142,13 +152,14 @@ const WebSearchCitation: React.FC<{ citation: Citation }> = ({ citation }) => {
|
|||||||
<WebSearchCard>
|
<WebSearchCard>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<WebSearchCardHeader>
|
<WebSearchCardHeader>
|
||||||
<CitationIndex>{citation.number}</CitationIndex>
|
|
||||||
{citation.showFavicon && citation.url && (
|
{citation.showFavicon && citation.url && (
|
||||||
<Favicon hostname={new URL(citation.url).hostname} alt={citation.title || citation.hostname || ''} />
|
<Favicon hostname={new URL(citation.url).hostname} alt={citation.title || citation.hostname || ''} />
|
||||||
)}
|
)}
|
||||||
<CitationLink className="text-nowrap" href={citation.url} onClick={(e) => handleLinkClick(citation.url, e)}>
|
<CitationLink className="text-nowrap" href={citation.url} onClick={(e) => handleLinkClick(citation.url, e)}>
|
||||||
{citation.title || <span className="hostname">{citation.hostname}</span>}
|
{citation.title || <span className="hostname">{citation.hostname}</span>}
|
||||||
</CitationLink>
|
</CitationLink>
|
||||||
|
|
||||||
|
<CitationIndex>{citation.number}</CitationIndex>
|
||||||
{fetchedContent && <CopyButton content={fetchedContent} />}
|
{fetchedContent && <CopyButton content={fetchedContent} />}
|
||||||
</WebSearchCardHeader>
|
</WebSearchCardHeader>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
@ -216,10 +227,19 @@ const PreviewIcon = styled.div`
|
|||||||
`
|
`
|
||||||
|
|
||||||
const CitationIndex = styled.div`
|
const CitationIndex = styled.div`
|
||||||
font-size: 14px;
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--color-reference);
|
||||||
|
font-size: 10px;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: var(--color-text-2);
|
color: var(--color-reference-text);
|
||||||
margin-right: 8px;
|
flex-shrink: 0;
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
`
|
`
|
||||||
|
|
||||||
const CitationLink = styled.a`
|
const CitationLink = styled.a`
|
||||||
@ -227,7 +247,7 @@ const CitationLink = styled.a`
|
|||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: var(--color-text-1);
|
color: var(--color-text-1);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
flex: 1;
|
||||||
.hostname {
|
.hostname {
|
||||||
color: var(--color-link);
|
color: var(--color-link);
|
||||||
}
|
}
|
||||||
@ -239,10 +259,14 @@ const CopyIconWrapper = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: var(--color-text-2);
|
color: var(--color-text-2);
|
||||||
opacity: 0.6;
|
opacity: 0;
|
||||||
margin-left: auto;
|
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
@ -254,10 +278,17 @@ const WebSearchCard = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px;
|
padding: 12px 0;
|
||||||
border-radius: var(--list-item-border-radius);
|
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
&:hover {
|
||||||
|
${CopyIconWrapper} {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
${CitationIndex} {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const WebSearchCardHeader = styled.div`
|
const WebSearchCardHeader = styled.div`
|
||||||
@ -267,6 +298,7 @@ const WebSearchCardHeader = styled.div`
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
`
|
`
|
||||||
|
|
||||||
const WebSearchCardContent = styled.div`
|
const WebSearchCardContent = styled.div`
|
||||||
@ -275,6 +307,7 @@ const WebSearchCardContent = styled.div`
|
|||||||
color: var(--color-text-2);
|
color: var(--color-text-2);
|
||||||
user-select: text;
|
user-select: text;
|
||||||
cursor: text;
|
cursor: text;
|
||||||
|
word-break: break-all;
|
||||||
|
|
||||||
&.selectable-text {
|
&.selectable-text {
|
||||||
-webkit-user-select: text;
|
-webkit-user-select: text;
|
||||||
@ -285,8 +318,15 @@ const WebSearchCardContent = styled.div`
|
|||||||
`
|
`
|
||||||
|
|
||||||
const PopoverContent = styled.div`
|
const PopoverContent = styled.div`
|
||||||
max-width: 300px;
|
max-width: min(300px, 60vw);
|
||||||
max-height: 50vh;
|
max-height: 60vh;
|
||||||
|
padding: 0 12px;
|
||||||
|
`
|
||||||
|
const PopoverContentItem = styled.div`
|
||||||
|
border-bottom: 0.5px solid var(--color-border);
|
||||||
|
&:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export default CitationsList
|
export default CitationsList
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user