Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

feat: add paddingX prop #1240

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-table-padding
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add prop to define table padding

We've added new prop called `paddingX` which can be used to set the padding along x axis of the `oc-table` or `oc-table-files`.

https://github.com/owncloud/owncloud-design-system/pull/1240
34 changes: 33 additions & 1 deletion src/components/table/OcTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import OcTr from "./_OcTableRow"
import OcTh from "./_OcTableCellHead"
import OcTd from "./_OcTableCellData"
import SortMixin from "./mixins/sort"
import { getSizeClass } from "../../utils/sizeClasses"

import { EVENT_THEAD_CLICKED, EVENT_TROW_CLICKED } from "./helpers/constants"

Expand Down Expand Up @@ -162,6 +163,16 @@ export default {
required: false,
default: 0,
},
/**
* Sets the padding size for x axis
* @values xsmall, small, medium, large, xlarge
*/
paddingX: {
type: String,
required: false,
default: "small",
validator: size => /(xsmall|small|medium|large|xlarge)/.test(size),
},
},
data() {
return {
Expand Down Expand Up @@ -218,7 +229,19 @@ export default {
props.class += ` ${field.thClass}`
}
if (this.sticky) {
props.style = `${this.headerPosition}px`
props.style = `top: ${this.headerPosition}px;`
}

if (index === 0) {
props.class += ` oc-pl-${getSizeClass(this.paddingX)} `
}

if (index === this.fields.length - 1) {
if (field.sortable) {
props.style += `padding-right: calc(var(--oc-space-${this.paddingX}) + 0.65em)`
} else {
props.class += ` oc-pr-${getSizeClass(this.paddingX)}`
}
}

this.extractSortThProps(props, field, index)
Expand All @@ -245,6 +268,15 @@ export default {
if (Object.prototype.hasOwnProperty.call(field, "wrap")) {
props.wrap = field.wrap
}

if (index === 0) {
props.class += ` oc-pl-${getSizeClass(this.paddingX)} `
}

if (index === this.fields.length - 1) {
props.class += ` oc-pr-${getSizeClass(this.paddingX)}`
}

return props
},
extractCellProps(field) {
Expand Down
10 changes: 10 additions & 0 deletions src/components/table/OcTableFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ export default {
required: false,
default: null,
},
/**
* Sets the padding size for x axis
* @values xsmall, small, medium, large, xlarge
*/
paddingX: {
type: String,
required: false,
default: "small",
validator: size => /(xsmall|small|medium|large|xlarge)/.test(size),
},
},
computed: {
fields() {
Expand Down