|
| 1 | +function optionsWithPropertyExists(options, property) { |
| 2 | + return typeof options !== 'undefined' && options.hasOwnProperty(property) |
| 3 | +} |
| 4 | + |
| 5 | +module.exports = function (options) { |
| 6 | + return function({ addComponents }) { |
| 7 | + addComponents({ |
| 8 | + 'table': { |
| 9 | + borderCollapse: 'collapse', |
| 10 | + }, |
| 11 | + 'caption': { |
| 12 | + paddingTop: '.75rem', |
| 13 | + paddingBottom: '.75rem', |
| 14 | + color: '#6c757d', |
| 15 | + textAlign: 'left', |
| 16 | + captionSide: 'bottom', |
| 17 | + }, |
| 18 | + 'th': { |
| 19 | + textAlign: 'inherit', |
| 20 | + }, |
| 21 | + '.table': { |
| 22 | + width: '100%', |
| 23 | + maxWidth: '100%', |
| 24 | + marginBottom: '1rem', |
| 25 | + backgroundColor: 'transparent', |
| 26 | + 'td,th': { |
| 27 | + padding: optionsWithPropertyExists(options, 'cellPadding') ? options.cellPadding : '.75rem', |
| 28 | + verticalAlign: 'top', |
| 29 | + borderTop: optionsWithPropertyExists(options, 'tableBorderColor') |
| 30 | + ? '1px solid ' + options.tableBorderColor |
| 31 | + : '1px solid #dee2e6', |
| 32 | + }, |
| 33 | + 'thead th': { |
| 34 | + verticalAlign: 'bottom', |
| 35 | + borderBottom: optionsWithPropertyExists(options, 'tableBorderColor') |
| 36 | + ? '2px solid ' + options.tableBorderColor |
| 37 | + : '2px solid #dee2e6', |
| 38 | + }, |
| 39 | + 'tbody+tbody': { |
| 40 | + borderTop: optionsWithPropertyExists(options, 'tableBorderColor') |
| 41 | + ? '2px solid ' + options.tableBorderColor |
| 42 | + : '2px solid #dee2e6', |
| 43 | + }, |
| 44 | + '.table': { |
| 45 | + backgroundColor: '#fff', |
| 46 | + }, |
| 47 | + }, |
| 48 | + '.table-sm td,.table-sm th': { |
| 49 | + padding: '.3rem', |
| 50 | + }, |
| 51 | + '.table-bordered': { |
| 52 | + border: optionsWithPropertyExists(options, 'tableBorderColor') |
| 53 | + ? '1px solid ' + options.tableBorderColor |
| 54 | + : '1px solid #dee2e6', |
| 55 | + 'td,th': { |
| 56 | + border: optionsWithPropertyExists(options, 'tableBorderColor') |
| 57 | + ? '1px solid ' + options.tableBorderColor |
| 58 | + : '1px solid #dee2e6', |
| 59 | + }, |
| 60 | + 'thead td,thead th': { |
| 61 | + borderBottomWidth: '2px', |
| 62 | + }, |
| 63 | + }, |
| 64 | + '.table-striped tbody tr:nth-of-type(odd)': { |
| 65 | + backgroundColor: optionsWithPropertyExists(options, 'tableStripedBackgroundColor') |
| 66 | + ? options.tableStripedBackgroundColor |
| 67 | + : 'rgba(0,0,0,.05)', |
| 68 | + }, |
| 69 | + '.table-hover tbody tr:hover': { |
| 70 | + backgroundColor: optionsWithPropertyExists(options, 'tableHoverBackgroundColor') |
| 71 | + ? options.tableHoverBackgroundColor |
| 72 | + : 'rgba(0,0,0,.075)', |
| 73 | + }, |
| 74 | + '.table-primary,.table-primary>td,.table-primary>th': { |
| 75 | + backgroundColor: '#b8daff', |
| 76 | + }, |
| 77 | + '.table-hover .table-primary:hover': { |
| 78 | + backgroundColor: '#9fcdff', |
| 79 | + }, |
| 80 | + '.table-hover .table-primary:hover>td,.table-hover .table-primary:hover>th': { |
| 81 | + backgroundColor: '#9fcdff', |
| 82 | + }, |
| 83 | + '.table-secondary,.table-secondary>td,.table-secondary>th': { |
| 84 | + backgroundColor: '#d6d8db', |
| 85 | + }, |
| 86 | + '.table-hover .table-secondary:hover': { |
| 87 | + backgroundColor: '#c8cbcf', |
| 88 | + }, |
| 89 | + '.table-hover .table-secondary:hover>td,.table-hover .table-secondary:hover>th': { |
| 90 | + backgroundColor: '#c8cbcf', |
| 91 | + }, |
| 92 | + '.table-success,.table-success>td,.table-success>th': { |
| 93 | + backgroundColor: '#c3e6cb', |
| 94 | + }, |
| 95 | + '.table-hover .table-success:hover': { |
| 96 | + backgroundColor: '#b1dfbb', |
| 97 | + }, |
| 98 | + '.table-hover .table-success:hover>td,.table-hover .table-success:hover>th': { |
| 99 | + backgroundColor: '#b1dfbb', |
| 100 | + }, |
| 101 | + '.table-info,.table-info>td,.table-info>th': { |
| 102 | + backgroundColor: '#bee5eb', |
| 103 | + }, |
| 104 | + '.table-hover .table-info:hover': { |
| 105 | + backgroundColor: '#abdde5', |
| 106 | + }, |
| 107 | + '.table-hover .table-info:hover>td,.table-hover .table-info:hover>th': { |
| 108 | + backgroundColor: '#abdde5', |
| 109 | + }, |
| 110 | + '.table-warning,.table-warning>td,.table-warning>th': { |
| 111 | + backgroundColor: '#ffeeba', |
| 112 | + }, |
| 113 | + '.table-hover .table-warning:hover': { |
| 114 | + backgroundColor: '#ffe8a1', |
| 115 | + }, |
| 116 | + '.table-hover .table-warning:hover>td,.table-hover .table-warning:hover>th': { |
| 117 | + backgroundColor: '#ffe8a1', |
| 118 | + }, |
| 119 | + '.table-danger,.table-danger>td,.table-danger>th': { |
| 120 | + backgroundColor: '#f5c6cb', |
| 121 | + }, |
| 122 | + '.table-hover .table-danger:hover': { |
| 123 | + backgroundColor: '#f1b0b7', |
| 124 | + }, |
| 125 | + '.table-hover .table-danger:hover>td,.table-hover .table-danger:hover>th': { |
| 126 | + backgroundColor: '#f1b0b7', |
| 127 | + }, |
| 128 | + '.table-light,.table-light>td,.table-light>th': { |
| 129 | + backgroundColor: '#fdfdfe', |
| 130 | + }, |
| 131 | + '.table-hover .table-light:hover': { |
| 132 | + backgroundColor: '#ececf6', |
| 133 | + }, |
| 134 | + '.table-hover .table-light:hover>td,.table-hover .table-light:hover>th': { |
| 135 | + backgroundColor: '#ececf6', |
| 136 | + }, |
| 137 | + '.table-dark,.table-dark>td,.table-dark>th': { |
| 138 | + backgroundColor: '#c6c8ca', |
| 139 | + }, |
| 140 | + '.table-hover .table-dark:hover': { |
| 141 | + backgroundColor: '#b9bbbe', |
| 142 | + }, |
| 143 | + '.table-hover .table-dark:hover>td,.table-hover .table-dark:hover>th': { |
| 144 | + backgroundColor: '#b9bbbe', |
| 145 | + }, |
| 146 | + '.table-active,.table-active>td,.table-active>th': { |
| 147 | + backgroundColor: 'rgba(0,0,0,.075)', |
| 148 | + }, |
| 149 | + '.table-hover .table-active:hover': { |
| 150 | + backgroundColor: 'rgba(0,0,0,.075)', |
| 151 | + }, |
| 152 | + '.table-hover .table-active:hover>td,.table-hover .table-active:hover>th': { |
| 153 | + backgroundColor: 'rgba(0,0,0,.075)', |
| 154 | + }, |
| 155 | + '.table .thead-dark th': { |
| 156 | + color: '#fff', |
| 157 | + backgroundColor: '#212529', |
| 158 | + borderColor: '#32383e', |
| 159 | + }, |
| 160 | + '.table .thead-light th': { |
| 161 | + color: '#495057', |
| 162 | + backgroundColor: '#e9ecef', |
| 163 | + borderColor: optionsWithPropertyExists(options, 'tableBorderColor') |
| 164 | + ? options.tableBorderColor |
| 165 | + : '#dee2e6', |
| 166 | + }, |
| 167 | + '.table-dark': { |
| 168 | + color: '#fff', |
| 169 | + backgroundColor: '#212529', |
| 170 | + }, |
| 171 | + '.table-dark td,.table-dark th,.table-dark thead th': { |
| 172 | + borderColor: '#32383e', |
| 173 | + }, |
| 174 | + '.table-dark.table-bordered': { |
| 175 | + border: '0', |
| 176 | + }, |
| 177 | + '.table-dark.table-striped tbody tr:nth-of-type(odd)': { |
| 178 | + backgroundColor: 'rgba(255,255,255,.05)', |
| 179 | + }, |
| 180 | + '.table-dark.table-hover tbody tr:hover': { |
| 181 | + backgroundColor: 'rgba(255,255,255,.075)', |
| 182 | + }, |
| 183 | + '.table-responsive': { |
| 184 | + display: 'block', |
| 185 | + width: '100%', |
| 186 | + overflowX: 'auto', |
| 187 | + '-webkit-overflow-scrolling': 'touch', |
| 188 | + '-ms-overflow-style': '-ms-autohiding-scrollbar', |
| 189 | + }, |
| 190 | + '.table-responsive>.table-bordered': { |
| 191 | + border: '0', |
| 192 | + }, |
| 193 | + '@media (max-width:575.98px)': { |
| 194 | + '.table-responsive-sm': { |
| 195 | + display: 'block', |
| 196 | + width: '100%', |
| 197 | + overflowX: 'auto', |
| 198 | + '-webkit-overflow-scrolling': 'touch', |
| 199 | + '-ms-overflow-style': '-ms-autohiding-scrollbar', |
| 200 | + }, |
| 201 | + '.table-responsive-sm>.table-bordered': { |
| 202 | + border: '0', |
| 203 | + } |
| 204 | + }, |
| 205 | + '@media (max-width:767.98px)': { |
| 206 | + '.table-responsive-md': { |
| 207 | + display: 'block', |
| 208 | + width: '100%', |
| 209 | + overflowX: 'auto', |
| 210 | + '-webkit-overflow-scrolling': 'touch', |
| 211 | + '-ms-overflow-style': '-ms-autohiding-scrollbar', |
| 212 | + }, |
| 213 | + '.table-responsive-sm>.table-bordered': { |
| 214 | + border: '0', |
| 215 | + } |
| 216 | + }, |
| 217 | + '@media (max-width:991.98px)': { |
| 218 | + '.table-responsive-lg': { |
| 219 | + display: 'block', |
| 220 | + width: '100%', |
| 221 | + overflowX: 'auto', |
| 222 | + '-webkit-overflow-scrolling': 'touch', |
| 223 | + '-ms-overflow-style': '-ms-autohiding-scrollbar', |
| 224 | + }, |
| 225 | + '.table-responsive-sm>.table-bordered': { |
| 226 | + border: '0', |
| 227 | + } |
| 228 | + }, |
| 229 | + '@media (max-width:1199.98px)': { |
| 230 | + '.table-responsive-xl': { |
| 231 | + display: 'block', |
| 232 | + width: '100%', |
| 233 | + overflowX: 'auto', |
| 234 | + '-webkit-overflow-scrolling': 'touch', |
| 235 | + '-ms-overflow-style': '-ms-autohiding-scrollbar', |
| 236 | + }, |
| 237 | + '.table-responsive-sm>.table-bordered': { |
| 238 | + border: '0', |
| 239 | + } |
| 240 | + }, |
| 241 | + }) |
| 242 | + } |
| 243 | +} |
0 commit comments