From d3b88e767d76c83aacecb2f0e1b438867234b8f6 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Mon, 9 Nov 2020 19:43:47 +0100 Subject: [PATCH] Done #4032 @3 --- .../src/Elementor/Widgets/SolutionGrid.php | 11 +++- wp-content/themes/STR/package.json | 1 + .../STR/resources/assets/images/print.svg | 32 ++++++++++ .../STR/resources/assets/images/solution.svg | 61 +++++++++++++++++++ .../resources/assets/scripts/solution-grid.js | 10 +++ .../assets/styles/widgets/solution-grid.styl | 24 +++++++- .../views/widgets/solution-grid.blade.php | 12 +++- wp-content/themes/STR/tailwind.config.js | 3 + wp-content/themes/STR/webpack.mix.js | 1 + wp-content/themes/STR/yarn.lock | 5 ++ 10 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 wp-content/themes/STR/resources/assets/images/print.svg create mode 100644 wp-content/themes/STR/resources/assets/images/solution.svg create mode 100644 wp-content/themes/STR/resources/assets/scripts/solution-grid.js diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/SolutionGrid.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/SolutionGrid.php index 347d5be..df5c653 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/SolutionGrid.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/SolutionGrid.php @@ -6,6 +6,7 @@ use Elementor\Controls_Manager; use Elementor\Utils; use function Roots\view; +use function Roots\asset; class SolutionGrid extends _Base { @@ -34,7 +35,8 @@ class SolutionGrid extends _Base { * @return array Widget scripts dependencies. */ public function get_script_depends() { - return []; + wp_enqueue_script('solution-grid', asset('/scripts/solution-grid.js'), ['jquery'], false, true); + return ['solution-grid']; } /** * Register the widget controls. @@ -76,6 +78,13 @@ class SolutionGrid extends _Base { 'url' => Utils::get_placeholder_image_src(), ], ], + [ + 'name' => 'pdf', + 'label' => __('Printable PDF', 'cube'), + 'label_block' => true, + 'type' => 'file-select', // Using the file-select-control-for-elementor plugin + 'placeholder' => __('PDF URL'), + ], ], 'title_field' => '<# var pName = puzzle.url.split("/").pop().split(".").shift(); sName = solution.url.split("/").pop().split(".").shift(); #>
{{{ pName }}}
{{{ sName }}}
', ] diff --git a/wp-content/themes/STR/package.json b/wp-content/themes/STR/package.json index 8f9bf32..95b6542 100644 --- a/wp-content/themes/STR/package.json +++ b/wp-content/themes/STR/package.json @@ -39,6 +39,7 @@ "lost": "^8.3.1", "mix-tailwindcss": "^1.0.2", "npm-run-all": "^4.1", + "print-js": "^1.5.0", "purgecss-with-wordpress": "^2.1.0", "rimraf": "^3.0.2", "rupture": "^0.7.1", diff --git a/wp-content/themes/STR/resources/assets/images/print.svg b/wp-content/themes/STR/resources/assets/images/print.svg new file mode 100644 index 0000000..d6cbf98 --- /dev/null +++ b/wp-content/themes/STR/resources/assets/images/print.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wp-content/themes/STR/resources/assets/images/solution.svg b/wp-content/themes/STR/resources/assets/images/solution.svg new file mode 100644 index 0000000..49a61b6 --- /dev/null +++ b/wp-content/themes/STR/resources/assets/images/solution.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wp-content/themes/STR/resources/assets/scripts/solution-grid.js b/wp-content/themes/STR/resources/assets/scripts/solution-grid.js new file mode 100644 index 0000000..0dbdd92 --- /dev/null +++ b/wp-content/themes/STR/resources/assets/scripts/solution-grid.js @@ -0,0 +1,10 @@ +import printJS from 'print-js' + +$(document).on('click', '[data-print-solution]', function(event) { + event.preventDefault(); + let PDF = $(this).attr('href'); + + if (PDF !== '') { + printJS(PDF); + } +}); diff --git a/wp-content/themes/STR/resources/assets/styles/widgets/solution-grid.styl b/wp-content/themes/STR/resources/assets/styles/widgets/solution-grid.styl index 10d8fbb..38c75b0 100644 --- a/wp-content/themes/STR/resources/assets/styles/widgets/solution-grid.styl +++ b/wp-content/themes/STR/resources/assets/styles/widgets/solution-grid.styl @@ -9,8 +9,30 @@ +below(768px) grid-template-columns: repeat(2, 1fr) - img + &-item border-radius: 1vw + overflow: hidden + position: relative +above($content-max-width) border-radius: 16px + + &:hover + .solution-grid-overlay + opacity: 1 + pointer-events: auto + + &-overlay + @apply opacity-0 pointer-events-none // only visible on hover + @apply absolute top-0 left-0 w-full h-full + @apply flex items-center justify-center + @apply bg-dark-blue bg-opacity-80 + transition: opacity 0.3s + + &-icon + box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.7) !important + border-radius: 50% !important + transition: transform 0.2s ease-out + + &:hover + transform: scale(1.1) diff --git a/wp-content/themes/STR/resources/views/widgets/solution-grid.blade.php b/wp-content/themes/STR/resources/views/widgets/solution-grid.blade.php index 6002c3e..32fe11a 100644 --- a/wp-content/themes/STR/resources/views/widgets/solution-grid.blade.php +++ b/wp-content/themes/STR/resources/views/widgets/solution-grid.blade.php @@ -1,7 +1,15 @@
@foreach($items as $item) - + @endforeach
diff --git a/wp-content/themes/STR/tailwind.config.js b/wp-content/themes/STR/tailwind.config.js index b5762dd..10782e3 100644 --- a/wp-content/themes/STR/tailwind.config.js +++ b/wp-content/themes/STR/tailwind.config.js @@ -8,6 +8,9 @@ module.exports = { colors: { 'dark-blue': '#0c2448', }, + backgroundOpacity: { + '80': '0.8', + }, }, }, variants: {}, diff --git a/wp-content/themes/STR/webpack.mix.js b/wp-content/themes/STR/webpack.mix.js index 5e941da..42dd55b 100644 --- a/wp-content/themes/STR/webpack.mix.js +++ b/wp-content/themes/STR/webpack.mix.js @@ -44,6 +44,7 @@ mix.stylus('resources/assets/styles/app.styl', 'styles', { mix.stylus('resources/assets/styles/editor.styl', 'styles'); mix.js('resources/assets/scripts/app.js', 'scripts') + .js('resources/assets/scripts/solution-grid.js', 'scripts') .js('resources/assets/scripts/customizer.js', 'scripts') .blocks('resources/assets/scripts/editor.js', 'scripts') .extract(); diff --git a/wp-content/themes/STR/yarn.lock b/wp-content/themes/STR/yarn.lock index cdd9fe3..6c33025 100644 --- a/wp-content/themes/STR/yarn.lock +++ b/wp-content/themes/STR/yarn.lock @@ -7097,6 +7097,11 @@ pretty-hrtime@^1.0.3: resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= +print-js@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/print-js/-/print-js-1.5.0.tgz#6f7e68c6d542ed5eeb535b2ad2469fc24fc9888c" + integrity sha512-Vy7UG2NGpNRMR1CcwoaK813tM3uUB0I4vTylxmFLXMb77gJb+6GB5aUmeasyT+CetddbmXUZsHr9BF+0VDN/fg== + private@^0.1.8, private@~0.1.5: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" -- 2.39.5