@orangesk/orange-design-system 2.0.0-beta.7 → 2.0.0-beta.8

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.
Files changed (43) hide show
  1. package/build/components/index.js +4 -4
  2. package/build/components/index.js.map +1 -1
  3. package/build/components/tsconfig.tsbuildinfo +1 -1
  4. package/build/components/types/index.d.ts +2 -2
  5. package/build/components/types/src/components/AnchorNavigation/AnchorNavigation.d.ts +1 -1
  6. package/build/components/types/src/components/AnchorNavigation/AnchorNavigation.static.d.ts +19 -17
  7. package/build/components/types/src/components/Card/Card.d.ts +1 -1
  8. package/build/components/types/src/components/Megamenu/constants.d.ts +2 -0
  9. package/build/components/types/src/scripts/index.d.ts +5 -0
  10. package/build/lib/after-components.css +1 -1
  11. package/build/lib/after-components.css.map +1 -1
  12. package/build/lib/before-components.css +1 -1
  13. package/build/lib/before-components.css.map +1 -1
  14. package/build/lib/components.css +1 -1
  15. package/build/lib/components.css.map +1 -1
  16. package/build/lib/megamenu.css +1 -1
  17. package/build/lib/megamenu.css.map +1 -1
  18. package/build/lib/megamenu.js +1 -1
  19. package/build/lib/megamenu.js.map +1 -1
  20. package/build/lib/scripts.js +4 -4
  21. package/build/lib/scripts.js.map +1 -1
  22. package/build/lib/style.css +1 -1
  23. package/build/lib/style.css.map +1 -1
  24. package/build/lib/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +10 -10
  26. package/src/components/AnchorNavigation/AnchorNavigation.static.ts +253 -73
  27. package/src/components/AnchorNavigation/AnchorNavigation.tsx +31 -24
  28. package/src/components/AnchorNavigation/styles/mixins.scss +14 -17
  29. package/src/components/AnchorNavigation/tests/AnchorNavigation.conformance.test.js +67 -0
  30. package/src/components/AnchorNavigation/tests/AnchorNavigation.unit.test.js +163 -0
  31. package/src/components/BlockAction/styles/mixins.scss +0 -6
  32. package/src/components/Card/Card.tsx +1 -0
  33. package/src/components/Link/styles/style.scss +1 -1
  34. package/src/components/Link/tests/Link.conformance.test.js +5 -20
  35. package/src/components/Link/tests/Link.unit.test.js +1 -10
  36. package/src/components/Megamenu/Megamenu.static.ts +2 -0
  37. package/src/components/Megamenu/Megamenu.tsx +671 -665
  38. package/src/components/Megamenu/MegamenuBlog.tsx +187 -183
  39. package/src/components/Megamenu/constants.ts +2 -0
  40. package/src/components/Megamenu/styles/mixins.scss +30 -1
  41. package/src/components/Megamenu/styles/style.scss +8 -0
  42. package/src/styles/base/globals.scss +18 -0
  43. package/src/styles/utilities/color.scss +4 -0
