Skip to content

Commit 6bec63d

Browse files
committed
feat(skiplink-web): adding configuration
1 parent a0248c3 commit 6bec63d

File tree

12 files changed

+149
-6
lines changed

12 files changed

+149
-6
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/tests/TestProjects/**/.classpath
2+
/tests/TestProjects/**/.project
3+
/tests/TestProjects/**/javascriptsource
4+
/tests/TestProjects/**/javasource
5+
/tests/TestProjects/**/resources
6+
/tests/TestProjects/**/userlib
7+
8+
/tests/TestProjects/Mendix8/theme/styles/native
9+
/tests/TestProjects/Mendix8/theme/styles/web/sass
10+
/tests/TestProjects/Mendix8/theme/*.*
11+
!/tests/TestProjects/Mendix8/theme/components.json
12+
!/tests/TestProjects/Mendix8/theme/favicon.ico
13+
!/tests/TestProjects/Mendix8/theme/LICENSE
14+
!/tests/TestProjects/Mendix8/theme/settings.json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@mendix/prettier-config-web-widgets");

packages/pluggableWidgets/skiplink-web/e2e/package.json

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from "@mendix/eslint-config-web-widgets/widget-ts.mjs";
2+
3+
export default config;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require("@mendix/pluggable-widgets-tools/test-config/jest.enzyme-free.config.js")
3+
};

packages/pluggableWidgets/skiplink-web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"packagePath": "com.mendix.widget.web",
1919
"marketplace": {
20-
"minimumMXVersion": "9.6.0",
20+
"minimumMXVersion": "11.1.0",
2121
"appNumber": 119999,
2222
"appName": "SkipLink",
2323
"reactReady": true
@@ -30,7 +30,7 @@
3030
"e2e": "run-e2e ci",
3131
"e2edev": "run-e2e dev --with-preps",
3232
"format": "prettier --ignore-path ./node_modules/@mendix/prettier-config-web-widgets/global-prettierignore --write .",
33-
"lint": "eslint src/ package.json",
33+
"lint": "eslint src package.json",
3434
"publish-marketplace": "rui-publish-marketplace",
3535
"release": "pluggable-widgets-tools release:web",
3636
"start": "pluggable-widgets-tools start:server",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@mendix/run-e2e/playwright.config.cjs");
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { hidePropertiesIn, Problem, Properties } from "@mendix/pluggable-widgets-tools";
2+
import {
3+
StructurePreviewProps,
4+
RowLayoutProps,
5+
ContainerProps,
6+
TextProps,
7+
structurePreviewPalette
8+
} from "@mendix/widget-plugin-platform/preview/structure-preview-api";
9+
10+
export function getProperties(values: any, defaultValues: Properties): Properties {
11+
// No conditional properties for skiplink, but function provided for consistency
12+
return defaultValues;
13+
}
14+
15+
export function check(values: any): Problem[] {
16+
const errors: Problem[] = [];
17+
if (!values.linkText) {
18+
errors.push({
19+
property: "linkText",
20+
message: "Link text is required"
21+
});
22+
}
23+
if (!values.mainContentId) {
24+
errors.push({
25+
property: "mainContentId",
26+
message: "Main content ID is required"
27+
});
28+
}
29+
return errors;
30+
}
31+
32+
export function getPreview(values: any, isDarkMode: boolean): StructurePreviewProps | null {
33+
const palette = structurePreviewPalette[isDarkMode ? "dark" : "light"];
34+
const titleHeader: RowLayoutProps = {
35+
type: "RowLayout",
36+
columnSize: "grow",
37+
backgroundColor: palette.background.topbarStandard,
38+
borders: true,
39+
borderWidth: 1,
40+
children: [
41+
{
42+
type: "Container",
43+
padding: 4,
44+
children: [
45+
{
46+
type: "Text",
47+
content: "SkipLink",
48+
fontColor: palette.text.secondary
49+
} as TextProps
50+
]
51+
}
52+
]
53+
};
54+
const linkContent: RowLayoutProps = {
55+
type: "RowLayout",
56+
columnSize: "grow",
57+
borders: true,
58+
padding: 0,
59+
children: [
60+
{
61+
type: "Container",
62+
padding: 6,
63+
children: [
64+
{
65+
type: "Text",
66+
content: values.linkText || "Skip to main content",
67+
fontSize: 14,
68+
fontColor: palette.text.primary,
69+
bold: true
70+
} as TextProps
71+
]
72+
}
73+
]
74+
};
75+
return {
76+
type: "Container",
77+
borders: true,
78+
children: [titleHeader, linkContent]
79+
} as ContainerProps;
80+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { createElement, ReactElement } from "react";
2+
3+
export interface SkipLinkPreviewProps {
4+
linkText: string;
5+
mainContentId: string;
6+
}
7+
8+
export const preview = (props: SkipLinkPreviewProps): ReactElement => {
9+
return (
10+
<div style={{ position: "relative", height: 40 }}>
11+
<a
12+
href={`#${props.mainContentId}`}
13+
style={{
14+
position: "absolute",
15+
top: 0,
16+
left: 0,
17+
background: "#fff",
18+
color: "#0078d4",
19+
padding: "8px 16px",
20+
zIndex: 1000,
21+
textDecoration: "none",
22+
border: "2px solid #0078d4",
23+
borderRadius: 4,
24+
fontWeight: "bold"
25+
}}
26+
>
27+
{props.linkText}
28+
</a>
29+
</div>
30+
);
31+
};
32+
33+
export function getPreviewCss(): string {
34+
return require("./SkipLink.css");
35+
}

packages/pluggableWidgets/skiplink-web/src/SkipLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./SkipLink.css";
1+
import "./ui/SkipLink.css";
22
import { useEffect } from "react";
33

44
export interface SkipLinkProps {

0 commit comments

Comments
 (0)