Skip to content

Commit be35bd3

Browse files
committed
Merge branch 'feature/add-active-color-prop' into develop
# Conflicts: # README.md
2 parents f3cc963 + f6e3644 commit be35bd3

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,19 @@ The `Table` has some additional properties to tweak its front-end behaviour.
269269
:striped="true"
270270
:prevent-overlapping-requests="false"
271271
:input-debounce-ms="1000"
272-
:preserve-scroll="true"
272+
:prevent-scroll="true"
273+
:active-classes="{text: 'text-red-500', border: 'border-red-300'}"
273274
/>
274275
</template>
275276
```
276277

277-
| Property | Description | Default |
278-
| --- | --- | --- |
279-
| striped | Adds a *striped* layout to the table. | `false` |
280-
| preventOverlappingRequests | Cancels a previous visit on new user input to prevent an inconsistent state. | `true` |
281-
| inputDebounceMs | Number of ms to wait before refreshing the table on user input. | 350 |
282-
| preventScroll | Configures the [Scroll preservation](https://inertiajs.com/scroll-management#scroll-preservation) behavior. You may also pass `table-top` to this property to scroll to the top of the table on new data. | false |
278+
| Property | Description | Default |
279+
|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
280+
| striped | Adds a *striped* layout to the table. | `false` |
281+
| preventOverlappingRequests | Cancels a previous visit on new user input to prevent an inconsistent state. | `true` |
282+
| inputDebounceMs | Number of ms to wait before refreshing the table on user input. | 350 |
283+
| preventScroll | Configures the [Scroll preservation](https://inertiajs.com/scroll-management#scroll-preservation) behavior. You may also pass `table-top` to this property to scroll to the top of the table on new data. | false |
284+
| activeClasses | Configures the CSS classes to apply on active elements like filters & column buttons and sorting indicator | {text: 'text-green-400', border: 'border-green-300' } |
283285

284286
#### Custom column cells
285287

js/Components/ButtonWithDropdown.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
:dusk="dusk"
88
:disabled="disabled"
99
class="w-full bg-white border rounded-md shadow-sm px-4 py-2 inline-flex justify-center text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
10-
:class="{'border-green-300': active, 'border-gray-300': !active, 'cursor-not-allowed': disabled }"
10+
:class="{
11+
[activeClasses.border]: props.active,
12+
'border-gray-300': !props.active,
13+
'cursor-not-allowed': props.disabled
14+
}"
1115
aria-haspopup="true"
1216
@click.prevent="toggle"
1317
>
@@ -32,7 +36,7 @@ import OnClickOutside from "./OnClickOutside.vue";
3236
import { createPopper } from "@popperjs/core/lib/popper-lite";
3337
import preventOverflow from "@popperjs/core/lib/modifiers/preventOverflow";
3438
import flip from "@popperjs/core/lib/modifiers/flip";
35-
import { ref, watch, onMounted } from "vue";
39+
import { ref, watch, onMounted, inject, computed } from "vue";
3640
3741
const props = defineProps({
3842
placement: {
@@ -86,4 +90,7 @@ onMounted(() => {
8690
});
8791
8892
defineExpose({ hide });
93+
94+
const activeClasses = inject("activeClasses");
95+
8996
</script>

js/Components/HeaderCell.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class="w-3 h-3 ml-2"
1919
:class="{
2020
'text-gray-400': !cell.sorted,
21-
'text-green-500': cell.sorted,
21+
[activeClasses.text]: cell.sorted,
2222
}"
2323
xmlns="http://www.w3.org/2000/svg"
2424
viewBox="0 0 320 512"
@@ -49,16 +49,21 @@
4949
</template>
5050

5151
<script setup>
52+
53+
import { inject } from "vue";
54+
5255
const props = defineProps({
5356
cell: {
5457
type: Object,
5558
required: true,
5659
},
5760
});
5861
62+
const activeClasses = inject("activeClasses");
63+
5964
function onClick() {
6065
if (props.cell.sortable) {
6166
props.cell.onSort(props.cell.key);
6267
}
6368
}
64-
</script>
69+
</script>

js/Components/Table.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ import TableGlobalSearch from "./TableGlobalSearch.vue";
199199
import TableSearchRows from "./TableSearchRows.vue";
200200
import TableReset from "./TableReset.vue";
201201
import TableWrapper from "./TableWrapper.vue";
202-
import { computed, onMounted, ref, watch, onUnmounted, getCurrentInstance, Transition } from "vue";
202+
import { computed, onMounted, ref, watch, onUnmounted, getCurrentInstance, Transition, provide } from "vue";
203203
import qs from "qs";
204204
import clone from "lodash-es/clone";
205205
import filter from "lodash-es/filter";
@@ -271,8 +271,21 @@ const props = defineProps({
271271
},
272272
required: false,
273273
},
274+
275+
activeClasses:{
276+
type: Object,
277+
required: false,
278+
default() {
279+
return {
280+
text: "text-green-400",
281+
border: "border-green-300"
282+
};
283+
}
284+
}
274285
});
275286
287+
provide("activeClasses", props.activeClasses);
288+
276289
const app = getCurrentInstance();
277290
const $inertia = app ? app.appContext.config.globalProperties.$inertia : props.inertia;
278291

js/Components/TableColumns.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class="h-5 w-5"
1111
:class="{
1212
'text-gray-400': !hasHiddenColumns,
13-
'text-green-400': hasHiddenColumns,
13+
[activeClasses.text]: hasHiddenColumns,
1414
}"
1515
viewBox="0 0 20 20"
1616
fill="currentColor"
@@ -76,6 +76,7 @@
7676

7777
<script setup>
7878
import ButtonWithDropdown from "./ButtonWithDropdown.vue";
79+
import { inject } from "vue";
7980
8081
const props = defineProps({
8182
columns: {
@@ -93,4 +94,5 @@ const props = defineProps({
9394
required: true,
9495
},
9596
});
97+
const activeClasses = inject("activeClasses");
9698
</script>

js/Components/TableFilter.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class="h-5 w-5"
1111
:class="{
1212
'text-gray-400': !hasEnabledFilters,
13-
'text-green-400': hasEnabledFilters,
13+
[activeClasses.text]: hasEnabledFilters,
1414
}"
1515
viewBox="0 0 20 20"
1616
fill="currentColor"
@@ -60,6 +60,7 @@
6060

6161
<script setup>
6262
import ButtonWithDropdown from "./ButtonWithDropdown.vue";
63+
import { inject } from "vue";
6364
6465
defineProps({
6566
hasEnabledFilters: {
@@ -77,5 +78,7 @@ defineProps({
7778
required: true,
7879
},
7980
});
80-
</script>
8181
82+
const activeClasses = inject("activeClasses");
83+
84+
</script>

0 commit comments

Comments
 (0)