-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
4 changed files
with
157 additions
and
118 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...lier_exploration/outlier_exploration.scss → ...xpandable_section/expandable_section.scss
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.mlSectionPanel { | ||
.mlExpandableSection { | ||
padding: 0 $euiSizeS $euiSizeS $euiSizeS; | ||
} |
52 changes: 52 additions & 0 deletions
52
...nalytics/pages/analytics_exploration/components/expandable_section/expandable_section.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,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import './expandable_section.scss'; | ||
|
||
import React, { useState, FC, ReactNode } from 'react'; | ||
|
||
import { EuiButtonEmpty, EuiPanel } from '@elastic/eui'; | ||
|
||
interface ExpandableSectionProps { | ||
content: ReactNode; | ||
headerContent: ReactNode; | ||
isExpanded?: boolean; | ||
title: ReactNode; | ||
} | ||
|
||
export const ExpandableSection: FC<ExpandableSectionProps> = ({ | ||
headerContent, | ||
// For now we don't have a need for complete external control | ||
// and just want to pass in a default value. If we wanted | ||
// full external control we'd also need to add a onToggleExpanded() | ||
// callback. | ||
isExpanded: isExpandedDefault = true, | ||
content, | ||
title, | ||
}) => { | ||
const [isExpanded, setIsExpanded] = useState(isExpandedDefault); | ||
const toggleExpanded = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
return ( | ||
<EuiPanel paddingSize="none" data-test-subj="mlDFAnalyticsOutlierExplorationTablePanel"> | ||
<div className="mlExpandableSection"> | ||
<EuiButtonEmpty | ||
onClick={toggleExpanded} | ||
iconType={isExpanded ? 'arrowUp' : 'arrowDown'} | ||
size="l" | ||
iconSide="right" | ||
flush="left" | ||
> | ||
{title} | ||
</EuiButtonEmpty> | ||
{headerContent} | ||
</div> | ||
{isExpanded && content} | ||
</EuiPanel> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
...n/data_frame_analytics/pages/analytics_exploration/components/expandable_section/index.ts
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,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { ExpandableSection } from './expandable_section'; |
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