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

Internal: Playing cards #29312

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c471131
ED13846 initial
max-zu Nov 18, 2024
7189b1d
ED13846 added styling configuration
max-zu Nov 18, 2024
8b5cd1a
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
53e49b6
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
52ada9f
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
311e629
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
02d2fed
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
cc41b58
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
17b6d81
Merge branch 'main' into playing-cards
elementorbot Nov 18, 2024
8fef682
Merge branch 'main' into playing-cards
elementorbot Nov 19, 2024
23411d8
ED13846 fixed handler and scripts initialization
max-zu Nov 19, 2024
4abee86
Merge branch 'main' into playing-cards
elementorbot Nov 19, 2024
379c0cd
Merge branch 'main' into playing-cards
elementorbot Nov 19, 2024
22bcfd5
ED13846 fixed handler and scripts initialization
max-zu Nov 19, 2024
7e5f8b9
ED13846 updated styles, added animations
max-zu Nov 19, 2024
d4af63c
Merge branch 'main' into playing-cards
elementorbot Nov 19, 2024
c1c31af
Update modules/playing-cards/widgets/playing-cards-widget.php
max-zu Nov 19, 2024
be085e2
Merge branch 'main' into playing-cards
elementorbot Nov 19, 2024
023c807
ED13846 added tests
max-zu Nov 19, 2024
c7d1712
ED13846 updated tests
max-zu Nov 19, 2024
247cade
ED13846 updated tests
max-zu Nov 19, 2024
408b6af
ED13846 updated tests
max-zu Nov 19, 2024
3b91fb0
ED13846 added snapshot
max-zu Nov 20, 2024
84a72b8
Update modules/playing-cards/assets/js/frontend/handlers/playing-card…
max-zu Nov 20, 2024
14e78cb
Update modules/playing-cards/assets/js/frontend/handlers/playing-card…
max-zu Nov 20, 2024
1b70c42
ED13846 updated styles, tests
max-zu Nov 20, 2024
466f070
ED13846 added comments
max-zu Nov 20, 2024
c2c634d
Update modules/playing-cards/widgets/playing-cards.php
max-zu Nov 20, 2024
8a68753
Update modules/playing-cards/widgets/playing-cards.php
max-zu Nov 20, 2024
2b46e6d
Update modules/playing-cards/module.php
max-zu Nov 20, 2024
9365aa0
ED13846 added comments
max-zu Nov 20, 2024
529db03
Merge branch 'main' into playing-cards
elementorbot Nov 20, 2024
7c40012
Merge branch 'main' into playing-cards
elementorbot Nov 20, 2024
00ce11b
Merge branch 'main' into playing-cards
elementorbot Nov 21, 2024
4f06df9
ED13846 fixed codestyle
max-zu Nov 21, 2024
7de1d80
ED13846 updated tests
max-zu Nov 21, 2024
7e788bd
Merge branch 'main' into playing-cards
elementorbot Nov 21, 2024
62cd3b0
ED13846 updated tests
max-zu Nov 21, 2024
aa1b0e4
ED13846 updated tests
max-zu Nov 21, 2024
71feb49
Merge branch 'main' into playing-cards
elementorbot Nov 21, 2024
35437e3
ED13846 updated tests
max-zu Nov 22, 2024
a375e81
Merge branch 'main' into playing-cards
max-zu Nov 22, 2024
23980ed
ED13846 updated tests
max-zu Nov 22, 2024
0c146e3
Merge branch 'main' into playing-cards
max-zu Nov 25, 2024
305028d
ED13846 updated tests
max-zu Nov 25, 2024
7b99172
ED12487 updated click handler
max-zu Nov 26, 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
1 change: 1 addition & 0 deletions assets/dev/js/frontend/elements-handlers-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function( $ ) {
'image-carousel.default': () => import( /* webpackChunkName: 'image-carousel' */ './handlers/image-carousel' ),
'text-editor.default': () => import( /* webpackChunkName: 'text-editor' */ './handlers/text-editor' ),
'wp-widget-media_audio.default': () => import( /* webpackChunkName: 'wp-audio' */ './handlers/wp-audio' ),
'playing-cards.default': () => import( /* webpackChunkName: 'playing-cards' */ 'elementor/modules/playing-cards/assets/js/frontend/handlers/playing-cards-handler' ),
};

