diff --git a/ui/src/shared/components/ViewTypeSelector.scss b/ui/src/shared/components/ViewTypeSelector.scss deleted file mode 100644 index eb80b48f7e..0000000000 --- a/ui/src/shared/components/ViewTypeSelector.scss +++ /dev/null @@ -1,159 +0,0 @@ -/* - Graph Type Selector Styles - ------------------------------------------------------------------------------ -*/ - -$graph-type--card: 190px; -$graph-type--margin: 4px; -$graph-type--graphic: 150px; - -.graph-type-selector { - background-color: $g3-castle; -} - -.graph-type-selector--container { - min-width: 200px; - padding: 30px; -} - -.graph-type-selector--grid { - width: 100%; - display: inline-block; - margin: 0 (-10px / 2); - margin-bottom: -10px; -} - -.graph-type-selector--option { - float: left; - width: $graph-type--card; - padding-bottom: $graph-type--card; - position: relative; - - > div > p { - margin: 0; - font-size: 14px; - font-weight: 900; - position: absolute; - bottom: 7%; - left: 10px; - width: calc(100% - 20px); - text-align: center; - display: inline-block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - - // Actual "card" - > div { - background-color: $g2-kevlar; - color: $g11-sidewalk; - border-radius: $ix-radius; - width: $graph-type--card - ($graph-type--margin / 2); - height: $graph-type--card - ($graph-type--margin / 2); - position: absolute; - top: 10px / 2; - left: 10px / 2; - transition: color 0.25s ease, border-color 0.25s ease, - background-color 0.25s ease; - - &:hover { - cursor: pointer; - background-color: $g4-onyx; - color: $g15-platinum; - } - } -} - -// Active state "card" -.graph-type-selector--option.active > div, -.graph-type-selector--option.active > div:hover { - background-color: $g5-pepper; - color: $g18-cloud; -} - -.graph-type-selector--graphic { - width: $graph-type--graphic; - height: $graph-type--graphic; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - - > svg, - > svg * { - transform: translate3d(0, 0, 0); - } - > svg { - width: 100%; - height: 100%; - } -} -.graph-type-selector--graphic-line { - stroke-width: 1px; - fill: none; - stroke-linecap: round; - stroke-miterlimit: 10; - - &.graphic-line-a { - stroke: $g11-sidewalk; - } - &.graphic-line-b { - stroke: $g9-mountain; - } - &.graphic-line-c { - stroke: $g7-graphite; - } - &.graphic-line-d { - stroke: $g13-mist; - } -} -.graph-type-selector--graphic-fill { - opacity: 0.045; - - &.graphic-fill-a { - fill: $g11-sidewalk; - } - &.graphic-fill-b { - fill: $g9-mountain; - } - &.graphic-fill-c { - fill: $g7-graphite; - } - &.graphic-fill-d { - fill: $g13-mist; - opacity: 1; - } -} -.graph-type-selector--option.active .graph-type-selector--graphic { - .graph-type-selector--graphic-line.graphic-line-a { - stroke: $c-pool; - } - .graph-type-selector--graphic-line.graphic-line-b { - stroke: $c-dreamsicle; - } - .graph-type-selector--graphic-line.graphic-line-c { - stroke: $c-rainforest; - } - .graph-type-selector--graphic-line.graphic-line-d { - stroke: $g17-whisper; - } - .graph-type-selector--graphic-fill.graphic-fill-a { - fill: $c-pool; - } - .graph-type-selector--graphic-fill.graphic-fill-b { - fill: $c-dreamsicle; - } - .graph-type-selector--graphic-fill.graphic-fill-c { - fill: $c-rainforest; - } - .graph-type-selector--graphic-fill.graphic-fill-a, - .graph-type-selector--graphic-fill.graphic-fill-b, - .graph-type-selector--graphic-fill.graphic-fill-c { - opacity: 0.22; - } - .graph-type-selector--graphic-fill.graphic-fill-d { - fill: $g17-whisper; - opacity: 1; - } -} \ No newline at end of file diff --git a/ui/src/shared/components/ViewTypeSelector.tsx b/ui/src/shared/components/ViewTypeSelector.tsx deleted file mode 100644 index 5c725980b0..0000000000 --- a/ui/src/shared/components/ViewTypeSelector.tsx +++ /dev/null @@ -1,50 +0,0 @@ -// Libraries -import React, {Component} from 'react' -import classnames from 'classnames' - -// Constants -import {GRAPH_TYPES} from 'src/dashboards/graphics/graph' - -// Decorators -import {ErrorHandling} from 'src/shared/decorators/errors' - -// Types -import {ViewType} from 'src/types/v2' - -interface Props { - type: string - onUpdateType: (newType: ViewType) => void -} - -@ErrorHandling -class ViewTypeSelector extends Component { - public render() { - const {type} = this.props - - return ( -
-
- {GRAPH_TYPES.map(graphType => ( -
-
- {graphType.graphic} -

{graphType.menuOption}

-
-
- ))} -
-
- ) - } - - private handleSelectType = (newType: ViewType) => (): void => { - this.props.onUpdateType(newType) - } -} - -export default ViewTypeSelector diff --git a/ui/src/shared/components/view_options/ViewTypeDropdown.scss b/ui/src/shared/components/view_options/ViewTypeDropdown.scss new file mode 100644 index 0000000000..28386c1e85 --- /dev/null +++ b/ui/src/shared/components/view_options/ViewTypeDropdown.scss @@ -0,0 +1,107 @@ +@import "src/style/modules"; + +.view-type-dropdown { + .dropdown-item--children, .dropdown--selected { + display: flex; + align-items: center; + } + + .dropdown--selected { + .view-type-dropdown--name { + margin-left: 8px; + } + + .view-type-dropdown--graphic { + width: 20px; + height: 20px; + } + } +} + +.view-type-dropdown--name { + margin-left: 10px; +} + +.view-type-dropdown--graphic { + width: 40px; + height: 40px; +} + +.vis-graphic--line { + stroke-width: 1px; + fill: none; + stroke-linecap: round; + stroke-miterlimit: 10; +} + +.vis-graphic--line-a { + stroke: $g11-sidewalk; +} + +.vis-graphic--line-b { + stroke: $g9-mountain; +} + +.vis-graphic--line-c { + stroke: $g7-graphite; +} + +.vis-graphic--line-d { + stroke: $g13-mist; +} + +.vis-graphic--fill-a { + fill: $g11-sidewalk; +} + +.vis-graphic--fill-b { + fill: $g9-mountain; +} + +.vis-graphic--fill-c { + fill: $g7-graphite; +} + +.vis-graphic--fill-d { + fill: $g13-mist; + opacity: 1; +} + +.vis-graphic--line-a { + stroke: $c-pool; +} + +.vis-graphic--line-b { + stroke: $c-dreamsicle; +} + +.vis-graphic--line-c { + stroke: $c-rainforest; +} + +.vis-graphic--line-d { + stroke: $g17-whisper; +} + +.vis-graphic--fill-a { + fill: $c-pool; +} + +.vis-graphic--fill-b { + fill: $c-dreamsicle; +} + +.vis-graphic--fill-c { + fill: $c-rainforest; +} + +.vis-graphic--fill-a, +.vis-graphic--fill-b, +.vis-graphic--fill-c { + opacity: 0.5; +} + +.vis-graphic--fill-d { + fill: $g17-whisper; + opacity: 1; +} diff --git a/ui/src/shared/components/view_options/ViewTypeDropdown.tsx b/ui/src/shared/components/view_options/ViewTypeDropdown.tsx index 774aab68dc..448d192944 100644 --- a/ui/src/shared/components/view_options/ViewTypeDropdown.tsx +++ b/ui/src/shared/components/view_options/ViewTypeDropdown.tsx @@ -6,13 +6,16 @@ import {connect} from 'react-redux' import {setType} from 'src/shared/actions/v2/timeMachines' // Components -import {Dropdown} from 'src/clockface' +import {Dropdown, DropdownMenuColors} from 'src/clockface' // Utils import {getActiveTimeMachine} from 'src/shared/selectors/timeMachines' // Constants -import {GRAPH_TYPES} from 'src/dashboards/graphics/graph' +import {VIS_GRAPHICS} from 'src/shared/constants/visGraphics' + +// Styles +import 'src/shared/components/view_options/ViewTypeDropdown.scss' // Types import {View, NewView, AppState, ViewType} from 'src/types/v2' @@ -33,7 +36,9 @@ class ViewTypeDropdown extends PureComponent { {this.dropdownItems} @@ -47,13 +52,14 @@ class ViewTypeDropdown extends PureComponent { } private get dropdownItems(): JSX.Element[] { - return GRAPH_TYPES.map(g => ( + return VIS_GRAPHICS.map(g => ( - {g.menuOption} +
{g.graphic}
+
{g.name}
)) } diff --git a/ui/src/dashboards/graphics/graph.tsx b/ui/src/shared/constants/visGraphics.tsx similarity index 69% rename from ui/src/dashboards/graphics/graph.tsx rename to ui/src/shared/constants/visGraphics.tsx index 592c214400..d3eaf396cd 100644 --- a/ui/src/dashboards/graphics/graph.tsx +++ b/ui/src/shared/constants/visGraphics.tsx @@ -2,19 +2,9 @@ import React from 'react' import {ViewType} from 'src/types/v2/dashboards' -type Graphic = JSX.Element - -interface GraphSVGs { - [ViewType.XY]: Graphic - [ViewType.LinePlusSingleStat]: Graphic - [ViewType.SingleStat]: Graphic - [ViewType.Gauge]: Graphic - [ViewType.Table]: Graphic -} - -const GRAPH_SVGS: GraphSVGs = { - xy: ( -
+const GRAPHIC_SVGS = { + [ViewType.XY]: ( +
), - 'single-stat': ( -
+ [ViewType.SingleStat]: ( +
), - 'line-plus-single-stat': ( -
+ [ViewType.LinePlusSingleStat]: ( +
), - gauge: ( -
+ [ViewType.Gauge]: ( +
), - table: ( -
+ [ViewType.Table]: ( +
@@ -358,35 +348,30 @@ const GRAPH_SVGS: GraphSVGs = { ), } -interface GraphType { - type: ViewType - menuOption: string - graphic: Graphic -} -export const GRAPH_TYPES: GraphType[] = [ +export const VIS_GRAPHICS = [ { type: ViewType.XY, - menuOption: 'Graph', - graphic: GRAPH_SVGS[ViewType.XY], + name: 'Graph', + graphic: GRAPHIC_SVGS[ViewType.XY], }, { type: ViewType.LinePlusSingleStat, - menuOption: 'Graph + Single Stat', - graphic: GRAPH_SVGS[ViewType.LinePlusSingleStat], + name: 'Graph + Single Stat', + graphic: GRAPHIC_SVGS[ViewType.LinePlusSingleStat], }, { type: ViewType.SingleStat, - menuOption: 'Single Stat', - graphic: GRAPH_SVGS[ViewType.SingleStat], + name: 'Single Stat', + graphic: GRAPHIC_SVGS[ViewType.SingleStat], }, { type: ViewType.Gauge, - menuOption: 'Gauge', - graphic: GRAPH_SVGS[ViewType.Gauge], + name: 'Gauge', + graphic: GRAPHIC_SVGS[ViewType.Gauge], }, { type: ViewType.Table, - menuOption: 'Table', - graphic: GRAPH_SVGS[ViewType.Table], + name: 'Table', + graphic: GRAPHIC_SVGS[ViewType.Table], }, ] diff --git a/ui/src/style/chronograf.scss b/ui/src/style/chronograf.scss index a94d029fe4..0c5561a1fd 100644 --- a/ui/src/style/chronograf.scss +++ b/ui/src/style/chronograf.scss @@ -29,7 +29,6 @@ @import 'src/shared/components/code_mirror/CodeMirror'; @import 'src/shared/components/code_mirror/CodeMirrorTheme'; @import 'src/dashboards/components/dashboard_empty/DashboardEmpty'; -@import 'src/shared/components/ViewTypeSelector'; @import 'src/shared/components/views/Markdown'; @import 'src/shared/components/custom_singular_time/CustomSingularTime'; @import 'src/onboarding/OnboardingWizard.scss';