Skip to content

Instantly share code, notes, and snippets.

@ndeet
Last active February 8, 2018 14:41
Show Gist options
  • Save ndeet/8998990 to your computer and use it in GitHub Desktop.
Save ndeet/8998990 to your computer and use it in GitHub Desktop.

Revisions

  1. ndeet revised this gist Feb 18, 2014. 2 changed files with 9 additions and 9 deletions.
    14 changes: 7 additions & 7 deletions color-preset.inc
    Original file line number Diff line number Diff line change
    @@ -9,15 +9,15 @@ $plugin = array(
    'title' => t('Color preset'),
    'description' => t('Set a color preset.'),
    // Achtung: render pane wird im Methodenaufruf mit "theme_" prefixed!
    'render pane' => 'ohm_color_preset_style_render_pane',
    'pane settings form' => 'ohm_color_preset_settings_form',
    'category' => t('Ohm'),
    'render pane' => 'MYTHEME_color_preset_style_render_pane',
    'pane settings form' => 'MYTHEME_color_preset_settings_form',
    'category' => t('MYTHEME'),
    );

    /**
    * Renders the pane content.
    */
    function theme_ohm_color_preset_style_render_pane($content) {
    function theme_MYTHEME_color_preset_style_render_pane($content) {
    if (!empty($content)) {
    return theme('panels_pane', $content);
    }
    @@ -26,13 +26,13 @@ function theme_ohm_color_preset_style_render_pane($content) {
    /**
    * Color preset settings form.
    */
    function ohm_color_preset_settings_form($style_settings) {
    function MYTHEME_color_preset_settings_form($style_settings) {
    $form = array();
    $form['preset_color'] = array(
    '#type' => 'select',
    '#title' => t('Choose color preset'),
    '#default_value' => (isset($style_settings['preset_color'])) ? $style_settings['preset_color'] : FALSE,
    '#options' => theme_ohm_color_preset_colors(),
    '#options' => theme_MYTHEME_color_preset_colors(),
    );

    return $form;
    @@ -42,7 +42,7 @@ function ohm_color_preset_settings_form($style_settings) {
    * Available color presets.
    * @return array
    */
    function theme_ohm_color_preset_colors() {
    function theme_MYTHEME_color_preset_colors() {
    return array(
    'grey' => t('Grey'),
    'yellow' => t('Yellow'),
    4 changes: 2 additions & 2 deletions panels-pane.preprocess.inc
    Original file line number Diff line number Diff line change
    @@ -7,12 +7,12 @@
    /**
    * Implements hook_preprocess_panels_pane().
    */
    function ohm_preprocess_panels_pane(&$variables) {
    function MYTHEME_preprocess_panels_pane(&$variables) {

    // Prüfen ob unser Style Plugin aktiv ist.
    if(isset($variables['pane']->style['style'])) {
    if($variables['pane']->style['style'] === 'color_presets') {
    // Setzt die in o.g. theme_ohm_preset_colors definierte Farbe als CSS-Klasse
    // Setzt die in o.g. theme_MYTHEME_preset_colors definierte Farbe als CSS-Klasse
    $variables['attributes_array']['class'][] = $variables['pane']->style['settings']['preset_color'];
    }
    }
  2. ndeet revised this gist Feb 14, 2014. 2 changed files with 2 additions and 6 deletions.
    4 changes: 1 addition & 3 deletions color-preset.inc
    Original file line number Diff line number Diff line change
    @@ -49,6 +49,4 @@ function theme_ohm_color_preset_colors() {
    'pink' => t('Pink')
    // etc.
    );
    }

    ?>
    }
    4 changes: 1 addition & 3 deletions panels-pane.preprocess.inc
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,4 @@ function ohm_preprocess_panels_pane(&$variables) {
    }

    return $variables;
    }

    ?>
    }
  3. ndeet revised this gist Feb 14, 2014. 2 changed files with 7 additions and 3 deletions.
    6 changes: 4 additions & 2 deletions color-preset.inc
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    <?php
    <?php
    /**
    * @file
    * Custom panels color presets.
    @@ -49,4 +49,6 @@ function theme_ohm_color_preset_colors() {
    'pink' => t('Pink')
    // etc.
    );
    }
    }

    ?>
    4 changes: 3 additions & 1 deletion panels-pane.preprocess.inc
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,6 @@ function ohm_preprocess_panels_pane(&$variables) {
    }

    return $variables;
    }
    }

    ?>
  4. ndeet revised this gist Feb 14, 2014. No changes.
  5. ndeet created this gist Feb 14, 2014.
    2 changes: 2 additions & 0 deletions MYTHEME.info
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    ; Register Style Plugin directory
    plugins[panels][styles] = panels/styles
    19 changes: 19 additions & 0 deletions _color_preset.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    .grey {
    background-color: #CCC;
    color: black;
    }

    .yellow {
    background-color: yellow;
    border: 1px solid red;
    }

    .pink {
    background-color: deeppink;
    color: white;
    font-size: 120%;

    h2 {
    text-transform: uppercase;
    }
    }
    52 changes: 52 additions & 0 deletions color-preset.inc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    <?php
    /**
    * @file
    * Custom panels color presets.
    */

    // Plugin registrieren
    $plugin = array(
    'title' => t('Color preset'),
    'description' => t('Set a color preset.'),
    // Achtung: render pane wird im Methodenaufruf mit "theme_" prefixed!
    'render pane' => 'ohm_color_preset_style_render_pane',
    'pane settings form' => 'ohm_color_preset_settings_form',
    'category' => t('Ohm'),
    );

    /**
    * Renders the pane content.
    */
    function theme_ohm_color_preset_style_render_pane($content) {
    if (!empty($content)) {
    return theme('panels_pane', $content);
    }
    }

    /**
    * Color preset settings form.
    */
    function ohm_color_preset_settings_form($style_settings) {
    $form = array();
    $form['preset_color'] = array(
    '#type' => 'select',
    '#title' => t('Choose color preset'),
    '#default_value' => (isset($style_settings['preset_color'])) ? $style_settings['preset_color'] : FALSE,
    '#options' => theme_ohm_color_preset_colors(),
    );

    return $form;
    }

    /**
    * Available color presets.
    * @return array
    */
    function theme_ohm_color_preset_colors() {
    return array(
    'grey' => t('Grey'),
    'yellow' => t('Yellow'),
    'pink' => t('Pink')
    // etc.
    );
    }
    21 changes: 21 additions & 0 deletions panels-pane.preprocess.inc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <?php
    /**
    * @file
    * Preprocess panels color presets.
    */

    /**
    * Implements hook_preprocess_panels_pane().
    */
    function ohm_preprocess_panels_pane(&$variables) {

    // Prüfen ob unser Style Plugin aktiv ist.
    if(isset($variables['pane']->style['style'])) {
    if($variables['pane']->style['style'] === 'color_presets') {
    // Setzt die in o.g. theme_ohm_preset_colors definierte Farbe als CSS-Klasse
    $variables['attributes_array']['class'][] = $variables['pane']->style['settings']['preset_color'];
    }
    }

    return $variables;
    }