@@ -0,0 +1,163 @@
1
+ import { render } from "@testing-library/react";
2
+
3
+ import { AnchorNavigation } from "../AnchorNavigation";
4
+
5
+ const basicItems = [
6
+ { label: "Key Features", href: "#features", isActive: true },
7
+ { label: "Pricing", href: "#pricing" },
8
+ { label: "Getting Started", href: "#getting-started" },
9
+ { label: "Contact", href: "#contact" },
10
+ ];
11
+
12
+ const moreItems = [
13
+ { label: "Overview", href: "#overview", isActive: true },
14
+ { label: "Features", href: "#features" },
15
+ { label: "Documentation", href: "#docs" },
16
+ { label: "API Reference", href: "#api" },
17
+ { label: "Examples", href: "#examples" },
18
+ { label: "Support", href: "#support" },
19
+ ];
20
+
21
+ describe("rendering AnchorNavigation", () => {
22
+ describe("initial state", () => {
23
+ it("has default class anchor-navigation", () => {
24
+ const { getByTestId } = render(
25
+ <AnchorNavigation data-testid="test-id" items={basicItems} />,
26
+ );
27
+ expect(getByTestId("test-id")).toHaveClass("anchor-navigation");
28
+ });
29
+
30
+ it("has data-anchor-navigation attribute", () => {
31
+ const { getByTestId } = render(
32
+ <AnchorNavigation data-testid="test-id" items={basicItems} />,
33
+ );
34
+ expect(getByTestId("test-id")).toHaveAttribute("data-anchor-navigation");
35
+ });
36
+
37
+ it("renders container with anchor-navigation__content class", () => {
38
+ const { container } = render(<AnchorNavigation items={basicItems} />);
39
+ expect(
40
+ container.querySelector(".anchor-navigation__content"),
41
+ ).toBeInTheDocument();
42
+ });
43
+
44
+ it("renders grid with correct classes", () => {
45
+ const { container } = render(<AnchorNavigation items={basicItems} />);
46
+ const grid = container.querySelector(".anchor-navigation__content-left");
47
+ expect(grid).toBeInTheDocument();
48
+ expect(grid).toHaveClass("list-inline");
49
+ expect(grid).toHaveClass("horizontal-scroll");
50
+ expect(grid).toHaveClass("mb-none");
51
+ });
52
+ });
53
+
54
+ describe("passed props", () => {
55
+ it("renders all navigation items", () => {
56
+ const { getByText } = render(<AnchorNavigation items={basicItems} />);
57
+
58
+ expect(getByText("Key Features")).toBeInTheDocument();
59
+ expect(getByText("Pricing")).toBeInTheDocument();
60
+ expect(getByText("Getting Started")).toBeInTheDocument();
61
+ expect(getByText("Contact")).toBeInTheDocument();
62
+ });
63
+
64
+ it("renders navigation items as links with correct href", () => {
65
+ const { container } = render(<AnchorNavigation items={basicItems} />);
66
+
67
+ const featuresLink = container.querySelector('a[href="#features"]');
68
+ const pricingLink = container.querySelector('a[href="#pricing"]');
69
+
70
+ expect(featuresLink).toBeInTheDocument();
71
+ expect(featuresLink).toHaveTextContent("Key Features");
72
+ expect(pricingLink).toBeInTheDocument();
73
+ expect(pricingLink).toHaveTextContent("Pricing");
74
+ });
75
+
76
+ it("applies active class to items with isActive prop", () => {
77
+ const { container } = render(<AnchorNavigation items={basicItems} />);
78
+
79
+ const activeLink = container.querySelector('a[href="#features"]');
80
+ const inactiveLink = container.querySelector('a[href="#pricing"]');
81
+
82
+ expect(activeLink).toHaveClass("is-active");
83
+ expect(inactiveLink).not.toHaveClass("is-active");
84
+ });
85
+
86
+ it("applies anchor-navigation__item class to all links", () => {
87
+ const { container } = render(<AnchorNavigation items={basicItems} />);
88
+
89
+ const links = container.querySelectorAll(".anchor-navigation__item");
90
+ expect(links).toHaveLength(basicItems.length);
91
+ });
92
+
93
+ it("renders multiple items correctly", () => {
94
+ const { getByText } = render(<AnchorNavigation items={moreItems} />);
95
+
96
+ expect(getByText("Overview")).toBeInTheDocument();
97
+ expect(getByText("Features")).toBeInTheDocument();
98
+ expect(getByText("Documentation")).toBeInTheDocument();
99
+ expect(getByText("API Reference")).toBeInTheDocument();
100
+ expect(getByText("Examples")).toBeInTheDocument();
101
+ expect(getByText("Support")).toBeInTheDocument();
102
+ });
103
+
104
+ it("applies custom className", () => {
105
+ const { getByTestId } = render(
106
+ <AnchorNavigation
107
+ data-testid="test-id"
108
+ items={basicItems}
109
+ className="custom-class"
110
+ />,
111
+ );
112
+ expect(getByTestId("test-id")).toHaveClass("anchor-navigation");
113
+ expect(getByTestId("test-id")).toHaveClass("custom-class");
114
+ });
115
+ });
116
+
117
+ describe("children content", () => {
118
+ it("renders children in content-right section when provided", () => {
119
+ const { container, getByText } = render(
120
+ <AnchorNavigation items={basicItems}>
121
+ <div>Additional Content</div>
122
+ </AnchorNavigation>,
123
+ );
124
+
125
+ const contentRight = container.querySelector(
126
+ ".anchor-navigation__content-right",
127
+ );
128
+ expect(contentRight).toBeInTheDocument();
129
+ expect(getByText("Additional Content")).toBeInTheDocument();
130
+ });
131
+
132
+ it("does not render content-right section when no children", () => {
133
+ const { container } = render(<AnchorNavigation items={basicItems} />);
134
+
135
+ const contentRight = container.querySelector(
136
+ ".anchor-navigation__content-right",
137
+ );
138
+ expect(contentRight).not.toBeInTheDocument();
139
+ });
140
+
141
+ it("renders complex children content", () => {
142
+ const { getByText, getByRole } = render(
143
+ <AnchorNavigation items={basicItems}>
144
+ <div className="pricing">
145
+ <div className="bold">2 €</div>
146
+ <div>No commitment</div>
147
+ </div>
148
+ <button>Get Started</button>
149
+ </AnchorNavigation>,
150
+ );
151
+
152
+ expect(getByText("2 €")).toBeInTheDocument();
153
+ expect(getByText("No commitment")).toBeInTheDocument();
154
+ expect(getByRole("button", { name: "Get Started" })).toBeInTheDocument();
155
+ });
156
+ });
157
+
158
+ describe("displayName", () => {
159
+ it("has correct displayName", () => {
160
+ expect(AnchorNavigation.displayName).toBe("AnchorNavigation");
161
+ });
162
+ });
163
+ });
@@ -3,12 +3,6 @@
3
3
 
