Refactored DataTable header-footer tokens

pull/5806/head
Cagatay Civici 2024-05-25 18:09:39 +03:00
parent bd90fbb4e2
commit ace2811b76
6 changed files with 48 additions and 27 deletions

View File

@ -296,6 +296,10 @@ export interface ColumnPassThroughOptions {
* Used to pass attributes to the footer cell's DOM element. * Used to pass attributes to the footer cell's DOM element.
*/ */
footerCell?: ColumnPassThroughOptionType; footerCell?: ColumnPassThroughOptionType;
/**
* Used to pass attributes to the footer content DOM element.
*/
columnFooter?: ColumnPassThroughOptionType;
/** /**
* Used to pass attributes to the body cell content's DOM element. * Used to pass attributes to the body cell content's DOM element.
*/ */

View File

@ -1,7 +1,7 @@
<template> <template>
<td :style="containerStyle" :class="containerClass" role="cell" :colspan="columnProp('colspan')" :rowspan="columnProp('rowspan')" v-bind="{ ...getColumnPT('root'), ...getColumnPT('footerCell') }" :data-p-frozen-column="columnProp('frozen')"> <td :style="containerStyle" :class="containerClass" role="cell" :colspan="columnProp('colspan')" :rowspan="columnProp('rowspan')" v-bind="{ ...getColumnPT('root'), ...getColumnPT('footerCell') }" :data-p-frozen-column="columnProp('frozen')">
<component v-if="column.children && column.children.footer" :is="column.children.footer" :column="column" /> <component v-if="column.children && column.children.footer" :is="column.children.footer" :column="column" />
{{ columnProp('footer') }} <span v-if="columnProp('footer')" :class="cx('columnFooter')" v-bind="getColumnPT('columnFooter')">{{ columnProp('footer') }}</span>
</td> </td>
</template> </template>

View File

@ -164,7 +164,8 @@ const theme = ({ dt }) => `
color: ${dt('datatable.filter.constraint.color')}; color: ${dt('datatable.filter.constraint.color')};
border-radius: ${dt('datatable.filter.constraint.border.radius')}; border-radius: ${dt('datatable.filter.constraint.border.radius')};
cursor: pointer; cursor: pointer;
transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')}; transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')},
box-shadow ${dt('datatable.transition.duration')};
} }
.p-datatable-filter-constraint-selected { .p-datatable-filter-constraint-selected {
@ -276,7 +277,6 @@ const theme = ({ dt }) => `
border-style: solid; border-style: solid;
border-width: ${dt('datatable.header.border.width')}; border-width: ${dt('datatable.header.border.width')};
padding: ${dt('datatable.header.padding')}; padding: ${dt('datatable.header.padding')};
font-weight: ${dt('datatable.header.font.weight')};
} }
.p-datatable-footer { .p-datatable-footer {
@ -286,7 +286,6 @@ const theme = ({ dt }) => `
border-style: solid; border-style: solid;
border-width: ${dt('datatable.footer.border.width')}; border-width: ${dt('datatable.footer.border.width')};
padding: ${dt('datatable.footer.padding')}; padding: ${dt('datatable.footer.padding')};
font-weight: ${dt('datatable.footer.font.weight')};
} }
.p-datatable-header-cell { .p-datatable-header-cell {
@ -296,15 +295,22 @@ const theme = ({ dt }) => `
border-style: solid; border-style: solid;
border-width: 0 0 1px 0; border-width: 0 0 1px 0;
color: ${dt('datatable.header.cell.color')}; color: ${dt('datatable.header.cell.color')};
font-weight: ${dt('datatable.header.font.weight')}; font-weight: normal;
transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')}, outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')}; text-align: left;
transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')},
outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')};
}
.p-datatable-column-title {
font-weight: ${dt('datatable.column.title.font.weight')};
} }
.p-datatable-tbody > tr { .p-datatable-tbody > tr {
outline-color: transparent; outline-color: transparent;
background: ${dt('datatable.row.background')}; background: ${dt('datatable.row.background')};
color: ${dt('datatable.row.color')}; color: ${dt('datatable.row.color')};
transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')}, outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')}; transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')},
outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')};
} }
.p-datatable-tbody > tr > td { .p-datatable-tbody > tr > td {
@ -346,11 +352,14 @@ const theme = ({ dt }) => `
border-color: ${dt('datatable.footer.cell.border.color')}; border-color: ${dt('datatable.footer.cell.border.color')};
border-style: solid; border-style: solid;
border-width: 0 0 1px 0; border-width: 0 0 1px 0;
font-weight: ${dt('datatable.footer.cell.font.weight')};
color: ${dt('datatable.footer.cell.color')}; color: ${dt('datatable.footer.cell.color')};
background: ${dt('datatable.footer.cell.background')}; background: ${dt('datatable.footer.cell.background')};
} }
.p-datatable-column-footer {
font-weight: ${dt('datatable.column.footer.font.weight')};
}
.p-datatable-sortable-column { .p-datatable-sortable-column {
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
@ -544,7 +553,8 @@ p-datatable-gridlines .p-datatable-tbody > tr:last-child > td {
background: transparent; background: transparent;
cursor: pointer; cursor: pointer;
border-radius: ${dt('datatable.row.toggle.button.border.radius')}; border-radius: ${dt('datatable.row.toggle.button.border.radius')};
transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')}, outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')}; transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')},
outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')};
outline-color: transparent; outline-color: transparent;
user-select: none; user-select: none;
} }
@ -616,6 +626,7 @@ const classes = {
columnResizer: 'p-datatable-column-resizer', columnResizer: 'p-datatable-column-resizer',
columnHeaderContent: 'p-datatable-column-header-content', columnHeaderContent: 'p-datatable-column-header-content',
columnTitle: 'p-datatable-column-title', columnTitle: 'p-datatable-column-title',
columnFooter: 'p-datatable-column-footer',
sortIcon: 'p-datatable-sort-icon', sortIcon: 'p-datatable-sort-icon',
pcSortBadge: 'p-datatable-sort-badge', pcSortBadge: 'p-datatable-sort-badge',
filter: ({ props }) => [ filter: ({ props }) => [

View File

@ -8,7 +8,6 @@ export default {
color: '{content.color}', color: '{content.color}',
borderWidth: '0 0 1px 0', borderWidth: '0 0 1px 0',
padding: '0.75rem 1rem', padding: '0.75rem 1rem',
fontWeight: '600'
}, },
headerCell: { headerCell: {
background: '{content.background}', background: '{content.background}',
@ -20,7 +19,6 @@ export default {
selectedColor: '{highlight.color}', selectedColor: '{highlight.color}',
gap: '0.5rem', gap: '0.5rem',
padding: '0.75rem 1rem', padding: '0.75rem 1rem',
fontWeight: '600',
focusRing: { focusRing: {
width: '{focus.ring.width}', width: '{focus.ring.width}',
style: '{focus.ring.style}', style: '{focus.ring.style}',
@ -29,6 +27,9 @@ export default {
shadow: '{focus.ring.shadow}' shadow: '{focus.ring.shadow}'
} }
}, },
columnTitle: {
fontWeight: '600',
},
row: { row: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}', hoverBackground: '{content.hover.background}',
@ -52,16 +53,17 @@ export default {
background: '{content.background}', background: '{content.background}',
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
color: '{content.color}', color: '{content.color}',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
fontWeight: '600' },
columnFooter: {
fontWeight: '600',
}, },
footer: { footer: {
background: '{content.background}', background: '{content.background}',
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
color: '{content.color}', color: '{content.color}',
borderWidth: '0 0 1px 0', borderWidth: '0 0 1px 0',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
fontWeight: '600'
}, },
dropPointColor: '{primary.color}', dropPointColor: '{primary.color}',
columnResizerWidth: '0.5rem', columnResizerWidth: '0.5rem',

View File

@ -5,8 +5,7 @@ export default {
header: { header: {
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
borderWidth: '1px 0 1px 0', borderWidth: '1px 0 1px 0',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
fontWeight: '700'
}, },
headerCell: { headerCell: {
selectedBackground: '{highlight.background}', selectedBackground: '{highlight.background}',
@ -15,7 +14,6 @@ export default {
selectedColor: '{highlight.color}', selectedColor: '{highlight.color}',
gap: '0.5rem', gap: '0.5rem',
padding: '0.75rem 1rem', padding: '0.75rem 1rem',
fontWeight: '700',
focusRing: { focusRing: {
width: '{focus.ring.width}', width: '{focus.ring.width}',
style: '{focus.ring.style}', style: '{focus.ring.style}',
@ -24,6 +22,9 @@ export default {
shadow: 'inset {focus.ring.shadow}' shadow: 'inset {focus.ring.shadow}'
} }
}, },
columnTitle: {
fontWeight: '700'
},
row: { row: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}', hoverBackground: '{content.hover.background}',
@ -45,14 +46,15 @@ export default {
}, },
footerCell: { footerCell: {
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
},
columnFooter: {
fontWeight: '700' fontWeight: '700'
}, },
footer: { footer: {
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
borderWidth: '0 0 1px 0', borderWidth: '0 0 1px 0',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
fontWeight: '700'
}, },
dropPointColor: '{primary.color}', dropPointColor: '{primary.color}',
columnResizerWidth: '0.5rem', columnResizerWidth: '0.5rem',

View File

@ -7,8 +7,7 @@ export default {
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
color: '{content.color}', color: '{content.color}',
borderWidth: '1px 0 1px 0', borderWidth: '1px 0 1px 0',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
fontWeight: '700'
}, },
headerCell: { headerCell: {
background: '{content.background}', background: '{content.background}',
@ -20,7 +19,6 @@ export default {
selectedColor: '{highlight.color}', selectedColor: '{highlight.color}',
gap: '0.5rem', gap: '0.5rem',
padding: '0.75rem 1rem', padding: '0.75rem 1rem',
fontWeight: '700',
focusRing: { focusRing: {
width: '{focus.ring.width}', width: '{focus.ring.width}',
style: '{focus.ring.style}', style: '{focus.ring.style}',
@ -29,6 +27,9 @@ export default {
shadow: '{focus.ring.shadow}' shadow: '{focus.ring.shadow}'
} }
}, },
columnTitle: {
fontWeight: '700'
},
row: { row: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}', hoverBackground: '{content.hover.background}',
@ -52,7 +53,9 @@ export default {
background: '{content.background}', background: '{content.background}',
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
color: '{content.color}', color: '{content.color}',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
},
columnFooter: {
fontWeight: '700' fontWeight: '700'
}, },
footer: { footer: {
@ -60,8 +63,7 @@ export default {
borderColor: '{datatable.border.color}', borderColor: '{datatable.border.color}',
color: '{content.color}', color: '{content.color}',
borderWidth: '0 0 1px 0', borderWidth: '0 0 1px 0',
padding: '0.75rem 1rem', padding: '0.75rem 1rem'
fontWeight: '700'
}, },
dropPointColor: '{primary.color}', dropPointColor: '{primary.color}',
columnResizerWidth: '0.5rem', columnResizerWidth: '0.5rem',