forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style(legend): align k7 design (opensearch-project#54)
The legend respect the chart theme margins. The toggle is now moved to the bottom left of the chart as in kibana new design. Added the euiScrollBar on legend. Refactored the use of classnames package using object for the conditional class fix opensearch-project#34
- Loading branch information
Showing
7 changed files
with
148 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,122 @@ | ||
$euiChartLegendMaxWidth: $euiSize * 10 + $euiSize; | ||
$euiChartLegendMaxHeight: $euiSize * 4 + $euiSize; | ||
$elasticChartsLegendMaxWidth: $euiSize * 10 + $euiSize; | ||
$elasticChartsLegendMaxHeight: $euiSize * 4 + $euiSize; | ||
|
||
.euiChartLegend { | ||
.elasticChartsLegend { | ||
position: absolute; | ||
display: flex; | ||
align-items: flex-start; | ||
flex-direction: row; | ||
} | ||
.euiChartLegend--collapsed { | ||
.elasticChartsLegend--collapsed { | ||
width: $euiSize * 2 !important; | ||
height: $euiSize * 2 !important; | ||
.euiChartLegendList { | ||
.elasticChartsLegendList { | ||
display: none; | ||
} | ||
} | ||
.euiChartLegend--debug { | ||
.elasticChartsLegend--debug { | ||
background: red; | ||
} | ||
.euiChartLegend--top { | ||
.elasticChartsLegend--top { | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
width: auto; | ||
height: $euiChartLegendMaxHeight; | ||
height: $elasticChartsLegendMaxHeight; | ||
flex-direction: column; | ||
order: 1; | ||
.euiChartLegend__listItem { | ||
.elasticChartsLegend__listItem { | ||
min-height: 50%; | ||
width: $euiChartLegendMaxWidth; | ||
min-width: $euiChartLegendMaxWidth; | ||
width: $elasticChartsLegendMaxWidth; | ||
min-width: $elasticChartsLegendMaxWidth; | ||
} | ||
} | ||
.euiChartLegend--bottom { | ||
.elasticChartsLegend--bottom { | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
width: auto; | ||
height: $euiChartLegendMaxHeight; | ||
height: $elasticChartsLegendMaxHeight; | ||
flex-direction: column; | ||
.euiChartLegend__listItem { | ||
.elasticChartsLegend__listItem { | ||
min-height: 50%; | ||
width: $euiChartLegendMaxWidth; | ||
min-width: $euiChartLegendMaxWidth; | ||
width: $elasticChartsLegendMaxWidth; | ||
min-width: $elasticChartsLegendMaxWidth; | ||
} | ||
} | ||
.euiChartLegend--left { | ||
.elasticChartsLegend--left { | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
width: $euiChartLegendMaxWidth; | ||
width: $elasticChartsLegendMaxWidth; | ||
order: 1; | ||
.euiChartLegend__listItem { | ||
.elasticChartsLegend__listItem { | ||
min-width: 100%; | ||
} | ||
} | ||
.euiChartLegend--right { | ||
.elasticChartsLegend--right { | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
width: $euiChartLegendMaxWidth; | ||
.euiChartLegend__listItem { | ||
width: $elasticChartsLegendMaxWidth; | ||
.elasticChartsLegend__listItem { | ||
min-width: 100%; | ||
} | ||
} | ||
|
||
|
||
.euiChartLegendCollapser { | ||
.elasticChartsLegendCollapser { | ||
width: 2 * $euiSize; | ||
height: 2 * $euiSize; | ||
flex-shrink: 0; | ||
flex-grow: 0; | ||
} | ||
.euiChartLegendCollapser--top { | ||
.elasticChartsLegendCollapser--top { | ||
order: 2; | ||
} | ||
.euiChartLegendCollapser--left { | ||
.elasticChartsLegendCollapser--left { | ||
order: 2; | ||
} | ||
|
||
|
||
|
||
.euiChartLegendListContainer { | ||
.elasticChartsLegendListContainer { | ||
overflow: hidden; | ||
flex-shrink: 1; | ||
flex-grow: 0; | ||
} | ||
.euiChartLegendList { | ||
.elasticChartsLegendList { | ||
overflow-y: auto; | ||
overflow-x: hidden; | ||
height: 100%; | ||
@include euiScrollBar; | ||
} | ||
.euiChartLegendListItem__title { | ||
width: $euiChartLegendMaxWidth - 4 * $euiSize; | ||
max-width: $euiChartLegendMaxWidth - 4 * $euiSize; | ||
} | ||
.euiChartLegendList__item { | ||
|
||
.elasticChartsLegendList__item { | ||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
} | ||
|
||
.elasticChartsLegendListItem__title { | ||
width: $elasticChartsLegendMaxWidth - 4 * $euiSize; | ||
max-width: $elasticChartsLegendMaxWidth - 4 * $euiSize; | ||
} | ||
|
||
.elasticChartsLegend__toggle { | ||
border-radius: $euiBorderRadius; | ||
border-bottom-right-radius: 0; | ||
border-top-left-radius: 0; | ||
border-bottom-left-radius: 0; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
opacity: 0; | ||
background-color: $euiColorEmptyShade; | ||
transition: opacity $euiAnimSpeedFast $euiAnimSlightResistance, | ||
background-color $euiAnimSpeedFast $euiAnimSlightResistance $euiAnimSpeedExtraSlow; | ||
&:focus { | ||
box-shadow: none; | ||
background-color: $euiFocusBackgroundColor !important; | ||
} | ||
} | ||
.elasticChartsLegend__toggle--isOpen { | ||
background-color: transparentize($euiColorDarkestShade, 0.9); | ||
} |
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
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,38 @@ | ||
import { EuiButtonIcon } from '@elastic/eui'; | ||
import classNames from 'classnames'; | ||
import { inject, observer } from 'mobx-react'; | ||
import React from 'react'; | ||
import { ChartStore } from '../state/chart_state'; | ||
|
||
interface ReactiveChartProps { | ||
chartStore?: ChartStore; | ||
} | ||
|
||
class LegendButtonComponent extends React.Component<ReactiveChartProps> { | ||
static displayName = 'Legend'; | ||
onCollapseLegend = () => { | ||
this.props.chartStore!.toggleLegendCollapsed(); | ||
} | ||
|
||
render() { | ||
const { initialized, legendItems, legendCollapsed, showLegend } = this.props.chartStore!; | ||
|
||
if (!showLegend.get() || !initialized.get() || legendItems.length === 0) { | ||
return null; | ||
} | ||
const isOpen = !legendCollapsed.get(); | ||
const className = classNames('elasticChartsLegend__toggle', { | ||
'elasticChartsLegend__toggle--isOpen': isOpen, | ||
}); | ||
return ( | ||
<EuiButtonIcon | ||
className={className} | ||
onClick={this.onCollapseLegend} | ||
iconType="list" | ||
aria-label={legendCollapsed.get() ? 'Expand legend' : 'Collapse legend'} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export const LegendButton = inject('chartStore')(observer(LegendButtonComponent)); |
Oops, something went wrong.