Skip to content

Commit

Permalink
feat: add layoutOpen flag for view layouts (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
bocembocem authored Nov 8, 2023
1 parent 84248e5 commit 51aa5f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const ViewAccordeon = <T extends ArrayViewLayoutProps | ObjectViewLayoutP
spec,
children,
}: T): JSX.Element | null => {
const [open, setOpen] = React.useState(true);
const [open, setOpen] = React.useState(
_.isBoolean(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true,
);

if (!isNotEmptyValue(value, spec)) {
return null;
Expand Down
6 changes: 5 additions & 1 deletion src/lib/kit/components/ViewLayouts/ViewCardAccordeon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import _ from 'lodash';

import {Card} from '../';
import {ArrayViewLayoutProps, ObjectViewLayoutProps} from '../../../core';
import {isNotEmptyValue} from '../../utils';
Expand All @@ -10,7 +12,9 @@ export const ViewCardAccordeon = <T extends ArrayViewLayoutProps | ObjectViewLay
spec,
children,
}: T): JSX.Element | null => {
const [open, setOpen] = React.useState(true);
const [open, setOpen] = React.useState(
_.isBoolean(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true,
);

const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);

Expand Down

0 comments on commit 51aa5f0

Please sign in to comment.