4
4
  @mixin layout-base {
5
5
  position: relative;
6
-
7
- &:focus-within,
8
- &:hover {
9
- outline: 2px solid var(--color-border-accent);
10
- outline-offset: 1px;
11
- }
12
6
  }
13
7
 
14
8
  @mixin control {
@@ -6,6 +6,7 @@ export const cardColors = [
6
6
  "black",
7
7
  "orange",
8
8
  "gray",
9
+ "gray-lighter",
9
10
  "blue",
10
11
  "green",
11
12
  "pink",
@@ -24,7 +24,7 @@
24
24
  @include mixins.base-inherit();
25
25
 
26
26
  &:hover {
27
- color: var(--color-fill-tertiary);
27
+ color: var(--color-text-accent);
28
28
  text-decoration: underline;
29
29
  }
30
30
  &:focus {
@@ -125,21 +125,6 @@ describe("Link Conformance Tests", () => {
125
125
  expect(results).toHaveNoViolations();
126
126
  });
127
127
 
128
- it("has no accessibility violations for inverse links", async () => {
129
- const { container } = render(
130
- <div>
131
- <Link href="#" isInverse>
132
- Inverse link
133
- </Link>
134
- <Link href="#" color="orange" isInverse>
135
- Orange inverse link
136
- </Link>
137
- </div>,
138
- );
139
- const results = await axe(container);
140
- expect(results).toHaveNoViolations();
141
- });
142
-
143
128
  it("has no accessibility violations for links with custom attributes", async () => {
144
129
  const { container } = render(
145
130
  <div>
@@ -212,11 +197,11 @@ describe("Link Conformance Tests", () => {
212
197
  describe("Cross-browser Compatibility", () => {
213
198
  it("renders consistently across different prop combinations", () => {
214
199
  const testCases = [
215
- { href: "/", color: "default", isInverse: false },
216
- { href: "/", color: "orange", isInverse: true },
217
- { href: "/", color: "black", isInverse: false },
218
- { tag: "button", type: "button", color: "default", isInverse: false },
219
- { tag: "button", type: "button", color: "orange", isInverse: true },
200
+ { href: "/", color: "default" },
201
+ { href: "/", color: "orange" },
202
+ { href: "/", color: "black" },
203
+ { tag: "button", type: "button", color: "default" },
204
+ { tag: "button", type: "button", color: "orange" },
220
205
  ];
221
206
 
222
207
  testCases.forEach((props, index) => {
@@ -8,9 +8,6 @@ Unit tests for the Link component:
8
8
  - Color Variants:
9
9
  - Applies correct class for each color variant (default, orange, black).
10
10
  - Combines color with inverse class when both are set.
11
- - Inverse Styling:
12
- - Applies inverse class when isInverse is true.
13
- - Does not apply inverse class when isInverse is false.
14
11
  - Props Forwarding:
15
12
  - Forwards additional HTML attributes (target, rel, aria-label, etc.).
16
13
  - Forwards event handlers (onClick, onMouseEnter, etc.).
@@ -222,13 +219,7 @@ describe("Link Component", () => {
222
219
 
223
220
  it("handles null and undefined props gracefully", () => {
224
221
  render(
225
- <Link
226
- href="/"
227
- data-testid="link"
228
- color={null}
229
- isInverse={undefined}
230
- className={null}
231
- >
222
+ <Link href="/" data-testid="link" color={null} className={null}>
232
223
  Test
233
224
  </Link>,
234
225
  );
@@ -287,8 +287,10 @@ export default class Megamenu {
287
287
  if (topElement) {
288
288
  if (window.scrollY > 15) {
289
289
  topElement.classList.add("is-hidden");
290
+ this.element.classList.add("top-hidden");
290
291
  } else {
291
292
  topElement.classList.remove("is-hidden");
293
+ this.element.classList.remove("top-hidden");
292
294
  }
293
295
  }
294
296
  }