forked from elastic/kibana
-
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.
* Added shape function * Added color arg type * Added shape render function * Added shapes * Added shape components and shape arg type * Cleaned up shapes * Added stroke-miterlimit to prevent corners from beveling * Removed unused prop and id from shape_picker_mini * Added default values to color, number, shape, and toggle. Generated id in popover * Updated default shape element expression * Fixed falsy check for borderWidth to allow 0. Changed default color arg value to black
- Loading branch information
Showing
43 changed files
with
407 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { shape } from './shape'; |
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,46 @@ | ||
export const shape = () => ({ | ||
name: 'shape', | ||
aliases: [], | ||
type: 'shape', | ||
help: 'Create a shape', | ||
context: { | ||
types: ['null'], | ||
}, | ||
args: { | ||
_: { | ||
types: ['string', 'null'], | ||
help: 'Pick a shape', | ||
aliases: ['shape'], | ||
default: 'square', | ||
}, | ||
fill: { | ||
types: ['string', 'null'], | ||
help: 'Valid CSS color string', | ||
default: 'black', | ||
}, | ||
border: { | ||
types: ['string', 'null'], | ||
aliases: ['stroke'], | ||
help: 'Valid CSS color string', | ||
}, | ||
borderWidth: { | ||
types: ['number', 'null'], | ||
aliases: ['strokeWidth'], | ||
help: 'Thickness of the border', | ||
default: '0', | ||
}, | ||
maintainAspect: { | ||
types: ['boolean'], | ||
help: 'Select true to maintain aspect ratio', | ||
default: false, | ||
}, | ||
}, | ||
fn: (context, { _, fill, border, borderWidth, maintainAspect }) => ({ | ||
type: 'shape', | ||
shape: _, | ||
fill, | ||
border, | ||
borderWidth, | ||
maintainAspect, | ||
}), | ||
}); |
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,12 @@ | ||
export const shape = () => ({ | ||
name: 'shape', | ||
to: { | ||
render: input => { | ||
return { | ||
type: 'render', | ||
as: 'shape', | ||
value: input, | ||
}; | ||
}, | ||
}, | ||
}); |
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,5 @@ | ||
import { pure } from 'recompose'; | ||
|
||
import { ShapePicker as Component } from './shape_picker'; | ||
|
||
export const ShapePicker = pure(Component); |
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,26 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { EuiFlexGrid, EuiFlexItem, EuiLink } from '@elastic/eui'; | ||
import { shapes } from '../../render_functions/shape/shapes'; | ||
import { ShapePreview } from '../shape_preview'; | ||
|
||
export const ShapePicker = ({ onChange }) => { | ||
return ( | ||
<EuiFlexGrid gutterSize="s" columns={4}> | ||
{Object.keys(shapes) | ||
.sort() | ||
.map(shapeKey => ( | ||
<EuiFlexItem key={shapeKey}> | ||
<EuiLink onClick={() => onChange(shapeKey)}> | ||
<ShapePreview value={shapeKey} /> | ||
</EuiLink> | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGrid> | ||
); | ||
}; | ||
|
||
ShapePicker.propTypes = { | ||
value: PropTypes.string, | ||
onChange: PropTypes.func, | ||
}; |
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,5 @@ | ||
import { pure } from 'recompose'; | ||
|
||
import { ShapePickerMini as Component } from './shape_picker_mini'; | ||
|
||
export const ShapePickerMini = pure(Component); |
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,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { EuiLink } from '@elastic/eui'; | ||
import { Popover } from '../popover'; | ||
import { ShapePicker } from '../shape_picker/'; | ||
import { ShapePreview } from '../shape_preview'; | ||
|
||
export const ShapePickerMini = ({ onChange, value, anchorPosition }) => { | ||
const button = handleClick => ( | ||
<EuiLink style={{ fontSize: 0 }} onClick={handleClick}> | ||
<ShapePreview value={value} /> | ||
</EuiLink> | ||
); | ||
|
||
return ( | ||
<Popover | ||
panelClassName="canvas canvasShapePickerMini--popover" | ||
button={button} | ||
anchorPosition={anchorPosition} | ||
> | ||
{() => <ShapePicker onChange={onChange} value={value} />} | ||
</Popover> | ||
); | ||
}; | ||
|
||
ShapePickerMini.propTypes = { | ||
value: PropTypes.string, | ||
onChange: PropTypes.func, | ||
anchorPosition: PropTypes.string, | ||
}; |
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,3 @@ | ||
.canvasShapePickerMini--popover { | ||
width: 220px; | ||
} |
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,5 @@ | ||
import { pure } from 'recompose'; | ||
|
||
import { ShapePreview as Component } from './shape_preview'; | ||
|
||
export const ShapePreview = pure(Component); |
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,11 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { shapes } from '../../render_functions/shape/shapes'; | ||
|
||
export const ShapePreview = ({ value }) => { | ||
return <div className="canvasShapePreview" dangerouslySetInnerHTML={{ __html: shapes[value] }} />; | ||
}; | ||
|
||
ShapePreview.propTypes = { | ||
value: PropTypes.string, | ||
}; |
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,10 @@ | ||
.canvasShapePreview { | ||
width: $euiSizeXXL; | ||
height: $euiSizeXXL; | ||
|
||
svg { | ||
fill: black; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} |
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,25 +1,25 @@ | ||
import { debug } from './debug'; | ||
import { dropdownFilter } from './dropdown_filter'; | ||
//import { grid } from './grid'; | ||
import { image } from './image'; | ||
import { repeatImage } from './repeatImage'; | ||
import { revealImage } from './revealImage'; | ||
import { markdown } from './markdown'; | ||
import { pie } from './pie'; | ||
import { plot } from './plot'; | ||
import { shape } from './shape'; | ||
import { table } from './table'; | ||
import { timeFilter } from './time_filter'; | ||
|
||
export const elementSpecs = [ | ||
timeFilter, | ||
dropdownFilter, | ||
debug, | ||
//grid, | ||
image, | ||
repeatImage, | ||
revealImage, | ||
markdown, | ||
plot, | ||
pie, | ||
shape, | ||
table, | ||
]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
export { shape } from './shape'; |
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,12 @@ | ||
import header from './header.svg'; | ||
|
||
export const shape = () => ({ | ||
name: 'shape', | ||
displayName: 'Shape', | ||
help: 'A customizable shape', | ||
width: 200, | ||
height: 200, | ||
image: header, | ||
expression: | ||
'shape "square" fill="#4cbce4" border="rgba(255,255,255,0)" borderWidth=0 maintainAspect=true | render', | ||
}); |
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,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { templateFromReactComponent } from '../../lib/template_from_react_component'; | ||
import { ColorPickerMini } from '../../components/color_picker_mini/'; | ||
|
||
const ColorArgInput = ({ onValueChange, argValue, workpad }) => ( | ||
<EuiFlexGroup gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<ColorPickerMini value={argValue} onChange={onValueChange} colors={workpad.colors} /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
|
||
ColorArgInput.propTypes = { | ||
argValue: PropTypes.any.isRequired, | ||
onValueChange: PropTypes.func.isRequired, | ||
workpad: PropTypes.shape({ | ||
colors: PropTypes.array.isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export const color = () => ({ | ||
name: 'color', | ||
displayName: 'Color', | ||
help: 'Color picker', | ||
simpleTemplate: templateFromReactComponent(ColorArgInput), | ||
default: '#000000', | ||
}); |
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,27 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { shapes } from '../../render_functions/shape/shapes'; | ||
import { templateFromReactComponent } from '../../lib/template_from_react_component'; | ||
import { ShapePickerMini } from '../../components/shape_picker_mini/'; | ||
|
||
const ShapeArgInput = ({ onValueChange, argValue }) => ( | ||
<EuiFlexGroup gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<ShapePickerMini value={argValue} onChange={onValueChange} shapes={shapes} /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
|
||
ShapeArgInput.propTypes = { | ||
argValue: PropTypes.any.isRequired, | ||
onValueChange: PropTypes.func.isRequired, | ||
}; | ||
|
||
export const shape = () => ({ | ||
name: 'shape', | ||
displayName: 'Shape', | ||
help: 'Shape picker', | ||
simpleTemplate: templateFromReactComponent(ShapeArgInput), | ||
default: '"square"', | ||
}); |
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
Oops, something went wrong.