You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

650 lines
18 KiB

10 years ago
10 years ago
  1. ---
  2. layout : 'default'
  3. css : ''
  4. element : 'sidebar'
  5. elementType : 'element'
  6. title : 'Sidebar'
  7. description : 'A sidebar hides additional content beside a page.'
  8. type : 'UI Module'
  9. themes : ['Default']
  10. ---
  11. <script src="/javascript/sidebar.js"></script>
  12. <%- @partial('header', { tabs: 'module' }) %>
  13. <div class="main container">
  14. <div class="ui active tab" data-tab="definition">
  15. <div class="peek">
  16. <div class="ui vertical pointing secondary menu">
  17. <a class="active item">Types</a>
  18. <a class="item">Variations</a>
  19. </div>
  20. </div>
  21. <h2 class="ui dividing header">Types</h2>
  22. <div class="transition example">
  23. <h4 class="ui header">Transitions</h4>
  24. <p>A sidebar can use different transitions to display itself</p>
  25. <div class="ui button" data-transition="overlay">
  26. Overlay
  27. </div>
  28. <div class="ui button" data-transition="push">
  29. Push
  30. </div>
  31. <div class="ui button" data-transition="reveal">
  32. Reveal
  33. </div>
  34. <div class="ui button" data-transition="slide along">
  35. Slide Along
  36. </div>
  37. <div class="ui button" data-transition="slide out">
  38. Slide Out
  39. </div>
  40. <div class="ui button" data-transition="scale down">
  41. Scale Down
  42. </div>
  43. </div>
  44. <div class="transition example">
  45. <h4 class="ui header">Safe</h4>
  46. <p>A safe transitioning sidebar does not adjust the page context</p>
  47. <div class="ui ignored info message">A safe transition does not create a new 3D context, this means any <code>fixed position</code> elements within your <code>pusher</code> will not be adjusted
  48. </div>
  49. <div class="ui button" data-transition="safe">
  50. Safe
  51. </div>
  52. </div>
  53. <div class="no example">
  54. <h4 class="ui header">Direction</h4>
  55. <p>A sidebar can appear on any side of content</p>
  56. <div class="code" data-type="html">
  57. <div class="ui sidebar">...</div>
  58. <div class="ui top sidebar">...</div>
  59. <div class="ui right sidebar">...</div>
  60. <div class="ui bottom sidebar">...</div>
  61. </div>
  62. <div class="ui variation toggle buttons">
  63. <div class="ui button" data-variation=".left">
  64. Left
  65. </div>
  66. <div class="ui button" data-variation=".top">
  67. Top
  68. </div>
  69. <div class="ui button" data-variation=".right">
  70. Right
  71. </div>
  72. <div class="ui button" data-variation=".bottom">
  73. Bottom
  74. </div>
  75. </div>
  76. </div>
  77. <h2 class="ui dividing header">Variations</h2>
  78. <div class="no styled example">
  79. <h4 class="ui header">Styled</h4>
  80. <p>A sidebar can be formatted to include additional styling for display</p>
  81. <div class="code" data-type="html">
  82. <div class="ui styled sidebar">...</div>
  83. </div>
  84. <div class="ui labeled icon button">
  85. <i class="left arrow icon"></i>
  86. Show
  87. </div>
  88. </div>
  89. <div class="no size example">
  90. <h4 class="ui header">Size</h4>
  91. <p>A sidebar can vary in width and height to allow more content</p>
  92. <div class="code" data-type="html">
  93. <div class="ui very thin sidebar">...</div>
  94. <div class="ui thin sidebar">...</div>
  95. <div class="ui wide sidebar">...</div>
  96. <div class="ui very wide sidebar">...</div>
  97. </div>
  98. <div class="ui variation toggle buttons">
  99. <div class="ui button" data-variation=".very.thin">
  100. Very Thin
  101. </div>
  102. <div class="ui button" data-variation=".thin">
  103. Thin
  104. </div>
  105. <div class="ui button" data-variation=".wide">
  106. Wide
  107. </div>
  108. <div class="ui button" data-variation=".very.wide">
  109. Very Wide
  110. </div>
  111. </div>
  112. </div>
  113. <div class="no floating example">
  114. <h4 class="ui header">Floating</h4>
  115. <p>A sidebar can appear floating above content</p>
  116. <div class="code" data-type="html">
  117. <div class="ui floating sidebar">...</div>
  118. </div>
  119. <div class="ui labeled icon button">
  120. <i class="left arrow icon"></i>
  121. Show
  122. </div>
  123. </div>
  124. </div>
  125. <div class="ui tab" data-tab="usage">
  126. <h2 class="ui dividing header">Initializing</h2>
  127. <p>Any content can be used as a sidebar by adding the class <code>ui sidebar</code> and initializing the menu in javascript.</p>
  128. <div class="ui ignored warning icon message">
  129. <i class="info letter icon"></i>
  130. <div class="content">
  131. <div class="header">Fixed Position</div>
  132. <p>Fixed position content may have issues changing it's position when a sidebar appears. There are two solutions</p>
  133. <ul class="ui list">
  134. <li>Specify your fixed content without using the css left or top properties.</li>
  135. <li>Apply styles on the fixed element to adjust its position when the sidebar appears. You can do this by descending from the body tag which receives the class <code>(direction) pushed</code> when the view is moved.</li>
  136. </ul>
  137. </div>
  138. </div>
  139. <div class="code" data-label="true" data-type="html">
  140. <div class="ui sidebar">
  141. Any content in the world
  142. </div>
  143. </div>
  144. <div class="code" data-label="true" data-type="javascript">
  145. $('.ui.sidebar')
  146. .sidebar()
  147. ;
  148. </div>
  149. <h2 class="ui dividing header">Usage</h2>
  150. <div class="no example">
  151. <h4 class="ui header">Showing a sidebar</h4>
  152. <p>A sidebar can be shown, hidden, or toggled. In the following examples sidebar is used in conjunction with <a href="/collections/menu.html">ui menu</a> to display a vertical menu as a sidebar.</p>
  153. <div class="code" data-type="html" data-title="Example HTML">
  154. <div class="ui red vertical demo sidebar menu">
  155. <a class="item">
  156. <i class="home icon"></i>
  157. Home
  158. </a>
  159. <a class="active item">
  160. <i class="heart icon"></i>
  161. Current Section
  162. </a>
  163. <a class="item">
  164. <i class="facebook icon"></i>
  165. Like us on Facebook
  166. </a>
  167. <div class="item">
  168. <b>More</b>
  169. <div class="menu">
  170. <a class="item">About</a>
  171. <a class="item">Contact Us</a>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="code" data-demo="true" data-type="javascript">
  177. $('.demo.sidebar')
  178. .sidebar('toggle')
  179. ;
  180. </div>
  181. </div>
  182. <h2 class="ui dividing header">Behavior</h2>
  183. <p>All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax:</p>
  184. <div class="code">
  185. $('.your.element')
  186. .sidebar('behavior name', argumentOne, argumentTwo)
  187. ;
  188. </div>
  189. <table class="ui definition celled sortable table segment">
  190. <thead>
  191. <tr>
  192. <th>Behavior</th>
  193. <th>Description</th>
  194. </tr>
  195. </thead>
  196. <tbody>
  197. <tr>
  198. <td>attach events(selector, event)</td>
  199. <td>Attaches sidebar action to given selector. Default event if none specified is toggle</td>
  200. </tr>
  201. <tr>
  202. <td>show</td>
  203. <td>Shows sidebar</td>
  204. </tr>
  205. <tr>
  206. <td>hide</td>
  207. <td>Hides sidebar</td>
  208. </tr>
  209. <tr>
  210. <td>toggle</td>
  211. <td>Toggles visibility of sidebar</td>
  212. </tr>
  213. <tr>
  214. <td>is open</td>
  215. <td>Returns whether sidebar is open</td>
  216. </tr>
  217. <tr>
  218. <td>is closed</td>
  219. <td>Returns whether sidebar is closed</td>
  220. </tr>
  221. <tr>
  222. <td>push page</td>
  223. <td>Pushes page content to be visible alongside sidebar</td>
  224. </tr>
  225. <tr>
  226. <td>get direction</td>
  227. <td>Returns direction of current sidebar</td>
  228. </tr>
  229. <tr>
  230. <td>pull page</td>
  231. <td>Returns page content to original position</td>
  232. </tr>
  233. <tr>
  234. <td>add body css</td>
  235. <td>Adds stylesheet to page head to trigger sidebar animations</td>
  236. </tr>
  237. <tr>
  238. <td>remove body css</td>
  239. <td>Removes any inline stylesheets for sidebar animation</td>
  240. </tr>
  241. <tr>
  242. <td>get transition event</td>
  243. <td>Returns vendor prefixed transition end event</td>
  244. </tr>
  245. </tbody>
  246. </table>
  247. </div>
  248. <div class="ui tab" data-tab="examples">
  249. <div class="no example">
  250. <h4 class="ui header">Triggering show/hide with other content</h4>
  251. <p>For convenience calling attach events will allow you to bind events. By default this will toggle the sidebar in and out of view on click</p>
  252. <div class="code" data-demo="true">
  253. $('.demo.sidebar').first()
  254. .sidebar('attach events', '.toggle.button')
  255. ;
  256. $('.toggle.button')
  257. .removeClass('disabled')
  258. ;
  259. </div>
  260. <div class="ui disabled secondary labeled icon toggle button">
  261. <i class="left arrow icon"></i>
  262. Trigger Sidebar
  263. </div>
  264. </div>
  265. <div class="no example">
  266. <h4 class="ui header">Triggering custom action with other content</h4>
  267. <p>You can also however specify what action should occur when the element is clicked</p>
  268. <div class="code" data-demo="true">
  269. $('.demo.sidebar').first()
  270. .sidebar('attach events', '.open.button', 'show')
  271. ;
  272. $('.open.button')
  273. .removeClass('disabled')
  274. ;
  275. </div>
  276. <div class="ui disabled secondary labeled icon open button">
  277. <i class="left arrow icon"></i>
  278. Open Sidebar
  279. </div>
  280. </div>
  281. </div>
  282. <div class="ui tab" data-tab="settings">
  283. <h3 class="ui header">
  284. Sidebar Settings
  285. <div class="sub header">Form settings modify the sidebar behavior</div>
  286. </h3>
  287. <table class="ui celled sortable definition table segment">
  288. <thead>
  289. <tr>
  290. <th>Setting</th>
  291. <th class="four wide">Default</th>
  292. <th>Description</th>
  293. </tr>
  294. </thead>
  295. <tbody>
  296. <tr>
  297. <td>overlay</td>
  298. <td>false</td>
  299. <td>Whether sidebar should overlay page instead of pushing page to the side</td>
  300. </tr>
  301. <tr>
  302. <td>exclusive</td>
  303. <td>true</td>
  304. <td>Whether multiple sidebars can be open at once</td>
  305. </tr>
  306. <tr>
  307. <td>useCSS</td>
  308. <td>true</td>
  309. <td>Whether to use css animations or fallback javascript animations</td>
  310. </tr>
  311. <tr>
  312. <td>duration</td>
  313. <td>300</td>
  314. <td>Duration of side bar transition animation</td>
  315. </tr>
  316. </tbody>
  317. </table>
  318. <div class="ui horizontal section icon divider"><i class="icon setting"></i></div>
  319. <h4 class="ui header">Callbacks</h4>
  320. <p>Callbacks specify a function to occur after a specific behavior.</p>
  321. <table class="ui celled sortable definition table segment">
  322. <thead>
  323. <tr>
  324. <th class="four wide">Setting</th>
  325. <th>Context</th>
  326. <th>Description</th>
  327. </tr>
  328. </thead>
  329. <tbody>
  330. <tr>
  331. <td>onShow</td>
  332. <td>Sidebar</td>
  333. <td>Is called when a sidebar is shown.</td>
  334. </tr>
  335. <tr>
  336. <td>onHide</td>
  337. <td>Sidebar</td>
  338. <td>Is called when a sidebar is hidden.</td>
  339. </tr>
  340. <tr>
  341. <td>onChange</td>
  342. <td>Sidebar</td>
  343. <td>Is called after a sidebar changes visibility</td>
  344. </tr>
  345. </tbody>
  346. </table>
  347. <div class="ui horizontal divider"><i class="icon setting"></i></div>
  348. <h3 class="ui header">
  349. DOM Settings
  350. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  351. </h3>
  352. <table class="ui celled definition table segment">
  353. <thead>
  354. <tr>
  355. <th>Setting</th>
  356. <th class="six wide">Default</th>
  357. <th>Description</th>
  358. </tr>
  359. </thead>
  360. <tbody>
  361. <tr>
  362. <td>namespace</td>
  363. <td>sidebar</td>
  364. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  365. </tr>
  366. <tr>
  367. <td>className</td>
  368. <td>
  369. <div class="code">
  370. className: {
  371. active : 'active',
  372. pushed : 'pushed',
  373. top : 'top',
  374. left : 'left',
  375. right : 'right',
  376. bottom : 'bottom'
  377. }
  378. </div>
  379. </td>
  380. <td>Class names used to attach style to state</td>
  381. </tr>
  382. </tbody>
  383. </table>
  384. <div class="ui horizontal divider"><i class="icon setting"></i></div>
  385. <h3 class="ui header">
  386. Debug Settings
  387. <div class="sub header">Debug settings controls debug output to the console</div>
  388. </h3>
  389. <table class="ui celled sortable definition table segment">
  390. <thead>
  391. <tr>
  392. <th>Setting</th>
  393. <th class="four wide">Default</th>
  394. <th>Description</th>
  395. </tr>
  396. </thead>
  397. <tbody>
  398. <tr>
  399. <td>name</td>
  400. <td>Sidebar</td>
  401. <td>Name used in debug logs</td>
  402. </tr>
  403. <tr>
  404. <td>debug</td>
  405. <td>True</td>
  406. <td>Provides standard debug output to console</td>
  407. </tr>
  408. <tr>
  409. <td>performance</td>
  410. <td>True</td>
  411. <td>Provides standard debug output to console</td>
  412. </tr>
  413. <tr>
  414. <td>verbose</td>
  415. <td>True</td>
  416. <td>Provides ancillary debug output to console</td>
  417. </tr>
  418. <tr>
  419. <td>errors</td>
  420. <td colspan="2">
  421. <div class="code">
  422. error : {
  423. method : 'The method you called is not defined.',
  424. notFound : 'There were no elements that matched the specified selector'
  425. }
  426. </div>
  427. </td>
  428. </tr>
  429. </tbody>
  430. </table>
  431. </div>
  432. </div>
  433. <div class="ui styled sidebar">
  434. <h3 class="ui header">You Might Like</h3>
  435. <div class="ui fluid vertical menu">
  436. <a class="item">
  437. <i class="chat outline icon"></i>
  438. More by this author
  439. </a>
  440. <a class="item">
  441. <i class="text file icon"></i>
  442. Suggested Articles
  443. </a>
  444. </div>
  445. <h3 class="ui header">Contact Us</h3>
  446. <div class="ui form">
  447. <div class="field">
  448. <label>Name</label>
  449. <div class="ui icon input">
  450. <i class="user icon"></i>
  451. <input type="text" data-placeholder="Name">
  452. </div>
  453. </div>
  454. <div class="field">
  455. <label>Message</label>
  456. <textarea></textarea>
  457. </div>
  458. <div class="ui black fluid button">Submit</div>
  459. </div>
  460. </div>
  461. <div class="ui thin styled sidebar">
  462. <h3 class="ui header">Share</h3>
  463. <div class="ui fluid vertical labeled icon buttons">
  464. <div class="ui facebook button">
  465. <i class="facebook icon"></i>
  466. Facebook
  467. </div>
  468. <div class="ui twitter button">
  469. <i class="twitter icon"></i>
  470. Twitter
  471. </div>
  472. <div class="ui google plus button">
  473. <i class="google plus icon"></i>
  474. Google
  475. </div>
  476. </div>
  477. </div>
  478. <div class="ui very thin styled sidebar">
  479. <div class="ui fluid vertical icon buttons">
  480. <div class="ui facebook button">
  481. <i class="facebook icon"></i>
  482. </div>
  483. <div class="ui twitter button">
  484. <i class="twitter icon"></i>
  485. </div>
  486. <div class="ui google plus button">
  487. <i class="google plus icon"></i>
  488. </div>
  489. </div>
  490. </div>
  491. <div class="ui wide styled sidebar">
  492. <h3 class="ui header">You Might Like</h3>
  493. <div class="ui fluid vertical menu">
  494. <a class="item">
  495. <i class="chat outline icon"></i>
  496. More by this author
  497. </a>
  498. <a class="item">
  499. <i class="text file icon"></i>
  500. Suggested Articles
  501. </a>
  502. </div>
  503. </div>
  504. <div class="ui very wide styled sidebar">
  505. <h3 class="ui header">Contact Us</h3>
  506. <div class="ui form">
  507. <div class="field">
  508. <label>Name</label>
  509. <div class="ui icon input">
  510. <i class="user icon"></i>
  511. <input type="text" data-placeholder="Name">
  512. </div>
  513. </div>
  514. <div class="field">
  515. <label>Message</label>
  516. <textarea></textarea>
  517. </div>
  518. <div class="ui black fluid button">Submit</div>
  519. </div>
  520. </div>
  521. <div class="ui vertical overlay sidebar menu">
  522. <a class="item">
  523. <i class="home icon"></i>
  524. Home
  525. </a>
  526. <a class="active item">
  527. <i class="heart icon"></i>
  528. Current Section
  529. </a>
  530. <a class="item">
  531. <i class="facebook icon"></i>
  532. Like us on Facebook
  533. </a>
  534. <div class="item">
  535. <b>More</b>
  536. <div class="menu">
  537. <a class="item">About</a>
  538. <a class="item">Contact Us</a>
  539. </div>
  540. </div>
  541. </div>
  542. <div class="ui floating vertical sidebar menu">
  543. <a class="item">
  544. <i class="home icon"></i>
  545. Home
  546. </a>
  547. <a class="active item">
  548. <i class="heart icon"></i>
  549. Current Section
  550. </a>
  551. <a class="item">
  552. <i class="facebook icon"></i>
  553. Like us on Facebook
  554. </a>
  555. <div class="item">
  556. <b>More</b>
  557. <div class="menu">
  558. <a class="item">About</a>
  559. <a class="item">Contact Us</a>
  560. </div>
  561. </div>
  562. </div>
  563. <div class="ui red vertical demo sidebar menu">
  564. <a class="item">
  565. <i class="home icon"></i>
  566. Home
  567. </a>
  568. <a class="active item">
  569. <i class="heart icon"></i>
  570. Current Section
  571. </a>
  572. <a class="item">
  573. <i class="facebook icon"></i>
  574. Like us on Facebook
  575. </a>
  576. <div class="item">
  577. <b>More</b>
  578. <div class="menu">
  579. <a class="item">About</a>
  580. <a class="item">Contact Us</a>
  581. </div>
  582. </div>
  583. </div>
  584. <div class="ui left sidebar vertical inverted menu">
  585. <div class="header item">Left Sidebar menu</div>
  586. <a class="item">One</a>
  587. <a class="item">Two</a>
  588. <a class="item">Three</a>
  589. </div>
  590. <div class="ui right sidebar inverted red vertical menu">
  591. <div class="header item">Right Sidebar menu</div>
  592. <a class="item">One</a>
  593. <a class="item">Two</a>
  594. <a class="item">Three</a>
  595. </div>
  596. <div class="ui top inverted teal sidebar menu">
  597. <div class="header item">Top Sidebar menu</div>
  598. <a class="item">One</a>
  599. <a class="item">Two</a>
  600. <a class="item">Three</a>
  601. </div>
  602. <div class="ui bottom inverted sidebar menu">
  603. <div class="header item">Bottom Sidebar menu</div>
  604. <a class="item">One</a>
  605. <a class="item">Two</a>
  606. <a class="item">Three</a>
  607. </div>