Skip to content

Commit

Permalink
Adds the ability to hide columns in agreement list on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
fellmirr committed Nov 18, 2024
1 parent ed8332c commit 2abb90b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type AgreementListConfigurationColumn = {
width?: string;
payment_date_format_template?: string;
payment_date_last_day_of_month_template?: string;
hide_on_mobile?: boolean;
};

type AgreementListConfiguration = {
Expand All @@ -58,7 +59,11 @@ export const AgreementList: React.FC<{
agreementKid: string;
} | null>(null);

const headers = configuration.columns.map((column) => ({
const columns = configuration.columns.filter(
(column) => window && !(window.innerWidth < 1180 && column.hide_on_mobile),
);

const headers = columns.map((column) => ({
label: column.title,
width: column.width,
}));
Expand Down Expand Up @@ -107,7 +112,7 @@ export const AgreementList: React.FC<{
const rows: ListRow<AgreementRow>[] = rowData.map((agreement) => ({
id: agreement.ID.toString(),
defaultExpanded: false,
cells: configuration.columns.map((column) => ({
cells: columns.map((column) => ({
value: formatColumnValue(column, agreement[column.value]),
})),
details: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,41 @@
}

@media only screen and (max-width: 1180px) {
.values {
flex-direction: column;
row-gap: 1.5em;
font-size: 1rem;

input {
width: 100%;
}
.wrapper {
grid-template-columns: 1fr;
column-gap: 0;
row-gap: 2rem;

.values {
flex-direction: column;
row-gap: 1.5em;
font-size: 1rem;

& > div {
&.valuesDatePickerContainer {
input {
width: 100%;

& > div {
width: 100%;
}
}

&.valuesAmountContainer {
input {
& > div {
&.valuesDatePickerContainer {
width: 100%;

& > div {
width: 100%;
}
}
}

&.valuesTaxUnitSelectorContainer {
width: 100%;
&.valuesAmountContainer {
input {
width: 100%;
}
}

& > div {
&.valuesTaxUnitSelectorContainer {
width: 100%;

& > div {
width: 100%;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export default {
title: "Column width in % (optional)",
type: "number",
},
{
name: "hide_on_mobile",
title: "Hide on mobile",
type: "boolean",
},
],
preview: {
select: {
Expand Down

0 comments on commit 2abb90b

Please sign in to comment.