Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHS-5963: FE performance refactor theme javascript #1691

Open
wants to merge 56 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2720e5f
feat(shs-5963: start adding drupal behaviours to js files
Nov 22, 2024
7f21bd6
feat(shs-5693): add drupal befaviours to navigation and table js
Nov 25, 2024
bbe6a41
feat(shs-5693): add drupal befaviours to equal height grid js
Nov 25, 2024
e69bbcf
feat(shs-5693): add drupal befaviours to video with caption js
Nov 25, 2024
7146a06
feat(shs-5693): add drupal behavior to page scroll js
Nov 25, 2024
7ac23de
feat(shs-5693): add drupal behavior to expanded collapse timeline js
Nov 25, 2024
6554921
feat(shs-5693): add drupal behavior to accordion toggle all js
Nov 25, 2024
0f8499c
feat(shs-5693): add drupal behavior to linked cards js
Nov 25, 2024
323290e
feat(shs-5693): add window variable in js
Nov 26, 2024
fe238de
feat(shs-5693): add drupal behavior to main content fallback js
Nov 26, 2024
9fbfbaa
feat(shs-5693): add drupal behavior to main content fallback js
Nov 26, 2024
00de244
feat(shs-5693): add drupal behavior to mega menu js
Nov 26, 2024
3f5fe06
feat(shs-5693): add drupal behavior to editoria11y js
Nov 27, 2024
e3c1552
feat(shs-5693): remove commented code
Nov 27, 2024
edf990e
feat(shs-5963): update webpack configuration to allow compilation of …
cienvaras Nov 27, 2024
f9c4a0b
Merge branch 'shs-5963-fe-performance-refactor-theme-javascript' of g…
cienvaras Nov 27, 2024
70ab7c2
fix(shs-5963): change how theme shared js is handled
cienvaras Nov 27, 2024
4e02ad3
feat(shs-5693): add shared files in webpack and attached files in menu
Nov 28, 2024
75a5bfa
feat(shs-5693): attached files in accordion, heros, spotlights and te…
Nov 28, 2024
ccba6d6
feat(shs-5693): attached files in heros and spotlights
Nov 29, 2024
51d05f8
feat(shs-5693): attached files for tables in wysiwyg and views
Nov 30, 2024
9b51bc6
feat(shs-5693): attached files for tables in wysiwyg
Nov 30, 2024
3991f05
feat(shs-5693): attached files for tables in views
Nov 30, 2024
4b0b16b
feat(shs-5693): attached files for timeline
Nov 30, 2024
1ec4c66
feat(shs-5693): attached files for equal height in vertical linked cards
Nov 30, 2024
786f38e
feat(shs-5693): attached file for linked cards
Dec 2, 2024
25f8327
feat(shs-5693): attached file for main content fallback
Dec 2, 2024
aff9c2a
feat(shs-5693): attached file for mega menu
Dec 2, 2024
68da5c8
feat(shs-5693): attached file for editiora11y
Dec 2, 2024
e1a7c7c
feat(shs-5693): attached file for prefered reduced motion and add to cal
Dec 2, 2024
d20ea84
feat(shs-5693): attached file for table wrap and table scope in text …
Dec 2, 2024
743a58a
feat(shs-5963): add carousel slides heights and prefered reduced moti…
Dec 2, 2024
cf45884
feat(shs-5963): add prefered reduced motion in previews
Dec 2, 2024
b859dd4
feat(shs-5963): add equal height grid in previews
Dec 2, 2024
9d935b5
feat(shs-5963): add expanded collapse timeline in previews
Dec 2, 2024
b4eedb9
feat(shs-5963): add accordion toggle all in previews
Dec 2, 2024
60ed989
feat(shs-5963): add linked card script in previews
Dec 2, 2024
4ead234
feat(shs-5963): add video with caption
Dec 3, 2024
63d87c3
feat(shs-5963): attach colorbox script in photoalbum
Dec 3, 2024
fca0f38
feat(shs-5963): move vertical tabs js to hs_layouts and attach to it,…
Dec 3, 2024
69a4b59
fix(shs-5963): fix lint theme issue in colorful.js and traditional.js
Dec 3, 2024
8bbc525
Merge branch '11.6.1-release' of github.com:SU-HSDO/suhumsci into shs…
Dec 3, 2024
2be0832
fix(shs-5963): fix js files and libraries naming
cienvaras Dec 4, 2024
f5dc114
fix(shs-5963): fixes in main-menu/megamenu js
cienvaras Dec 4, 2024
d8877ea
fix(shs-5963): load wysiwyg related scripts based on field type
cienvaras Dec 5, 2024
14261e2
fix(shs-5963): refactor js for handling vertical tabs in layout build…
cienvaras Dec 6, 2024
e856027
fix(shs-5963): add once library to accordion,add to cal and page scro…
Dec 10, 2024
fb5bf62
fix(shs-5963): add once library to carousels and tables related scrip…
Dec 10, 2024
09100c3
fix(shs-5963): add once library to main menu scripts
Dec 10, 2024
422f0f4
fix(shs-5963): add once library to secondary menu scripts
Dec 10, 2024
818fc06
fix(shs-5963): add once library to linked cards, equal height grid, v…
Dec 11, 2024
146897c
fix(shs-5963): add once library to colorbox.js, remove preprocess of …
Dec 11, 2024
57eb19b
fix(shs-5963): add once library to main content fallback and megamenu
Dec 11, 2024
5d85789
fix(shs-5963): remove incorrect library from hs_layouts layouts defin…
cienvaras Dec 20, 2024
7b4911c
fix(shs-5963): template fixes
cienvaras Dec 20, 2024
d232b31
fix(shs-5963): fixes in js scripts and templates
cienvaras Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ docroot/themes/humsci/humsci_colorful/css/humsci_colorful-ckeditor.css
docroot/themes/humsci/humsci_traditional/css/humsci_traditional-ckeditor.css
docroot/themes/humsci/humsci_colorful/css/humsci_colorful-preview.css
docroot/themes/humsci/humsci_traditional/css/humsci_traditional-preview.css
docroot/themes/humsci/humsci_traditional/js/index.js
docroot/themes/humsci/humsci_colorful/js/index.js
docroot/themes/humsci/humsci_basic/dist/js
docroot/themes/humsci/humsci_traditional/js
docroot/themes/humsci/humsci_colorful/js
# Ignore build artifacts
deployment_identifier
/deploy
Expand Down
7 changes: 7 additions & 0 deletions docroot/modules/humsci/hs_layouts/hs_layouts.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ three_column_w_image:
css:
layout:
css/three-column-w-image.css: {}

news_style:
css:
layout:
css/news-style.css: {}

layout_builder_admin:
css:
theme:
Expand All @@ -20,3 +22,8 @@ images_loaded:
dependencies:
- core/jquery

layout-builder-vertical-tabs:
js:
js/layout-builder-vertical-tabs.js: {}
dependencies:
- core/drupal
10 changes: 10 additions & 0 deletions docroot/modules/humsci/hs_layouts/hs_layouts.module
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ function hs_layouts_plugin_filter_block__layout_builder_alter(&$definitions, &$e
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function hs_layouts_preprocess_page(&$variables) {
// Load layout-builder-vertical-tabs lib in the layout builder override form.
if (\Drupal::routeMatch()->getRouteName() == 'layout_builder.overrides.node.view') {
$variables['#attached']['library'][] = 'hs_layouts/layout-builder-vertical-tabs';
}
}

/**
* Implements hook_preprocess().
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function closeDetails() {
// Close Revision Information Details element in Layout Builder by default.
// Close Revision Information Details element in Layout Builder by default.
if (document.querySelector('.layout-builder-form')) {
const details = document.querySelector('.layout-builder-form details');
if (details) {
Expand Down
4 changes: 3 additions & 1 deletion docroot/themes/humsci/humsci_basic/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"node": true
},
"globals": {
"Drupal": "readonly"
"Drupal": "readonly",
"jQuery": "readonly",
"once": "readonly"
},
"rules": {
"no-restricted-globals": 0,
Expand Down
10 changes: 3 additions & 7 deletions docroot/themes/humsci/humsci_basic/humsci_basic.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ description: A base for visually distinctive HumSci themes.
package: 'Humanities & Sciences'
core_version_requirement: ^9.4 || ^10
'base theme': stable9
# libraries: Libraries are loaded via sub-themes
libraries:
- humsci_basic/main-content-fallback
- humsci_basic/editoria11y

regions:
page_top: 'Page top'
Expand All @@ -27,9 +29,3 @@ libraries-override:
css:
layout:
css/three-column-w-image.css: false

# we_megamenu/form.we-mega-menu-frontend:
# css:
# theme:
# assets/css/we_megamenu_backend.css: false
# assets/includes/bootstrap/css/bootstrap.min.css: false
131 changes: 130 additions & 1 deletion docroot/themes/humsci/humsci_basic/humsci_basic.libraries.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,132 @@
accordion:
js:
dist/js/accordion.js: {}
dependencies:
- core/drupal
- core/once

addtocal:
js:
dist/js/addtocal.js: {}
dependencies:
- core/drupal
- core/once

carousel-slides-height:
js:
dist/js/carousel-slides-height.js: {}
dependencies:
- core/drupal
- core/once

colorbox:
js:
dist/js/colorbox.js: {}
dependencies:
- core/drupal
- core/once

editoria11y:
js:
dist/js/editoria11y.js: {}
dependencies:
- core/drupal
- core/once

equal-height-grid:
js:
dist/js/equal-height-grid.js: {}
dependencies:
- core/drupal
- core/once

linked-cards:
js:
dist/js/linked-cards.js: {}
dependencies:
- core/drupal
- core/once

main-content-fallback:
js:
dist/js/main-content-fallback.js: {}
dependencies:
- core/drupal
- core/once

main-menu:
js:
dist/js/main-menu.js: {}
dependencies:
- core/drupal
- core/once

megamenu:
js:
dist/js/megamenu.js: {}
dependencies:
- core/drupal
- core/once

page-scroll-animations:
js:
dist/js/page-scroll-animations.js: {}
dependencies:
- core/drupal
- core/once

prefered-reduced-motion:
js:
dist/js/prefered-reduced-motion.js: {}
dependencies:
- core/drupal
- core/once

search:
js:
src/js/shared/search/search-expand.js: {}
dist/js/search.js: {}
dependencies:
- core/drupal
- core/once

secondary-menu:
js:
dist/js/secondary-toggler.js: {}
dependencies:
- core/drupal
- core/once

table-pattern:
js:
dist/js/table-pattern.js: {}
dependencies:
- core/drupal
- core/once

table-scope:
js:
dist/js/table-scope.js: {}
dependencies:
- core/drupal
- core/once

table-wrap:
js:
dist/js/table-wrap.js: {}
dependencies:
- core/drupal
- core/once

timeline:
js:
dist/js/timeline.js: {}
dependencies:
- core/drupal
- core/once

video-with-caption:
js:
dist/js/video-with-caption.js: {}
dependencies:
- core/drupal
- core/once
21 changes: 19 additions & 2 deletions docroot/themes/humsci/humsci_basic/humsci_basic.theme
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ function _humsci_basic_check_link_access(array &$link_items) {
}
}


/**
* Implements hook_preprocess_HOOK() for we_megamenu li.
*/
Expand Down Expand Up @@ -220,7 +219,6 @@ function humsci_basic_preprocess_we_megamenu_frontend(&$vars) {
*/
function humsci_basic_preprocess_views_view(&$variables) {
$view = $variables['view'];

switch ($view->id()) {
case 'hs_default_search':
$variables['#attached']['library'][] = 'humsci_basic/search';
Expand Down Expand Up @@ -250,3 +248,22 @@ function humsci_basic_preprocess_paragraph(&$variables) {
}
$variables['content']['field_hs_view'][0]['#heading_tag'] = $heading_tag;
}

/**
* Implements hook_preprocess_HOOK().
*/
function humsci_basic_preprocess_field(&$variables) {
$wysiwyg_types = ['text_long', 'text_with_summary'];
if (in_array($variables['field_type'], $wysiwyg_types)) {
$variables['#attached']['library'][] = 'humsci_basic/table-wrap';
$variables['#attached']['library'][] = 'humsci_basic/table-scope';
$variables['#attached']['library'][] = 'humsci_basic/page-scroll-animations';
}
}

/**
* Implements hook_preprocess_ENTITY__BUNDLE().
*/
function humsci_basic_preprocess_node__hs_event(&$variables) {
$variables['#attached']['library'][] = 'humsci_basic/addtocal';
}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import '../shared/index';

// Add Colorful and Airy specific JS below
Loading
Loading