-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
108 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
querybook/webapp/components/DataTableViewColumn/DataTableColumnCardNestedType.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as React from 'react'; | ||
|
||
import { ComplexType } from 'lib/utils/complex-types'; | ||
import { IconButton } from 'ui/Button/IconButton'; | ||
import { AccentText, StyledText } from 'ui/StyledText/StyledText'; | ||
|
||
interface IDataTableColumnCardNestedTypeProps { | ||
complexType: ComplexType; | ||
} | ||
export const DataTableColumnCardNestedType: React.FunctionComponent< | ||
IDataTableColumnCardNestedTypeProps | ||
> = ({ complexType }) => { | ||
const hasChildren = complexType.children?.length > 0; | ||
const [expanded, setExpanded] = React.useState(false); | ||
|
||
const rowProps = { | ||
className: 'flex-row', | ||
}; | ||
|
||
if (hasChildren) { | ||
rowProps['onClick'] = () => setExpanded(!expanded); | ||
rowProps['aria-label'] = expanded | ||
? 'click to collapse' | ||
: 'click to expand'; | ||
rowProps['data-balloon-pos'] = 'down-left'; | ||
} | ||
|
||
return ( | ||
<div className="DataTableColumnCardNestedType"> | ||
<div {...rowProps}> | ||
{hasChildren && ( | ||
<IconButton | ||
icon={expanded ? 'Minus' : 'Plus'} | ||
size="16" | ||
noPadding={true} | ||
className="expand-icon" | ||
/> | ||
)} | ||
<AccentText weight="extra" className="mr12"> | ||
{complexType.key} | ||
</AccentText> | ||
<StyledText | ||
color="light" | ||
className={`column-type ${!hasChildren && 'nested-indent'}`} | ||
> | ||
{complexType.type} | ||
</StyledText> | ||
</div> | ||
{hasChildren && | ||
expanded && | ||
complexType.children?.map((child) => ( | ||
<div className="nested-indent m16" key={child.key}> | ||
<DataTableColumnCardNestedType complexType={child} /> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters