Changeset 2174452
- Timestamp:
- 10/16/2019 06:22:49 PM (6 years ago)
- Location:
- slide/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
slide/trunk/index.css
r2173048 r2174452 69 69 } 70 70 71 .wp-block-slide-slide__background { 72 position: absolute; 73 top: 0; 74 bottom: 0; 75 left: 0; 76 right: 0; 77 } 78 71 79 .wp-block-slide-slide .fragment { 72 80 opacity: 0.5; -
slide/trunk/index.js
r2173048 r2174452 8 8 editPost, 9 9 data, 10 components 10 components, 11 blockEditor 11 12 }) => { 12 13 const { __ } = i18n; 13 14 const { registerBlockType, createBlock } = blocks; 14 const { InnerBlocks, InspectorControls,RichTextToolbarButton } = editor;15 const { RichTextToolbarButton } = editor; 15 16 const { createElement: e, Fragment } = element; 16 17 const { registerFormatType, toggleFormat } = richText; … … 18 19 const { PluginDocumentSettingPanel } = editPost; 19 20 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; 21 23 const colorKey = 'presentation-color'; 22 24 const bgColorKey = 'presentation-background-color'; … … 101 103 icon: 'art' 102 104 }, 105 e(__experimentalGradientPickerControl, { 106 onChange: (value) => updateMeta(value, bgColorKey), 107 value: meta[bgColorKey] 108 }), 103 109 e(ColorPicker, { 104 110 disableAlpha: true, … … 175 181 }); 176 182 183 const ALLOWED_MEDIA_TYPES = ['image']; 184 177 185 registerBlockType('slide/slide', { 178 186 title: __('Slide', 'slide'), … … 184 192 type: 'string' 185 193 }, 194 color: { 195 type: 'string' 196 }, 186 197 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: { 187 210 type: 'string' 188 211 } … … 197 220 e( 198 221 PanelBody, 199 { title: __('Slide Notes', 'slide') }, 222 { 223 title: __('Slide Notes', 'slide'), 224 icon: 'edit', 225 initialOpen: false 226 }, 200 227 e(TextareaControl, { 201 228 label: __('Anything you want to remember.', 'slide'), … … 206 233 e( 207 234 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 }, 209 255 e(ColorPicker, { 210 256 disableAlpha: true, … … 213 259 onChangeComplete: ({ hex: backgroundColor }) => 214 260 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 }) 215 330 }) 216 331 ) … … 221 336 className, 222 337 style: { 223 backgroundColor: attributes.backgroundColor 338 color: attributes.color || undefined, 339 backgroundColor: attributes.backgroundColor || undefined 224 340 } 225 341 }, 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 ), 226 354 e(InnerBlocks) 227 355 ) 228 356 ), 229 save: ({ attributes }) => 230 e(231 'section',232 {233 'data-background-color': attributes.backgroundColor357 save: ({ attributes }) => e( 358 'section', 359 { 360 style: { 361 color: attributes.color || undefined 234 362 }, 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 ) 237 370 }); 238 371 -
slide/trunk/index.php
r2173048 r2174452 5 5 * Plugin URI: https://wordpress.org/plugins/slide/ 6 6 * Description: Allows you to create presentations with the block editor. 7 * Version: 0.0. 37 * Version: 0.0.4 8 8 * Author: Ella van Durpe 9 9 * Author URI: https://ellavandurpe.com … … 29 29 $data = get_plugin_data( WP_PLUGIN_DIR . '/gutenberg/gutenberg.php' ); 30 30 31 if ( version_compare( $data[ 'Version' ], '6. 6' ) === -1 ) {31 if ( version_compare( $data[ 'Version' ], '6.7' ) === -1 ) { 32 32 ?> 33 33 <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> 35 35 </div> 36 36 <?php … … 56 56 'wp-data', 57 57 'wp-components', 58 'wp-block-editor', 58 59 ), 59 60 filemtime( dirname( __FILE__ ) . '/index.js' ), -
slide/trunk/readme.md
r2174102 r2174452 5 5 Requires at least: 5.2 6 6 Requires PHP: 5.6 7 Tested up to: 5. 28 Stable tag: 0.0. 37 Tested up to: 5.3 8 Stable tag: 0.0.4 9 9 License: GPL-2.0-or-later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
slide/trunk/template.php
r2171838 r2174452 8 8 content: '\f211'; 9 9 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;17 10 } 18 11
Note: See TracChangeset
for help on using the changeset viewer.