-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update code.org/promote carousels to use Swiper (#58508)
* set up swiper_page_promote.js * update stats_carousel.haml and stats_impact_carousel.haml to use swiper * clean up css
- Loading branch information
Showing
9 changed files
with
59 additions
and
219 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
apps/src/sites/code.org/pages/views/swiper_page_promote.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Adds carousel functionality to code.org/promote | ||
|
||
// This uses the Swiper library WebComponent. | ||
// See docs here: https://swiperjs.com/swiper-api#web-component. | ||
|
||
// import function to register Swiper custom elements | ||
import {register} from 'swiper/element/bundle'; | ||
// register Swiper custom elements | ||
register(); | ||
|
||
const swipers = [ | ||
document.querySelector('swiper-container.swiper-01'), | ||
document.querySelector('swiper-container.swiper-02'), | ||
]; | ||
|
||
const swiperParams = { | ||
autoHeight: false, | ||
pagination: { | ||
clickable: true, | ||
}, | ||
spaceBetween: 24, | ||
// Custom CSS | ||
injectStyles: [ | ||
` | ||
:host .swiper-pagination { | ||
position: relative; | ||
margin-top: 2rem; | ||
} | ||
`, | ||
], | ||
}; | ||
|
||
swipers.forEach(swiper => { | ||
Object.assign(swiper, swiperParams); | ||
swiper.initialize(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,8 @@ theme: responsive | |
|
||
= view 'popup_window.js' | ||
|
||
= view :swiper_page_promote | ||
|
||
:javascript | ||
var petition; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Adds Swiper to code.org/promote | ||
%script{src: webpack_asset_path('js/code.org/views/swiper_page_promote.js')} |