Plugin Directory

Changeset 2174452


Ignore:
Timestamp:
10/16/2019 06:22:49 PM (6 years ago)
Author:
iseulde
Message:

v0.0.4

Location:
slide/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • slide/trunk/index.css

    r2173048 r2174452  
    6969}
    7070
     71.wp-block-slide-slide__background {
     72    position: absolute;
     73    top: 0;
     74    bottom: 0;
     75    left: 0;
     76    right: 0;
     77}
     78
    7179.wp-block-slide-slide .fragment {
    7280    opacity: 0.5;
  • slide/trunk/index.js

    r2173048 r2174452  
    88  editPost,
    99  data,
    10   components
     10  components,
     11  blockEditor
    1112}) => {
    1213  const { __ } = i18n;
    1314  const { registerBlockType, createBlock } = blocks;
    14   const { InnerBlocks, InspectorControls, RichTextToolbarButton } = editor;
     15  const { RichTextToolbarButton } = editor;
    1516  const { createElement: e, Fragment } = element;
    1617  const { registerFormatType, toggleFormat } = richText;
     
    1819  const { PluginDocumentSettingPanel } = editPost;
    1920  const { useSelect, useDispatch, subscribe, select, dispatch } = data;
    20   const { TextareaControl, ColorPicker, PanelBody, RangeControl, TextControl, SelectControl, ToggleControl } = components;
     21  const { TextareaControl, ColorPicker, PanelBody, RangeControl, TextControl, SelectControl, ToggleControl, Button, FocalPointPicker } = components;
     22  const { MediaUpload, __experimentalGradientPickerControl, InnerBlocks, InspectorControls } = blockEditor;
    2123  const colorKey = 'presentation-color';
    2224  const bgColorKey = 'presentation-background-color';
     
    101103            icon: 'art'
    102104          },
     105          e(__experimentalGradientPickerControl, {
     106            onChange: (value) => updateMeta(value, bgColorKey),
     107            value: meta[bgColorKey]
     108          }),
    103109          e(ColorPicker, {
    104110            disableAlpha: true,
     
    175181  });
    176182
     183  const ALLOWED_MEDIA_TYPES = ['image'];
     184
    177185  registerBlockType('slide/slide', {
    178186    title: __('Slide', 'slide'),
     
    184192        type: 'string'
    185193      },
     194      color: {
     195        type: 'string'
     196      },
    186197      backgroundColor: {
     198        type: 'string'
     199      },
     200      backgroundId: {
     201        type: 'string'
     202      },
     203      backgroundUrl: {
     204        type: 'string'
     205      },
     206      focalPoint: {
     207        type: 'object'
     208      },
     209      backgroundOpacity: {
    187210        type: 'string'
    188211      }
     
    197220          e(
    198221            PanelBody,
    199             { title: __('Slide Notes', 'slide') },
     222            {
     223              title: __('Slide Notes', 'slide'),
     224              icon: 'edit',
     225              initialOpen: false
     226            },
    200227            e(TextareaControl, {
    201228              label: __('Anything you want to remember.', 'slide'),
     
    206233          e(
    207234            PanelBody,
    208             { title: __('Background', 'slide') },
     235            {
     236              title: __('Font', 'slide'),
     237              icon: 'text',
     238              initialOpen: false
     239            },
     240            e(ColorPicker, {
     241              disableAlpha: true,
     242              label: __('Color', 'slide'),
     243              color: attributes.color,
     244              onChangeComplete: ({ hex: color }) =>
     245                setAttributes({ color })
     246            })
     247          ),
     248          e(
     249            PanelBody,
     250            {
     251              title: __('Background Color', 'slide'),
     252              icon: 'art',
     253              initialOpen: false
     254            },
    209255            e(ColorPicker, {
    210256              disableAlpha: true,
     
    213259              onChangeComplete: ({ hex: backgroundColor }) =>
    214260                setAttributes({ backgroundColor })
     261            }),
     262            !!attributes.backgroundUrl && e(RangeControl, {
     263              label: __('Opacity', 'slide'),
     264              value: 100 - parseInt(attributes.backgroundOpacity, 10),
     265              min: 0,
     266              max: 100,
     267              onChange: (value) => setAttributes({
     268                backgroundOpacity: 100 - value + ''
     269              })
     270            })
     271          ),
     272          e(
     273            PanelBody,
     274            {
     275              title: __('Background Image', 'slide'),
     276              icon: 'format-image',
     277              initialOpen: false
     278            },
     279            e(MediaUpload, {
     280              onSelect: (media) => {
     281                if (!media || !media.url) {
     282                  setAttributes({
     283                    backgroundUrl: undefined,
     284                    backgroundId: undefined,
     285                    backgroundPosition: undefined,
     286                    backgroundOpacity: undefined
     287                  });
     288                  return;
     289                }
     290
     291                setAttributes({
     292                  backgroundUrl: media.url,
     293                  backgroundId: media.id
     294                });
     295              },
     296              allowedTypes: ALLOWED_MEDIA_TYPES,
     297              value: attributes.backgroundId,
     298              render: ({ open }) => e(Button, {
     299                isDefault: true,
     300                onClick: open
     301              }, attributes.backgroundUrl ? __('Change') : __('Add Background Image'))
     302            }),
     303            ' ',
     304            !!attributes.backgroundUrl && e(Button, {
     305              isDefault: true,
     306              onClick: () => {
     307                setAttributes({
     308                  backgroundUrl: undefined,
     309                  backgroundId: undefined,
     310                  backgroundPosition: undefined,
     311                  backgroundOpacity: undefined
     312                });
     313              }
     314            }, __('Remove')),
     315            e('br'), e('br'),
     316            !!attributes.backgroundUrl && e(FocalPointPicker, {
     317              label: __('Focal Point Picker'),
     318              url: attributes.backgroundUrl,
     319              value: attributes.focalPoint,
     320              onChange: (focalPoint) => setAttributes({ focalPoint })
     321            }),
     322            !!attributes.backgroundUrl && e(RangeControl, {
     323              label: __('Opacity', 'slide'),
     324              value: parseInt(attributes.backgroundOpacity, 10),
     325              min: 0,
     326              max: 100,
     327              onChange: (value) => setAttributes({
     328                backgroundOpacity: value + ''
     329              })
    215330            })
    216331          )
     
    221336            className,
    222337            style: {
    223               backgroundColor: attributes.backgroundColor
     338              color: attributes.color || undefined,
     339              backgroundColor: attributes.backgroundColor || undefined
    224340            }
    225341          },
     342          e(
     343            'div',
     344            {
     345              className: 'wp-block-slide-slide__background',
     346              style: {
     347                backgroundImage: attributes.backgroundUrl ? `url("${attributes.backgroundUrl}")` : undefined,
     348                backgroundSize: 'cover',
     349                backgroundPosition: attributes.focalPoint ? `${attributes.focalPoint.x * 100}% ${attributes.focalPoint.y * 100}%` : '50% 50%',
     350                opacity: attributes.backgroundOpacity ? attributes.backgroundOpacity / 100 : undefined
     351              }
     352            }
     353          ),
    226354          e(InnerBlocks)
    227355        )
    228356      ),
    229     save: ({ attributes }) =>
    230       e(
    231         'section',
    232         {
    233           'data-background-color': attributes.backgroundColor
     357    save: ({ attributes }) => e(
     358      'section',
     359      {
     360        style: {
     361          color: attributes.color || undefined
    234362        },
    235         e(InnerBlocks.Content)
    236       )
     363        'data-background-color': attributes.backgroundColor || undefined,
     364        'data-background-image': attributes.backgroundUrl ? attributes.backgroundUrl : undefined,
     365        'data-background-position': attributes.focalPoint ? `${attributes.focalPoint.x * 100}% ${attributes.focalPoint.y * 100}%` : undefined,
     366        'data-background-opacity': attributes.backgroundOpacity ? attributes.backgroundOpacity / 100 : undefined
     367      },
     368      e(InnerBlocks.Content)
     369    )
    237370  });
    238371
  • slide/trunk/index.php

    r2173048 r2174452  
    55 * Plugin URI:  https://wordpress.org/plugins/slide/
    66 * Description: Allows you to create presentations with the block editor.
    7  * Version:     0.0.3
     7 * Version:     0.0.4
    88 * Author:      Ella van Durpe
    99 * Author URI:  https://ellavandurpe.com
     
    2929    $data = get_plugin_data( WP_PLUGIN_DIR . '/gutenberg/gutenberg.php' );
    3030
    31     if ( version_compare( $data[ 'Version' ], '6.6' ) === -1 ) {
     31    if ( version_compare( $data[ 'Version' ], '6.7' ) === -1 ) {
    3232        ?>
    3333        <div class="notice notice-error is-dismissible">
    34             <p><?php _e( '"Slide" needs "Gutenberg" version 6.6. Please update.', 'slide' ); ?></p>
     34            <p><?php _e( '"Slide" needs "Gutenberg" version 6.7. Please update.', 'slide' ); ?></p>
    3535        </div>
    3636        <?php
     
    5656            'wp-data',
    5757            'wp-components',
     58            'wp-block-editor',
    5859        ),
    5960        filemtime( dirname( __FILE__ ) . '/index.js' ),
  • slide/trunk/readme.md

    r2174102 r2174452  
    55    Requires at least: 5.2
    66    Requires PHP:      5.6
    7     Tested up to:      5.2
    8     Stable tag:        0.0.3
     7    Tested up to:      5.3
     8    Stable tag:        0.0.4
    99    License:           GPL-2.0-or-later
    1010    License URI:       http://www.gnu.org/licenses/gpl-2.0.html
  • slide/trunk/template.php

    r2171838 r2174452  
    88            content: '\f211';
    99            top: 3px;
    10         }
    11 
    12         .dashicons, .dashicons-before:before {
    13             font-family: dashicons !important;
    14             font-style: normal !important;
    15             padding: 10px 30px 10px 0 !important;
    16             color: #eb0569;
    1710        }
    1811
Note: See TracChangeset for help on using the changeset viewer.