|
| 1 | +import Library from '../Library'; |
| 2 | + |
| 3 | +// "Fixture" for example table contents |
| 4 | +function ExampleTBody() { |
| 5 | + return ( |
| 6 | + <tbody> |
| 7 | + <tr> |
| 8 | + <td>Alphanumeric Balloons</td> |
| 9 | + <td>Champagne Delusions</td> |
| 10 | + </tr> |
| 11 | + <tr> |
| 12 | + <td>Elephantine Fry-ups</td> |
| 13 | + <td>Gargantuan Hiccups</td> |
| 14 | + </tr> |
| 15 | + <tr className="is-selected"> |
| 16 | + <td>Illicit Jugglers</td> |
| 17 | + <td>Katydid Lozenges Meringue</td> |
| 18 | + </tr> |
| 19 | + <tr> |
| 20 | + <td>Alphanumeric Balloons</td> |
| 21 | + <td>Champagne Delusions</td> |
| 22 | + </tr> |
| 23 | + <tr> |
| 24 | + <td>Elephantine Fry-ups</td> |
| 25 | + <td>Gargantuan Hiccups</td> |
| 26 | + </tr> |
| 27 | + <tr> |
| 28 | + <td>Illicit Jugglers</td> |
| 29 | + <td>Katydid Lozenges Moebius</td> |
| 30 | + </tr> |
| 31 | + <tr> |
| 32 | + <td>Elephantine Fry-ups</td> |
| 33 | + <td>Gargantuan Hiccups</td> |
| 34 | + </tr> |
| 35 | + <tr> |
| 36 | + <td>Illicit Jugglers</td> |
| 37 | + <td>Katydid Lozenges Meringue</td> |
| 38 | + </tr> |
| 39 | + <tr> |
| 40 | + <td>Alphanumeric Balloons</td> |
| 41 | + <td>Champagne Delusions</td> |
| 42 | + </tr> |
| 43 | + </tbody> |
| 44 | + ); |
| 45 | +} |
| 46 | + |
| 47 | +export default function TablePatterns() { |
| 48 | + return ( |
| 49 | + <Library.Page title="Tables"> |
| 50 | + <p> |
| 51 | + These <code>table</code> patterns support a basic table layout that |
| 52 | + adapts to available space. They are intended for simpler tabular |
| 53 | + display: maximum 2 or possibly 3 columns. Remember that{' '} |
| 54 | + <code>table</code> content needs to be usable in tight and narrow |
| 55 | + spaces. |
| 56 | + </p> |
| 57 | + <Library.Pattern title="Table"> |
| 58 | + <Library.Example title="Basic table" variant="wide"> |
| 59 | + <p> |
| 60 | + By default, a <code>table</code> will fill available horizontal |
| 61 | + space, and will use whatever height is needed to render its rows.{' '} |
| 62 | + <code>tr.is-selected</code> styles a row as selected. |
| 63 | + </p> |
| 64 | + |
| 65 | + <Library.Demo withSource> |
| 66 | + <table className="hyp-table"> |
| 67 | + <thead> |
| 68 | + <tr> |
| 69 | + <th scope="col">Column A</th> |
| 70 | + <th scope="col">Column B</th> |
| 71 | + </tr> |
| 72 | + </thead> |
| 73 | + <ExampleTBody /> |
| 74 | + </table> |
| 75 | + </Library.Demo> |
| 76 | + </Library.Example> |
| 77 | + |
| 78 | + <Library.Example title="Adjusting column widths"> |
| 79 | + <p> |
| 80 | + Table column widths may be adjusted by styling <code>thead th</code>{' '} |
| 81 | + elements. In this example, the column widths are set to 30% and 70%. |
| 82 | + </p> |
| 83 | + <Library.Demo withSource> |
| 84 | + <table className="hyp-table"> |
| 85 | + <thead> |
| 86 | + <tr> |
| 87 | + <th scope="col" style="width:30%"> |
| 88 | + Column A |
| 89 | + </th> |
| 90 | + <th scope="col" style="width:70%"> |
| 91 | + Column B |
| 92 | + </th> |
| 93 | + </tr> |
| 94 | + </thead> |
| 95 | + <ExampleTBody /> |
| 96 | + </table> |
| 97 | + </Library.Demo> |
| 98 | + </Library.Example> |
| 99 | + |
| 100 | + <Library.Example title="Constraining with a scrollbox"> |
| 101 | + <p> |
| 102 | + In this example, the <code>table</code> is constrained within a{' '} |
| 103 | + <code>scrollbox</code> with a <code>max-height</code>. |
| 104 | + </p> |
| 105 | + <Library.Demo withSource> |
| 106 | + <div |
| 107 | + style="max-height:250px" |
| 108 | + className="hyp-scrollbox--with-header" |
| 109 | + > |
| 110 | + <table className="hyp-table"> |
| 111 | + <thead> |
| 112 | + <tr> |
| 113 | + <th scope="col">Column A</th> |
| 114 | + <th scope="col">Column B</th> |
| 115 | + </tr> |
| 116 | + </thead> |
| 117 | + <ExampleTBody /> |
| 118 | + </table> |
| 119 | + </div> |
| 120 | + </Library.Demo> |
| 121 | + </Library.Example> |
| 122 | + </Library.Pattern> |
| 123 | + </Library.Page> |
| 124 | + ); |
| 125 | +} |
0 commit comments