Plugin Directory

Changeset 2175288


Ignore:
Timestamp:
10/17/2019 08:53:03 PM (6 years ago)
Author:
iseulde
Message:

v0.0.8

Location:
slide/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • slide/trunk/index.js

    r2175185 r2175288  
    1111  url,
    1212  codeEditor
    13 }) => {
     13}, FontPicker) => {
    1414  const { __ } = i18n;
    1515  const { registerBlockType, createBlock } = blocks;
     
    1919  const { PluginDocumentSettingPanel } = editPost;
    2020  const { useSelect, useDispatch, subscribe, select, dispatch } = data;
    21   const { TextareaControl, ColorPicker, PanelBody, RangeControl, TextControl, SelectControl, ToggleControl, Button, FocalPointPicker, ExternalLink } = components;
     21  const { TextareaControl, ColorPicker, PanelBody, RangeControl, SelectControl, ToggleControl, Button, FocalPointPicker, ExternalLink } = components;
    2222  const { MediaUpload, __experimentalGradientPickerControl, InnerBlocks, InspectorControls, RichTextToolbarButton } = blockEditor;
    2323  const { addQueryArgs } = url;
     
    3232  const fontSizeKey = 'presentation-font-size';
    3333  const fontFamilyKey = 'presentation-font-family';
     34  const fontFamilyUrlKey = 'presentation-font-url-family';
    3435  const transitionKey = 'presentation-transition';
    3536  const transitionSpeedKey = 'presentation-transition-speed';
     
    110111      };
    111112
     113      console.log(meta[fontFamilyUrlKey]);
     114
    112115      return [
    113116        ...Object.keys(rules).map((key) => {
     
    126129        }),
    127130        e('style', null, meta[cssKey]),
     131        !!meta[fontFamilyUrlKey] && e(
     132          'style',
     133          null,
     134          `@import url("${meta[fontFamilyUrlKey]}")`
     135        ),
    128136        e(
    129137          PluginDocumentSettingPanel,
     
    141149            onChange: (value) => updateMeta(value + '', fontSizeKey)
    142150          }),
    143           e(TextControl, {
     151          e(FontPicker, {
    144152            label: __('Font Family', 'slide'),
    145             help: __('E.g. "Helvetica, sans-serif" or "Georgia, serif"', 'slide'),
    146153            value: meta[fontFamilyKey],
    147154            onChange: (value) => updateMeta(value, fontFamilyKey)
     
    638645    window.requestAnimationFrame(resize);
    639646  }
    640 })(window.wp);
     647})(
     648  window.wp,
     649  (({
     650    i18n: { __ },
     651    element: { createElement: e },
     652    components: { BaseControl },
     653    compose: { withInstanceId },
     654    data: { select, dispatch }
     655  }) => {
     656    const fontFamilyUrlKey = 'presentation-font-url-family';
     657    const googleFonts = {
     658      'Abril Fatface': { weight: ['400'] },
     659      Anton: { weight: ['400'] },
     660      Arvo: { weight: ['400', '700'] },
     661      Asap: { weight: ['400', '500', '600', '700'] },
     662      'Barlow Condensed': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] },
     663      Barlow: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] },
     664      'Cormorant Garamond': { weight: ['300', '400', '500', '600', '700'] },
     665      Faustina: { weight: ['400', '500', '600', '700'] },
     666      'Fira Sans': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] },
     667      'IBM Plex Sans': { weight: ['100', '200', '300', '400', '500', '600', '700'] },
     668      Inconsolata: { weight: ['400', '700'] },
     669      Heebo: { weight: ['100', '300', '400', '500', '700', '800', '900'] },
     670      Karla: { weight: ['400', '700'] },
     671      Lato: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] },
     672      Lora: { weight: ['400', '700'] },
     673      Merriweather: { weight: ['300', '400', '500', '600', '700', '800', '900'] },
     674      Montserrat: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] },
     675      'Noto Sans': { weight: ['400', '700'] },
     676      'Noto Serif': { weight: ['400', '700'] },
     677      'Open Sans': { weight: ['300', '400', '500', '600', '700', '800'] },
     678      Oswald: { weight: ['200', '300', '400', '500', '600', '700'] },
     679      'Playfair Display': { weight: ['400', '700', '900'] },
     680      'PT Serif': { weight: ['400', '700'] },
     681      Roboto: { weight: ['100', '300', '400', '500', '700', '900'] },
     682      Rubik: { weight: ['300', '400', '500', '700', '900'] },
     683      Tajawal: { weight: ['200', '300', '400', '500', '700', '800', '900'] },
     684      Ubuntu: { weight: ['300', '400', '500', '700'] },
     685      Yrsa: { weight: ['300', '400', '500', '600', '700'] }
     686    };
     687
     688    return withInstanceId(({ label, value, help, instanceId, onChange, className, ...props }) => {
     689      const id = `inspector-coblocks-font-family-${instanceId}`;
     690      const systemFonts = [
     691        { value: '', label: __('Default') },
     692        { value: 'Arial', label: 'Arial' },
     693        { value: 'Helvetica', label: 'Helvetica' },
     694        { value: 'Times New Roman', label: 'Times New Roman' },
     695        { value: 'Georgia', label: 'Georgia' }
     696      ];
     697      const fonts = [];
     698
     699      // Add Google Fonts
     700      Object.keys(googleFonts).map((k) => {
     701        fonts.push(
     702          { value: k, label: k }
     703        );
     704      });
     705
     706      systemFonts.reverse().map((font) => {
     707        fonts.unshift(font);
     708      });
     709
     710      const onChangeValue = ({ target: { value } }) => {
     711        const googleFontsAttr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
     712        const isSystemFont = systemFonts.filter(function (font) {
     713          return font.label === value;
     714        }).length > 0;
     715
     716        let url = '';
     717
     718        if (!isSystemFont) {
     719          url = 'https://fonts.googleapis.com/css?family=' + value.replace(/ /g, '+') + googleFontsAttr;
     720        }
     721
     722        onChange(value);
     723        dispatch('core/editor').editPost({
     724          meta: {
     725            [fontFamilyUrlKey]: url
     726          }
     727        });
     728      };
     729
     730      return (
     731        e(
     732          BaseControl,
     733          {
     734            label,
     735            id,
     736            help,
     737            className
     738          },
     739          e(
     740            'select',
     741            {
     742              id,
     743              className: 'components-select-control__input components-select-control__input--coblocks-fontfamily',
     744              onChange: onChangeValue,
     745              'aria-describedby': help ? `${id}__help` : undefined,
     746              ...props
     747            },
     748            fonts.map((option, index) =>
     749              e('option', {
     750                key: `${option.label}-${option.value}-${index}`,
     751                value: option.value,
     752                selected: value === option.value ? 'selected' : ''
     753              }, option.label)
     754            )
     755          )
     756        )
     757      );
     758    });
     759  })(window.wp)
     760);
  • slide/trunk/index.php

    r2175185 r2175288  
    55 * Plugin URI:  https://wordpress.org/plugins/slide/
    66 * Description: Allows you to create presentations with the block editor.
    7  * Version:     0.0.7
     7 * Version:     0.0.8
    88 * Author:      Ella van Durpe
    99 * Author URI:  https://ellavandurpe.com
     
    5959            'wp-block-editor',
    6060            'wp-url',
     61            'wp-compose',
    6162        ),
    6263        filemtime( dirname( __FILE__ ) . '/index.js' ),
     
    134135    }
    135136
     137    $font_url = get_post_meta( get_the_ID(), 'presentation-font-family-url', true );
     138
     139    if ( $font_url ) {
     140        wp_enqueue_style(
     141            'slide-default-font',
     142            $font_url,
     143            array()
     144        );
     145    }
     146
    136147    wp_enqueue_style(
    137148        'slide-common',
  • slide/trunk/readme.md

    r2175185 r2175288  
    66    Requires PHP:      5.6
    77    Tested up to:      5.3
    8     Stable tag:        0.0.7
     8    Stable tag:        0.0.8
    99    License:           GPL-2.0-or-later
    1010    License URI:       http://www.gnu.org/licenses/gpl-2.0.html
  • slide/trunk/register.php

    r2175129 r2175288  
    6161    'font-size',
    6262    'font-family',
     63    'font-family-url',
    6364    'transition',
    6465    'transition-speed',
Note: See TracChangeset for help on using the changeset viewer.