Skip to content

Commit 0b1842a

Browse files
authored
Merge pull request #9 from vtexdocs/feat/cookie-bar
Feat/cookie bar
2 parents 408e335 + 598140b commit 0b1842a

File tree

16 files changed

+532
-190
lines changed

16 files changed

+532
-190
lines changed

dist/index.d.mts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ interface Item extends SubItem {
2525
children: SubItem[];
2626
}
2727

28-
interface Props$1 {
28+
interface Props$2 {
2929
/** List of headings in the current documentation page */
3030
headingList?: Item[];
3131
}
3232
/** Table of contents for documentation pages. */
33-
declare const TableOfContents: ({ headingList }: Props$1) => react_jsx_runtime.JSX.Element;
33+
declare const TableOfContents: ({ headingList }: Props$2) => react_jsx_runtime.JSX.Element;
3434

3535
interface SideBarSectionState {
3636
/** Array containing the name of the parents of the expanded page in the menu. */
@@ -65,6 +65,11 @@ declare const Search: () => react_jsx_runtime.JSX.Element;
6565

6666
declare function SearchInput(): react_jsx_runtime.JSX.Element;
6767

68+
interface Props$1 {
69+
onAccept: () => void;
70+
}
71+
declare const CookieBar: ({ onAccept }: Props$1) => react_jsx_runtime.JSX.Element;
72+
6873
type Section = {
6974
link: string;
7075
title: string;
@@ -127,4 +132,4 @@ interface AlgoliaConfig {
127132
}
128133
declare const createAlgoliaClient: (config: AlgoliaConfig) => void;
129134

130-
export { FeedbackSection, HamburgerMenu, Item, LibraryContext, LibraryContextProvider, MarkdownRenderer, Search, createAlgoliaClient as SearchConfig, SearchInput, Sidebar, TableOfContents };
135+
export { CookieBar, FeedbackSection, HamburgerMenu, Item, LibraryContext, LibraryContextProvider, MarkdownRenderer, Search, createAlgoliaClient as SearchConfig, SearchInput, Sidebar, TableOfContents };

dist/index.mjs

Lines changed: 138 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5619,13 +5619,13 @@ var styles_default4 = { container: container2, title, description, linkContainer
56195619
// src/components/whats-next-card/index.tsx
56205620
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
56215621
var WhatsNextCard = ({
5622-
title: title5,
5622+
title: title6,
56235623
description: description4,
56245624
linkTitle,
56255625
linkTo
56265626
}) => {
56275627
return /* @__PURE__ */ jsx7(Link, { href: linkTo, sx: styles_default4.container, children: /* @__PURE__ */ jsxs5(Box4, { children: [
5628-
/* @__PURE__ */ jsx7(Text, { sx: styles_default4.title, className: "title", children: title5 }),
5628+
/* @__PURE__ */ jsx7(Text, { sx: styles_default4.title, className: "title", children: title6 }),
56295629
/* @__PURE__ */ jsx7(Text, { sx: styles_default4.description, className: "description", children: description4 }),
56305630
/* @__PURE__ */ jsxs5(Flex3, { sx: styles_default4.linkContainer, children: [
56315631
/* @__PURE__ */ jsx7(Text, { sx: styles_default4.link, className: "link", children: linkTitle }),
@@ -5703,10 +5703,10 @@ var LibraryContextProvider = ({ children, ...props }) => {
57035703
setActiveSectionName(props.sectionSelected);
57045704
}, [props.sectionSelected]);
57055705
const { fallback } = props;
5706-
const toggleSidebarElementStatus = (title5) => {
5706+
const toggleSidebarElementStatus = (title6) => {
57075707
setSidebarElementStatus((sidebarElementStatus2) => {
5708-
const open = sidebarElementStatus2.has(title5) === false ? true : !sidebarElementStatus2.get(title5);
5709-
return new Map(sidebarElementStatus2.set(title5, open));
5708+
const open = sidebarElementStatus2.has(title6) === false ? true : !sidebarElementStatus2.get(title6);
5709+
return new Map(sidebarElementStatus2.set(title6, open));
57105710
});
57115711
};
57125712
const closeSidebarElements = (parentsArray) => {
@@ -5718,9 +5718,9 @@ var LibraryContextProvider = ({ children, ...props }) => {
57185718
}
57195719
});
57205720
};
5721-
const openSidebarElement = (title5) => {
5721+
const openSidebarElement = (title6) => {
57225722
setSidebarElementStatus((sidebarElementStatus2) => {
5723-
return new Map(sidebarElementStatus2.set(title5, true));
5723+
return new Map(sidebarElementStatus2.set(title6, true));
57245724
});
57255725
};
57265726
const goToPreviousItem = () => {
@@ -5864,7 +5864,11 @@ var en_default = {
58645864
"sidebar_search.placeholder": "Search in",
58655865
"image.error_loading": "An error occurred while trying to load the image.",
58665866
api_reference_sidebar_filter_clear: "Clear all",
5867-
api_reference_sidebar_filter: "Filter by"
5867+
api_reference_sidebar_filter: "Filter by",
5868+
"cookie_bar.title": "We use cookies",
5869+
"cookie_bar.description": "This website uses cookies to improve site navigation, analyze website usage, and assist in our marketing efforts.",
5870+
"cookie_bar.accept": "I understand",
5871+
"cookie_bar.decline": "I decline"
58685872
};
58695873

58705874
// src/messages/es.json
@@ -5881,7 +5885,11 @@ var es_default = {
58815885
"sidebar_search.placeholder": "Search in",
58825886
"image.error_loading": "An error occurred while trying to load the image.",
58835887
api_reference_sidebar_filter_clear: "Clear all",
5884-
api_reference_sidebar_filter: "Filter by"
5888+
api_reference_sidebar_filter: "Filter by",
5889+
"cookie_bar.title": "We use cookies",
5890+
"cookie_bar.description": "This website uses cookies to improve site navigation, analyze website usage, and assist in our marketing efforts.",
5891+
"cookie_bar.accept": "I understand",
5892+
"cookie_bar.decline": "I decline"
58855893
};
58865894

58875895
// src/messages/pt.json
@@ -5898,7 +5906,11 @@ var pt_default = {
58985906
"sidebar_search.placeholder": "Search in",
58995907
"image.error_loading": "An error occurred while trying to load the image.",
59005908
api_reference_sidebar_filter_clear: "Clear all",
5901-
api_reference_sidebar_filter: "Filter by"
5909+
api_reference_sidebar_filter: "Filter by",
5910+
"cookie_bar.title": "We use cookies",
5911+
"cookie_bar.description": "This website uses cookies to improve site navigation, analyze website usage, and assist in our marketing efforts.",
5912+
"cookie_bar.accept": "I understand",
5913+
"cookie_bar.decline": "I decline"
59025914
};
59035915

59045916
// src/utils/get-message.ts
@@ -6172,7 +6184,7 @@ var TableOfContents = ({ headingList }) => {
61726184
setHeadingItems(headings);
61736185
}, [router.asPath, headingList]);
61746186
const Item = ({
6175-
title: title5,
6187+
title: title6,
61766188
slug,
61776189
level,
61786190
active
@@ -6187,7 +6199,7 @@ var TableOfContents = ({ headingList }) => {
61876199
subItem: level === 1 ? "" : slug
61886200
}));
61896201
},
6190-
children: /* @__PURE__ */ jsx11(Text2, { sx: styles_default5.item(level, active), children: title5 })
6202+
children: /* @__PURE__ */ jsx11(Text2, { sx: styles_default5.item(level, active), children: title6 })
61916203
}
61926204
);
61936205
};
@@ -7965,7 +7977,7 @@ var cardTitle = (containerType) => {
79657977
// src/components/documentation-card/index.tsx
79667978
import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
79677979
var DocumentationCard = ({
7968-
title: title5,
7980+
title: title6,
79697981
description: description4,
79707982
link: link2,
79717983
containerType,
@@ -7975,7 +7987,7 @@ var DocumentationCard = ({
79757987
return /* @__PURE__ */ jsx23(Link5, { href: link2, legacyBehavior: true, children: /* @__PURE__ */ jsx23("a", { onClick, style: { width: "100%" }, children: /* @__PURE__ */ jsxs17(Box13, { sx: cardContainer3(containerType), children: [
79767988
/* @__PURE__ */ jsxs17(Flex11, { sx: titleContainer2(containerType), children: [
79777989
/* @__PURE__ */ jsx23(Icon24, { sx: { color: "#4A596B" }, size: 24 }),
7978-
/* @__PURE__ */ jsx23(Text7, { className: "title", sx: cardTitle(containerType), children: title5 })
7990+
/* @__PURE__ */ jsx23(Text7, { className: "title", sx: cardTitle(containerType), children: title6 })
79797991
] }),
79807992
/* @__PURE__ */ jsx23(Text7, { className: "description", sx: styles_default13.description, children: description4 })
79817993
] }) }) });
@@ -10111,7 +10123,7 @@ var expanded_results_icon_default = ExpandedResultsIcon;
1011110123
import { jsx as jsx49, jsxs as jsxs41 } from "react/jsx-runtime";
1011210124
var SearchCard = ({
1011310125
Icon: Icon24,
10114-
title: title5,
10126+
title: title6,
1011510127
method,
1011610128
breadcrumbs,
1011710129
actionType,
@@ -10133,8 +10145,8 @@ var SearchCard = ({
1013310145
active: false
1013410146
}
1013510147
) : null,
10136-
title5 === "overview" && `${hit.doccategory} `,
10137-
title5
10148+
title6 === "overview" && `${hit.doccategory} `,
10149+
title6
1013810150
] }),
1013910151
/* @__PURE__ */ jsxs41(Text13, { className: "searchCardDescription", sx: styles_default19.description, children: [
1014010152
/* @__PURE__ */ jsx49(Flex17, { children: /* @__PURE__ */ jsx49(
@@ -10485,7 +10497,116 @@ var Search = () => {
1048510497
] });
1048610498
};
1048710499
var search_default2 = Search;
10500+
10501+
// src/lib/cookie-bar/index.tsx
10502+
import { useContext as useContext17 } from "react";
10503+
import { CookieConsent } from "react-cookie-consent";
10504+
10505+
// src/lib/cookie-bar/styles.ts
10506+
var bar = {
10507+
backgroundColor: "#FFF",
10508+
borderRadius: "8px",
10509+
color: "#5E6E84",
10510+
padding: "20px",
10511+
width: "80%",
10512+
left: "50%",
10513+
transform: "translateX(-50%)",
10514+
maxWidth: "1280px",
10515+
alignItems: "center",
10516+
justifyContent: "center",
10517+
boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)"
10518+
};
10519+
var barContent = {
10520+
display: "flex",
10521+
flex: "1 0 300px",
10522+
flexDirection: "column",
10523+
maxWidth: "100%"
10524+
};
10525+
var title5 = {
10526+
color: "#5E6E84",
10527+
marginBottom: "10px",
10528+
lineHeight: "28px",
10529+
fontSize: "25px",
10530+
fontWeight: "400"
10531+
};
10532+
var buttonContainer = {
10533+
display: "flex",
10534+
flexWrap: "wrap",
10535+
gap: "10px",
10536+
justifyContent: "center",
10537+
margin: "15px"
10538+
};
10539+
var acceptButton = {
10540+
background: "#F71963",
10541+
color: "#FFF",
10542+
padding: "7px 16px",
10543+
borderRadius: "2px",
10544+
margin: "0",
10545+
height: "32px",
10546+
fontWeight: "400",
10547+
":hover": {
10548+
opacity: "0.7"
10549+
}
10550+
};
10551+
var declineButton = {
10552+
border: "1px solid #F71963",
10553+
background: "#FFF",
10554+
color: "#F71963",
10555+
borderRadius: "2px",
10556+
fontWeight: "400",
10557+
margin: "0",
10558+
height: "32px",
10559+
":hover": {
10560+
opacity: "0.7"
10561+
}
10562+
};
10563+
var styles_default23 = {
10564+
bar,
10565+
barContent,
10566+
title: title5,
10567+
acceptButton,
10568+
declineButton,
10569+
buttonContainer
10570+
};
10571+
10572+
// src/lib/cookie-bar/index.tsx
10573+
import { Flex as Flex21, Text as Text16 } from "@vtex/brand-ui";
10574+
import aa3 from "search-insights";
10575+
import { jsx as jsx54, jsxs as jsxs46 } from "react/jsx-runtime";
10576+
var Button6 = ({ children, style, ...props }) => {
10577+
return /* @__PURE__ */ jsx54(Flex21, { sx: style, ...props, children });
10578+
};
10579+
var CookieBar = ({ onAccept }) => {
10580+
const { locale } = useContext17(LibraryContext);
10581+
return /* @__PURE__ */ jsxs46(
10582+
CookieConsent,
10583+
{
10584+
enableDeclineButton: true,
10585+
buttonStyle: styles_default23.acceptButton,
10586+
declineButtonStyle: styles_default23.declineButton,
10587+
style: styles_default23.bar,
10588+
onAccept: () => {
10589+
aa3("init", {
10590+
partial: true,
10591+
useCookie: true
10592+
});
10593+
onAccept();
10594+
},
10595+
declineButtonText: messages[locale]["cookie_bar.decline"],
10596+
buttonText: messages[locale]["cookie_bar.accept"],
10597+
ButtonComponent: Button6,
10598+
customButtonWrapperAttributes: { style: styles_default23.buttonContainer },
10599+
customContentAttributes: { style: styles_default23.barContent },
10600+
children: [
10601+
/* @__PURE__ */ jsx54(Text16, { sx: styles_default23.title, children: messages[locale]["cookie_bar.title"] }),
10602+
/* @__PURE__ */ jsx54(Text16, { children: messages[locale]["cookie_bar.description"] })
10603+
]
10604+
}
10605+
);
10606+
};
10607+
var cookie_bar_default = CookieBar;
1048810608
export {
10609+
cookie_bar_default as CookieBar,
1048910610
feedback_section_default as FeedbackSection,
1049010611
hamburger_menu_default as HamburgerMenu,
1049110612
LibraryContext,

dist/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)