Skip to content

Commit

Permalink
Apply automatic changes
Browse files Browse the repository at this point in the history
Signed-off-by: VF-WP GitHub Actions Bot <[email protected]>
  • Loading branch information
VF-WP GitHub Actions Bot authored and VF-WP GitHub Actions Bot committed Nov 20, 2024
1 parent c6bb5b0 commit 59b8b37
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 67 deletions.
2 changes: 1 addition & 1 deletion vf-components/vf-componenet-rollup/package.variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $componentInfo: (
version: "1.0.0-beta.4",
location: "components/vf-componenet-rollup",
vfCoreVersion: "2.2.47",
buildTimeStamp: "Mon, 18 Nov 2024 13:20:38 GMT"
buildTimeStamp: "Wed, 20 Nov 2024 00:58:58 GMT"
);
2 changes: 1 addition & 1 deletion vf-components/vfwp-admin/package.variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $componentInfo: (
version: "0.0.1",
location: "components/vfwp-admin",
vfCoreVersion: "2.2.47",
buildTimeStamp: "Mon, 18 Nov 2024 13:20:38 GMT"
buildTimeStamp: "Wed, 20 Nov 2024 00:58:58 GMT"
);
2 changes: 1 addition & 1 deletion vf-components/vfwp-autocomplete/package.variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $componentInfo: (
version: "0.0.1",
location: "components/vfwp-autocomplete",
vfCoreVersion: "2.2.47",
buildTimeStamp: "Mon, 18 Nov 2024 13:20:38 GMT"
buildTimeStamp: "Wed, 20 Nov 2024 00:58:58 GMT"
);
2 changes: 1 addition & 1 deletion vf-components/vfwp-gutenberg-blocks/package.variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $componentInfo: (
version: "0.0.1",
location: "components/vfwp-gutenberg-blocks",
vfCoreVersion: "2.2.47",
buildTimeStamp: "Mon, 18 Nov 2024 13:20:38 GMT"
buildTimeStamp: "Wed, 20 Nov 2024 00:58:58 GMT"
);
2 changes: 1 addition & 1 deletion vf-components/vfwp-gutenberg-iframe/package.variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $componentInfo: (
version: "0.0.1",
location: "components/vfwp-gutenberg-iframe",
vfCoreVersion: "2.2.47",
buildTimeStamp: "Mon, 18 Nov 2024 13:20:38 GMT"
buildTimeStamp: "Wed, 20 Nov 2024 00:58:58 GMT"
);
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
/* stylelint-enable */
/*!
* Component: @visual-framework/embl-breadcrumbs-lookup
* Version: 1.2.0
* Version: 1.2.1
* Location: components/vf-core-components/embl-breadcrumbs-lookup
*/
.embl-grid .embl-breadcrumbs-lookup:first-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function emblBreadcrumbAppend(breadcrumbTarget,termName,facet,type) {
// console.warn('embl-js-breadcrumbs-lookup: No matching breadcrumb found for `' + termName + '`; Will formulate a URL.');
if (facet == "who") {
// fallback for people: search people directory
termObject.url = "https://www.embl.org/search/?searchQuery="+termName.replace(/[\W_]+/g," ").replace(/\s+/g, "-").toLowerCase()+"&activeFacet=People%20directory&origin=breadcrumbTermNotFound";
termObject.url = "https://www.embl.org/search/#stq="+termName.replace(/[\W_]+/g," ").replace(/\s+/g, "-").toLowerCase()+"&activeFacet=People%20directory&origin=breadcrumbTermNotFound";
} else {
// otherwise try and search
termObject.url = "https://www.embl.org/search/#stq="+termName+"&taxonomyFacet="+facet+"&origin=breadcrumbTermNotFound"; // if no link specified, do a search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Component: @visual-framework/vf-back-to-top
* Version: 1.0.2
* Location: components/vf-core-components/vf-back-to-top
* Build time: Mon, 18 Nov 2024 13:20:18 GMT
* Build time: Wed, 20 Nov 2024 00:58:39 GMT
*/
.vf-back-to-top {
display: inline;
Expand Down
2 changes: 1 addition & 1 deletion wp-content/themes/vf-wp/assets/assets/vf-flag/vf-flag.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Component: @visual-framework/vf-flag
* Version: 1.0.0-alpha.2
* Location: components/vf-core-components/vf-flag
* Build time: Mon, 18 Nov 2024 13:20:18 GMT
* Build time: Wed, 20 Nov 2024 00:58:39 GMT
*/
.vf-flag {
display: table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Component: @visual-framework/vf-mega-menu
* Version: 1.0.2
* Location: components/vf-core-components/vf-mega-menu
* Build time: Mon, 18 Nov 2024 13:20:18 GMT
* Build time: Wed, 20 Nov 2024 00:58:39 GMT
*/
.vf-mega-menu__link {
display: -webkit-box;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Component: @visual-framework/vf-sidebar
* Version: 1.0.0-alpha.2
* Location: components/vf-core-components/vf-sidebar
* Build time: Mon, 18 Nov 2024 13:20:18 GMT
* Build time: Wed, 20 Nov 2024 00:58:39 GMT
*/
.vf-sidebar {
overflow: hidden;
Expand Down
2 changes: 1 addition & 1 deletion wp-content/themes/vf-wp/assets/assets/vf-tabs/vf-tabs.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
/* stylelint-enable */
/*!
* Component: @visual-framework/vf-tabs
* Version: 2.1.4
* Version: 2.1.8
* Location: components/vf-core-components/vf-tabs
*/
.vf-tabs__list {
Expand Down
62 changes: 38 additions & 24 deletions wp-content/themes/vf-wp/assets/assets/vf-tabs/vf-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @param {boolean} [activateDeepLinkOnLoad] - if deep linked tabs should be activated on page load, defaults to true
* @example vfTabs(document.querySelectorAll('.vf-component__container')[0]);
*/
function vfTabs(scope, activateDeepLinkOnLoad) {
function vfTabs(scope) {
/* eslint-disable no-redeclare */
var scope = scope || document;
var activateDeepLinkOnLoad = activateDeepLinkOnLoad || true;
Expand All @@ -18,6 +18,7 @@ function vfTabs(scope, activateDeepLinkOnLoad) {
"[data-vf-js-tabs-content] [id^='vf-tabs__section']"
);
const tabs = scope.querySelectorAll("[data-vf-js-tabs] .vf-tabs__link");

if (!tabsList || !panels || !tabs) {
// exit: either tabs or tabbed content not found
return;
Expand All @@ -40,7 +41,6 @@ function vfTabs(scope, activateDeepLinkOnLoad) {
tab.removeAttribute("aria-selected");
tab.setAttribute("tabindex", "-1");
tab.classList.remove("is-active");

// Handle clicking of tabs for mouse users
tab.addEventListener("click", e => {
e.preventDefault();
Expand Down Expand Up @@ -101,32 +101,45 @@ function vfTabs(scope, activateDeepLinkOnLoad) {
// activate any deeplinks to a specific tab
if (activateDeepLinkOnLoad) {
vfTabsDeepLinkOnLoad(tabs, panels);
Array.prototype.forEach.call(panels, panel => {
let links = panel.querySelectorAll("[href*='vf-tabs__section']");
links.forEach(link => {
link.addEventListener("click", e => {
e.preventDefault();
let href = e.currentTarget.getAttribute("href");
vfTabsDeepLinkOnLoad(tabs, panels, href);
});
});
});
}
}

// The tab switching function
const vfTabsSwitch = (newTab, panels) => {
// Update url based on tab id
const data = newTab.getAttribute("id");
const url = "#" + data;
window.history.replaceState(data, null, url);
var url = "#" + data;
// var url = window.location.origin + window.location.pathname + window.location.search;
// url += url.endsWith("/") ? "#" + data : "/#" + data;
window.history.pushState(data, null, url);

// get the parent ul of the clicked tab
let parentTabSet = newTab.closest(".vf-tabs__list");
let oldTab = parentTabSet.querySelector("[aria-selected]");
if (oldTab) {
oldTab.removeAttribute("aria-selected");
oldTab.setAttribute("tabindex", "-1");
oldTab.classList.remove("is-active");

for (let item = 0; item < panels.length; item++) {
const panel = panels[item];
if (panel.id === oldTab.id) {
panel.hidden = true;
break;
}
let parentTabSet = newTab.closest(".vf-tabs");
let tabs = parentTabSet.querySelectorAll("[data-vf-js-tabs] .vf-tabs__link");

tabs.forEach(tab => {
if (tab.getAttribute("aria-selected")) {
tab.removeAttribute("aria-selected");
tab.setAttribute("tabindex", "-1");
tab.classList.remove("is-active");

panels.forEach(panel => {
if (panel.id === tab.id) {
panel.hidden = true;
}
});
}
}
});

newTab.focus({ preventScroll: true });
// Make the active tab focusable by the user (Tab key)
Expand All @@ -136,19 +149,20 @@ const vfTabsSwitch = (newTab, panels) => {
newTab.classList.add("is-active");
// Get the indices of the new tab to find the correct
// tab panel to show
for (let item = 0; item < panels.length; item++) {
const panel = panels[item];
panels.forEach(panel => {
if (panel.id === newTab.id) {
panel.hidden = false;
break;
}
}
});
};

function vfTabsDeepLinkOnLoad(tabs, panels) {
function vfTabsDeepLinkOnLoad(tabs, panels, href) {
var hash;
// 1. See if there is a `#vf-tabs__section--88888`
if (window.location.hash) {
var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
} else if (href) {
hash = href.substring(href.indexOf("#") + 1);
} else {
// No hash found
return false;
Expand Down
60 changes: 60 additions & 0 deletions wp-content/themes/vf-wp/assets/assets/vf-tabs/vf-tabs.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* vf-tabs react component
* See vf-extensions-react for usage guidance
*
*/
import { useEffect } from "react";
import { vfTabs } from "@visual-framework/vf-tabs/vf-tabs";

function VfTabs(tabsData) {
useEffect(() => {
vfTabs();
}, []);
return (
<>
<div className="vf-tabs">
<ul className="vf-tabs__list" data-vf-js-tabs>
{Object.entries(tabsData).map(tab_forlink => {
return (
<li className="vf-tabs__item" key={tab_forlink[0]}>
<a
className="vf-tabs__link"
href={`#vf-tabs__section--${tab_forlink[1][1].tab_number}`}
dangerouslySetInnerHTML={{
__html: tab_forlink[1][0].tab_title
}}
></a>
</li>
);
})}
</ul>
</div>
<div className="vf-tabs-content" data-vf-js-tabs-content>
{Object.entries(tabsData).map(tab_forsection => {
return (
<section
className="vf-tabs__section"
id={`vf-tabs__section--${tab_forsection[1][1].tab_number}`}
key={tab_forsection[0]}
>
{tab_forsection[1][2].tab_heading !== "" ? (
<h2
dangerouslySetInnerHTML={{
__html: `${tab_forsection[1][2].tab_heading}`
}}
></h2>
) : null}
<p
dangerouslySetInnerHTML={{
__html: `${tab_forsection[1][3].tab_content}`
}}
></p>
</section>
);
})}
</div>
</>
);
}

export default VfTabs;
Loading

0 comments on commit 59b8b37

Please sign in to comment.