@vtex/faststore-plugin-buyer-portal 2.0.47 → 2.0.49

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 (46) hide show
  1. package/package.json +1 -1
  2. package/public/buyer-portal-icons.svg +9 -0
  3. package/src/features/accounting-fields/components/AccountingFieldDropdown/AccountingFieldDropdown.tsx +5 -2
  4. package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +4 -9
  5. package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +2 -9
  6. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +14 -31
  7. package/src/features/contracts/layouts/ContractListingLayout/ContractListingLayout.tsx +123 -108
  8. package/src/features/contracts/layouts/ContractListingLayout/ContractSettingsNav.tsx +39 -63
  9. package/src/features/contracts/layouts/ContractListingLayout/__tests__/utils.test.ts +51 -0
  10. package/src/features/contracts/layouts/ContractListingLayout/contract-listing-layout.scss +106 -61
  11. package/src/features/contracts/layouts/ContractListingLayout/utils.ts +53 -0
  12. package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +4 -1
  13. package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +2 -9
  14. package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +2 -9
  15. package/src/features/shared/components/BasicDrawer/BasicDrawer.tsx +3 -2
  16. package/src/features/shared/components/BasicDrawer/BasicDrawerHeading.tsx +4 -1
  17. package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +3 -10
  18. package/src/features/shared/components/VerticalNav/VerticalNavTree.tsx +5 -30
  19. package/src/features/shared/components/VerticalNav/vertical-nav.scss +42 -29
  20. package/src/features/shared/hooks/index.ts +2 -0
  21. package/src/features/shared/hooks/useDropdownAlign.ts +27 -0
  22. package/src/features/shared/hooks/useShellScrollReset.ts +27 -0
  23. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +26 -65
  24. package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +4 -41
  25. package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +4 -39
  26. package/src/features/shared/layouts/SumaPageLayout/FullSidebarNav.tsx +0 -1
  27. package/src/features/shared/layouts/SumaPageLayout/SumaPageLayout.tsx +13 -7
  28. package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +32 -47
  29. package/src/features/shared/layouts/SumaPageLayout/SumaSidebarDrawer.tsx +25 -1
  30. package/src/features/shared/layouts/SumaPageLayout/suma-sidebar-drawer.scss +133 -5
  31. package/src/features/shared/localization/__tests__/page-loader-entries.test.ts +2 -2
  32. package/src/features/shared/types/VerticalNav.ts +0 -1
  33. package/src/features/shared/utils/__tests__/getDropdownAlign.test.ts +17 -0
  34. package/src/features/shared/utils/__tests__/getSumaListingSidebarLinks.test.ts +30 -0
  35. package/src/features/shared/utils/__tests__/isNavLinkActive.test.ts +117 -0
  36. package/src/features/shared/utils/__tests__/routeLayoutMapping.test.ts +21 -1
  37. package/src/features/shared/utils/constants.ts +1 -1
  38. package/src/features/shared/utils/getDropdownAlign.ts +11 -0
  39. package/src/features/shared/utils/getSumaListingSidebarLinks.ts +8 -1
  40. package/src/features/shared/utils/isNavLinkActive.ts +40 -0
  41. package/src/features/shared/utils/routeLayoutMapping.ts +17 -4
  42. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +2 -9
  43. package/src/pages/contract-information.tsx +1 -1
  44. package/src/pages/contracts.tsx +30 -45
  45. package/src/pages/home.tsx +17 -25
  46. package/src/pages/org-unit-details.tsx +15 -102
@@ -13,62 +13,127 @@
13
13
  @import "../../components/AddContractsDrawer/add-contracts-drawer.scss";
14
14
  @import "../../components/ConfirmRemoveDrawer/confirm-remove-drawer.scss";
15
15
 
