@treely/strapi-slices 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/PortfolioProject.d.ts +2 -0
- package/dist/models/strapi/StrapiPortfolio.d.ts +1 -0
- package/dist/slices/ProjectsMap/MapMarker.d.ts +2 -1
- package/dist/strapi-slices.cjs.development.js +7 -4
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +7 -4
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/models/PortfolioProject.ts +2 -0
- package/src/models/strapi/StrapiPortfolio.ts +1 -0
- package/src/slices/ProjectsGrid/ProjectsGrid.test.tsx +23 -0
- package/src/slices/ProjectsGrid/ProjectsGrid.tsx +3 -1
- package/src/slices/ProjectsMap/MapMarker.test.tsx +22 -2
- package/src/slices/ProjectsMap/MapMarker.tsx +8 -3
- package/src/slices/ProjectsMap/ProjectsMap.tsx +1 -0
package/package.json
CHANGED
|
@@ -3,7 +3,9 @@ import CreditsAvailableState from './CreditsAvailableState';
|
|
|
3
3
|
import FPMProject from './fpm/FPMProject';
|
|
4
4
|
|
|
5
5
|
interface PortfolioProject extends FPMProject {
|
|
6
|
+
/** Remember to prefix the slug with portfolioHost */
|
|
6
7
|
slug?: string;
|
|
8
|
+
portfolioHost?: string;
|
|
7
9
|
thumbnail?: StrapiImage | null;
|
|
8
10
|
creditsAvailable?: CreditsAvailableState;
|
|
9
11
|
footerSubTitle?: string;
|
|
@@ -34,4 +34,27 @@ describe('The ProjectsGrid component', () => {
|
|
|
34
34
|
|
|
35
35
|
expect(screen.getByText(fpmProjectMock.title)).toBeInTheDocument();
|
|
36
36
|
});
|
|
37
|
+
|
|
38
|
+
it('links to the portfolio', () => {
|
|
39
|
+
setup();
|
|
40
|
+
|
|
41
|
+
expect(screen.getByRole('link')).toHaveProperty(
|
|
42
|
+
'href',
|
|
43
|
+
'http://localhost/portfolio/slug'
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('prefixes the url with the portfolio host', () => {
|
|
48
|
+
setup({
|
|
49
|
+
...defaultProps,
|
|
50
|
+
projects: [
|
|
51
|
+
{ ...defaultProps.projects[0], portfolioHost: 'https://example.org' },
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(screen.getByRole('link')).toHaveProperty(
|
|
56
|
+
'href',
|
|
57
|
+
'https://example.org/portfolio/slug'
|
|
58
|
+
);
|
|
59
|
+
});
|
|
37
60
|
});
|
|
@@ -46,7 +46,9 @@ export const ProjectsGrid: React.FC<ProjectsGridProps> = ({
|
|
|
46
46
|
condition={!!project.slug}
|
|
47
47
|
wrapper={(children: JSX.Element) => (
|
|
48
48
|
<Link
|
|
49
|
-
href={
|
|
49
|
+
href={`${project.portfolioHost || ''}/portfolio/${
|
|
50
|
+
project.slug
|
|
51
|
+
}`}
|
|
50
52
|
passHref
|
|
51
53
|
key={project.id}
|
|
52
54
|
legacyBehavior
|
|
@@ -6,6 +6,7 @@ import messagesEn from './messages.en';
|
|
|
6
6
|
|
|
7
7
|
const defaultProps: MapMarkerProps = {
|
|
8
8
|
title: 'Project title',
|
|
9
|
+
portfolioHost: '',
|
|
9
10
|
isPublic: true,
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -37,7 +38,26 @@ describe('The MapMarker component', () => {
|
|
|
37
38
|
|
|
38
39
|
expect(screen.getByTestId('mapmarker-pin').parentElement).toHaveProperty(
|
|
39
40
|
'href',
|
|
40
|
-
|
|
41
|
+
'http://localhost/portfolio/slug'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
fireEvent.mouseEnter(screen.getByTestId('mapmarker-pin'));
|
|
45
|
+
|
|
46
|
+
waitFor(() => {
|
|
47
|
+
const button = screen.getByText(
|
|
48
|
+
messagesEn['sections.projectsMap.link.text']
|
|
49
|
+
);
|
|
50
|
+
expect(button).toBeInTheDocument();
|
|
51
|
+
expect(button).toHaveProperty('href', '/portfolio/slug');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('prefixes the url with the portfolio host', () => {
|
|
56
|
+
setup({ slug: 'slug', portfolioHost: 'https://example.com' });
|
|
57
|
+
|
|
58
|
+
expect(screen.getByTestId('mapmarker-pin').parentElement).toHaveProperty(
|
|
59
|
+
'href',
|
|
60
|
+
'https://example.com/portfolio/slug'
|
|
41
61
|
);
|
|
42
62
|
|
|
43
63
|
fireEvent.mouseEnter(screen.getByTestId('mapmarker-pin'));
|
|
@@ -49,7 +69,7 @@ describe('The MapMarker component', () => {
|
|
|
49
69
|
expect(button).toBeInTheDocument();
|
|
50
70
|
expect(button).toHaveProperty(
|
|
51
71
|
'href',
|
|
52
|
-
|
|
72
|
+
'https://example.com/portfolio/slug'
|
|
53
73
|
);
|
|
54
74
|
});
|
|
55
75
|
});
|
|
@@ -20,6 +20,7 @@ export interface MapMarkerProps {
|
|
|
20
20
|
isPublic?: boolean;
|
|
21
21
|
projectDeveloper?: string;
|
|
22
22
|
slug?: string;
|
|
23
|
+
portfolioHost?: string;
|
|
23
24
|
creditsAvailable?: CreditsAvailableState;
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -28,6 +29,7 @@ const MapMarker = ({
|
|
|
28
29
|
projectDeveloper,
|
|
29
30
|
slug,
|
|
30
31
|
creditsAvailable,
|
|
32
|
+
portfolioHost = '',
|
|
31
33
|
isPublic = false,
|
|
32
34
|
}: MapMarkerProps) => {
|
|
33
35
|
const { formatMessage } = useContext(IntlContext);
|
|
@@ -42,7 +44,10 @@ const MapMarker = ({
|
|
|
42
44
|
onMouseLeave={onClose}
|
|
43
45
|
cursor="grab"
|
|
44
46
|
>
|
|
45
|
-
<Box
|
|
47
|
+
<Box
|
|
48
|
+
as={slug ? NextLink : undefined}
|
|
49
|
+
href={slug && `${portfolioHost}/portfolio/${slug}`}
|
|
50
|
+
>
|
|
46
51
|
<MapPin
|
|
47
52
|
size="40px"
|
|
48
53
|
color={blue600}
|
|
@@ -64,7 +69,7 @@ const MapMarker = ({
|
|
|
64
69
|
<>
|
|
65
70
|
<CreditsAvailableBadge
|
|
66
71
|
status={creditsAvailable}
|
|
67
|
-
href={slug &&
|
|
72
|
+
href={slug && `${portfolioHost}/portfolio/${slug}`}
|
|
68
73
|
/>
|
|
69
74
|
<Box height="3" />
|
|
70
75
|
</>
|
|
@@ -84,7 +89,7 @@ const MapMarker = ({
|
|
|
84
89
|
variant="outline"
|
|
85
90
|
size="sm"
|
|
86
91
|
as={NextLink}
|
|
87
|
-
href={
|
|
92
|
+
href={`${portfolioHost}/portfolio/${slug}`}
|
|
88
93
|
mt="4"
|
|
89
94
|
whiteSpace="nowrap"
|
|
90
95
|
>
|
|
@@ -97,6 +97,7 @@ export const ProjectsMap: React.FC<ProjectsMapProps> = ({
|
|
|
97
97
|
<MapMarker
|
|
98
98
|
title={project.title}
|
|
99
99
|
isPublic={project.isPublic}
|
|
100
|
+
portfolioHost={project.portfolioHost}
|
|
100
101
|
slug={project.slug}
|
|
101
102
|
creditsAvailable={project.creditsAvailable}
|
|
102
103
|
projectDeveloper={project.projectDeveloper?.name}
|