diff --git a/src/components/data/attributetable/attributetable.scss b/src/components/data/attributetable/attributetable.scss index 9f4e4e7..11a0952 100644 --- a/src/components/data/attributetable/attributetable.scss +++ b/src/components/data/attributetable/attributetable.scss @@ -1,10 +1,55 @@ .mykn-attributetable { display: table; + background-color: var(--typogrpahy-color-background); + width: 100%; + + &--compact { + width: unset; + + & .mykn-attributetable__body { + grid-template-columns: 1fr; + row-gap: 0; + } + + & .mykn-attributetable__row { + border: none; + padding-block-end: 0; + padding-block-start: 0; + + &:last-of-type { + border: none; + padding-block-end: 0; + padding-block-start: 0; + } + } + + // Cell key bold + & .mykn-attributetable__cell--key { + font-weight: var(--typography-font-weight-bold); + } + } &__body { display: grid; - grid-template-columns: auto auto; + grid-template-columns: 1fr; column-gap: var(--spacing-h); + row-gap: 0; + } + + &__row { + display: grid; + grid-template-columns: 1fr 2fr; + column-gap: var(--spacing-h); + align-items: center; + + border-block-start: 1px solid var(--typography-color-border); + padding-block-end: var(--spacing-v); + padding-block-start: var(--spacing-v); + + &:last-of-type { + border-block-end: 1px solid var(--typography-color-border); + padding-block-end: var(--spacing-v); + } } &__cell { @@ -15,20 +60,25 @@ font-weight: var(--typography-font-weight-normal); line-height: var(--typography-line-height-body-s); margin: 0; - } - &--valign-start &__cell { - align-items: flex-start; - } + &--key { + grid-column: 1; - &__cell--key { - font-weight: var(--typography-font-weight-bold); - } - &__cell--key > .mykn-icon:last-child { - margin-inline-start: var(--spacing-h); + > .mykn-icon:last-child { + margin-inline-start: var(--spacing-h); + } + } + + &--value { + grid-column: 2; + } + + > .mykn-icon { + margin-inline-end: var(--spacing-h); + } } - &__cell > .mykn-icon { - margin-inline-end: var(--spacing-h); + &--valign-start &__cell { + align-items: flex-start; } } diff --git a/src/components/data/attributetable/attributetable.stories.tsx b/src/components/data/attributetable/attributetable.stories.tsx index 5caae5c..c56edcc 100644 --- a/src/components/data/attributetable/attributetable.stories.tsx +++ b/src/components/data/attributetable/attributetable.stories.tsx @@ -29,6 +29,22 @@ export const AttributeTableComponent: Story = { }, }; +export const AttributeTableComponentCompact: Story = { + args: { + object: { + url: "https://www.example.com", + omschrijving: "Afvalpas vervangen", + zaaktype: "https://www.example.com", + versie: 2, + opmerkingen: null, + actief: false, + toekomstig: false, + concept: true, + }, + compact: true, + }, +}; + export const LabeledAttributeTableComponent: Story = { args: { labeledObject: { diff --git a/src/components/data/attributetable/attributetable.tsx b/src/components/data/attributetable/attributetable.tsx index e43fab2..a6a102d 100644 --- a/src/components/data/attributetable/attributetable.tsx +++ b/src/components/data/attributetable/attributetable.tsx @@ -24,8 +24,8 @@ export type AttributeTableProps = { labelCancel?: string; labelEdit?: string; valign?: "middle" | "start"; + compact?: boolean; }; - export const AttributeTable: React.FC = ({ object = {}, labeledObject = {}, @@ -35,6 +35,7 @@ export const AttributeTable: React.FC = ({ labelCancel, labelEdit, valign = "middle", + compact = false, ...props }) => { const intl = useIntl(); @@ -66,7 +67,13 @@ export const AttributeTable: React.FC = ({ {renderRows()} ) : ( -
{renderRows()}
+
+ {renderRows()} +
); }; @@ -80,6 +87,7 @@ export const AttributeTable: React.FC = ({ object={object} labeledObject={labeledObject} labelEdit={labelEdit} + compact={compact} onClick={() => setIsFormOpenState(true)} /> )); @@ -89,6 +97,7 @@ export const AttributeTable: React.FC = ({ className={clsx( "mykn-attributetable", `mykn-attributetable--valign-${valign}`, + { "mykn-attributetable--compact": compact }, )} {...props} > @@ -105,8 +114,8 @@ export type AttributeTableRowProps = { isFormOpen: boolean; labelEdit?: string; onClick: React.MouseEventHandler; + compact?: boolean; }; - export const AttributeTableRow: React.FC = ({ editable = false, field, @@ -114,6 +123,7 @@ export const AttributeTableRow: React.FC = ({ object = {}, labeledObject = {}, labelEdit, + compact = false, onClick, }) => { const id = useId(); @@ -143,9 +153,6 @@ export const AttributeTableRow: React.FC = ({ { ...field, label: label || field.name }, ); - /** - * Renders the value (if not already a React.ReactNode). - */ const renderValue = () => { return editable ? (