Skip to content

Commit 2b948d4

Browse files
authored
Merge branch 'main' into add-basic-form-block-styles
2 parents 2c01415 + 678120a commit 2b948d4

5 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add link icon to Card component @Tishasoumya-02
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix icon in search @iRohitSingh
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { useSelector } from 'react-redux';
2+
import { useLocation, useHistory } from 'react-router-dom';
3+
import type { ObjectBrowserItem, GetSiteResponse } from '@plone/types';
4+
import linkSVG from '@plone/volto/icons/link.svg';
5+
import Icon from '@plone/volto/components/theme/Icon/Icon';
6+
import { Button } from '@plone/components';
7+
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
8+
9+
type FormState = {
10+
site: { data: GetSiteResponse };
11+
};
12+
13+
const useLinkIconNavigation = (item?: Partial<ObjectBrowserItem>) => {
14+
const location = useLocation();
15+
const history = useHistory();
16+
17+
const handleLinkIconClick = (e: React.MouseEvent<HTMLButtonElement>) => {
18+
e.preventDefault();
19+
e.stopPropagation();
20+
21+
const targetUrl = item?.['@id'];
22+
if (targetUrl) {
23+
const flattenedTargetUrl = flattenToAppURL(targetUrl);
24+
const searchParams = new URLSearchParams();
25+
searchParams.set('return_to', location.pathname);
26+
27+
history.push({
28+
pathname: flattenedTargetUrl,
29+
search: searchParams.toString(),
30+
});
31+
}
32+
};
33+
return handleLinkIconClick;
34+
};
35+
const LinkIconButton = ({ item }: { item?: Partial<ObjectBrowserItem> }) => {
36+
const site = useSelector<FormState, GetSiteResponse>(
37+
(state) => state.site?.data,
38+
);
39+
const hideProfileLinks = site?.['kitconcept.disable_profile_links'];
40+
const handleLinkIconClick = useLinkIconNavigation(item);
41+
return (
42+
hideProfileLinks && (
43+
<div className="card-link-icon">
44+
<Button aria-label="link" onClick={handleLinkIconClick}>
45+
<Icon name={linkSVG} size="33px" />
46+
</Button>
47+
</div>
48+
)
49+
);
50+
};
51+
52+
export default LinkIconButton;

frontend/packages/volto-light-theme/src/theme/_search-page.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
}
7575
}
7676
svg {
77+
display: inline;
7778
margin-right: 5px;
7879
vertical-align: bottom;
7980
}

frontend/packages/volto-light-theme/src/theme/card.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,30 @@
7979
}
8080
}
8181
}
82+
83+
// Common styles for link icon overlay
84+
.card-link-icon {
85+
position: absolute;
86+
z-index: 10;
87+
top: 0px;
88+
right: 0px;
89+
filter: drop-shadow(3px 3px 12px rgba(0, 0, 0, 0.5));
90+
opacity: 0;
91+
transition: opacity 0.2s ease;
92+
93+
button {
94+
border: none;
95+
border-radius: 50%;
96+
background: rgba(236, 235, 235, 0.75);
97+
cursor: pointer;
98+
}
99+
}
100+
101+
&:hover .card-link-icon,
102+
&:focus-within .card-link-icon {
103+
opacity: 1;
104+
}
105+
82106
// Additional links within the card
83107
a:not(.card-primary-link) {
84108
position: relative;
@@ -165,6 +189,12 @@
165189
}
166190
}
167191

192+
// Hides the link icon in edit and add page
193+
#page-edit .card-link-icon,
194+
#page-add .card-link-icon {
195+
display: none;
196+
}
197+
168198
// Cards in columns
169199
@container (min-width: #{$largest-mobile-screen}) {
170200
.card {

0 commit comments

Comments
 (0)