styleguide.styleguide.inc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. // $Id: styleguide.styleguide.inc,v 1.7 2010/10/22 20:59:56 agentken Exp $
  3. /**
  4. * Implements hook_styleguide().
  5. */
  6. function styleguide_styleguide() {
  7. $items['a'] = array(
  8. 'title' => t('Link'),
  9. 'content' => ucfirst(styleguide_word(3)) . ' ' . l(styleguide_word(3), 'node') . ' ' . styleguide_word(4) . '.',
  10. );
  11. $items['em'] = array(
  12. 'title' => t('Emphasis'),
  13. 'content' => ucfirst(styleguide_word(3)) . ' <em>' . styleguide_word(3) . '</em> ' . styleguide_word(4) . '.',
  14. );
  15. $items['strong'] = array(
  16. 'title' => t('Strong'),
  17. 'content' => ucfirst(styleguide_word(3)) . ' <strong>' . styleguide_word(3) . '</strong> ' . styleguide_word(4) . '.',
  18. );
  19. $items['ul'] = array(
  20. 'title' => t('Unordered list'),
  21. 'theme' => 'item_list',
  22. 'variables' => array('items' => styleguide_list(), 'type' => 'ul'),
  23. 'group' => t('Lists'),
  24. );
  25. $items['ol'] = array(
  26. 'title' => t('Ordered list'),
  27. 'theme' => 'item_list',
  28. 'variables' => array('items' => styleguide_list(), 'type' => 'ol'),
  29. 'group' => t('Lists'),
  30. );
  31. $items['ul_title'] = array(
  32. 'title' => t('Unordered list, with title'),
  33. 'theme' => 'item_list',
  34. 'variables' => array('items' => styleguide_list(), 'type' => 'ul', 'title' => ucwords(styleguide_word())),
  35. 'group' => t('Lists'),
  36. );
  37. $items['ol_title'] = array(
  38. 'title' => t('Ordered list, with title'),
  39. 'theme' => 'item_list',
  40. 'variables' => array('items' => styleguide_list(), 'type' => 'ol', 'title' => ucwords(styleguide_word())),
  41. 'group' => t('Lists'),
  42. );
  43. $items['menu_tree'] = array(
  44. 'title' => t('Menu tree'),
  45. 'content' => menu_tree('management'),
  46. 'group' => t('Menus'),
  47. );
  48. $items['table'] = array(
  49. 'title' => t('Table'),
  50. 'theme' => 'table',
  51. 'variables' => array('header' => styleguide_header(), 'rows' => styleguide_rows()),
  52. 'group' => t('Tables'),
  53. );
  54. $items['text'] = array(
  55. 'title' => t('Text block'),
  56. 'content' => styleguide_paragraph(3),
  57. 'group' => t('Text'),
  58. );
  59. $items['image-horizontal'] = array(
  60. 'title' => t('Image, horizontal'),
  61. 'theme' => 'image',
  62. 'variables' => array('path' => styleguide_image('horizontal'), 'alt' => t('My image'), 'title' => t('My image')),
  63. 'group' => t('Media'),
  64. );
  65. $items['image-vertical'] = array(
  66. 'title' => t('Image, vertical'),
  67. 'theme' => 'image',
  68. 'variables' => array('path' => styleguide_image('vertical'), 'alt' => t('My image'), 'title' => t('My image')),
  69. 'group' => t('Media'),
  70. );
  71. $items['image-inset-horizontal'] = array(
  72. 'title' => t('Image, horizontal, within text'),
  73. 'content' => styleguide_paragraph(1) . theme('image', array('path' => styleguide_image('horizontal'), 'alt' => t('My image'), 'title' => t('My image'))) . styleguide_paragraph(2),
  74. 'group' => t('Media'),
  75. );
  76. $items['image-inset-vertical'] = array(
  77. 'title' => t('Image, vertical, within text'),
  78. 'content' => styleguide_paragraph(1) . theme('image', array('path' => styleguide_image('vertical'), 'alt' => t('My image'), 'title' => t('My image'))) . styleguide_paragraph(2),
  79. 'group' => t('Media'),
  80. );
  81. $content = '';
  82. for ($i = 1; $i <=6; $i++) {
  83. $content .= "<h$i>" . "h$i: " . implode(' ', styleguide_list()) . "</h$i>";
  84. }
  85. $items['headings'] = array(
  86. 'title' => "Headings",
  87. 'content' => $content,
  88. 'group' => t('Text'),
  89. );
  90. $content = '';
  91. for ($i = 1; $i <=6; $i++) {
  92. $content .= "<h$i>" . "h$i: " . implode(' ', styleguide_list()) . "</h$i>" . styleguide_paragraph(1);
  93. }
  94. $items['headings_text'] = array(
  95. 'title' => "Headings with text",
  96. 'content' => $content,
  97. 'group' => t('Text'),
  98. );
  99. $messages = array('status', 'warning', 'error');
  100. foreach ($messages as $message) {
  101. $items[$message . '-message'] = array(
  102. 'title' => ucwords($message) . ' message',
  103. 'content' => '<div class="messages ' . $message . '"><h2 class="element-invisible">Status message</h2>' . styleguide_sentence() . '</div>',
  104. );
  105. }
  106. // Form elements.
  107. $fake = $form_state = array();
  108. $elements = styleguide_form($fake, $form_state);
  109. $basic = array();
  110. $fieldsets = array();
  111. $tabs = array();
  112. $markup = array();
  113. foreach (element_children($elements) as $key) {
  114. if (!isset($elements[$key]['#type']) || $elements[$key]['#type'] == 'item') {
  115. $markup[] = $key;
  116. }
  117. elseif ($elements[$key]['#type'] == 'fieldset') {
  118. $fieldsets[] = $key;
  119. }
  120. elseif ($key == 'vertical_tabs') {
  121. $tabs[] = $key;
  122. }
  123. // We skip these.
  124. elseif (in_array($elements[$key]['#type'], array('button', 'submit', 'image_button'))) {
  125. $buttons[] = $key;
  126. }
  127. else {
  128. $basic[] = $key;
  129. }
  130. }
  131. $items['form'] = array(
  132. 'title' => t('Forms, basic'),
  133. 'content' => drupal_get_form('styleguide_form', $basic),
  134. 'group' => t('Forms'),
  135. );
  136. $items['form-submit'] = array(
  137. 'title' => t('Forms, submit'),
  138. 'content' => drupal_get_form('styleguide_form', array('submit')),
  139. 'group' => t('Forms'),
  140. );
  141. $items['form-button'] = array(
  142. 'title' => t('Forms, button'),
  143. 'content' => drupal_get_form('styleguide_form', array('button')),
  144. 'group' => t('Forms'),
  145. );
  146. $items['form-image-button'] = array(
  147. 'title' => t('Forms, image button'),
  148. 'content' => drupal_get_form('styleguide_form', array('image_button')),
  149. 'group' => t('Forms'),
  150. );
  151. $items['form-markup'] = array(
  152. 'title' => t('Forms, markup'),
  153. 'content' => drupal_get_form('styleguide_form', $markup),
  154. 'group' => t('Forms'),
  155. );
  156. $items['form-fieldsets'] = array(
  157. 'title' => t('Forms, fieldsets'),
  158. 'content' => drupal_get_form('styleguide_form', $fieldsets),
  159. 'group' => t('Forms'),
  160. );
  161. $items['form-vertical-tabs'] = array(
  162. 'title' => t('Forms, vertical tabs'),
  163. 'content' => drupal_get_form('styleguide_form', $tabs),
  164. 'group' => t('Forms'),
  165. );
  166. return $items;
  167. }