You are here

function responsive_menu_generate_breakpoint_css in Responsive and off-canvas menu 8.2

Same name and namespace in other branches
  1. 8.3 responsive_menu.module \responsive_menu_generate_breakpoint_css()
  2. 4.4.x responsive_menu.module \responsive_menu_generate_breakpoint_css()
  3. 4.0.x responsive_menu.module \responsive_menu_generate_breakpoint_css()
  4. 4.1.x responsive_menu.module \responsive_menu_generate_breakpoint_css()
  5. 4.3.x responsive_menu.module \responsive_menu_generate_breakpoint_css()

Generates the breakpoint css in the public directory.

Parameters

string $breakpoint: The breakpoint string to store in the css file.

2 calls to responsive_menu_generate_breakpoint_css()
responsive_menu_page_bottom in ./responsive_menu.module
Implements hook_page_bottom().
SettingsForm::submitForm in src/Form/SettingsForm.php
Form submission handler.

File

./responsive_menu.module, line 432
Contains procedural code.

Code

function responsive_menu_generate_breakpoint_css($breakpoint) {

  // Fetch the wrapping element (nav, div) from the config.
  $element = \Drupal::config('responsive_menu.settings')
    ->get('horizontal_wrapping_element');

  // Construct the css to be saved into a file. This needs to be more specific
  // than the module's css otherwise it won't take effect.
  $css = '@media ' . $breakpoint . ' { ' . $element . '.responsive-menu-block-wrapper { display: block; } .responsive-menu-toggle-wrapper.responsive-menu-toggle { display: none; } }';
  $path = _get_breakpoint_css_filepath();

  // Ensure the directory exists, if not create it.
  if (!file_exists($path)) {
    file_prepare_directory($path, FILE_CREATE_DIRECTORY);
  }
  $filepath = $path . RESPONSIVE_MENU_BREAKPOINT_FILENAME;

  // Save out the css file.
  file_unmanaged_save_data($css, $filepath, FILE_EXISTS_REPLACE);
}