16
+ // App shell: the page fills the viewport and only the content section (and
17
+ // the sidebar, when it is taller than the space left) scrolls. The window
18
+ // never scrolls, so the header, the sidebar and the menus opened from the
19
+ // header stay in place.
20
+ :root:has([data-fs-bp-contract-listing-page]) {
21
+ overflow: hidden;
22
+
23
+ // FastStore places a dropdown menu against the document when it opens, so
24
+ // it can't follow the section's scroll. Keep the content still while a menu
25
+ // opened from it is open; header menus don't need it.
26
+ &:has(
27
+ body
28
+ > [data-fs-dropdown-overlay]
29
+ > [data-fs-dropdown-menu]:not(
30
+ [data-fs-bp-org-unit-details-navbar-menu],
31
+ [data-fs-bp-org-unit-header-nav-menu]
32
+ )
33
+ )
34
+ [data-fs-bp-contract-listing-section] {
35
+ overflow-y: hidden;
36
+ }
37
+ }
38
+
39
+ [data-fs-bp-contract-listing-page] {
40
+ display: flex;
41
+ flex-direction: column;
42
+ height: 100vh;
43
+ height: 100dvh;
44
+
45
+ > [data-fs-bp-org-unit-details-navbar] {
46
+ flex: none;
47
+ }
48
+ }
49
+
16
50
  [data-fs-bp-contract-listing-body] {
17
51
  display: grid;
52
+ flex: 1;
18
53
  grid-template-columns: 1fr;
54
+ grid-template-rows: minmax(0, 1fr);
19
55
  width: 100%;
20
- max-width: 90rem;
21
- margin: var(--fs-bp-margin-0) var(--fs-bp-margin-auto);
56
+ min-height: 0;
22
57
 
23
58
  @include u.media(">=notebook") {
24
59
  grid-template-columns: 20rem 1fr;
25
60
  }
61
+
62
+ > [data-fs-bp-contract-listing-sidebar] {
63
+ @include u.media(">=notebook") {
64
+ width: 20rem;
65
+ min-width: 20rem;
66
+ }
67
+ }
26
68
  }
27
69
 