if ( elementorFrontendConfig.experimentalFeatures[ 'nested-elements' ] ) {
Expand Down
1 change: 1 addition & 0 deletions core/modules-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function get_modules_names() {
'global-classes',
'wc-product-editor',
'checklist',
'playing-cards',
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export default class PlayingCardHandler extends elementorModules.frontend.handlers.Base {
onInit() {
this.clickHandler = this.onClick.bind( this );
super.onInit();

this.elements = this.getDefaultElements();
}

getDefaultSettings() {
const cardItemPrefix = 'e-playing-cards-item';

Check failure on line 11 in modules/playing-cards/assets/js/frontend/handlers/playing-cards-handler.js

View workflow job for this annotation

GitHub Actions / JS-Lint

Trailing spaces not allowed
return {
selectors: {
playingCardContainer: '.e-playing-cards',
playingCardItem: `.${ cardItemPrefix }`,
},
classes: {
playingCardBack: `${ cardItemPrefix }-back_suit`,
},
};
}

getDefaultElements() {
const { selectors } = this.getSettings();

return { $playingCardContainer: this.findElement( selectors.playingCardContainer ) };
}

bindEvents() {
this.elements.$playingCardContainer.on( 'click', this.clickHandler );
}
max-zu marked this conversation as resolved.
Show resolved Hide resolved

unbindEvents() {
this.elements.$playingCardContainer.off();
}

onClick( e ) {
const { selectors, classes } = this.getSettings();
const clickedCard = e.target.closest( selectors.playingCardItem );

if ( clickedCard ) {
clickedCard.classList.toggle( classes.playingCardBack );
}
}
}
1 change: 1 addition & 0 deletions modules/playing-cards/assets/scss/frontend.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "widgets/playing-cards";
77 changes: 77 additions & 0 deletions modules/playing-cards/assets/scss/widgets/playing-cards.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.e-playing-cards {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: var(--e-playing-cards-gap);

&-item {
width: var(--e-playing-card-width);
aspect-ratio: .5;
border-radius: var(--e-playing-card-border-radius);
border: 2px solid #ddd;
box-shadow: 1px 3px 5px rgba(184, 184, 184, 0.75);
transform-style: preserve-3d;
transition: transform 0.6s ease;
position: relative;

&.e-playing-cards-item-back_suit {
transform: rotateY(180deg);
}

&::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
border-radius: var(--e-playing-card-border-radius);
background: var(--e-playing-card-background-back-url) no-repeat center center;
background-size: cover;
backface-visibility: hidden;
transform: rotateY(180deg);
}

&-face {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
border-radius: var(--e-playing-card-border-radius);
background: linear-gradient(145deg, #f4f4f4, #e0e0e0);
backface-visibility: hidden;
position: absolute;
font-size: 3rem;
font-weight: bold;
}

&-top {
align-self: flex-start;
}

&-center {
font-size: 5rem;
font-weight: bold;
transition: color 0.3s ease, transform 0.3s ease;

&:hover {
transform: scale(1.1);
color: #007acc;
}
}

&-bottom {
align-self: flex-end;
}
}

.red_suit {
color: red;
text-shadow: 1px 1px 3px rgba(255, 0, 0, 0.5);
}

.black_suit {
color: black;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}
}
50 changes: 50 additions & 0 deletions modules/playing-cards/module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
namespace Elementor\Modules\PlayingCards;

use Elementor\Core\Base\Module AS BaseModule;
use Elementor\Plugin;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

class Module extends BaseModule {
public function get_name() {
return 'playing-cards';
}

protected function get_widgets() {
return [
'Playing_Cards',
];
}
public function __construct() {
max-zu marked this conversation as resolved.
Show resolved Hide resolved
parent::__construct();
max-zu marked this conversation as resolved.
Show resolved Hide resolved
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] );
add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] );
}

public function register_styles() {
$direction_suffix = is_rtl() ? '-rtl' : '';
$has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints();

$widget_style_name = 'widget-playing-cards';

wp_register_style(
$widget_style_name,
$this->get_frontend_file_url( "{$widget_style_name}{$direction_suffix}.min.css", $has_custom_breakpoints ),
[ 'elementor-frontend' ],
ELEMENTOR_VERSION
);
}

public function register_scripts() {
wp_register_script(
'playing-cards-frontend',
$this->get_js_assets_url( 'playing-cards' ),
[ 'elementor-frontend' ],
ELEMENTOR_VERSION,
true
);
}
}
Loading
Loading