mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-16 19:40:58 +03:00
chore(*): upgrade prettier (#570)
* chore(*): upgrade prettier * chore(*): upgrade prettier
This commit is contained in:
parent
08ef5bf838
commit
10bf7bc084
|
@ -4,11 +4,11 @@ module.exports = {
|
||||||
[
|
[
|
||||||
'@babel/plugin-transform-runtime',
|
'@babel/plugin-transform-runtime',
|
||||||
{
|
{
|
||||||
regenerator: true
|
regenerator: true,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
['@babel/plugin-proposal-decorators', { legacy: true }],
|
['@babel/plugin-proposal-decorators', { legacy: true }],
|
||||||
'@babel/plugin-proposal-class-properties',
|
'@babel/plugin-proposal-class-properties',
|
||||||
'@babel/plugin-proposal-export-default-from'
|
'@babel/plugin-proposal-export-default-from',
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ The client driver provides a way to connect to the server via websockets (see th
|
||||||
```js
|
```js
|
||||||
var socket = socketCluster.connect({
|
var socket = socketCluster.connect({
|
||||||
hostname: 'localhost',
|
hostname: 'localhost',
|
||||||
port: 8000
|
port: 8000,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -39,13 +39,13 @@ SocketCluster client handles reconnecting for you, but you still might want to k
|
||||||
##### JavaScript
|
##### JavaScript
|
||||||
|
|
||||||
```js
|
```js
|
||||||
socket.on('connect', status => {
|
socket.on('connect', (status) => {
|
||||||
// Here will come the next step
|
// Here will come the next step
|
||||||
});
|
});
|
||||||
socket.on('disconnect', code => {
|
socket.on('disconnect', (code) => {
|
||||||
console.warn('Socket disconnected with code', code);
|
console.warn('Socket disconnected with code', code);
|
||||||
});
|
});
|
||||||
socket.on('error', error => {
|
socket.on('error', (error) => {
|
||||||
console.warn('Socket error', error);
|
console.warn('Socket error', error);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -125,7 +125,7 @@ const message = {
|
||||||
payload: state,
|
payload: state,
|
||||||
id: socket.id,
|
id: socket.id,
|
||||||
instanceId: window.btoa(location.href),
|
instanceId: window.btoa(location.href),
|
||||||
name: document.title
|
name: document.title,
|
||||||
};
|
};
|
||||||
socket.emit(socket.id ? 'log' : 'log-noid', message);
|
socket.emit(socket.id ? 'log' : 'log-noid', message);
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setupFiles: ['devui/tests/setup.js']
|
setupFiles: ['devui/tests/setup.js'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"jest": "^26.2.2",
|
"jest": "^26.2.2",
|
||||||
"lerna": "^3.22.1",
|
"lerna": "^3.22.1",
|
||||||
"lint-staged": "^10.2.11",
|
"lint-staged": "^10.2.11",
|
||||||
"prettier": "^1.19.1"
|
"prettier": "^2.0.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lerna": "lerna",
|
"lerna": "lerna",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
d3-state-visualizer
|
# d3-state-visualizer
|
||||||
===================
|
|
||||||
Enables real-time visualization of your application state.
|
Enables real-time visualization of your application state.
|
||||||
|
|
||||||
Created by [@romseguy](https://github.com/romseguy) and merged from [`reduxjs/d3-state-visualizer`](https://github.com/reduxjs/d3-state-visualizer).
|
Created by [@romseguy](https://github.com/romseguy) and merged from [`reduxjs/d3-state-visualizer`](https://github.com/reduxjs/d3-state-visualizer).
|
||||||
|
@ -18,13 +18,13 @@ import { tree } from 'd3-state-visualizer';
|
||||||
const appState = {
|
const appState = {
|
||||||
todoStore: {
|
todoStore: {
|
||||||
todos: [
|
todos: [
|
||||||
{ title: 'd3'},
|
{ title: 'd3' },
|
||||||
{ title: 'state' },
|
{ title: 'state' },
|
||||||
{ title: 'visualizer' },
|
{ title: 'visualizer' },
|
||||||
{ title: 'tree' }
|
{ title: 'tree' },
|
||||||
],
|
],
|
||||||
completedCount: 1
|
completedCount: 1,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const render = tree(document.getElementById('root'), {
|
const render = tree(document.getElementById('root'), {
|
||||||
|
@ -35,40 +35,42 @@ const render = tree(document.getElementById('root'), {
|
||||||
isSorted: false,
|
isSorted: false,
|
||||||
widthBetweenNodesCoeff: 1.5,
|
widthBetweenNodesCoeff: 1.5,
|
||||||
heightBetweenNodesCoeff: 2,
|
heightBetweenNodesCoeff: 2,
|
||||||
style: {border: '1px solid black'},
|
style: { border: '1px solid black' },
|
||||||
tooltipOptions: {offset: {left: 30, top: 10}, indentationSize: 2}
|
tooltipOptions: { offset: { left: 30, top: 10 }, indentationSize: 2 },
|
||||||
});
|
});
|
||||||
|
|
||||||
render();
|
render();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Charts API
|
## Charts API
|
||||||
|
|
||||||
The APIs are minimal and consists of a single function you provide with:
|
The APIs are minimal and consists of a single function you provide with:
|
||||||
|
|
||||||
- a DOM element
|
- a DOM element
|
||||||
- a plain old JS object for options.
|
- a plain old JS object for options.
|
||||||
|
|
||||||
#### Tree
|
#### Tree
|
||||||
|
|
||||||
This chart is a bit special as it accepts either one of the two following options, but **not both**:
|
This chart is a bit special as it accepts either one of the two following options, but **not both**:
|
||||||
|
|
||||||
- `tree`: a properly formed tree structure such as one generated by [map2tree](https://github.com/reduxjs/redux-devtools/tree/master/packages/map2tree) or [react2tree](https://github.com/romseguy/react2tree)
|
- `tree`: a properly formed tree structure such as one generated by [map2tree](https://github.com/reduxjs/redux-devtools/tree/master/packages/map2tree) or [react2tree](https://github.com/romseguy/react2tree)
|
||||||
- `state`: a plain javascript object mapping arbitrarily nested keys to values – which will be transformed into a tree structure, again using [map2tree](https://github.com/reduxjs/redux-devtools/tree/master/packages/map2tree).
|
- `state`: a plain javascript object mapping arbitrarily nested keys to values – which will be transformed into a tree structure, again using [map2tree](https://github.com/reduxjs/redux-devtools/tree/master/packages/map2tree).
|
||||||
|
|
||||||
Other options are listed below and have reasonable default values if you want to omit them:
|
Other options are listed below and have reasonable default values if you want to omit them:
|
||||||
|
|
||||||
Option | Type | Default | Description
|
| Option | Type | Default | Description |
|
||||||
--------------------------|----------|-------------|-------------------------------------------------------------------------
|
| ------------------------- | ------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
`id` | String | `'d3svg'` | Sets the identifier of the SVG element —i.e your chart— that will be added to the DOM element you passed as first argument
|
| `id` | String | `'d3svg'` | Sets the identifier of the SVG element —i.e your chart— that will be added to the DOM element you passed as first argument |
|
||||||
`style` | Object | `{}` | Sets the CSS style of the chart
|
| `style` | Object | `{}` | Sets the CSS style of the chart |
|
||||||
`size` | Number | `500` | Sets size of the chart in pixels
|
| `size` | Number | `500` | Sets size of the chart in pixels |
|
||||||
`aspectRatio` | Float | `1.0` | Sets the chart height to `size * aspectRatio` and [viewBox](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox) in order to preserve the aspect ratio of the chart. [Great video](https://www.youtube.com/watch?v=FCOeMy7HrBc) if you want to learn more about how SVG works
|
| `aspectRatio` | Float | `1.0` | Sets the chart height to `size * aspectRatio` and [viewBox](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox) in order to preserve the aspect ratio of the chart. [Great video](https://www.youtube.com/watch?v=FCOeMy7HrBc) if you want to learn more about how SVG works |
|
||||||
`widthBetweenNodesCoeff` | Float | `1.0` | Alters the horizontal space between each node
|
| `widthBetweenNodesCoeff` | Float | `1.0` | Alters the horizontal space between each node |
|
||||||
`heightBetweenNodesCoeff` | Float | `1.0` | Alters the vertical space between each node
|
| `heightBetweenNodesCoeff` | Float | `1.0` | Alters the vertical space between each node |
|
||||||
`isSorted` | Boolean | `false` | Sorts the chart in alphabetical order
|
| `isSorted` | Boolean | `false` | Sorts the chart in alphabetical order |
|
||||||
`transitionDuration` | Number | `750` | Sets the duration of all the transitions used by the chart
|
| `transitionDuration` | Number | `750` | Sets the duration of all the transitions used by the chart |
|
||||||
`tooltipOptions` | Object | [here](https://github.com/reduxjs/redux-devtools/tree/master/packages/d3tooltip) | Sets the options for the [tooltip](https://github.com/reduxjs/redux-devtools/tree/master/packages/d3tooltip) that is showing up when you're hovering the nodes
|
| `tooltipOptions` | Object | [here](https://github.com/reduxjs/redux-devtools/tree/master/packages/d3tooltip) | Sets the options for the [tooltip](https://github.com/reduxjs/redux-devtools/tree/master/packages/d3tooltip) that is showing up when you're hovering the nodes |
|
||||||
`rootKeyName` | String | `'state'` | Sets the first node's name of the resulting tree structure. **Warning**: only works if you provide a `state` option
|
| `rootKeyName` | String | `'state'` | Sets the first node's name of the resulting tree structure. **Warning**: only works if you provide a `state` option |
|
||||||
`pushMethod` | String | `'push'` | Sets the method that shall be used to add array children to the tree. **Warning**: only works if you provide a `state` option
|
| `pushMethod` | String | `'push'` | Sets the method that shall be used to add array children to the tree. **Warning**: only works if you provide a `state` option |
|
||||||
|
|
||||||
More to come...
|
More to come...
|
||||||
|
|
||||||
|
@ -80,4 +82,4 @@ More to come...
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
* Threshold for large arrays so only a single node is displayed instead of all the children. That single node would be exclude from searching until selected.
|
- Threshold for large arrays so only a single node is displayed instead of all the children. That single node would be exclude from searching until selected.
|
||||||
|
|
|
@ -1,42 +1,39 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>State tree with d3-state-visualizer</title>
|
<title>State tree with d3-state-visualizer</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
.node {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.node {
|
.nodeCircle {
|
||||||
cursor: pointer;
|
stroke: black;
|
||||||
}
|
stroke-width: 1.5px;
|
||||||
|
}
|
||||||
|
|
||||||
.nodeCircle {
|
.nodeText {
|
||||||
stroke: black;
|
font-family: sans-serif;
|
||||||
stroke-width: 1.5px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nodeText {
|
.link {
|
||||||
font-family: sans-serif;
|
fill: none;
|
||||||
font-size: 10px;
|
stroke: #ccc;
|
||||||
}
|
stroke-width: 1.5px;
|
||||||
|
}
|
||||||
|
|
||||||
.link {
|
.tooltip {
|
||||||
fill: none;
|
font-family: Consolas, Menlo, Monaco, monospace;
|
||||||
stroke: #ccc;
|
font-size: 0.8em;
|
||||||
stroke-width: 1.5px;
|
background: rgba(0, 0, 0, 0.5);
|
||||||
}
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
.tooltip {
|
border-radius: 5px;
|
||||||
font-family: Consolas, Menlo, Monaco, monospace;
|
}
|
||||||
font-size: 0.8em;
|
</style>
|
||||||
background: rgba(0, 0, 0, 0.5);
|
</head>
|
||||||
color: white;
|
<body>
|
||||||
padding: 10px;
|
<div id="root"></div>
|
||||||
border-radius: 5px;
|
<script src="/static/bundle.js"></script>
|
||||||
}
|
</body>
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="root">
|
|
||||||
</div>
|
|
||||||
<script src="/static/bundle.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,18 +6,18 @@ const appState = {
|
||||||
{ title: 'd3' },
|
{ title: 'd3' },
|
||||||
{ title: 'state' },
|
{ title: 'state' },
|
||||||
{ title: 'visualizer' },
|
{ title: 'visualizer' },
|
||||||
{ title: 'tree' }
|
{ title: 'tree' },
|
||||||
],
|
],
|
||||||
completedCount: 1,
|
completedCount: 1,
|
||||||
alphabeticalOrder: true
|
alphabeticalOrder: true,
|
||||||
},
|
},
|
||||||
someStore: {
|
someStore: {
|
||||||
someProperty: 0,
|
someProperty: 0,
|
||||||
someObject: {
|
someObject: {
|
||||||
anotherProperty: 'value',
|
anotherProperty: 'value',
|
||||||
someArray: [0, 1, 2]
|
someArray: [0, 1, 2],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const render = tree(document.getElementById('root'), {
|
const render = tree(document.getElementById('root'), {
|
||||||
|
@ -29,7 +29,7 @@ const render = tree(document.getElementById('root'), {
|
||||||
widthBetweenNodesCoeff: 1.5,
|
widthBetweenNodesCoeff: 1.5,
|
||||||
heightBetweenNodesCoeff: 2,
|
heightBetweenNodesCoeff: 2,
|
||||||
style: { border: '1px solid black' },
|
style: { border: '1px solid black' },
|
||||||
tooltipOptions: { offset: { left: 30, top: 10 }, indentationSize: 2 }
|
tooltipOptions: { offset: { left: 30, top: 10 }, indentationSize: 2 },
|
||||||
});
|
});
|
||||||
|
|
||||||
render();
|
render();
|
||||||
|
|
|
@ -7,9 +7,9 @@ new WebpackDevServer(webpack(config), {
|
||||||
hot: true,
|
hot: true,
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
stats: {
|
stats: {
|
||||||
colors: true
|
colors: true,
|
||||||
}
|
},
|
||||||
}).listen(3000, 'localhost', function(err) {
|
}).listen(3000, 'localhost', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
|
@ -7,16 +7,16 @@ module.exports = {
|
||||||
entry: [
|
entry: [
|
||||||
'webpack-dev-server/client?http://localhost:3000',
|
'webpack-dev-server/client?http://localhost:3000',
|
||||||
'webpack/hot/only-dev-server',
|
'webpack/hot/only-dev-server',
|
||||||
'./index'
|
'./index',
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'dist'),
|
path: path.join(__dirname, 'dist'),
|
||||||
filename: 'bundle.js',
|
filename: 'bundle.js',
|
||||||
publicPath: '/static/'
|
publicPath: '/static/',
|
||||||
},
|
},
|
||||||
plugins: [new webpack.HotModuleReplacementPlugin()],
|
plugins: [new webpack.HotModuleReplacementPlugin()],
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js']
|
extensions: ['.js'],
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -24,8 +24,8 @@ module.exports = {
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loaders: ['babel-loader'],
|
loaders: ['babel-loader'],
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: __dirname
|
include: __dirname,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ function sortObject(obj, strict) {
|
||||||
const tObj = {};
|
const tObj = {};
|
||||||
Object.keys(obj)
|
Object.keys(obj)
|
||||||
.sort()
|
.sort()
|
||||||
.forEach(key => (tObj[key] = sortObject(obj[key])));
|
.forEach((key) => (tObj[key] = sortObject(obj[key])));
|
||||||
return tObj;
|
return tObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
134
packages/d3-state-visualizer/src/charts/tree/tree.js
vendored
134
packages/d3-state-visualizer/src/charts/tree/tree.js
vendored
|
@ -6,7 +6,7 @@ import {
|
||||||
getTooltipString,
|
getTooltipString,
|
||||||
toggleChildren,
|
toggleChildren,
|
||||||
visit,
|
visit,
|
||||||
getNodeGroupByDepthCount
|
getNodeGroupByDepthCount,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import d3tooltip from 'd3tooltip';
|
import d3tooltip from 'd3tooltip';
|
||||||
|
|
||||||
|
@ -21,20 +21,20 @@ const defaultOptions = {
|
||||||
colors: {
|
colors: {
|
||||||
default: '#ccc',
|
default: '#ccc',
|
||||||
collapsed: 'lightsteelblue',
|
collapsed: 'lightsteelblue',
|
||||||
parent: 'white'
|
parent: 'white',
|
||||||
},
|
},
|
||||||
radius: 7
|
radius: 7,
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
colors: {
|
colors: {
|
||||||
default: 'black',
|
default: 'black',
|
||||||
hover: 'skyblue'
|
hover: 'skyblue',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
stroke: '#000',
|
stroke: '#000',
|
||||||
fill: 'none'
|
fill: 'none',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
size: 500,
|
size: 500,
|
||||||
aspectRatio: 1.0,
|
aspectRatio: 1.0,
|
||||||
|
@ -43,7 +43,7 @@ const defaultOptions = {
|
||||||
top: 10,
|
top: 10,
|
||||||
right: 10,
|
right: 10,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
left: 50
|
left: 50,
|
||||||
},
|
},
|
||||||
isSorted: false,
|
isSorted: false,
|
||||||
heightBetweenNodesCoeff: 2,
|
heightBetweenNodesCoeff: 2,
|
||||||
|
@ -57,13 +57,13 @@ const defaultOptions = {
|
||||||
right: undefined,
|
right: undefined,
|
||||||
offset: {
|
offset: {
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0
|
top: 0,
|
||||||
},
|
},
|
||||||
style: undefined
|
style: undefined,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function(DOMNode, options = {}) {
|
export default function (DOMNode, options = {}) {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
style,
|
style,
|
||||||
|
@ -81,7 +81,7 @@ export default function(DOMNode, options = {}) {
|
||||||
pushMethod,
|
pushMethod,
|
||||||
tree,
|
tree,
|
||||||
tooltipOptions,
|
tooltipOptions,
|
||||||
onClickText
|
onClickText,
|
||||||
} = deepmerge(defaultOptions, options);
|
} = deepmerge(defaultOptions, options);
|
||||||
|
|
||||||
const width = size - margin.left - margin.right;
|
const width = size - margin.left - margin.right;
|
||||||
|
@ -91,7 +91,7 @@ export default function(DOMNode, options = {}) {
|
||||||
|
|
||||||
const attr = {
|
const attr = {
|
||||||
id,
|
id,
|
||||||
preserveAspectRatio: 'xMinYMin slice'
|
preserveAspectRatio: 'xMinYMin slice',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!style.width) {
|
if (!style.width) {
|
||||||
|
@ -103,10 +103,7 @@ export default function(DOMNode, options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const root = d3.select(DOMNode);
|
const root = d3.select(DOMNode);
|
||||||
const zoom = d3.behavior
|
const zoom = d3.behavior.zoom().scaleExtent([0.1, 3]).scale(initialZoom);
|
||||||
.zoom()
|
|
||||||
.scaleExtent([0.1, 3])
|
|
||||||
.scale(initialZoom);
|
|
||||||
const vis = root
|
const vis = root
|
||||||
.append('svg')
|
.append('svg')
|
||||||
.attr(attr)
|
.attr(attr)
|
||||||
|
@ -121,7 +118,7 @@ export default function(DOMNode, options = {}) {
|
||||||
.attr({
|
.attr({
|
||||||
transform: `translate(${margin.left + style.node.radius}, ${
|
transform: `translate(${margin.left + style.node.radius}, ${
|
||||||
margin.top
|
margin.top
|
||||||
}) scale(${initialZoom})`
|
}) scale(${initialZoom})`,
|
||||||
});
|
});
|
||||||
|
|
||||||
let layout = d3.layout.tree().size([width, height]);
|
let layout = d3.layout.tree().size([width, height]);
|
||||||
|
@ -141,8 +138,8 @@ export default function(DOMNode, options = {}) {
|
||||||
id: 'root',
|
id: 'root',
|
||||||
parentId: null,
|
parentId: null,
|
||||||
x: height / 2,
|
x: height / 2,
|
||||||
y: 0
|
y: 0,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// traverses a map with node positions by going through the chain
|
// traverses a map with node positions by going through the chain
|
||||||
|
@ -169,7 +166,7 @@ export default function(DOMNode, options = {}) {
|
||||||
if (isEmpty(data) || !data.name) {
|
if (isEmpty(data) || !data.name) {
|
||||||
data = {
|
data = {
|
||||||
name: 'error',
|
name: 'error',
|
||||||
message: 'Please provide a state map or a tree structure'
|
message: 'Please provide a state map or a tree structure',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,13 +178,13 @@ export default function(DOMNode, options = {}) {
|
||||||
// top-level elemnt always has id "root"
|
// top-level elemnt always has id "root"
|
||||||
visit(
|
visit(
|
||||||
data,
|
data,
|
||||||
node => {
|
(node) => {
|
||||||
maxLabelLength = Math.max(node.name.length, maxLabelLength);
|
maxLabelLength = Math.max(node.name.length, maxLabelLength);
|
||||||
node.id = node.id || 'root';
|
node.id = node.id || 'root';
|
||||||
},
|
},
|
||||||
node =>
|
(node) =>
|
||||||
node.children && node.children.length > 0
|
node.children && node.children.length > 0
|
||||||
? node.children.map(c => {
|
? node.children.map((c) => {
|
||||||
c.id = `${node.id || ''}|${c.name}`;
|
c.id = `${node.id || ''}|${c.name}`;
|
||||||
return c;
|
return c;
|
||||||
})
|
})
|
||||||
|
@ -200,69 +197,69 @@ export default function(DOMNode, options = {}) {
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
// path generator for links
|
// path generator for links
|
||||||
const diagonal = d3.svg.diagonal().projection(d => [d.y, d.x]);
|
const diagonal = d3.svg.diagonal().projection((d) => [d.y, d.x]);
|
||||||
// set tree dimensions and spacing between branches and nodes
|
// set tree dimensions and spacing between branches and nodes
|
||||||
const maxNodeCountByLevel = Math.max(...getNodeGroupByDepthCount(data));
|
const maxNodeCountByLevel = Math.max(...getNodeGroupByDepthCount(data));
|
||||||
|
|
||||||
layout = layout.size([
|
layout = layout.size([
|
||||||
maxNodeCountByLevel * 25 * heightBetweenNodesCoeff,
|
maxNodeCountByLevel * 25 * heightBetweenNodesCoeff,
|
||||||
width
|
width,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let nodes = layout.nodes(data);
|
let nodes = layout.nodes(data);
|
||||||
let links = layout.links(nodes);
|
let links = layout.links(nodes);
|
||||||
|
|
||||||
nodes.forEach(
|
nodes.forEach(
|
||||||
node =>
|
(node) =>
|
||||||
(node.y = node.depth * (maxLabelLength * 7 * widthBetweenNodesCoeff))
|
(node.y = node.depth * (maxLabelLength * 7 * widthBetweenNodesCoeff))
|
||||||
);
|
);
|
||||||
|
|
||||||
const nodePositions = nodes.map(n => ({
|
const nodePositions = nodes.map((n) => ({
|
||||||
parentId: n.parent && n.parent.id,
|
parentId: n.parent && n.parent.id,
|
||||||
id: n.id,
|
id: n.id,
|
||||||
x: n.x,
|
x: n.x,
|
||||||
y: n.y
|
y: n.y,
|
||||||
}));
|
}));
|
||||||
const nodePositionsById = {};
|
const nodePositionsById = {};
|
||||||
nodePositions.forEach(node => (nodePositionsById[node.id] = node));
|
nodePositions.forEach((node) => (nodePositionsById[node.id] = node));
|
||||||
|
|
||||||
// process the node selection
|
// process the node selection
|
||||||
let node = vis
|
let node = vis
|
||||||
.selectAll('g.node')
|
.selectAll('g.node')
|
||||||
.property('__oldData__', d => d)
|
.property('__oldData__', (d) => d)
|
||||||
.data(nodes, d => d.id || (d.id = ++nodeIndex));
|
.data(nodes, (d) => d.id || (d.id = ++nodeIndex));
|
||||||
let nodeEnter = node
|
let nodeEnter = node
|
||||||
.enter()
|
.enter()
|
||||||
.append('g')
|
.append('g')
|
||||||
.attr({
|
.attr({
|
||||||
class: 'node',
|
class: 'node',
|
||||||
transform: d => {
|
transform: (d) => {
|
||||||
const position = findParentNodePosition(
|
const position = findParentNodePosition(
|
||||||
nodePositionsById,
|
nodePositionsById,
|
||||||
d.id,
|
d.id,
|
||||||
n => previousNodePositionsById[n.id]
|
(n) => previousNodePositionsById[n.id]
|
||||||
);
|
);
|
||||||
const previousPosition =
|
const previousPosition =
|
||||||
(position && previousNodePositionsById[position.id]) ||
|
(position && previousNodePositionsById[position.id]) ||
|
||||||
previousNodePositionsById.root;
|
previousNodePositionsById.root;
|
||||||
return `translate(${previousPosition.y},${previousPosition.x})`;
|
return `translate(${previousPosition.y},${previousPosition.x})`;
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.style({
|
.style({
|
||||||
fill: style.text.colors.default,
|
fill: style.text.colors.default,
|
||||||
cursor: 'pointer'
|
cursor: 'pointer',
|
||||||
})
|
})
|
||||||
.on({
|
.on({
|
||||||
mouseover: function mouseover() {
|
mouseover: function mouseover() {
|
||||||
d3.select(this).style({
|
d3.select(this).style({
|
||||||
fill: style.text.colors.hover
|
fill: style.text.colors.hover,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
mouseout: function mouseout() {
|
mouseout: function mouseout() {
|
||||||
d3.select(this).style({
|
d3.select(this).style({
|
||||||
fill: style.text.colors.default
|
fill: style.text.colors.default,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!tooltipOptions.disabled) {
|
if (!tooltipOptions.disabled) {
|
||||||
|
@ -280,14 +277,14 @@ export default function(DOMNode, options = {}) {
|
||||||
.append('circle')
|
.append('circle')
|
||||||
.attr({
|
.attr({
|
||||||
class: 'nodeCircle',
|
class: 'nodeCircle',
|
||||||
r: 0
|
r: 0,
|
||||||
})
|
})
|
||||||
.on({
|
.on({
|
||||||
click: clickedNode => {
|
click: (clickedNode) => {
|
||||||
if (d3.event.defaultPrevented) return;
|
if (d3.event.defaultPrevented) return;
|
||||||
toggleChildren(clickedNode);
|
toggleChildren(clickedNode);
|
||||||
update();
|
update();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
nodeEnterInnerGroup
|
nodeEnterInnerGroup
|
||||||
|
@ -296,29 +293,29 @@ export default function(DOMNode, options = {}) {
|
||||||
class: 'nodeText',
|
class: 'nodeText',
|
||||||
'text-anchor': 'middle',
|
'text-anchor': 'middle',
|
||||||
transform: 'translate(0,0)',
|
transform: 'translate(0,0)',
|
||||||
dy: '.35em'
|
dy: '.35em',
|
||||||
})
|
})
|
||||||
.style({
|
.style({
|
||||||
'fill-opacity': 0
|
'fill-opacity': 0,
|
||||||
})
|
})
|
||||||
.text(d => d.name)
|
.text((d) => d.name)
|
||||||
.on({
|
.on({
|
||||||
click: onClickText
|
click: onClickText,
|
||||||
});
|
});
|
||||||
|
|
||||||
// update the text to reflect whether node has children or not
|
// update the text to reflect whether node has children or not
|
||||||
node.select('text').text(d => d.name);
|
node.select('text').text((d) => d.name);
|
||||||
|
|
||||||
// change the circle fill depending on whether it has children and is collapsed
|
// change the circle fill depending on whether it has children and is collapsed
|
||||||
node.select('circle').style({
|
node.select('circle').style({
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
'stroke-width': '1.5px',
|
'stroke-width': '1.5px',
|
||||||
fill: d =>
|
fill: (d) =>
|
||||||
d._children
|
d._children
|
||||||
? style.node.colors.collapsed
|
? style.node.colors.collapsed
|
||||||
: d.children
|
: d.children
|
||||||
? style.node.colors.parent
|
? style.node.colors.parent
|
||||||
: style.node.colors.default
|
: style.node.colors.default,
|
||||||
});
|
});
|
||||||
|
|
||||||
// transition nodes to their new position
|
// transition nodes to their new position
|
||||||
|
@ -326,7 +323,7 @@ export default function(DOMNode, options = {}) {
|
||||||
.transition()
|
.transition()
|
||||||
.duration(transitionDuration)
|
.duration(transitionDuration)
|
||||||
.attr({
|
.attr({
|
||||||
transform: d => `translate(${d.y},${d.x})`
|
transform: (d) => `translate(${d.y},${d.x})`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ensure circle radius is correct
|
// ensure circle radius is correct
|
||||||
|
@ -342,7 +339,7 @@ export default function(DOMNode, options = {}) {
|
||||||
(d.children || d._children ? -1 : 1) *
|
(d.children || d._children ? -1 : 1) *
|
||||||
(this.getBBox().width / 2 + style.node.radius + 5);
|
(this.getBBox().width / 2 + style.node.radius + 5);
|
||||||
return `translate(${x},0)`;
|
return `translate(${x},0)`;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// blink updated nodes
|
// blink updated nodes
|
||||||
|
@ -366,17 +363,17 @@ export default function(DOMNode, options = {}) {
|
||||||
.transition()
|
.transition()
|
||||||
.duration(transitionDuration)
|
.duration(transitionDuration)
|
||||||
.attr({
|
.attr({
|
||||||
transform: d => {
|
transform: (d) => {
|
||||||
const position = findParentNodePosition(
|
const position = findParentNodePosition(
|
||||||
previousNodePositionsById,
|
previousNodePositionsById,
|
||||||
d.id,
|
d.id,
|
||||||
n => nodePositionsById[n.id]
|
(n) => nodePositionsById[n.id]
|
||||||
);
|
);
|
||||||
const futurePosition =
|
const futurePosition =
|
||||||
(position && nodePositionsById[position.id]) ||
|
(position && nodePositionsById[position.id]) ||
|
||||||
nodePositionsById.root;
|
nodePositionsById.root;
|
||||||
return `translate(${futurePosition.y},${futurePosition.x})`;
|
return `translate(${futurePosition.y},${futurePosition.x})`;
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.remove();
|
.remove();
|
||||||
|
|
||||||
|
@ -385,7 +382,7 @@ export default function(DOMNode, options = {}) {
|
||||||
nodeExit.select('text').style('fill-opacity', 0);
|
nodeExit.select('text').style('fill-opacity', 0);
|
||||||
|
|
||||||
// update the links
|
// update the links
|
||||||
let link = vis.selectAll('path.link').data(links, d => d.target.id);
|
let link = vis.selectAll('path.link').data(links, (d) => d.target.id);
|
||||||
|
|
||||||
// enter any new links at the parent's previous position
|
// enter any new links at the parent's previous position
|
||||||
link
|
link
|
||||||
|
@ -393,30 +390,27 @@ export default function(DOMNode, options = {}) {
|
||||||
.insert('path', 'g')
|
.insert('path', 'g')
|
||||||
.attr({
|
.attr({
|
||||||
class: 'link',
|
class: 'link',
|
||||||
d: d => {
|
d: (d) => {
|
||||||
const position = findParentNodePosition(
|
const position = findParentNodePosition(
|
||||||
nodePositionsById,
|
nodePositionsById,
|
||||||
d.target.id,
|
d.target.id,
|
||||||
n => previousNodePositionsById[n.id]
|
(n) => previousNodePositionsById[n.id]
|
||||||
);
|
);
|
||||||
const previousPosition =
|
const previousPosition =
|
||||||
(position && previousNodePositionsById[position.id]) ||
|
(position && previousNodePositionsById[position.id]) ||
|
||||||
previousNodePositionsById.root;
|
previousNodePositionsById.root;
|
||||||
return diagonal({
|
return diagonal({
|
||||||
source: previousPosition,
|
source: previousPosition,
|
||||||
target: previousPosition
|
target: previousPosition,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.style(style.link);
|
.style(style.link);
|
||||||
|
|
||||||
// transition links to their new position
|
// transition links to their new position
|
||||||
link
|
link.transition().duration(transitionDuration).attr({
|
||||||
.transition()
|
d: diagonal,
|
||||||
.duration(transitionDuration)
|
});
|
||||||
.attr({
|
|
||||||
d: diagonal
|
|
||||||
});
|
|
||||||
|
|
||||||
// transition exiting nodes to the parent's new position
|
// transition exiting nodes to the parent's new position
|
||||||
link
|
link
|
||||||
|
@ -424,20 +418,20 @@ export default function(DOMNode, options = {}) {
|
||||||
.transition()
|
.transition()
|
||||||
.duration(transitionDuration)
|
.duration(transitionDuration)
|
||||||
.attr({
|
.attr({
|
||||||
d: d => {
|
d: (d) => {
|
||||||
const position = findParentNodePosition(
|
const position = findParentNodePosition(
|
||||||
previousNodePositionsById,
|
previousNodePositionsById,
|
||||||
d.target.id,
|
d.target.id,
|
||||||
n => nodePositionsById[n.id]
|
(n) => nodePositionsById[n.id]
|
||||||
);
|
);
|
||||||
const futurePosition =
|
const futurePosition =
|
||||||
(position && nodePositionsById[position.id]) ||
|
(position && nodePositionsById[position.id]) ||
|
||||||
nodePositionsById.root;
|
nodePositionsById.root;
|
||||||
return diagonal({
|
return diagonal({
|
||||||
source: futurePosition,
|
source: futurePosition,
|
||||||
target: futurePosition
|
target: futurePosition,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.remove();
|
.remove();
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ export function getNodeGroupByDepthCount(rootNode) {
|
||||||
|
|
||||||
nodeGroupByDepthCount[depth + 1] += node.children.length;
|
nodeGroupByDepthCount[depth + 1] += node.children.length;
|
||||||
|
|
||||||
node.children.forEach(childNode => {
|
node.children.forEach((childNode) => {
|
||||||
traverseFrom(childNode, depth + 1);
|
traverseFrom(childNode, depth + 1);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ }
|
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
library: 'd3-state-visualizer',
|
library: 'd3-state-visualizer',
|
||||||
libraryTarget: 'umd'
|
libraryTarget: 'umd',
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js']
|
extensions: ['.js'],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ var config = Object.assign({}, baseConfig);
|
||||||
config.mode = 'development';
|
config.mode = 'development';
|
||||||
config.plugins = [
|
config.plugins = [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env.NODE_ENV': JSON.stringify('development')
|
'process.env.NODE_ENV': JSON.stringify('development'),
|
||||||
})
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|
|
@ -7,8 +7,8 @@ var config = Object.assign({}, baseConfig);
|
||||||
config.mode = 'production';
|
config.mode = 'production';
|
||||||
config.plugins = [
|
config.plugins = [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env.NODE_ENV': JSON.stringify('production')
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||||
})
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|
12
packages/d3tooltip/src/index.js
vendored
12
packages/d3tooltip/src/index.js
vendored
|
@ -6,7 +6,7 @@ const defaultOptions = {
|
||||||
left: undefined, // mouseX
|
left: undefined, // mouseX
|
||||||
top: undefined, // mouseY
|
top: undefined, // mouseY
|
||||||
offset: { left: 0, top: 0 },
|
offset: { left: 0, top: 0 },
|
||||||
root: undefined
|
root: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function tooltip(d3, className = 'tooltip', options = {}) {
|
export default function tooltip(d3, className = 'tooltip', options = {}) {
|
||||||
|
@ -22,7 +22,7 @@ export default function tooltip(d3, className = 'tooltip', options = {}) {
|
||||||
|
|
||||||
function tip(selection) {
|
function tip(selection) {
|
||||||
selection.on({
|
selection.on({
|
||||||
'mouseover.tip': node => {
|
'mouseover.tip': (node) => {
|
||||||
let [mouseX, mouseY] = d3.mouse(rootNode);
|
let [mouseX, mouseY] = d3.mouse(rootNode);
|
||||||
let [x, y] = [left || mouseX + offset.left, top || mouseY - offset.top];
|
let [x, y] = [left || mouseX + offset.left, top || mouseY - offset.top];
|
||||||
|
|
||||||
|
@ -36,22 +36,22 @@ export default function tooltip(d3, className = 'tooltip', options = {}) {
|
||||||
'z-index': 1001,
|
'z-index': 1001,
|
||||||
left: x + 'px',
|
left: x + 'px',
|
||||||
top: y + 'px',
|
top: y + 'px',
|
||||||
...styles
|
...styles,
|
||||||
})
|
})
|
||||||
.html(() => text(node));
|
.html(() => text(node));
|
||||||
},
|
},
|
||||||
|
|
||||||
'mousemove.tip': node => {
|
'mousemove.tip': (node) => {
|
||||||
let [mouseX, mouseY] = d3.mouse(rootNode);
|
let [mouseX, mouseY] = d3.mouse(rootNode);
|
||||||
let [x, y] = [left || mouseX + offset.left, top || mouseY - offset.top];
|
let [x, y] = [left || mouseX + offset.left, top || mouseY - offset.top];
|
||||||
|
|
||||||
el.style({
|
el.style({
|
||||||
left: x + 'px',
|
left: x + 'px',
|
||||||
top: y + 'px'
|
top: y + 'px',
|
||||||
}).html(() => text(node));
|
}).html(() => text(node));
|
||||||
},
|
},
|
||||||
|
|
||||||
'mouseout.tip': () => el.remove()
|
'mouseout.tip': () => el.remove(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
packages/d3tooltip/src/utils/index.js
vendored
2
packages/d3tooltip/src/utils/index.js
vendored
|
@ -3,5 +3,5 @@ import functor from './functor';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
prependClass,
|
prependClass,
|
||||||
functor
|
functor,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,27 +3,27 @@ const path = require('path');
|
||||||
module.exports = (env = {}) => ({
|
module.exports = (env = {}) => ({
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
entry: {
|
entry: {
|
||||||
app: ['./src/index.js']
|
app: ['./src/index.js'],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
library: 'd3tooltip',
|
library: 'd3tooltip',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
path: path.resolve(__dirname, 'dist'),
|
path: path.resolve(__dirname, 'dist'),
|
||||||
filename: env.minimize ? 'd3tooltip.min.js' : 'd3tooltip.js'
|
filename: env.minimize ? 'd3tooltip.min.js' : 'd3tooltip.js',
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: !!env.minimize
|
minimize: !!env.minimize,
|
||||||
},
|
},
|
||||||
performance: {
|
performance: {
|
||||||
hints: false
|
hints: false,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ addDecorator(
|
||||||
showStoriesPanel: true,
|
showStoriesPanel: true,
|
||||||
showAddonPanel: true,
|
showAddonPanel: true,
|
||||||
showSearchBox: false,
|
showSearchBox: false,
|
||||||
addonPanelInRight: true
|
addonPanelInRight: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ addDecorator(withInfo);
|
||||||
const req = require.context('../src/', true, /stories\/index\.js$/);
|
const req = require.context('../src/', true, /stories\/index\.js$/);
|
||||||
|
|
||||||
function loadStories() {
|
function loadStories() {
|
||||||
req.keys().forEach(filename => req(filename));
|
req.keys().forEach((filename) => req(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
configure(loadStories, module);
|
configure(loadStories, module);
|
||||||
|
|
|
@ -19,7 +19,7 @@ const themes = listThemes();
|
||||||
export default class Panel extends React.Component {
|
export default class Panel extends React.Component {
|
||||||
state = DEFAULT_THEME_STATE;
|
state = DEFAULT_THEME_STATE;
|
||||||
|
|
||||||
onChange = o => {
|
onChange = (o) => {
|
||||||
const state = { [o.name.split(' ').slice(-1)[0]]: o.value };
|
const state = { [o.name.split(' ').slice(-1)[0]]: o.value };
|
||||||
this.props.channel.emit(EVENT_ID_DATA, state);
|
this.props.channel.emit(EVENT_ID_DATA, state);
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
@ -37,19 +37,19 @@ export default class Panel extends React.Component {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
name: 'theme',
|
name: 'theme',
|
||||||
value: theme,
|
value: theme,
|
||||||
options: themes
|
options: themes,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
name: 'color scheme',
|
name: 'color scheme',
|
||||||
value: scheme,
|
value: scheme,
|
||||||
options: schemes
|
options: schemes,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
name: 'light',
|
name: 'light',
|
||||||
value: light
|
value: light,
|
||||||
}
|
},
|
||||||
]}
|
]}
|
||||||
onFieldChange={this.onChange}
|
onFieldChange={this.onChange}
|
||||||
onFieldClick={this.onClick}
|
onFieldClick={this.onClick}
|
||||||
|
|
|
@ -5,5 +5,5 @@ export const CSS_CLASS = 'redux-devtools-storybook';
|
||||||
export const DEFAULT_THEME_STATE = {
|
export const DEFAULT_THEME_STATE = {
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
scheme: 'default',
|
scheme: 'default',
|
||||||
light: true
|
light: true,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,11 +3,11 @@ import addons from '@storybook/addons';
|
||||||
import Panel from './Panel';
|
import Panel from './Panel';
|
||||||
import { ADDON_ID, PANEL_ID } from './constant';
|
import { ADDON_ID, PANEL_ID } from './constant';
|
||||||
|
|
||||||
addons.register(ADDON_ID, api => {
|
addons.register(ADDON_ID, (api) => {
|
||||||
const channel = addons.getChannel();
|
const channel = addons.getChannel();
|
||||||
addons.addPanel(PANEL_ID, {
|
addons.addPanel(PANEL_ID, {
|
||||||
title: 'Theme',
|
title: 'Theme',
|
||||||
render: ({ active }) =>
|
render: ({ active }) =>
|
||||||
active ? <Panel channel={channel} api={api} /> : null
|
active ? <Panel channel={channel} api={api} /> : null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Theme extends React.Component {
|
||||||
channel.removeListener(EVENT_ID_DATA, this.onChannel);
|
channel.removeListener(EVENT_ID_DATA, this.onChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChannel = state => {
|
onChannel = (state) => {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,4 +25,4 @@ class Theme extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const withTheme = story => <Theme>{story()}</Theme>;
|
export const withTheme = (story) => <Theme>{story()}</Theme>;
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default class Button extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseUp = e => {
|
onMouseUp = (e) => {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ Button.propTypes = {
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
]),
|
]),
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
|
@ -82,11 +82,11 @@ Button.propTypes = {
|
||||||
'base0C',
|
'base0C',
|
||||||
'base0D',
|
'base0D',
|
||||||
'base0E',
|
'base0E',
|
||||||
'base0F'
|
'base0F',
|
||||||
]),
|
]),
|
||||||
theme: PropTypes.object
|
theme: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
Button.defaultProps = {
|
Button.defaultProps = {
|
||||||
tooltipPosition: 'top'
|
tooltipPosition: 'top',
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ storiesOf('Button', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
primary={boolean('primary', true)}
|
primary={boolean('primary', true)}
|
||||||
size={select('size', ['big', 'normal', 'small'], 'normal')}
|
size={select('size', ['big', 'normal', 'small'], 'normal')}
|
||||||
|
@ -52,7 +52,7 @@ storiesOf('Button', module)
|
||||||
'base0C',
|
'base0C',
|
||||||
'base0D',
|
'base0D',
|
||||||
'base0E',
|
'base0E',
|
||||||
'base0F'
|
'base0F',
|
||||||
],
|
],
|
||||||
'base08'
|
'base08'
|
||||||
)}
|
)}
|
||||||
|
@ -65,7 +65,7 @@ storiesOf('Button', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
size={select('size', ['big', 'normal', 'small'], 'normal')}
|
size={select('size', ['big', 'normal', 'small'], 'normal')}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { css } from 'styled-components';
|
||||||
import { fadeIn } from '../../utils/animations';
|
import { fadeIn } from '../../utils/animations';
|
||||||
import colorEffect from '../../utils/color';
|
import colorEffect from '../../utils/color';
|
||||||
|
|
||||||
const both = tooltipPosition => {
|
const both = (tooltipPosition) => {
|
||||||
switch (tooltipPosition) {
|
switch (tooltipPosition) {
|
||||||
case 'bottom':
|
case 'bottom':
|
||||||
return `
|
return `
|
||||||
|
@ -46,7 +46,7 @@ const both = tooltipPosition => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const before = tooltipPosition => {
|
const before = (tooltipPosition) => {
|
||||||
switch (tooltipPosition) {
|
switch (tooltipPosition) {
|
||||||
case 'bottom-left':
|
case 'bottom-left':
|
||||||
return `
|
return `
|
||||||
|
@ -110,13 +110,13 @@ const after = (tooltipPosition, color) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDirection = tooltipPosition => {
|
const getDirection = (tooltipPosition) => {
|
||||||
return tooltipPosition.indexOf('-') > 0
|
return tooltipPosition.indexOf('-') > 0
|
||||||
? tooltipPosition.substring(0, tooltipPosition.indexOf('-'))
|
? tooltipPosition.substring(0, tooltipPosition.indexOf('-'))
|
||||||
: tooltipPosition;
|
: tooltipPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSize = size => {
|
const getSize = (size) => {
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 'big':
|
case 'big':
|
||||||
return 'min-height: 34px; padding: 2px 12px;';
|
return 'min-height: 34px; padding: 2px 12px;';
|
||||||
|
@ -146,7 +146,7 @@ export const commonStyle = ({ theme, mark, size }) => css`
|
||||||
}
|
}
|
||||||
|
|
||||||
${mark &&
|
${mark &&
|
||||||
`
|
`
|
||||||
background-color: ${colorEffect(
|
background-color: ${colorEffect(
|
||||||
theme[mark],
|
theme[mark],
|
||||||
'fade',
|
'fade',
|
||||||
|
@ -169,7 +169,7 @@ export const tooltipStyle = ({
|
||||||
tooltipTitle,
|
tooltipTitle,
|
||||||
tooltipPosition,
|
tooltipPosition,
|
||||||
mark,
|
mark,
|
||||||
size
|
size,
|
||||||
}) => css`
|
}) => css`
|
||||||
${commonStyle({ theme, mark, size })}
|
${commonStyle({ theme, mark, size })}
|
||||||
|
|
||||||
|
@ -208,7 +208,8 @@ export const tooltipStyle = ({
|
||||||
${theme.type === 'material' ? `animation: ${fadeIn} 500ms;` : ''}
|
${theme.type === 'material' ? `animation: ${fadeIn} 500ms;` : ''}
|
||||||
}
|
}
|
||||||
|
|
||||||
${theme.type !== 'material' &&
|
${
|
||||||
|
theme.type !== 'material' &&
|
||||||
`
|
`
|
||||||
&:after {
|
&:after {
|
||||||
content: "";
|
content: "";
|
||||||
|
@ -218,7 +219,8 @@ export const tooltipStyle = ({
|
||||||
${after(tooltipPosition, theme.base02)}
|
${after(tooltipPosition, theme.base02)}
|
||||||
${getDirection(tooltipPosition)}: 7px;
|
${getDirection(tooltipPosition)}: 7px;
|
||||||
}
|
}
|
||||||
`}
|
`
|
||||||
|
}
|
||||||
|
|
||||||
&:hover:after,
|
&:hover:after,
|
||||||
&:hover:before {
|
&:hover:before {
|
||||||
|
|
|
@ -33,14 +33,16 @@ export const style = ({ theme, primary, disabled }) => css`
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
${!disabled &&
|
${
|
||||||
|
!disabled &&
|
||||||
`
|
`
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background-color: ${primary ? theme.base07 : theme.base02};
|
background-color: ${primary ? theme.base07 : theme.base02};
|
||||||
box-shadow: 1px 1px 2px ${theme.base03};
|
box-shadow: 1px 1px 2px ${theme.base03};
|
||||||
}
|
}
|
||||||
`}
|
`
|
||||||
|
}
|
||||||
&:focus {
|
&:focus {
|
||||||
border: 1px solid ${theme.base0D};
|
border: 1px solid ${theme.base0D};
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ Container.propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
themeData: PropTypes.object,
|
themeData: PropTypes.object,
|
||||||
theme: PropTypes.object,
|
theme: PropTypes.object,
|
||||||
className: PropTypes.string
|
className: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Container;
|
export default Container;
|
||||||
|
|
|
@ -6,8 +6,8 @@ export const MainContainerWrapper = styled.div`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
background-color: ${props => color(props.theme.base00, 'lighten', 0.03)};
|
background-color: ${(props) => color(props.theme.base00, 'lighten', 0.03)};
|
||||||
color: ${props => props.theme.base07};
|
color: ${(props) => props.theme.base07};
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
||||||
div,
|
div,
|
||||||
|
@ -16,13 +16,13 @@ export const MainContainerWrapper = styled.div`
|
||||||
keygen,
|
keygen,
|
||||||
select,
|
select,
|
||||||
button {
|
button {
|
||||||
font-family: ${props => props.theme.fontFamily || 'monaco, monospace'};
|
font-family: ${(props) => props.theme.fontFamily || 'monaco, monospace'};
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror div,
|
.CodeMirror div,
|
||||||
pre,
|
pre,
|
||||||
.monitor-LogMonitor * {
|
.monitor-LogMonitor * {
|
||||||
font-family: ${props =>
|
font-family: ${(props) =>
|
||||||
props.theme.codeFontFamily || props.theme.fontFamily || 'monospace'};
|
props.theme.codeFontFamily || props.theme.fontFamily || 'monospace'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ export default class ContextMenu extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseUp = e => {
|
onMouseUp = (e) => {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
};
|
};
|
||||||
|
|
||||||
onClick = e => {
|
onClick = (e) => {
|
||||||
this.props.onClick(e.target.value);
|
this.props.onClick(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export default class ContextMenu extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateItems(items) {
|
updateItems(items) {
|
||||||
this.items = items.map(item => {
|
this.items = items.map((item) => {
|
||||||
const value = item.value || item.name;
|
const value = item.value || item.name;
|
||||||
if (item.type === 'button') return item;
|
if (item.type === 'button') return item;
|
||||||
return (
|
return (
|
||||||
|
@ -80,7 +80,7 @@ export default class ContextMenu extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
menuRef = c => {
|
menuRef = (c) => {
|
||||||
this.menu = c;
|
this.menu = c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,5 +103,5 @@ ContextMenu.propTypes = {
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
x: PropTypes.number.isRequired,
|
x: PropTypes.number.isRequired,
|
||||||
y: PropTypes.number.isRequired,
|
y: PropTypes.number.isRequired,
|
||||||
visible: PropTypes.bool
|
visible: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
export const items = [
|
export const items = [
|
||||||
{
|
{
|
||||||
name: 'Menu Item 1'
|
name: 'Menu Item 1',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Menu Item 2'
|
name: 'Menu Item 2',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Menu Item 3'
|
name: 'Menu Item 3',
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -13,11 +13,11 @@ export default class Dialog extends (PureComponent || Component) {
|
||||||
else this.props.onSubmit();
|
else this.props.onSubmit();
|
||||||
};
|
};
|
||||||
|
|
||||||
getFormButtonRef = node => {
|
getFormButtonRef = (node) => {
|
||||||
this.submitButton = node;
|
this.submitButton = node;
|
||||||
};
|
};
|
||||||
|
|
||||||
onKeyDown = e => {
|
onKeyDown = (e) => {
|
||||||
if (e.keyCode === 27 /* esc */) {
|
if (e.keyCode === 27 /* esc */) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.props.onDismiss(false);
|
this.props.onDismiss(false);
|
||||||
|
@ -81,7 +81,7 @@ export default class Dialog extends (PureComponent || Component) {
|
||||||
onClick={this.onSubmit}
|
onClick={this.onSubmit}
|
||||||
>
|
>
|
||||||
{submitText}
|
{submitText}
|
||||||
</Button>
|
</Button>,
|
||||||
]
|
]
|
||||||
: actions}
|
: actions}
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,5 +111,5 @@ Dialog.propTypes = {
|
||||||
modal: PropTypes.bool,
|
modal: PropTypes.bool,
|
||||||
onDismiss: PropTypes.func,
|
onDismiss: PropTypes.func,
|
||||||
onSubmit: PropTypes.func,
|
onSubmit: PropTypes.func,
|
||||||
theme: PropTypes.object
|
theme: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default class Editor extends Component {
|
||||||
readOnly: this.props.readOnly,
|
readOnly: this.props.readOnly,
|
||||||
autofocus: this.props.autofocus,
|
autofocus: this.props.autofocus,
|
||||||
foldGutter: this.props.foldGutter,
|
foldGutter: this.props.foldGutter,
|
||||||
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']
|
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.props.onChange) {
|
if (this.props.onChange) {
|
||||||
|
@ -56,7 +56,7 @@ export default class Editor extends Component {
|
||||||
this.cm = null;
|
this.cm = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRef = node => {
|
getRef = (node) => {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ Editor.propTypes = {
|
||||||
theme: PropTypes.object,
|
theme: PropTypes.object,
|
||||||
foldGutter: PropTypes.bool,
|
foldGutter: PropTypes.bool,
|
||||||
autofocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
onChange: PropTypes.func
|
onChange: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
Editor.defaultProps = {
|
Editor.defaultProps = {
|
||||||
|
@ -84,5 +84,5 @@ Editor.defaultProps = {
|
||||||
lineWrapping: false,
|
lineWrapping: false,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
foldGutter: true,
|
foldGutter: true,
|
||||||
autofocus: false
|
autofocus: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ const value2 = `
|
||||||
/* eslint-disable react/prop-types */
|
/* eslint-disable react/prop-types */
|
||||||
export default class WithTabs extends Component {
|
export default class WithTabs extends Component {
|
||||||
state = {
|
state = {
|
||||||
selected: 'Function 1'
|
selected: 'Function 1',
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -25,16 +25,16 @@ export default class WithTabs extends Component {
|
||||||
{
|
{
|
||||||
name: 'Function 1',
|
name: 'Function 1',
|
||||||
component: Editor,
|
component: Editor,
|
||||||
selector: () => ({ value: value1, lineNumbers })
|
selector: () => ({ value: value1, lineNumbers }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Function 2',
|
name: 'Function 2',
|
||||||
component: Editor,
|
component: Editor,
|
||||||
selector: () => ({ value: value2, lineNumbers })
|
selector: () => ({ value: value2, lineNumbers }),
|
||||||
}
|
},
|
||||||
]}
|
]}
|
||||||
selected={this.state.selected}
|
selected={this.state.selected}
|
||||||
onClick={selected => {
|
onClick={(selected) => {
|
||||||
this.setState({ selected });
|
this.setState({ selected });
|
||||||
}}
|
}}
|
||||||
align={select('align', ['left', 'right', 'center'], 'left')}
|
align={select('align', ['left', 'right', 'center'], 'left')}
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const defaultStyle = `
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const themedStyle = theme => css`
|
export const themedStyle = (theme) => css`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
|
|
|
@ -49,5 +49,5 @@ Form.propTypes = {
|
||||||
formData: PropTypes.any,
|
formData: PropTypes.any,
|
||||||
widgets: PropTypes.objectOf(
|
widgets: PropTypes.objectOf(
|
||||||
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||||
)
|
),
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,6 +22,6 @@ storiesOf('Form', module)
|
||||||
{
|
{
|
||||||
info:
|
info:
|
||||||
'Wrapper around [`react-jsonschema-form`](https://github.com/mozilla-services/react-jsonschema-form)' +
|
'Wrapper around [`react-jsonschema-form`](https://github.com/mozilla-services/react-jsonschema-form)' +
|
||||||
' with custom widgets.'
|
' with custom widgets.',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,83 +7,83 @@ module.exports = {
|
||||||
properties: {
|
properties: {
|
||||||
name: {
|
name: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: 'Full name'
|
title: 'Full name',
|
||||||
},
|
},
|
||||||
age: {
|
age: {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
title: 'Age'
|
title: 'Age',
|
||||||
},
|
},
|
||||||
bio: {
|
bio: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: 'Bio'
|
title: 'Bio',
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: 'Password',
|
title: 'Password',
|
||||||
minLength: 3
|
minLength: 3,
|
||||||
},
|
},
|
||||||
multipleChoicesList: {
|
multipleChoicesList: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
title: 'A multiple choices list',
|
title: 'A multiple choices list',
|
||||||
items: {
|
items: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
enum: ['foo', 'bar', 'fuzz']
|
enum: ['foo', 'bar', 'fuzz'],
|
||||||
},
|
},
|
||||||
uniqueItems: true
|
uniqueItems: true,
|
||||||
},
|
},
|
||||||
numberEnum: {
|
numberEnum: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
title: 'Number enum',
|
title: 'Number enum',
|
||||||
enum: [1, 2, 3]
|
enum: [1, 2, 3],
|
||||||
},
|
},
|
||||||
numberEnumRadio: {
|
numberEnumRadio: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
title: 'Number enum',
|
title: 'Number enum',
|
||||||
enum: [1, 2, 3]
|
enum: [1, 2, 3],
|
||||||
},
|
},
|
||||||
integerRange: {
|
integerRange: {
|
||||||
title: 'Integer range',
|
title: 'Integer range',
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
minimum: 42,
|
minimum: 42,
|
||||||
maximum: 100
|
maximum: 100,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
name: {
|
name: {
|
||||||
'ui:autofocus': true
|
'ui:autofocus': true,
|
||||||
},
|
},
|
||||||
age: {
|
age: {
|
||||||
'ui:widget': 'updown'
|
'ui:widget': 'updown',
|
||||||
},
|
},
|
||||||
bio: {
|
bio: {
|
||||||
'ui:widget': 'textarea'
|
'ui:widget': 'textarea',
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
'ui:widget': 'password',
|
'ui:widget': 'password',
|
||||||
'ui:help': 'Hint: Make it strong!'
|
'ui:help': 'Hint: Make it strong!',
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
'ui:widget': 'alt-datetime'
|
'ui:widget': 'alt-datetime',
|
||||||
},
|
},
|
||||||
multipleChoicesList: {
|
multipleChoicesList: {
|
||||||
'ui:widget': 'checkboxes'
|
'ui:widget': 'checkboxes',
|
||||||
},
|
},
|
||||||
numberEnumRadio: {
|
numberEnumRadio: {
|
||||||
'ui:widget': 'radio',
|
'ui:widget': 'radio',
|
||||||
'ui:options': {
|
'ui:options': {
|
||||||
inline: true
|
inline: true,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
integerRange: {
|
integerRange: {
|
||||||
'ui:widget': 'range'
|
'ui:widget': 'range',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
name: 'Chuck Norris',
|
name: 'Chuck Norris',
|
||||||
age: 75,
|
age: 75,
|
||||||
bio: 'Roundhouse kicking asses since 1940',
|
bio: 'Roundhouse kicking asses since 1940',
|
||||||
password: 'noneed',
|
password: 'noneed',
|
||||||
integerRange: 52
|
integerRange: 52,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,9 +49,9 @@ Notification.propTypes = {
|
||||||
children: PropTypes.any.isRequired,
|
children: PropTypes.any.isRequired,
|
||||||
type: PropTypes.oneOf(['info', 'success', 'warning', 'error']),
|
type: PropTypes.oneOf(['info', 'success', 'warning', 'error']),
|
||||||
onClose: PropTypes.func,
|
onClose: PropTypes.func,
|
||||||
theme: PropTypes.object
|
theme: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
Notification.defaultProps = {
|
Notification.defaultProps = {
|
||||||
type: 'info'
|
type: 'info',
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,11 +13,11 @@ export default class SegmentedControl extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick = e => {
|
onClick = (e) => {
|
||||||
this.props.onClick(e.target.value);
|
this.props.onClick(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMouseUp = e => {
|
onMouseUp = (e) => {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ export default class SegmentedControl extends Component {
|
||||||
const { values, selected } = this.props;
|
const { values, selected } = this.props;
|
||||||
return (
|
return (
|
||||||
<SegmentedWrapper disabled={this.props.disabled} theme={this.props.theme}>
|
<SegmentedWrapper disabled={this.props.disabled} theme={this.props.theme}>
|
||||||
{values.map(button => (
|
{values.map((button) => (
|
||||||
<button
|
<button
|
||||||
key={button}
|
key={button}
|
||||||
value={button}
|
value={button}
|
||||||
|
@ -46,5 +46,5 @@ SegmentedControl.propTypes = {
|
||||||
selected: PropTypes.string,
|
selected: PropTypes.string,
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
theme: PropTypes.object
|
theme: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,12 +23,12 @@ Select.propTypes = {
|
||||||
simpleValue: PropTypes.bool, // pass the value with label to onChange
|
simpleValue: PropTypes.bool, // pass the value with label to onChange
|
||||||
value: PropTypes.any, // initial field value
|
value: PropTypes.any, // initial field value
|
||||||
valueKey: PropTypes.string, // path of the label value in option objects
|
valueKey: PropTypes.string, // path of the label value in option objects
|
||||||
openOuterUp: PropTypes.bool // value to control the opening direction
|
openOuterUp: PropTypes.bool, // value to control the opening direction
|
||||||
};
|
};
|
||||||
|
|
||||||
Select.defaultProps = {
|
Select.defaultProps = {
|
||||||
autosize: true,
|
autosize: true,
|
||||||
clearable: false,
|
clearable: false,
|
||||||
simpleValue: true,
|
simpleValue: true,
|
||||||
menuMaxHeight: 200
|
menuMaxHeight: 200,
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,6 +42,6 @@ storiesOf('Select', module)
|
||||||
{
|
{
|
||||||
info:
|
info:
|
||||||
'Wrapper around [React Select](https://github.com/JedWatson/react-select) with themes ' +
|
'Wrapper around [React Select](https://github.com/JedWatson/react-select) with themes ' +
|
||||||
'and new props like `openOuterUp` and `menuMaxHeight`.'
|
'and new props like `openOuterUp` and `menuMaxHeight`.',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export const options = [
|
export const options = [
|
||||||
{ value: 'one', label: 'One' },
|
{ value: 'one', label: 'One' },
|
||||||
{ value: 'two', label: 'Two' },
|
{ value: 'two', label: 'Two' },
|
||||||
{ value: 'hundred', label: 'One hundred' }
|
{ value: 'hundred', label: 'One hundred' },
|
||||||
];
|
];
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default class Slider extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange = e => {
|
onChange = (e) => {
|
||||||
this.props.onChange(parseFloat(e.target.value));
|
this.props.onChange(parseFloat(e.target.value));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ Slider.propTypes = {
|
||||||
withValue: PropTypes.bool,
|
withValue: PropTypes.bool,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
theme: PropTypes.object
|
theme: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
Slider.defaultProps = { value: 0, min: 0, max: 100 };
|
Slider.defaultProps = { value: 0, min: 0, max: 100 };
|
||||||
|
|
|
@ -15,11 +15,11 @@ export default class Tabs extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseUp = e => {
|
onMouseUp = (e) => {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
};
|
};
|
||||||
|
|
||||||
onClick = e => {
|
onClick = (e) => {
|
||||||
this.props.onClick(e.target.value);
|
this.props.onClick(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ Tabs.propTypes = {
|
||||||
main: PropTypes.bool,
|
main: PropTypes.bool,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
collapsible: PropTypes.bool,
|
collapsible: PropTypes.bool,
|
||||||
position: PropTypes.oneOf(['left', 'right', 'center'])
|
position: PropTypes.oneOf(['left', 'right', 'center']),
|
||||||
};
|
};
|
||||||
|
|
||||||
Tabs.defaultProps = { position: 'left' };
|
Tabs.defaultProps = { position: 'left' };
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class TabsHeader extends Component {
|
||||||
visibleTabs: props.tabs.slice(),
|
visibleTabs: props.tabs.slice(),
|
||||||
hiddenTabs: [],
|
hiddenTabs: [],
|
||||||
subMenuOpened: false,
|
subMenuOpened: false,
|
||||||
contextMenu: undefined
|
contextMenu: undefined,
|
||||||
};
|
};
|
||||||
this.iconWidth = 0;
|
this.iconWidth = 0;
|
||||||
this.hiddenTabsWidth = [];
|
this.hiddenTabsWidth = [];
|
||||||
|
@ -154,22 +154,22 @@ export default class TabsHeader extends Component {
|
||||||
this.setState({ subMenuOpened: false, contextMenu: undefined });
|
this.setState({ subMenuOpened: false, contextMenu: undefined });
|
||||||
};
|
};
|
||||||
|
|
||||||
getTabsWrapperRef = node => {
|
getTabsWrapperRef = (node) => {
|
||||||
this.tabsWrapperRef = node;
|
this.tabsWrapperRef = node;
|
||||||
};
|
};
|
||||||
|
|
||||||
getTabsRef = node => {
|
getTabsRef = (node) => {
|
||||||
this.tabsRef = node;
|
this.tabsRef = node;
|
||||||
};
|
};
|
||||||
|
|
||||||
expandMenu = e => {
|
expandMenu = (e) => {
|
||||||
const rect = e.currentTarget.children[0].getBoundingClientRect();
|
const rect = e.currentTarget.children[0].getBoundingClientRect();
|
||||||
this.setState({
|
this.setState({
|
||||||
contextMenu: {
|
contextMenu: {
|
||||||
top: rect.top + 10,
|
top: rect.top + 10,
|
||||||
left: rect.left
|
left: rect.left,
|
||||||
},
|
},
|
||||||
subMenuOpened: true
|
subMenuOpened: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -211,5 +211,5 @@ TabsHeader.propTypes = {
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
position: PropTypes.string,
|
position: PropTypes.string,
|
||||||
collapsible: PropTypes.bool,
|
collapsible: PropTypes.bool,
|
||||||
selected: PropTypes.string
|
selected: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ const Component = ({ selected }) => (
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
fontSize: '22px'
|
fontSize: '22px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Selected {selected}
|
Selected {selected}
|
||||||
|
@ -17,24 +17,24 @@ const Component = ({ selected }) => (
|
||||||
);
|
);
|
||||||
/* eslint-enable react/prop-types */
|
/* eslint-enable react/prop-types */
|
||||||
|
|
||||||
const selector = tab => ({ selected: tab.name });
|
const selector = (tab) => ({ selected: tab.name });
|
||||||
|
|
||||||
export const tabs = [
|
export const tabs = [
|
||||||
{
|
{
|
||||||
name: 'Tab1',
|
name: 'Tab1',
|
||||||
component: Component,
|
component: Component,
|
||||||
selector
|
selector,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Tab2',
|
name: 'Tab2',
|
||||||
component: Component,
|
component: Component,
|
||||||
selector
|
selector,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Tab3',
|
name: 'Tab3',
|
||||||
component: Component,
|
component: Component,
|
||||||
selector
|
selector,
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const simple10Tabs = [];
|
export const simple10Tabs = [];
|
||||||
|
|
|
@ -11,12 +11,12 @@ export const TabsContainer = styled.div`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
> div > div:first-child {
|
> div > div:first-child {
|
||||||
${props =>
|
${(props) =>
|
||||||
props.position !== 'left' &&
|
props.position !== 'left' &&
|
||||||
`
|
`
|
||||||
margin-left: auto !important;
|
margin-left: auto !important;
|
||||||
`}
|
`}
|
||||||
${props =>
|
${(props) =>
|
||||||
props.position === 'center' &&
|
props.position === 'center' &&
|
||||||
`
|
`
|
||||||
margin-right: auto !important;
|
margin-right: auto !important;
|
||||||
|
|
|
@ -7,11 +7,13 @@ export const style = ({ theme, main }) => css`
|
||||||
background-color: ${theme.base01};
|
background-color: ${theme.base01};
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
${!main &&
|
${
|
||||||
|
!main &&
|
||||||
`
|
`
|
||||||
border-top: 1px solid ${theme.base01};
|
border-top: 1px solid ${theme.base01};
|
||||||
border-bottom: 1px solid ${theme.base02};
|
border-bottom: 1px solid ${theme.base02};
|
||||||
`}
|
`
|
||||||
|
}
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -9,7 +9,7 @@ export const style = ({ theme, main }) => css`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
${!main &&
|
${!main &&
|
||||||
`
|
`
|
||||||
border-top: 1px solid ${theme.base01};
|
border-top: 1px solid ${theme.base01};
|
||||||
border-bottom: 1px solid ${theme.base02};
|
border-bottom: 1px solid ${theme.base02};
|
||||||
`}
|
`}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
text,
|
text,
|
||||||
number,
|
number,
|
||||||
boolean,
|
boolean,
|
||||||
select
|
select,
|
||||||
} from '@storybook/addon-knobs';
|
} from '@storybook/addon-knobs';
|
||||||
import PlayIcon from 'react-icons/lib/md/play-arrow';
|
import PlayIcon from 'react-icons/lib/md/play-arrow';
|
||||||
import RecordIcon from 'react-icons/lib/md/fiber-manual-record';
|
import RecordIcon from 'react-icons/lib/md/fiber-manual-record';
|
||||||
|
@ -21,7 +21,7 @@ import {
|
||||||
Select,
|
Select,
|
||||||
Slider,
|
Slider,
|
||||||
SegmentedControl,
|
SegmentedControl,
|
||||||
Tabs
|
Tabs,
|
||||||
} from '../../';
|
} from '../../';
|
||||||
import { options } from '../../Select/stories/options';
|
import { options } from '../../Select/stories/options';
|
||||||
import { simple10Tabs } from '../../Tabs/stories/data';
|
import { simple10Tabs } from '../../Tabs/stories/data';
|
||||||
|
@ -54,7 +54,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
onClick={action('button clicked')}
|
onClick={action('button clicked')}
|
||||||
|
@ -72,7 +72,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
onClick={action('button clicked')}
|
onClick={action('button clicked')}
|
||||||
|
@ -98,7 +98,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
onClick={action('button clicked')}
|
onClick={action('button clicked')}
|
||||||
|
@ -123,7 +123,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
onClick={action('button clicked')}
|
onClick={action('button clicked')}
|
||||||
|
@ -147,7 +147,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
onClick={action('button clicked')}
|
onClick={action('button clicked')}
|
||||||
>
|
>
|
||||||
|
@ -171,7 +171,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
disabled
|
disabled
|
||||||
onClick={action('previous state clicked')}
|
onClick={action('previous state clicked')}
|
||||||
|
@ -188,7 +188,7 @@ storiesOf('Toolbar', module)
|
||||||
'bottom-left',
|
'bottom-left',
|
||||||
'bottom-right',
|
'bottom-right',
|
||||||
'top-left',
|
'top-left',
|
||||||
'top-right'
|
'top-right',
|
||||||
])}
|
])}
|
||||||
onClick={action('next state clicked')}
|
onClick={action('next state clicked')}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const Divider = styled.div`
|
const Divider = styled.div`
|
||||||
background-color: ${props => props.theme.base02};
|
background-color: ${(props) => props.theme.base02};
|
||||||
box-shadow: 1px 1px 2px ${props => props.theme.base00};
|
box-shadow: 1px 1px 2px ${(props) => props.theme.base00};
|
||||||
height: ${props => props.theme.inputHeight || '30'}px;
|
height: ${(props) => props.theme.inputHeight || '30'}px;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
margin: auto 3px !important;
|
margin: auto 3px !important;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
|
@ -5,24 +5,24 @@ const Toolbar = styled.div`
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-family: ${props => props.theme.fontFamily || 'monospace'};
|
font-family: ${(props) => props.theme.fontFamily || 'monospace'};
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
${props => props.fullHeight && 'height: 100%;'}
|
${(props) => props.fullHeight && 'height: 100%;'}
|
||||||
padding: ${props => (props.compact ? '0' : '5px')} 5px;
|
padding: ${(props) => (props.compact ? '0' : '5px')} 5px;
|
||||||
background-color: ${props => props.theme.base01};
|
background-color: ${(props) => props.theme.base01};
|
||||||
text-align: center;
|
text-align: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
${({ borderPosition, theme }) =>
|
${({ borderPosition, theme }) =>
|
||||||
borderPosition && `border-${borderPosition}: 1px solid ${theme.base02};`}
|
borderPosition && `border-${borderPosition}: 1px solid ${theme.base02};`}
|
||||||
|
|
||||||
& > div {
|
& > div {
|
||||||
margin: auto ${props => (props.noBorder ? '0' : '1px;')};
|
margin: auto ${(props) => (props.noBorder ? '0' : '1px;')};
|
||||||
}
|
}
|
||||||
|
|
||||||
& button {
|
& button {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
${props => props.noBorder && 'border-color: transparent;'}
|
${(props) => props.noBorder && 'border-color: transparent;'}
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ const Toolbar = styled.div`
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 0 !important;
|
border-radius: 0 !important;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: ${props => props.theme.base01};
|
background-color: ${(props) => props.theme.base01};
|
||||||
}
|
}
|
||||||
|
|
||||||
.Select-menu-outer {
|
.Select-menu-outer {
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#56b6c2',
|
base0C: '#56b6c2',
|
||||||
base0D: '#61afef',
|
base0D: '#61afef',
|
||||||
base0E: '#c678dd',
|
base0E: '#c678dd',
|
||||||
base0F: '#be5046'
|
base0F: '#be5046',
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,5 +18,5 @@ export default {
|
||||||
base0C: '#86c1b9',
|
base0C: '#86c1b9',
|
||||||
base0D: '#1155cc',
|
base0D: '#1155cc',
|
||||||
base0E: '#aa17e6',
|
base0E: '#aa17e6',
|
||||||
base0F: '#a16946'
|
base0F: '#a16946',
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,5 +17,5 @@ export default {
|
||||||
base0C: '#a1efe4',
|
base0C: '#a1efe4',
|
||||||
base0D: '#62d6e8',
|
base0D: '#62d6e8',
|
||||||
base0E: '#b45bcf',
|
base0E: '#b45bcf',
|
||||||
base0F: '#00f769'
|
base0F: '#00f769',
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,5 +17,5 @@ export default {
|
||||||
base0C: '#0086b3',
|
base0C: '#0086b3',
|
||||||
base0D: '#183691',
|
base0D: '#183691',
|
||||||
base0E: '#795da3',
|
base0E: '#795da3',
|
||||||
base0F: '#ed6a43'
|
base0F: '#ed6a43',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#c6c5fe',
|
base0C: '#c6c5fe',
|
||||||
base0D: '#96cbfe',
|
base0D: '#96cbfe',
|
||||||
base0E: '#ff73fd',
|
base0E: '#ff73fd',
|
||||||
base0F: '#b18a3d'
|
base0F: '#b18a3d',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#02abea',
|
base0C: '#02abea',
|
||||||
base0D: '#0000d3',
|
base0D: '#0000d3',
|
||||||
base0E: '#4700a5',
|
base0E: '#4700a5',
|
||||||
base0F: '#90713a'
|
base0F: '#90713a',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#80CBC4',
|
base0C: '#80CBC4',
|
||||||
base0D: '#89DDFF',
|
base0D: '#89DDFF',
|
||||||
base0E: '#82AAFF',
|
base0E: '#82AAFF',
|
||||||
base0F: '#EC5F67'
|
base0F: '#EC5F67',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#5FB3B3',
|
base0C: '#5FB3B3',
|
||||||
base0D: '#6699CC',
|
base0D: '#6699CC',
|
||||||
base0E: '#C594C5',
|
base0E: '#C594C5',
|
||||||
base0F: '#AB7967'
|
base0F: '#AB7967',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#72b9bf',
|
base0C: '#72b9bf',
|
||||||
base0D: '#5299bf',
|
base0D: '#5299bf',
|
||||||
base0E: '#9989cc',
|
base0E: '#9989cc',
|
||||||
base0F: '#b08060'
|
base0F: '#b08060',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#29adff',
|
base0C: '#29adff',
|
||||||
base0D: '#83769c',
|
base0D: '#83769c',
|
||||||
base0E: '#ff77a8',
|
base0E: '#ff77a8',
|
||||||
base0F: '#ffccaa'
|
base0F: '#ffccaa',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#52CBB0',
|
base0C: '#52CBB0',
|
||||||
base0D: '#33B5E1',
|
base0D: '#33B5E1',
|
||||||
base0E: '#A363D5',
|
base0E: '#A363D5',
|
||||||
base0F: '#D73C9A'
|
base0F: '#D73C9A',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#2d9574',
|
base0C: '#2d9574',
|
||||||
base0D: '#4f97d7',
|
base0D: '#4f97d7',
|
||||||
base0E: '#a31db1',
|
base0E: '#a31db1',
|
||||||
base0F: '#b03060'
|
base0F: '#b03060',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#149bda',
|
base0C: '#149bda',
|
||||||
base0D: '#7864fa',
|
base0D: '#7864fa',
|
||||||
base0E: '#b33ce8',
|
base0E: '#b33ce8',
|
||||||
base0F: '#d41acd'
|
base0F: '#d41acd',
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,5 +16,5 @@ export default {
|
||||||
base0C: '#6eb958',
|
base0C: '#6eb958',
|
||||||
base0D: '#88a4d3',
|
base0D: '#88a4d3',
|
||||||
base0E: '#bb90e2',
|
base0E: '#bb90e2',
|
||||||
base0F: '#b49368'
|
base0F: '#b49368',
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default colors => ({
|
export default (colors) => ({
|
||||||
...colors,
|
...colors,
|
||||||
fontFamily: "'Source Sans Pro', sans-serif",
|
fontFamily: "'Source Sans Pro', sans-serif",
|
||||||
codeFontFamily: "'Source Code Pro', monospace",
|
codeFontFamily: "'Source Code Pro', monospace",
|
||||||
|
@ -10,5 +10,5 @@ export default colors => ({
|
||||||
selectArrowWidth: 4, // Math.floor(theme.inputHeight / 7)
|
selectArrowWidth: 4, // Math.floor(theme.inputHeight / 7)
|
||||||
inputInternalHeight: 28, // theme.inputHeight - theme.inputBorderWidth * 2
|
inputInternalHeight: 28, // theme.inputHeight - theme.inputBorderWidth * 2
|
||||||
inputBorderColor: colors.base02,
|
inputBorderColor: colors.base02,
|
||||||
inputFocusedStyle: `border-color: ${colors.base0D}`
|
inputFocusedStyle: `border-color: ${colors.base0D}`,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export default colors => ({
|
export default (colors) => ({
|
||||||
fontFamily: "'Roboto', sans-serif",
|
fontFamily: "'Roboto', sans-serif",
|
||||||
codeFontFamily: "'Roboto Mono', monospace",
|
codeFontFamily: "'Roboto Mono', monospace",
|
||||||
inputPadding: 5,
|
inputPadding: 5,
|
||||||
inputBorderRadius: 0,
|
inputBorderRadius: 0,
|
||||||
inputBorderColor: `transparent transparent ${colors.base02}`,
|
inputBorderColor: `transparent transparent ${colors.base02}`,
|
||||||
inputFocusedStyle: `box-shadow: inset 0 -2px 0 ${colors.base0D};`
|
inputFocusedStyle: `box-shadow: inset 0 -2px 0 ${colors.base0D};`,
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { keyframes } from 'styled-components';
|
||||||
export const spin = keyframes`
|
export const spin = keyframes`
|
||||||
to { transform: rotate(1turn); }
|
to { transform: rotate(1turn); }
|
||||||
`;
|
`;
|
||||||
export const spinner = theme => `
|
export const spinner = (theme) => `
|
||||||
animation: ${spin} 400ms infinite linear;
|
animation: ${spin} 400ms infinite linear;
|
||||||
width: ${theme.spinnerSize}px;
|
width: ${theme.spinnerSize}px;
|
||||||
height: ${theme.spinnerSize}px;
|
height: ${theme.spinnerSize}px;
|
||||||
|
@ -21,7 +21,7 @@ export const fadeIn = keyframes`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Based on https://github.com/mladenplavsic/css-ripple-effect
|
// Based on https://github.com/mladenplavsic/css-ripple-effect
|
||||||
export const ripple = theme => `
|
export const ripple = (theme) => `
|
||||||
& {
|
& {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export const prefixSelectors = (tag, selectors, style) =>
|
export const prefixSelectors = (tag, selectors, style) =>
|
||||||
selectors.map(selector => `${tag}::-${selector} ${style}`);
|
selectors.map((selector) => `${tag}::-${selector} ${style}`);
|
||||||
|
|
|
@ -8,9 +8,6 @@ import Color from 'color';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default (color, effect, val) =>
|
export default (color, effect, val) =>
|
||||||
new Color(color)
|
new Color(color)[effect](val).hsl().string();
|
||||||
[effect](val)
|
|
||||||
.hsl()
|
|
||||||
.string();
|
|
||||||
|
|
||||||
// TODO: memoize it
|
// TODO: memoize it
|
||||||
|
|
|
@ -6,7 +6,7 @@ const getStyle = (styles, type) =>
|
||||||
|
|
||||||
export default (styles, component) =>
|
export default (styles, component) =>
|
||||||
styled(component || 'div')`
|
styled(component || 'div')`
|
||||||
${props =>
|
${(props) =>
|
||||||
props.theme.type
|
props.theme.type
|
||||||
? getStyle(styles, props.theme.type)
|
? getStyle(styles, props.theme.type)
|
||||||
: // used outside of container (theme provider)
|
: // used outside of container (theme provider)
|
||||||
|
@ -15,7 +15,7 @@ export default (styles, component) =>
|
||||||
'default'
|
'default'
|
||||||
)({
|
)({
|
||||||
...props,
|
...props,
|
||||||
theme: getDefaultTheme(props.theme)
|
theme: getDefaultTheme(props.theme),
|
||||||
})}
|
})}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ function invertColors(theme) {
|
||||||
base04: theme.base03,
|
base04: theme.base03,
|
||||||
base05: theme.base02,
|
base05: theme.base02,
|
||||||
base06: theme.base01,
|
base06: theme.base01,
|
||||||
base07: theme.base00
|
base07: theme.base00,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,7 @@ import * as additionalSchemes from '../colorSchemes';
|
||||||
import invertColors from '../utils/invertColors';
|
import invertColors from '../utils/invertColors';
|
||||||
|
|
||||||
export const schemes = { ...baseSchemes, ...additionalSchemes };
|
export const schemes = { ...baseSchemes, ...additionalSchemes };
|
||||||
export const listSchemes = () =>
|
export const listSchemes = () => Object.keys(schemes).slice(1).sort(); // remove `__esModule`
|
||||||
Object.keys(schemes)
|
|
||||||
.slice(1)
|
|
||||||
.sort(); // remove `__esModule`
|
|
||||||
export const listThemes = () => Object.keys(themes);
|
export const listThemes = () => Object.keys(themes);
|
||||||
|
|
||||||
export const getTheme = ({ theme: type, scheme, light }) => {
|
export const getTheme = ({ theme: type, scheme, light }) => {
|
||||||
|
@ -23,7 +20,7 @@ export const getTheme = ({ theme: type, scheme, light }) => {
|
||||||
let theme = {
|
let theme = {
|
||||||
type,
|
type,
|
||||||
light,
|
light,
|
||||||
...themes.default(colors)
|
...themes.default(colors),
|
||||||
};
|
};
|
||||||
if (type !== 'default') {
|
if (type !== 'default') {
|
||||||
theme = { ...theme, ...themes[type](colors) };
|
theme = { ...theme, ...themes[type](colors) };
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render, mount } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Button } from '../src';
|
import { Button } from '../src';
|
||||||
|
|
||||||
describe('Button', function() {
|
describe('Button', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(<Button>Text</Button>);
|
const wrapper = render(<Button>Text</Button>);
|
||||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Container } from '../src';
|
import { Container } from '../src';
|
||||||
|
|
||||||
describe('Container', function() {
|
describe('Container', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(
|
const wrapper = render(
|
||||||
<Container
|
<Container
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { renderToJson } from 'enzyme-to-json';
|
||||||
import { ContextMenu } from '../src';
|
import { ContextMenu } from '../src';
|
||||||
import { items } from '../src/ContextMenu/stories/data';
|
import { items } from '../src/ContextMenu/stories/data';
|
||||||
|
|
||||||
describe('ContextMenu', function() {
|
describe('ContextMenu', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(
|
const wrapper = render(
|
||||||
<ContextMenu items={items} onClick={() => {}} x={100} y={100} />
|
<ContextMenu items={items} onClick={() => {}} x={100} y={100} />
|
||||||
|
@ -17,10 +17,7 @@ describe('ContextMenu', function() {
|
||||||
<ContextMenu items={items} onClick={onClick} x={100} y={100} />
|
<ContextMenu items={items} onClick={onClick} x={100} y={100} />
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapper
|
wrapper.find('button').first().simulate('click');
|
||||||
.find('button')
|
|
||||||
.first()
|
|
||||||
.simulate('click');
|
|
||||||
expect(onClick).toBeCalled();
|
expect(onClick).toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render, mount } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Dialog } from '../src';
|
import { Dialog } from '../src';
|
||||||
|
|
||||||
describe('Dialog', function() {
|
describe('Dialog', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(<Dialog />);
|
const wrapper = render(<Dialog />);
|
||||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||||
|
@ -27,10 +27,7 @@ describe('Dialog', function() {
|
||||||
const onDismiss = jest.fn();
|
const onDismiss = jest.fn();
|
||||||
const wrapper = mount(<Dialog open onDismiss={onDismiss} />);
|
const wrapper = mount(<Dialog open onDismiss={onDismiss} />);
|
||||||
|
|
||||||
wrapper
|
wrapper.find('button').first().simulate('click');
|
||||||
.find('button')
|
|
||||||
.first()
|
|
||||||
.simulate('click');
|
|
||||||
expect(onDismiss).toBeCalled();
|
expect(onDismiss).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,10 +35,7 @@ describe('Dialog', function() {
|
||||||
const onSubmit = jest.fn();
|
const onSubmit = jest.fn();
|
||||||
const wrapper = mount(<Dialog open onSubmit={onSubmit} />);
|
const wrapper = mount(<Dialog open onSubmit={onSubmit} />);
|
||||||
|
|
||||||
wrapper
|
wrapper.find('button').last().simulate('click');
|
||||||
.find('button')
|
|
||||||
.last()
|
|
||||||
.simulate('click');
|
|
||||||
expect(onSubmit).toBeCalled();
|
expect(onSubmit).toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { mountToJson } from 'enzyme-to-json';
|
||||||
import { Editor } from '../src';
|
import { Editor } from '../src';
|
||||||
import 'codemirror/mode/javascript/javascript';
|
import 'codemirror/mode/javascript/javascript';
|
||||||
|
|
||||||
describe('Editor', function() {
|
describe('Editor', function () {
|
||||||
const getBoundingClientRect = jest.fn();
|
const getBoundingClientRect = jest.fn();
|
||||||
const getClientRects = jest.fn();
|
const getClientRects = jest.fn();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ describe('Editor', function() {
|
||||||
return {
|
return {
|
||||||
item: () => null,
|
item: () => null,
|
||||||
length: 0,
|
length: 0,
|
||||||
[Symbol.iterator]: jest.fn()
|
[Symbol.iterator]: jest.fn(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { shallowToJson } from 'enzyme-to-json';
|
||||||
import { Form } from '../src';
|
import { Form } from '../src';
|
||||||
import { schema, uiSchema, formData } from '../src/Form/stories/schema';
|
import { schema, uiSchema, formData } from '../src/Form/stories/schema';
|
||||||
|
|
||||||
describe('Form', function() {
|
describe('Form', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<Form formData={formData} schema={schema} uiSchema={uiSchema} />
|
<Form formData={formData} schema={schema} uiSchema={uiSchema} />
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render, mount } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Notification } from '../src';
|
import { Notification } from '../src';
|
||||||
|
|
||||||
describe('Notification', function() {
|
describe('Notification', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(<Notification>Message</Notification>);
|
const wrapper = render(<Notification>Message</Notification>);
|
||||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render, mount } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { SegmentedControl } from '../src';
|
import { SegmentedControl } from '../src';
|
||||||
|
|
||||||
describe('SegmentedControl', function() {
|
describe('SegmentedControl', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(
|
const wrapper = render(
|
||||||
<SegmentedControl
|
<SegmentedControl
|
||||||
|
@ -26,10 +26,7 @@ describe('SegmentedControl', function() {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapper
|
wrapper.find('button').first().simulate('click');
|
||||||
.find('button')
|
|
||||||
.first()
|
|
||||||
.simulate('click');
|
|
||||||
expect(onClick).toBeCalled();
|
expect(onClick).toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { renderToJson, mountToJson } from 'enzyme-to-json';
|
||||||
import { Select } from '../src';
|
import { Select } from '../src';
|
||||||
import { options } from '../src/Select/stories/options';
|
import { options } from '../src/Select/stories/options';
|
||||||
|
|
||||||
describe('Select', function() {
|
describe('Select', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(<Select options={options} onChange={() => {}} />);
|
const wrapper = render(<Select options={options} onChange={() => {}} />);
|
||||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render, mount } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Slider } from '../src';
|
import { Slider } from '../src';
|
||||||
|
|
||||||
describe('Slider', function() {
|
describe('Slider', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(<Slider />);
|
const wrapper = render(<Slider />);
|
||||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Tabs } from '../src';
|
import { Tabs } from '../src';
|
||||||
import { tabs, simple10Tabs } from '../src/Tabs/stories/data';
|
import { tabs, simple10Tabs } from '../src/Tabs/stories/data';
|
||||||
|
|
||||||
describe('Tabs', function() {
|
describe('Tabs', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(<Tabs tabs={tabs} onClick={() => {}} />);
|
const wrapper = render(<Tabs tabs={tabs} onClick={() => {}} />);
|
||||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||||
|
@ -28,10 +28,7 @@ describe('Tabs', function() {
|
||||||
const onClick = jest.fn();
|
const onClick = jest.fn();
|
||||||
const wrapper = mount(<Tabs tabs={tabs} onClick={onClick} />);
|
const wrapper = mount(<Tabs tabs={tabs} onClick={onClick} />);
|
||||||
|
|
||||||
wrapper
|
wrapper.find('button').first().simulate('click');
|
||||||
.find('button')
|
|
||||||
.first()
|
|
||||||
.simulate('click');
|
|
||||||
expect(onClick).toBeCalled();
|
expect(onClick).toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { render } from 'enzyme';
|
||||||
import { renderToJson } from 'enzyme-to-json';
|
import { renderToJson } from 'enzyme-to-json';
|
||||||
import { Toolbar, Divider, Spacer, Button } from '../src';
|
import { Toolbar, Divider, Spacer, Button } from '../src';
|
||||||
|
|
||||||
describe('Toolbar', function() {
|
describe('Toolbar', function () {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const wrapper = render(
|
const wrapper = render(
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
|
|
|
@ -12,7 +12,7 @@ map2tree(
|
||||||
someMap,
|
someMap,
|
||||||
(options = {
|
(options = {
|
||||||
key: 'state', // the name you want for as the root node of the output tree
|
key: 'state', // the name you want for as the root node of the output tree
|
||||||
pushMethod: 'push' // use 'unshift' to change the order children nodes are added
|
pushMethod: 'push', // use 'unshift' to change the order children nodes are added
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
@ -26,14 +26,14 @@ const someMap = {
|
||||||
{ title: 'map', someNestedObject: { foo: 'bar' } },
|
{ title: 'map', someNestedObject: { foo: 'bar' } },
|
||||||
{ title: 'to', someNestedArray: ['foo', 'bar'] },
|
{ title: 'to', someNestedArray: ['foo', 'bar'] },
|
||||||
{ title: 'tree' },
|
{ title: 'tree' },
|
||||||
{ title: 'map2tree' }
|
{ title: 'map2tree' },
|
||||||
],
|
],
|
||||||
completedCount: 1
|
completedCount: 1,
|
||||||
},
|
},
|
||||||
otherReducer: {
|
otherReducer: {
|
||||||
foo: 0,
|
foo: 0,
|
||||||
bar: { key: 'value' }
|
bar: { key: 'value' },
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@ function getNode(tree, key) {
|
||||||
|
|
||||||
visit(
|
visit(
|
||||||
tree,
|
tree,
|
||||||
d => {
|
(d) => {
|
||||||
if (d.name === key) {
|
if (d.name === key) {
|
||||||
node = d;
|
node = d;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
d => d.children
|
(d) => d.children
|
||||||
);
|
);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
@ -61,7 +61,7 @@ export default function map2tree(
|
||||||
for (let i = 0; i < value.length; i++) {
|
for (let i = 0; i < value.length; i++) {
|
||||||
newNode.children[pushMethod]({
|
newNode.children[pushMethod]({
|
||||||
name: `${key}[${i}]`,
|
name: `${key}[${i}]`,
|
||||||
[isPlainObject(value[i]) ? 'object' : 'value']: value[i]
|
[isPlainObject(value[i]) ? 'object' : 'value']: value[i],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (isPlainObject(value)) {
|
} else if (isPlainObject(value)) {
|
||||||
|
|
|
@ -11,12 +11,12 @@ test('# rootNodeKey', () => {
|
||||||
describe('# shallow map', () => {
|
describe('# shallow map', () => {
|
||||||
test('## null', () => {
|
test('## null', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: null
|
a: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
name: 'state',
|
name: 'state',
|
||||||
children: [{ name: 'a', value: null }]
|
children: [{ name: 'a', value: null }],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -26,15 +26,15 @@ describe('# shallow map', () => {
|
||||||
test('## value', () => {
|
test('## value', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: 'foo',
|
a: 'foo',
|
||||||
b: 'bar'
|
b: 'bar',
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
name: 'state',
|
name: 'state',
|
||||||
children: [
|
children: [
|
||||||
{ name: 'a', value: 'foo' },
|
{ name: 'a', value: 'foo' },
|
||||||
{ name: 'b', value: 'bar' }
|
{ name: 'b', value: 'bar' },
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -43,12 +43,12 @@ describe('# shallow map', () => {
|
||||||
|
|
||||||
test('## object', () => {
|
test('## object', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: { aa: 'foo' }
|
a: { aa: 'foo' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
name: 'state',
|
name: 'state',
|
||||||
children: [{ name: 'a', children: [{ name: 'aa', value: 'foo' }] }]
|
children: [{ name: 'a', children: [{ name: 'aa', value: 'foo' }] }],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -57,7 +57,7 @@ describe('# shallow map', () => {
|
||||||
|
|
||||||
test('## immutable Map', () => {
|
test('## immutable Map', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: immutable.fromJS({ aa: 'foo', ab: 'bar' })
|
a: immutable.fromJS({ aa: 'foo', ab: 'bar' }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -67,10 +67,10 @@ describe('# shallow map', () => {
|
||||||
name: 'a',
|
name: 'a',
|
||||||
children: [
|
children: [
|
||||||
{ name: 'aa', value: 'foo' },
|
{ name: 'aa', value: 'foo' },
|
||||||
{ name: 'ab', value: 'bar' }
|
{ name: 'ab', value: 'bar' },
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -80,7 +80,7 @@ describe('# shallow map', () => {
|
||||||
describe('# deep map', () => {
|
describe('# deep map', () => {
|
||||||
test('## null', () => {
|
test('## null', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: { aa: null }
|
a: { aa: null },
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -91,11 +91,11 @@ describe('# deep map', () => {
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'aa',
|
name: 'aa',
|
||||||
value: null
|
value: null,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -104,7 +104,7 @@ describe('# deep map', () => {
|
||||||
|
|
||||||
test('## object', () => {
|
test('## object', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: { aa: { aaa: 'foo' } }
|
a: { aa: { aaa: 'foo' } },
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -115,11 +115,11 @@ describe('# deep map', () => {
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'aa',
|
name: 'aa',
|
||||||
children: [{ name: 'aaa', value: 'foo' }]
|
children: [{ name: 'aaa', value: 'foo' }],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -129,7 +129,7 @@ describe('# deep map', () => {
|
||||||
|
|
||||||
describe('# array map', () => {
|
describe('# array map', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: [1, 2]
|
a: [1, 2],
|
||||||
};
|
};
|
||||||
|
|
||||||
test('## push', () => {
|
test('## push', () => {
|
||||||
|
@ -140,10 +140,10 @@ describe('# array map', () => {
|
||||||
name: 'a',
|
name: 'a',
|
||||||
children: [
|
children: [
|
||||||
{ name: 'a[0]', value: 1 },
|
{ name: 'a[0]', value: 1 },
|
||||||
{ name: 'a[1]', value: 2 }
|
{ name: 'a[1]', value: 2 },
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -159,10 +159,10 @@ describe('# array map', () => {
|
||||||
name: 'a',
|
name: 'a',
|
||||||
children: [
|
children: [
|
||||||
{ name: 'a[1]', value: 2 },
|
{ name: 'a[1]', value: 2 },
|
||||||
{ name: 'a[0]', value: 1 }
|
{ name: 'a[0]', value: 1 },
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map, options)).toEqual(expected);
|
expect(map2tree(map, options)).toEqual(expected);
|
||||||
|
@ -171,7 +171,7 @@ describe('# array map', () => {
|
||||||
|
|
||||||
test('## null', () => {
|
test('## null', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: [null]
|
a: [null],
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -179,9 +179,9 @@ describe('# array map', () => {
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'a',
|
name: 'a',
|
||||||
children: [{ name: 'a[0]', value: null }]
|
children: [{ name: 'a[0]', value: null }],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -192,7 +192,7 @@ describe('# array map', () => {
|
||||||
describe('# collection map', () => {
|
describe('# collection map', () => {
|
||||||
test('## value', () => {
|
test('## value', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: [{ aa: 1 }, { aa: 2 }]
|
a: [{ aa: 1 }, { aa: 2 }],
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -202,10 +202,10 @@ describe('# collection map', () => {
|
||||||
name: 'a',
|
name: 'a',
|
||||||
children: [
|
children: [
|
||||||
{ name: 'a[0]', object: { aa: 1 } },
|
{ name: 'a[0]', object: { aa: 1 } },
|
||||||
{ name: 'a[1]', object: { aa: 2 } }
|
{ name: 'a[1]', object: { aa: 2 } },
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
@ -214,7 +214,7 @@ describe('# collection map', () => {
|
||||||
|
|
||||||
test('## object', () => {
|
test('## object', () => {
|
||||||
const map = {
|
const map = {
|
||||||
a: [{ aa: { aaa: 'foo' } }]
|
a: [{ aa: { aaa: 'foo' } }],
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -222,9 +222,9 @@ describe('# collection map', () => {
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'a',
|
name: 'a',
|
||||||
children: [{ name: 'a[0]', object: { aa: { aaa: 'foo' } } }]
|
children: [{ name: 'a[0]', object: { aa: { aaa: 'foo' } } }],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(map2tree(map)).toEqual(expected);
|
expect(map2tree(map)).toEqual(expected);
|
||||||
|
|
|
@ -3,27 +3,27 @@ const path = require('path');
|
||||||
module.exports = (env = {}) => ({
|
module.exports = (env = {}) => ({
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
entry: {
|
entry: {
|
||||||
app: ['./src/index.js']
|
app: ['./src/index.js'],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
library: 'd3tooltip',
|
library: 'd3tooltip',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
path: path.resolve(__dirname, 'dist'),
|
path: path.resolve(__dirname, 'dist'),
|
||||||
filename: env.minimize ? 'map2tree.min.js' : 'map2tree.js'
|
filename: env.minimize ? 'map2tree.min.js' : 'map2tree.js',
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: !!env.minimize
|
minimize: !!env.minimize,
|
||||||
},
|
},
|
||||||
performance: {
|
performance: {
|
||||||
hints: false
|
hints: false,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,23 +19,23 @@ import base16Themes from './base16Themes';
|
||||||
function getStylingFromBase16(base16Theme) {
|
function getStylingFromBase16(base16Theme) {
|
||||||
return {
|
return {
|
||||||
myComponent: {
|
myComponent: {
|
||||||
backgroundColor: base16Theme.base00
|
backgroundColor: base16Theme.base00,
|
||||||
},
|
},
|
||||||
|
|
||||||
myComponentToggleColor({ style, className }, clickCount) {
|
myComponentToggleColor({ style, className }, clickCount) {
|
||||||
return {
|
return {
|
||||||
style: {
|
style: {
|
||||||
...style,
|
...style,
|
||||||
backgroundColor: clickCount % 2 ? 'red' : 'blue'
|
backgroundColor: clickCount % 2 ? 'red' : 'blue',
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const createStylingFromTheme = createStyling(getStylingFromBase16, {
|
const createStylingFromTheme = createStyling(getStylingFromBase16, {
|
||||||
defaultBase16: base16Themes.solarized,
|
defaultBase16: base16Themes.solarized,
|
||||||
base16Themes
|
base16Themes,
|
||||||
});
|
});
|
||||||
|
|
||||||
class MyComponent extends Component {
|
class MyComponent extends Component {
|
||||||
|
|
22
packages/react-base16-styling/src/index.js
vendored
22
packages/react-base16-styling/src/index.js
vendored
|
@ -11,7 +11,7 @@ const BASE16_KEYS = Object.keys(DEFAULT_BASE16);
|
||||||
|
|
||||||
// we need a correcting factor, so that a dark, but not black background color
|
// we need a correcting factor, so that a dark, but not black background color
|
||||||
// converts to bright enough inversed color
|
// converts to bright enough inversed color
|
||||||
const flip = x => (x < 0.25 ? 1 : x < 0.5 ? 0.9 - x : 1.1 - x);
|
const flip = (x) => (x < 0.25 ? 1 : x < 0.5 ? 0.9 - x : 1.1 - x);
|
||||||
|
|
||||||
const invertColor = flow(
|
const invertColor = flow(
|
||||||
parse,
|
parse,
|
||||||
|
@ -22,11 +22,11 @@ const invertColor = flow(
|
||||||
);
|
);
|
||||||
|
|
||||||
const merger = function merger(styling) {
|
const merger = function merger(styling) {
|
||||||
return prevStyling => ({
|
return (prevStyling) => ({
|
||||||
className: [prevStyling.className, styling.className]
|
className: [prevStyling.className, styling.className]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(' '),
|
.join(' '),
|
||||||
style: { ...(prevStyling.style || {}), ...(styling.style || {}) }
|
style: { ...(prevStyling.style || {}), ...(styling.style || {}) },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ const mergeStyling = function mergeStyling(customStyling, defaultStyling) {
|
||||||
case 'function':
|
case 'function':
|
||||||
return (styling, ...args) =>
|
return (styling, ...args) =>
|
||||||
merger({
|
merger({
|
||||||
className: customStyling
|
className: customStyling,
|
||||||
})(defaultStyling(styling, ...args));
|
})(defaultStyling(styling, ...args));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -64,7 +64,7 @@ const mergeStyling = function mergeStyling(customStyling, defaultStyling) {
|
||||||
case 'function':
|
case 'function':
|
||||||
return (styling, ...args) =>
|
return (styling, ...args) =>
|
||||||
merger({
|
merger({
|
||||||
style: customStyling
|
style: customStyling,
|
||||||
})(defaultStyling(styling, ...args));
|
})(defaultStyling(styling, ...args));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -74,7 +74,7 @@ const mergeStyling = function mergeStyling(customStyling, defaultStyling) {
|
||||||
return (styling, ...args) =>
|
return (styling, ...args) =>
|
||||||
customStyling(
|
customStyling(
|
||||||
merger(styling)({
|
merger(styling)({
|
||||||
className: defaultStyling
|
className: defaultStyling,
|
||||||
}),
|
}),
|
||||||
...args
|
...args
|
||||||
);
|
);
|
||||||
|
@ -82,7 +82,7 @@ const mergeStyling = function mergeStyling(customStyling, defaultStyling) {
|
||||||
return (styling, ...args) =>
|
return (styling, ...args) =>
|
||||||
customStyling(
|
customStyling(
|
||||||
merger(styling)({
|
merger(styling)({
|
||||||
style: defaultStyling
|
style: defaultStyling,
|
||||||
}),
|
}),
|
||||||
...args
|
...args
|
||||||
);
|
);
|
||||||
|
@ -120,7 +120,7 @@ const getStylingByKeys = (mergedStyling, keys, ...args) => {
|
||||||
keys = [keys];
|
keys = [keys];
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = keys.map(key => mergedStyling[key]).filter(Boolean);
|
const styles = keys.map((key) => mergedStyling[key]).filter(Boolean);
|
||||||
|
|
||||||
const props = styles.reduce(
|
const props = styles.reduce(
|
||||||
(obj, s) => {
|
(obj, s) => {
|
||||||
|
@ -148,7 +148,7 @@ const getStylingByKeys = (mergedStyling, keys, ...args) => {
|
||||||
return props;
|
return props;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const invertBase16Theme = base16Theme =>
|
export const invertBase16Theme = (base16Theme) =>
|
||||||
Object.keys(base16Theme).reduce(
|
Object.keys(base16Theme).reduce(
|
||||||
(t, key) => (
|
(t, key) => (
|
||||||
(t[key] = /^base/.test(key)
|
(t[key] = /^base/.test(key)
|
||||||
|
@ -169,7 +169,7 @@ export const createStyling = curry(
|
||||||
if (base16Theme) {
|
if (base16Theme) {
|
||||||
themeOrStyling = {
|
themeOrStyling = {
|
||||||
...base16Theme,
|
...base16Theme,
|
||||||
...themeOrStyling
|
...themeOrStyling,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ export const getBase16Theme = (theme, base16Themes) => {
|
||||||
: undefined;
|
: undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const invertTheme = theme => {
|
export const invertTheme = (theme) => {
|
||||||
if (typeof theme === 'string') {
|
if (typeof theme === 'string') {
|
||||||
return `${theme}:inverted`;
|
return `${theme}:inverted`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ const base16Theme = {
|
||||||
base0C: '#009999',
|
base0C: '#009999',
|
||||||
base0D: '#009900',
|
base0D: '#009900',
|
||||||
base0E: '#9999ff',
|
base0E: '#9999ff',
|
||||||
base0F: '#ff0099'
|
base0F: '#ff0099',
|
||||||
};
|
};
|
||||||
|
|
||||||
const invertedBase16Theme = {
|
const invertedBase16Theme = {
|
||||||
|
@ -40,7 +40,7 @@ const invertedBase16Theme = {
|
||||||
base0C: '#0fa8a8',
|
base0C: '#0fa8a8',
|
||||||
base0D: '#32cb32',
|
base0D: '#32cb32',
|
||||||
base0E: '#6868ce',
|
base0E: '#6868ce',
|
||||||
base0F: '#ff2ac3'
|
base0F: '#ff2ac3',
|
||||||
};
|
};
|
||||||
|
|
||||||
const apathyInverted = {
|
const apathyInverted = {
|
||||||
|
@ -61,28 +61,28 @@ const apathyInverted = {
|
||||||
base0D: '#a7994f',
|
base0D: '#a7994f',
|
||||||
base0E: '#469038',
|
base0E: '#469038',
|
||||||
base0F: '#3a9257',
|
base0F: '#3a9257',
|
||||||
scheme: 'apathy:inverted'
|
scheme: 'apathy:inverted',
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStylingFromBase16 = base16 => ({
|
const getStylingFromBase16 = (base16) => ({
|
||||||
testClass: 'testClass',
|
testClass: 'testClass',
|
||||||
testStyle: {
|
testStyle: {
|
||||||
color: base16.base00
|
color: base16.base00,
|
||||||
},
|
},
|
||||||
testFunc: ({ style }, arg) => ({
|
testFunc: ({ style }, arg) => ({
|
||||||
className: 'testClass--' + arg,
|
className: 'testClass--' + arg,
|
||||||
style: {
|
style: {
|
||||||
...style,
|
...style,
|
||||||
width: 0,
|
width: 0,
|
||||||
color: base16.base00
|
color: base16.base00,
|
||||||
}
|
},
|
||||||
}),
|
}),
|
||||||
baseStyle: {
|
baseStyle: {
|
||||||
color: 'red'
|
color: 'red',
|
||||||
},
|
},
|
||||||
additionalStyle: {
|
additionalStyle: {
|
||||||
border: 0
|
border: 0,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test('invertTheme', () => {
|
test('invertTheme', () => {
|
||||||
|
@ -98,26 +98,26 @@ test('getBase16Theme', () => {
|
||||||
|
|
||||||
test('createStyling (default)', () => {
|
test('createStyling (default)', () => {
|
||||||
const styling = createStyling(getStylingFromBase16, {
|
const styling = createStyling(getStylingFromBase16, {
|
||||||
defaultBase16: apathy
|
defaultBase16: apathy,
|
||||||
});
|
});
|
||||||
const defaultStyling = styling(undefined);
|
const defaultStyling = styling(undefined);
|
||||||
|
|
||||||
expect(defaultStyling('testClass')).toEqual({ className: 'testClass' });
|
expect(defaultStyling('testClass')).toEqual({ className: 'testClass' });
|
||||||
expect(defaultStyling('testStyle')).toEqual({
|
expect(defaultStyling('testStyle')).toEqual({
|
||||||
style: { color: apathy.base00 }
|
style: { color: apathy.base00 },
|
||||||
});
|
});
|
||||||
expect(defaultStyling('testFunc', 'mod')).toEqual({
|
expect(defaultStyling('testFunc', 'mod')).toEqual({
|
||||||
className: 'testClass--mod',
|
className: 'testClass--mod',
|
||||||
style: {
|
style: {
|
||||||
width: 0,
|
width: 0,
|
||||||
color: apathy.base00
|
color: apathy.base00,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('createStyling (custom)', () => {
|
test('createStyling (custom)', () => {
|
||||||
const styling = createStyling(getStylingFromBase16, {
|
const styling = createStyling(getStylingFromBase16, {
|
||||||
defaultBase16: apathy
|
defaultBase16: apathy,
|
||||||
});
|
});
|
||||||
let customStyling = styling({
|
let customStyling = styling({
|
||||||
testClass: 'customClass',
|
testClass: 'customClass',
|
||||||
|
@ -126,35 +126,35 @@ test('createStyling (custom)', () => {
|
||||||
className: styling.className + ' customClass--' + arg,
|
className: styling.className + ' customClass--' + arg,
|
||||||
style: {
|
style: {
|
||||||
...styling.style,
|
...styling.style,
|
||||||
border: 0
|
border: 0,
|
||||||
}
|
},
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(customStyling('testClass')).toEqual({
|
expect(customStyling('testClass')).toEqual({
|
||||||
className: 'testClass customClass'
|
className: 'testClass customClass',
|
||||||
});
|
});
|
||||||
expect(customStyling('testStyle')).toEqual({
|
expect(customStyling('testStyle')).toEqual({
|
||||||
style: { color: apathy.base00, height: 0 }
|
style: { color: apathy.base00, height: 0 },
|
||||||
});
|
});
|
||||||
expect(customStyling('testFunc', 'mod')).toEqual({
|
expect(customStyling('testFunc', 'mod')).toEqual({
|
||||||
className: 'testClass--mod customClass--mod',
|
className: 'testClass--mod customClass--mod',
|
||||||
style: {
|
style: {
|
||||||
width: 0,
|
width: 0,
|
||||||
color: apathy.base00,
|
color: apathy.base00,
|
||||||
border: 0
|
border: 0,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
customStyling = styling({
|
customStyling = styling({
|
||||||
testClass: () => ({
|
testClass: () => ({
|
||||||
className: 'customClass'
|
className: 'customClass',
|
||||||
}),
|
}),
|
||||||
testStyle: () => ({
|
testStyle: () => ({
|
||||||
style: {
|
style: {
|
||||||
border: 0
|
border: 0,
|
||||||
}
|
},
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(customStyling('testClass')).toEqual({ className: 'customClass' });
|
expect(customStyling('testClass')).toEqual({ className: 'customClass' });
|
||||||
|
@ -163,27 +163,27 @@ test('createStyling (custom)', () => {
|
||||||
|
|
||||||
test('createStyling (multiple)', () => {
|
test('createStyling (multiple)', () => {
|
||||||
const styling = createStyling(getStylingFromBase16, {
|
const styling = createStyling(getStylingFromBase16, {
|
||||||
defaultBase16: apathy
|
defaultBase16: apathy,
|
||||||
});
|
});
|
||||||
let customStyling = styling({
|
let customStyling = styling({
|
||||||
baseStyle: ({ style }) => ({ style: { ...style, color: 'blue' } })
|
baseStyle: ({ style }) => ({ style: { ...style, color: 'blue' } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(customStyling(['baseStyle', 'additionalStyle'])).toEqual({
|
expect(customStyling(['baseStyle', 'additionalStyle'])).toEqual({
|
||||||
style: {
|
style: {
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
border: 0
|
border: 0,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
customStyling = styling({
|
customStyling = styling({
|
||||||
additionalStyle: ({ style }) => ({ style: { ...style, border: 1 } })
|
additionalStyle: ({ style }) => ({ style: { ...style, border: 1 } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(customStyling(['baseStyle', 'additionalStyle'])).toEqual({
|
expect(customStyling(['baseStyle', 'additionalStyle'])).toEqual({
|
||||||
style: {
|
style: {
|
||||||
color: 'red',
|
color: 'red',
|
||||||
border: 1
|
border: 1,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,7 +58,7 @@ const theme = {
|
||||||
base0C: '#a1efe4',
|
base0C: '#a1efe4',
|
||||||
base0D: '#66d9ef',
|
base0D: '#66d9ef',
|
||||||
base0E: '#ae81ff',
|
base0E: '#ae81ff',
|
||||||
base0F: '#cc6633'
|
base0F: '#cc6633',
|
||||||
};
|
};
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -80,16 +80,16 @@ const theme = {
|
||||||
extend: theme,
|
extend: theme,
|
||||||
// underline keys for literal values
|
// underline keys for literal values
|
||||||
valueLabel: {
|
valueLabel: {
|
||||||
textDecoration: 'underline'
|
textDecoration: 'underline',
|
||||||
},
|
},
|
||||||
// switch key for objects to uppercase when object is expanded.
|
// switch key for objects to uppercase when object is expanded.
|
||||||
// `nestedNodeLabel` receives additional argument `expandable`
|
// `nestedNodeLabel` receives additional argument `expandable`
|
||||||
nestedNodeLabel: ({ style }, keyPath, nodeType, expanded) => ({
|
nestedNodeLabel: ({ style }, keyPath, nodeType, expanded) => ({
|
||||||
style: {
|
style: {
|
||||||
...style,
|
...style,
|
||||||
textTransform: expanded ? 'uppercase' : style.textTransform
|
textTransform: expanded ? 'uppercase' : style.textTransform,
|
||||||
}
|
},
|
||||||
})
|
}),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -124,7 +124,7 @@ You can pass the following properties to customize rendered labels and values:
|
||||||
```jsx
|
```jsx
|
||||||
<JSONTree
|
<JSONTree
|
||||||
labelRenderer={([key]) => <strong>{key}</strong>}
|
labelRenderer={([key]) => <strong>{key}</strong>}
|
||||||
valueRenderer={raw => <em>{raw}</em>}
|
valueRenderer={(raw) => <em>{raw}</em>}
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
4
packages/react-json-tree/examples/server.js
vendored
4
packages/react-json-tree/examples/server.js
vendored
|
@ -6,8 +6,8 @@ var config = require('./webpack.config');
|
||||||
new WebpackDevServer(webpack(config), {
|
new WebpackDevServer(webpack(config), {
|
||||||
publicPath: config.output.publicPath,
|
publicPath: config.output.publicPath,
|
||||||
hot: true,
|
hot: true,
|
||||||
historyApiFallback: true
|
historyApiFallback: true,
|
||||||
}).listen(3000, 'localhost', function(err) {
|
}).listen(3000, 'localhost', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
48
packages/react-json-tree/examples/src/App.js
vendored
48
packages/react-json-tree/examples/src/App.js
vendored
|
@ -5,19 +5,19 @@ import JSONTree from 'react-json-tree';
|
||||||
const getLabelStyle = ({ style }, nodeType, expanded) => ({
|
const getLabelStyle = ({ style }, nodeType, expanded) => ({
|
||||||
style: {
|
style: {
|
||||||
...style,
|
...style,
|
||||||
textTransform: expanded ? 'uppercase' : style.textTransform
|
textTransform: expanded ? 'uppercase' : style.textTransform,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const getBoolStyle = ({ style }, nodeType) => ({
|
const getBoolStyle = ({ style }, nodeType) => ({
|
||||||
style: {
|
style: {
|
||||||
...style,
|
...style,
|
||||||
border: nodeType === 'Boolean' ? '1px solid #DD3333' : style.border,
|
border: nodeType === 'Boolean' ? '1px solid #DD3333' : style.border,
|
||||||
borderRadius: nodeType === 'Boolean' ? 3 : style.borderRadius
|
borderRadius: nodeType === 'Boolean' ? 3 : style.borderRadius,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const getItemString = type => (
|
const getItemString = (type) => (
|
||||||
<span>
|
<span>
|
||||||
{' // '}
|
{' // '}
|
||||||
{type}
|
{type}
|
||||||
|
@ -30,14 +30,14 @@ const getValueLabelStyle = ({ style }, nodeType, keyPath) => ({
|
||||||
color:
|
color:
|
||||||
!Number.isNaN(keyPath[0]) && !(parseInt(keyPath, 10) % 2)
|
!Number.isNaN(keyPath[0]) && !(parseInt(keyPath, 10) % 2)
|
||||||
? '#33F'
|
? '#33F'
|
||||||
: style.color
|
: style.color,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const longString =
|
const longString =
|
||||||
'Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.'; // eslint-disable-line max-len
|
'Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.'; // eslint-disable-line max-len
|
||||||
|
|
||||||
const Custom = function(value) {
|
const Custom = function (value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
};
|
};
|
||||||
Custom.prototype[Symbol.toStringTag] = 'Custom';
|
Custom.prototype[Symbol.toStringTag] = 'Custom';
|
||||||
|
@ -56,42 +56,42 @@ const data = {
|
||||||
evenMoreNested: {
|
evenMoreNested: {
|
||||||
veryNested: {
|
veryNested: {
|
||||||
insanelyNested: {
|
insanelyNested: {
|
||||||
ridiculouslyDeepValue: 'Hello'
|
ridiculouslyDeepValue: 'Hello',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
baz: undefined,
|
baz: undefined,
|
||||||
func: function User() {}
|
func: function User() {},
|
||||||
},
|
},
|
||||||
emptyObject: {},
|
emptyObject: {},
|
||||||
symbol: Symbol('value'),
|
symbol: Symbol('value'),
|
||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
immutable: Map([
|
immutable: Map([
|
||||||
['key', 'value'],
|
['key', 'value'],
|
||||||
[{ objectKey: 'value' }, { objectKey: 'value' }]
|
[{ objectKey: 'value' }, { objectKey: 'value' }],
|
||||||
]),
|
]),
|
||||||
map: new window.Map([
|
map: new window.Map([
|
||||||
['key', 'value'],
|
['key', 'value'],
|
||||||
[0, 'value'],
|
[0, 'value'],
|
||||||
[{ objectKey: 'value' }, { objectKey: 'value' }]
|
[{ objectKey: 'value' }, { objectKey: 'value' }],
|
||||||
]),
|
]),
|
||||||
weakMap: new window.WeakMap([
|
weakMap: new window.WeakMap([
|
||||||
[{ objectKey: 'value' }, { objectKey: 'value' }]
|
[{ objectKey: 'value' }, { objectKey: 'value' }],
|
||||||
]),
|
]),
|
||||||
set: new window.Set(['value', 0, { objectKey: 'value' }]),
|
set: new window.Set(['value', 0, { objectKey: 'value' }]),
|
||||||
weakSet: new window.WeakSet([
|
weakSet: new window.WeakSet([
|
||||||
{ objectKey: 'value1' },
|
{ objectKey: 'value1' },
|
||||||
{ objectKey: 'value2' }
|
{ objectKey: 'value2' },
|
||||||
]),
|
]),
|
||||||
hugeArray: Array.from({ length: 10000 }).map((_, i) => `item #${i}`),
|
hugeArray: Array.from({ length: 10000 }).map((_, i) => `item #${i}`),
|
||||||
customProfile: {
|
customProfile: {
|
||||||
avatar: new Custom('placehold.it/50x50'),
|
avatar: new Custom('placehold.it/50x50'),
|
||||||
name: new Custom('Name')
|
name: new Custom('Name'),
|
||||||
},
|
},
|
||||||
longString
|
longString,
|
||||||
};
|
};
|
||||||
|
|
||||||
const theme = {
|
const theme = {
|
||||||
|
@ -112,7 +112,7 @@ const theme = {
|
||||||
base0C: '#a1efe4',
|
base0C: '#a1efe4',
|
||||||
base0D: '#66d9ef',
|
base0D: '#66d9ef',
|
||||||
base0E: '#ae81ff',
|
base0E: '#ae81ff',
|
||||||
base0F: '#cc6633'
|
base0F: '#cc6633',
|
||||||
};
|
};
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
|
@ -149,7 +149,7 @@ const App = () => (
|
||||||
extend: theme,
|
extend: theme,
|
||||||
nestedNodeLabel: getLabelStyle,
|
nestedNodeLabel: getLabelStyle,
|
||||||
value: getBoolStyle,
|
value: getBoolStyle,
|
||||||
valueLabel: getValueLabelStyle
|
valueLabel: getValueLabelStyle,
|
||||||
}}
|
}}
|
||||||
getItemString={getItemString}
|
getItemString={getItemString}
|
||||||
/>
|
/>
|
||||||
|
@ -163,7 +163,7 @@ const App = () => (
|
||||||
data={data}
|
data={data}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
labelRenderer={([raw]) => <span>(({raw})):</span>}
|
labelRenderer={([raw]) => <span>(({raw})):</span>}
|
||||||
valueRenderer={raw => (
|
valueRenderer={(raw) => (
|
||||||
<em>
|
<em>
|
||||||
<span role="img" aria-label="mellow">
|
<span role="img" aria-label="mellow">
|
||||||
😐
|
😐
|
||||||
|
|
|
@ -9,12 +9,12 @@ module.exports = {
|
||||||
entry: [
|
entry: [
|
||||||
!isProduction && 'webpack-dev-server/client?http://localhost:3000',
|
!isProduction && 'webpack-dev-server/client?http://localhost:3000',
|
||||||
!isProduction && 'webpack/hot/only-dev-server',
|
!isProduction && 'webpack/hot/only-dev-server',
|
||||||
'./src/index'
|
'./src/index',
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'dist'),
|
path: path.join(__dirname, 'dist'),
|
||||||
filename: 'bundle.js',
|
filename: 'bundle.js',
|
||||||
publicPath: '/static/'
|
publicPath: '/static/',
|
||||||
},
|
},
|
||||||
plugins: [new webpack.HotModuleReplacementPlugin()],
|
plugins: [new webpack.HotModuleReplacementPlugin()],
|
||||||
module: {
|
module: {
|
||||||
|
@ -22,8 +22,8 @@ module.exports = {
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
include: path.join(__dirname, 'src')
|
include: path.join(__dirname, 'src'),
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
2
packages/react-json-tree/src/ItemRange.js
vendored
2
packages/react-json-tree/src/ItemRange.js
vendored
|
@ -8,7 +8,7 @@ export default class ItemRange extends React.Component {
|
||||||
from: PropTypes.number.isRequired,
|
from: PropTypes.number.isRequired,
|
||||||
to: PropTypes.number.isRequired,
|
to: PropTypes.number.isRequired,
|
||||||
renderChildNodes: PropTypes.func.isRequired,
|
renderChildNodes: PropTypes.func.isRequired,
|
||||||
nodeType: PropTypes.string.isRequired
|
nodeType: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const JSONArrayNode = ({ data, ...props }) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
JSONArrayNode.propTypes = {
|
JSONArrayNode.propTypes = {
|
||||||
data: PropTypes.array
|
data: PropTypes.array,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default JSONArrayNode;
|
export default JSONArrayNode;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user