28
70
  [data-fs-bp-contract-listing-sidebar] {
29
71
  @import "../../../shared/components/VerticalNav/vertical-nav.scss";
30
72
  @import "../../../shared/components/LetterHighlight/letter-highlight.scss";
31
73
 
74
+ // This padding plus the items' own inset matches the header's side
75
+ // padding, so the item text lines up with the logo.
32
76
  display: none;
33
- padding: var(--fs-bp-padding-5) var(--fs-bp-padding-5) var(--fs-bp-padding-12) var(--fs-bp-padding-5);
34
- border-right: 1px solid var(--fs-bp-color-neutral-2);
77
+ padding: var(--fs-bp-padding-5);
35
78
  overflow-y: auto;
36
79
 
37
80
  @include u.media(">=notebook") {
38
81
  display: block;
39
82
  }
40
83
 
41
- [data-fs-bp-contract-listing-back-link] {
84
+ // [href] outranks BasicDrawer's "[data-fs-bp-basic-drawer-body] a" color,
85
+ // which otherwise turns the link blue when the sidebar opens in the drawer.
86
+ a[data-fs-bp-contract-listing-back-link][href] {
42
87
  display: inline-flex;
43
88
  align-items: center;
44
- gap: var(--fs-bp-gap-2);
45
- margin-bottom: var(--fs-bp-margin-5);
46
- padding: var(--fs-bp-padding-2) var(--fs-bp-padding-3);
89
+ gap: var(--fs-bp-gap-1);
90
+ min-height: var(--fs-bp-spacing-9);
91
+ margin: var(--fs-bp-margin-0) var(--fs-bp-margin-5) var(--fs-bp-margin-5);
92
+ font-size: var(--fs-bp-text-size-0);
93
+ font-weight: var(--fs-bp-weight-medium);
94
+ line-height: var(--fs-bp-line-height-base);
95
+ color: var(--fs-bp-color-neutral-7);
47
96
  text-decoration: none;
48
- @include text-style("action");
49
- color: var(--fs-bp-color-neutral-8);
50
- border-radius: var(--fs-bp-border-radius-full);
97
+ transition: color var(--fs-transition-timing) var(--fs-transition-function),
98
+ transform var(--fs-transition-timing) var(--fs-transition-function);
99
+
100
+ [data-fs-icon] {
101
+ transform: rotate(180deg);
102
+ transition: transform var(--fs-transition-timing)
103
+ var(--fs-transition-function);
104
+ }
51
105
 
52
106
  &:hover {
53
- background-color: var(--fs-bp-color-neutral-1);
107
+ color: var(--fs-bp-color-brand);
108
+
109
+ // The icon is rotated, so +x moves the chevron left
110
+ [data-fs-icon] {
111
+ transform: rotate(180deg) translateX(var(--fs-border-width-thick));
112
+ }
54
113
  }
55
114
 
56
- [data-fs-icon] {
57
- transform: rotate(180deg);
115
+ &:active {
116
+ transform: scale(0.95);
58
117
  }
59
118
  }
60
119
 
61
120
  [data-fs-bp-suma-sidebar-identity] {
62
- padding: var(--fs-bp-padding-0) var(--fs-bp-padding-3);
121
+ display: flex;
122
+ flex-direction: column;
123
+ padding: var(--fs-bp-padding-0) var(--fs-bp-padding-5);
63
124
  margin-bottom: var(--fs-bp-margin-5);
64
125
 
65
126
  [data-fs-bp-letter-highlight] {
66
- background-color: #1f1f1f;
127
+ background-color: var(--fs-bp-color-black);
67
128
  color: var(--fs-bp-color-white);
68
- width: var(--fs-bp-spacing-11);
69
- height: var(--fs-bp-spacing-11);
70
- font-size: var(--fs-bp-text-size-3);
71
- margin-bottom: var(--fs-bp-margin-4);
129
+ // 52px: no single token, so spacing-10 (48px) + spacing-1 (4px).
130
+ width: calc(var(--fs-bp-spacing-10) + var(--fs-bp-spacing-1));
131
+ height: calc(var(--fs-bp-spacing-10) + var(--fs-bp-spacing-1));
132
+ // 18px: text-size-2 (16px) plus FastStore's mobile type-scale step (2px)
133
+ font-size: calc(var(--fs-bp-text-size-2) + var(--fs-text-scale-mobile));
134
+ font-weight: var(--fs-bp-weight-semibold);
135
+ margin-bottom: var(--fs-bp-margin-3);
136
+ box-shadow: var(--fs-shadow-hover);
72
137
  }
73
138
 
74
139
  [data-fs-bp-suma-sidebar-identity-row] {
@@ -77,26 +142,18 @@
77
142
  gap: var(--fs-bp-gap-3);
78
143
 
79
144
  [data-fs-bp-suma-sidebar-identity-name] {
80
- @include text-style("display-6");
81
- font-weight: var(--fs-bp-weight-bold);
145
+ font-size: calc(var(--fs-bp-text-size-2) + var(--fs-text-scale-mobile));
146
+ font-weight: var(--fs-bp-weight-semibold);
147
+ line-height: var(--fs-bp-line-height-base);
82
148
  color: var(--fs-bp-color-black);
83
- white-space: nowrap;
84
- overflow: hidden;
85
- text-overflow: ellipsis;
149
+ min-width: 0;
150
+ overflow-wrap: anywhere;
86
151
  }
87
152
 
88
153
  [data-fs-bp-suma-sidebar-identity-default] {
89
154
  flex-shrink: 0;
90
155
  color: var(--fs-bp-color-brand);
91
156
  }
92
-
93
- [data-fs-bp-suma-sidebar-identity-contract] {
94
- @include text-style("body");
95
- color: var(--fs-bp-color-neutral-8);
96
- white-space: nowrap;
97
- overflow: hidden;
98
- text-overflow: ellipsis;
99
- }
100
157
  }
101
158
  }
102
159
 
@@ -117,22 +174,6 @@
117
174
 
118
175
  [data-fs-vertical-nav-menu-list] {
119
176
  margin-top: var(--fs-bp-margin-0);
120
- @include text-style("emphasis");
121
- color: var(--fs-bp-color-black);
122
-
123
- [data-fs-vertical-nav-menu-link],
124
- [data-fs-bp-vertical-submenu-title] {
125
- @include text-style("emphasis");
126
- color: var(--fs-bp-color-neutral-9);
127
-
128
- @include u.media(">=tablet") {
129
- color: var(--fs-bp-color-neutral-8);
130
- }
131
- }
132
-
133
- [data-fs-bp-vertical-submenu-title] {
134
- color: #858585;
135
- }
136
177
  }
137
178
  }
138
179
  }
@@ -140,21 +181,18 @@
140
181
  &[data-fs-bp-suma-sidebar-variant="unit"] {
141
182
  [data-fs-vertical-nav-menu-list] {
142
183
  margin-top: var(--fs-bp-margin-0);
143
- @include text-style("emphasis");
144
-
145
- [data-fs-vertical-nav-menu-link] {
146
- @include text-style("emphasis");
147
- color: var(--fs-bp-color-neutral-9);
148
-
149
- @include u.media(">=tablet") {
150
- color: var(--fs-bp-color-neutral-8);
151
- }
152
- }
153
184
  }
154
185
  }
155
186
 
156
- [data-fs-vertical-nav-menu-link] {
157
- border-radius: var(--fs-bp-border-radius-full);
187
+ @media (prefers-reduced-motion: reduce) {
188
+ a[data-fs-bp-contract-listing-back-link][href],
189
+ a[data-fs-bp-contract-listing-back-link][href] [data-fs-icon] {
190
+ transition: none;
191
+ }
192
+
193
+ a[data-fs-bp-contract-listing-back-link][href]:active {
194
+ transform: none;
195
+ }
158
196
  }
159
197
  }
160
198
 
@@ -166,17 +204,24 @@
166
204
  @import "../../../accounting-fields/components/AccountingFieldEmptyAlert/accounting-field-empty-alert.scss";
167
205
 
168
206
  width: 100%;
207
+ min-width: 0;
169
208
  padding: var(--fs-bp-margin-0) var(--fs-bp-padding-5);
170
209
  padding-bottom: var(--fs-bp-padding-12);
210
+ overflow-y: auto;
211
+ // Hiding the scrollbar while a menu is open doesn't shift the content
212
+ scrollbar-gutter: stable;
171
213
 
172
214
  @include u.media(">=tablet") {
173
215
  padding-left: var(--fs-bp-padding-10);
174
216
  padding-right: var(--fs-bp-padding-10);
175
217
  }
176
218
 
219
+ // The divider lives on the section, not the sticky sidebar, so it spans the
220
+ // full body height.
177
221
  @include u.media(">=notebook") {
178
222
  padding-left: var(--fs-bp-padding-12);
179
223
  padding-right: var(--fs-bp-padding-12);
224
+ border-left: var(--fs-border-width) solid var(--fs-bp-color-neutral-3);
180
225
  }
181
226
 
182
227
  [data-fs-bp-contracts-settings-card] {
@@ -1,5 +1,9 @@
1
1
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
2
+ import { contractScopedLink } from "../../../shared/utils/contractScopedLink";
3
+ import { getContractSettingsLinks } from "../../../shared/utils/getContractSettingsLinks";
2
4
 
5
+ import type { FeatureFlags } from "../../../shared/components/BuyerPortalProvider/BuyerPortalProvider";
6
+ import type { LocalizeFn } from "../../../shared/localization/types";
3
7
  import type { ContractData } from "../../types";
4
8
 
5
9
  export const getDefaultContractId = (contracts: ContractData[]) =>
@@ -40,3 +44,52 @@ export const parseRemovedCount = (
40
44
  const count = Number(raw);
41
45
  return Number.isInteger(count) && count > 0 ? count : null;
42
46
  };
47
+
48
+ /**
49
+ * Page links of the single-contract card. Without SUMA they keep the labels of
50
+ * the contract sidebar ("Profile", "Assortments"), as on the pre-SUMA unit page.
51
+ */
52
+ export const getContractCardLinks = (
53
+ linkParams: { orgUnitId: string; contractId: string },
54
+ t: LocalizeFn,
55
+ featureFlags?: FeatureFlags
56
+ ) => {
57
+ if (!featureFlags?.suma) {
58
+ return getContractSettingsLinks(linkParams, t, featureFlags);
59
+ }
60
+
61
+ const links = [
62
+ {
63
+ name: t("contracts.nav.basicInformation"),
64
+ link: contractScopedLink(buyerPortalRoutes.profileDetails, linkParams),
65
+ },
66
+ {
67
+ name: t("layouts.navigation.addresses"),
68
+ link: contractScopedLink(buyerPortalRoutes.addresses, linkParams),
69
+ },
70
+ ];
71
+
72
+ if (featureFlags.enableRecipientsContractLevel) {
73
+ links.push({
74
+ name: t("layouts.navigation.recipients"),
75
+ link: contractScopedLink(buyerPortalRoutes.recipients, linkParams),
76
+ });
77
+ }
78
+
79
+ links.push(
80
+ {
81
+ name: t("layouts.navigation.paymentMethods"),
82
+ link: contractScopedLink(buyerPortalRoutes.paymentMethods, linkParams),
83
+ },
84
+ {
85
+ name: t("layouts.navigation.creditCards"),
86
+ link: contractScopedLink(buyerPortalRoutes.creditCards, linkParams),
87
+ },
88
+ {
89
+ name: t("contracts.nav.assortment"),
90
+ link: contractScopedLink(buyerPortalRoutes.productAssortment, linkParams),
91
+ }
92
+ );
93
+
94
+ return links;
95
+ };
@@ -55,6 +55,8 @@ export type OrgUnitDetailsNavbarProps = {
55
55
  * value, no Menu button.
56
56
  */
57
57
  sidebarVariant?: SumaSidebarVariant | "full";
58
+ /** Contract the drawer's links point to, when it differs from `contractId`. */
59
+ sidebarContractId?: string;
58
60
  showBackLink?: boolean;
59
61
  /** Page name shown by the `"full"` drawer. */
60
62
  pageName?: string;
@@ -65,6 +67,7 @@ export const OrgUnitDetailsNavbar = ({
65
67
  orgId,
66
68
  contractId = "",
67
69
  sidebarVariant,
70
+ sidebarContractId = contractId,
68
71
  showBackLink = false,
69
72
  pageName = "",
70
73
  }: OrgUnitDetailsNavbarProps) => {
@@ -176,7 +179,7 @@ export const OrgUnitDetailsNavbar = ({
176
179
  {sidebarVariant && sidebarVariant !== "full" && isOpenSidebarMenu && (
177
180
  <SumaSidebarDrawer
178
181
  orgUnitId={orgId}
179
- contractId={contractId}
182
+ contractId={sidebarContractId}
180
183
  variant={sidebarVariant}
181
184
  showBackLink={showBackLink}
182
185
  {...sidebarMenuDrawerProps}
@@ -12,7 +12,6 @@ import {
12
12
  useQueryParams,
13
13
  } from "../../../shared/hooks";
14
14
  import { GlobalLayout } from "../../../shared/layouts";
15
- import { OrgUnitTabsLayout } from "../../../shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout";
16
15
  import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
17
16
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
18
17
  import { CreateOrgUnitDrawer, OrgUnitsHierarchyTree } from "../../components";
@@ -27,7 +26,7 @@ export type OrgUnitsLayoutProps = {
27
26
 
28
27
  export const OrgUnitsLayout = ({ data, search }: OrgUnitsLayoutProps) => {
29
28
  const { setQueryString, removeQueryString } = useQueryParams();
30
- const { currentOrgUnit, featureFlags } = useBuyerPortal();
29
+ const { currentOrgUnit } = useBuyerPortal();
31
30
  const { t } = useLocalization();
32
31
 
33
32
  const { open, ...drawerProps } = useDrawerProps();
@@ -108,13 +107,7 @@ export const OrgUnitsLayout = ({ data, search }: OrgUnitsLayoutProps) => {
108
107
 
109
108
  return (
110
109
  <GlobalLayout>
111
- {featureFlags?.suma ? (
112
- <SumaPageLayout>{orgUnitsSection}</SumaPageLayout>
113
- ) : (
114
- <OrgUnitTabsLayout pageName={t("orgUnits.titles.organization")}>
115
- {orgUnitsSection}
116
- </OrgUnitTabsLayout>
117
- )}
110
+ <SumaPageLayout>{orgUnitsSection}</SumaPageLayout>
118
111
  </GlobalLayout>
119
112
  );
120
113
  };
@@ -3,7 +3,6 @@ import { Table } from "../../../shared/components/Table/Table";
3
3
  import { getTableColumns } from "../../../shared/components/Table/utils/tableColumns";
4
4
  import { useBuyerPortal } from "../../../shared/hooks";
5
5
  import { GlobalLayout } from "../../../shared/layouts";
6
- import { OrgUnitTabsLayout } from "../../../shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout";
7
6
  import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
8
7
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
9
8
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
@@ -19,7 +18,7 @@ export type RolesLayoutProps = {
19
18
  export const RolesLayout = ({
20
19
  data: { rolesAndPermissions },
21
20
  }: RolesLayoutProps) => {
22
- const { currentOrgUnit, featureFlags } = useBuyerPortal();
21
+ const { currentOrgUnit } = useBuyerPortal();
23
22
  const { t } = useLocalization();
24
23
 
25
24
  const columns = getTableColumns({ nameColumnLabel: t("shared.labels.name") });
@@ -49,13 +48,7 @@ export const RolesLayout = ({
49
48
 
50
49
  return (
51
50
  <GlobalLayout>
52
- {featureFlags?.suma ? (
53
- <SumaPageLayout>{rolesSection}</SumaPageLayout>
54
- ) : (
55
- <OrgUnitTabsLayout pageName={t("shared.labels.organization")}>
56
- {rolesSection}
57
- </OrgUnitTabsLayout>
58
- )}
51
+ <SumaPageLayout>{rolesSection}</SumaPageLayout>
59
52
  </GlobalLayout>
60
53
  );
61
54
  };
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { type TransitionEventHandler } from "react";
2
2
 
3
3
  import { SlideOver, useFadeEffect } from "@faststore/ui";
4
4
 
@@ -9,8 +9,9 @@ import { BasicDrawerButton } from "./BasicDrawerButton";
9
9
  import { BasicDrawerFooter } from "./BasicDrawerFooter";
10
10
  import { BasicDrawerHeading } from "./BasicDrawerHeading";
11
11
 
12
- export type BasicDrawerProps = Omit<DrawerProps, "open"> & {
12
+ export type BasicDrawerProps = Omit<DrawerProps, "open" | "onTransitionEnd"> & {
13
13
  children: React.ReactNode;
14
+ onTransitionEnd: TransitionEventHandler<HTMLDivElement>;
14
15
  id?: string;
15
16
  isOpen: boolean;
16
17
  onDismiss?: () => void;
@@ -8,12 +8,15 @@ export type BasicDrawerHeadingProps = {
8
8
  title: React.ReactNode;
9
9
  onClose?: () => void;
10
10
  onBack?: () => void;
11
+ /** Overrides the default close icon. */
12
+ closeIcon?: React.ReactNode;
11
13
  } & Omit<ComponentProps<"header">, "title">;
12
14
 
13
15
  export const BasicDrawerHeading = ({
14
16
  title,
15
17
  onClose,
16
18
  onBack,
19
+ closeIcon = <Icon name="Close" width={14} height={14} />,
17
20
  ...props
18
21
  }: BasicDrawerHeadingProps) => {
19
22
  return (
@@ -31,7 +34,7 @@ export const BasicDrawerHeading = ({
31
34
  data-fs-bp-basic-drawer-heading-close-button
32
35
  aria-label="close drawer btn"
33
36
  onClick={onClose}
34
- icon={<Icon name="Close" width={14} height={14} />}
37
+ icon={closeIcon}
35
38
  />
36
39
  </header>
37
40
  );
@@ -5,21 +5,14 @@ import { useRouter } from "next/router";
5
5
  import { useLink_unstable as useLink } from "@faststore/core/experimental";
6
6
  import { Link } from "@faststore/ui";
7
7
 
8
+ import { isNavLinkActive } from "../../utils/isNavLinkActive";
9
+
8
10
  export type VerticalNavLinkProps = {
9
11
  children: ReactNode;
10
12
  link: string;
11
13
  depth?: number;
12
14
  };
13
15
 
14
- function isActiveLink(asPath: string, link: string) {
15
- const normalizedLink = link.startsWith("/") ? link : link.slice(0, -1);
16
- return (
17
- asPath === normalizedLink ||
18
- asPath.startsWith(normalizedLink + "/") ||
19
- asPath.startsWith(normalizedLink + "?")
20
- );
21
- }
22
-
23
16
  export const VerticalNavLink = ({
24
17
  link,
25
18
  children,
@@ -29,7 +22,7 @@ export const VerticalNavLink = ({
29
22
  const { resolveLink } = useLink();
30
23
  const resolvedLink = resolveLink(link);
31
24
 
32
- const isActive = isActiveLink(asPath, link);
25
+ const isActive = isNavLinkActive(asPath, link);
33
26
 
34
27
  return (
35
28
  <li key={resolvedLink} data-fs-vertical-nav-menu-item>
@@ -1,6 +1,4 @@
1
- import React, { useState } from "react";
2
-
3
- import { IconButton } from "@faststore/ui";
1
+ import type { MouseEvent } from "react";
4
2
 
5
3
  import { Icon } from "../Icon";
6
4
 
@@ -22,24 +20,11 @@ const VerticalNavTreeItem = ({
22
20
  link,
23
21
  submenu,
24
22
  actions,
25
- collapsible = false,
26
23
  depth = 0,
27
24
  hasNotification = false,
28
25
  loading = false,
29
26
  }: VerticalNavTreeItemProps) => {
30
- const [isOpen, setIsOpen] = useState(true);
31
-
32
- const onClickToggleBtn = (e: React.MouseEvent) => {
33
- e.preventDefault();
34
-
35
- if (!collapsible) {
36
- return;
37
- }
38
-
39
- setIsOpen(!isOpen);
40
- };
41
-
42
- const handleActionsClick = (e: React.MouseEvent) => e.preventDefault();
27
+ const handleActionsClick = (e: MouseEvent) => e.preventDefault();
43
28
 
44
29
  return !Array.isArray(submenu?.items) ? (
45
30
  <VerticalNav.Link link={link ?? ""} depth={depth}>
@@ -56,14 +41,6 @@ const VerticalNavTreeItem = ({
56
41
  ) : (
57
42
  <li>
58
43
  <div data-fs-bp-vertical-submenu-title>
59
- {submenu.items.length > 0 && collapsible && (
60
- <IconButton
61
- aria-label="toggle vertical submenu"
62
- data-fs-bp-vertical-submenu-toggle={isOpen}
63
- icon={<Icon name="ArrowRight" width={20} height={20} />}
64
- onClick={onClickToggleBtn}
65
- />
66
- )}
67
44
  {name}
68
45
  {hasNotification && (
69
46
  <span data-fs-bp-vertical-item-has-notification></span>
@@ -85,11 +62,9 @@ const VerticalNavTreeItem = ({
85
62
  </div>
86
63
  )}
87
64
  </div>
88
- {isOpen && (
89
- <ul>
90
- <VerticalNavTree items={submenu.items} depth={depth + 1} />
91
- </ul>
92
- )}
65
+ <ul>
66
+ <VerticalNavTree items={submenu.items} depth={depth + 1} />
67
+ </ul>
93
68
  </li>
94
69
  );
95
70
  };
@@ -31,12 +31,17 @@
31
31
  width: 100%;
32
32
  }
33
33
 
34
+ li + li,
35
+ li > ul {
36
+ margin-top: var(--fs-border-width-thick);
37
+ }
38
+
34
39
  [data-fs-vertical-nav-menu-link],
35
40
  [data-fs-bp-vertical-submenu-title] {
36
41
  display: flex;
37
42
  text-decoration: none;
38
43
  @include text-style('emphasis');
39
- color: var(--fs-bp-color-neutral-9);
44
+ color: var(--fs-bp-color-neutral-7);
40
45
  padding: var(--fs-bp-padding-1) var(--fs-bp-padding-5);
41
46
  width: 21.25rem;
42
47
  min-height: var(--fs-bp-spacing-9);
@@ -46,10 +51,19 @@
46
51
  align-items: center;
47
52
  position: relative;
48
53
  gap: var(--fs-bp-gap-1);
54
+ transition:
55
+ background-color var(--fs-transition-timing) var(--fs-transition-function),
56
+ color var(--fs-transition-timing) var(--fs-transition-function);
49
57
 
50
- &:hover {
58
+ &:has([data-fs-bp-vertical-nav-link-actions]) {
59
+ padding-right: var(--fs-bp-padding-1);
60
+ }
61
+
62
+ &:hover,
63
+ &:focus-within {
51
64
  [data-fs-bp-vertical-nav-link-actions] {
52
65
  visibility: visible;
66
+ opacity: 1;
53
67
  }
54
68
  }
55
69
 
@@ -67,10 +81,15 @@
67
81
  gap: var(--fs-bp-gap-2);
68
82
  margin-left: auto;
69
83
  visibility: hidden;
84
+ opacity: 0;
85
+ transition:
86
+ opacity var(--fs-transition-timing) var(--fs-transition-function),
87
+ visibility var(--fs-transition-timing) var(--fs-transition-function);
70
88
 
71
89
  &:has([data-fs-button][aria-expanded="true"]),
72
90
  &[data-fs-bp-vertical-nav-link-loading] {
73
91
  visibility: visible;
92
+ opacity: 1;
74
93
  }
75
94
  }
76
95
 
@@ -79,31 +98,16 @@
79
98
  }
80
99
 
81
100
  [data-fs-button][data-fs-icon-button=true] {
82
- --fs-button-height: var(--fs-bp-spacing-7);
101
+ --fs-button-height: var(--fs-bp-spacing-8);
83
102
  --fs-button-border-radius: var(--fs-bp-border-radius-full);
103
+ // One step darker than the item's hover/active background
104
+ --fs-button-tertiary-bkg-color-hover: var(--fs-bp-color-neutral-2);
84
105
 
85
106
  svg {
86
107
  color: var(--fs-bp-color-neutral-8);
87
108
  }
88
109
  }
89
110
 
90
- [data-fs-bp-vertical-submenu-toggle] {
91
- margin-left: calc(-1 * var(--fs-bp-margin-8));
92
-
93
- &[data-fs-button][data-fs-icon-button=true] {
94
- svg {
95
- transition: all 0.2s;
96
- color: var(--fs-bp-color-neutral-7);
97
- }
98
- }
99
-
100
- &[data-fs-bp-vertical-submenu-toggle="true"] {
101
- svg {
102
- transform: rotate(90deg);
103
- }
104
- }
105
- }
106
-
107
111
  [data-fs-bp-vertical-item-has-notification] {
108
112
  flex: 0 0 auto;
109
113
  width: 0.438rem; // 7px
@@ -126,22 +130,16 @@
126
130
  }
127
131
 
128
132
  [data-fs-vertical-nav-menu-link] {
133
+ // Stays highlighted while the pointer is on the item's action button
129
134
  &:hover {
130
135
  background-color: var(--fs-bp-color-neutral-1);
131
- }
132
-
133
- @include u.media(">=tablet") {
134
136
  color: var(--fs-bp-color-neutral-8);
135
137
  }
136
-
137
- &:has([data-fs-bp-vertical-nav-link-actions]:hover),
138
- &:has([data-fs-bp-vertical-submenu-toggle]:hover) {
139
- background-color: transparent;
140
- }
141
138
  }
142
139
 
143
140
  [data-fs-vertical-nav-menu-link-is-active="true"] {
144
141
  background-color: var(--fs-bp-color-neutral-1);
142
+ color: var(--fs-bp-color-neutral-8);
145
143
  }
146
144
 
147
145
  &:first-child {
@@ -149,7 +147,22 @@
149
147
  }
150
148
 
151
149
  [data-fs-bp-vertical-submenu-title] {
152
- color: #858585;
150
+ color: var(--fs-bp-color-neutral-5);
151
+ // Same inset as the items' action button, so "+" and "..." line up
152
+ padding-right: var(--fs-bp-padding-1);
153
+
154
+ // The group's add action stays visible, like the prototype's "+"
155
+ > [data-fs-bp-vertical-nav-link-actions] {
156
+ visibility: visible;
157
+ opacity: 1;
158
+ }
159
+ }
160
+ }
161
+
162
+ @media (prefers-reduced-motion: reduce) {
163
+ [data-fs-vertical-nav-menu-link],
164
+ [data-fs-bp-vertical-nav-link-actions] {
165
+ transition: none;
153
166
  }
154
167
  }
155
168
  }