mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Add basic popover with additional information
This commit is contained in:
parent
87a32314ae
commit
e421df8151
|
|
@ -1253,11 +1253,12 @@ function getRenderedAttributeValue(renderer, attribute, type) {
|
||||||
container = document.createElement(containerTagName);
|
container = document.createElement(containerTagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let testValue;
|
||||||
let defaultValue;
|
let defaultValue;
|
||||||
try {
|
try {
|
||||||
const read = attribute.read || getProperty(attribute.name);
|
const read = attribute.read || getProperty(attribute.name);
|
||||||
|
|
||||||
let testValue = type.testValue;
|
testValue = type.testValue;
|
||||||
if (attribute.overrideStringValue !== undefined) {
|
if (attribute.overrideStringValue !== undefined) {
|
||||||
switch (type.name) {
|
switch (type.name) {
|
||||||
case 'string':
|
case 'string':
|
||||||
|
|
@ -1285,6 +1286,8 @@ function getRenderedAttributeValue(renderer, attribute, type) {
|
||||||
const result = read(container.firstChild);
|
const result = read(container.firstChild);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
testValue,
|
||||||
|
defaultValue,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
result,
|
result,
|
||||||
didWarn: _didWarn,
|
didWarn: _didWarn,
|
||||||
|
|
@ -1292,6 +1295,8 @@ function getRenderedAttributeValue(renderer, attribute, type) {
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
|
testValue,
|
||||||
|
defaultValue,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
result: null,
|
result: null,
|
||||||
didWarn: _didWarn,
|
didWarn: _didWarn,
|
||||||
|
|
@ -1398,25 +1403,112 @@ function RendererResult({version, result, defaultValue, didWarn, didError}) {
|
||||||
return <div css={style}>{displayResult}</div>;
|
return <div css={style}>{displayResult}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Result(props) {
|
function ResultPopover(props) {
|
||||||
const {react15, react16, hasSameBehavior} = props;
|
|
||||||
const style = {position: 'absolute', width: '100%', height: '100%'};
|
|
||||||
if (!hasSameBehavior) {
|
|
||||||
style.border = '4px solid purple';
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div css={style}>
|
<pre
|
||||||
<div css={{position: 'absolute', width: '50%', height: '100%'}}>
|
css={{
|
||||||
<RendererResult version={15} {...react15} />
|
padding: '1em',
|
||||||
</div>
|
width: '25em',
|
||||||
<div
|
}}>
|
||||||
css={{position: 'absolute', width: '50%', left: '50%', height: '100%'}}>
|
{JSON.stringify(
|
||||||
<RendererResult version={16} {...react16} />
|
{
|
||||||
</div>
|
react15: props.react15,
|
||||||
</div>
|
react16: props.react16,
|
||||||
|
hasSameBehavior: props.hasSameBehavior,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
)}
|
||||||
|
</pre>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Result extends React.Component {
|
||||||
|
state = {showInfo: false};
|
||||||
|
onMouseEnter = () => {
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
}
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
this.setState({showInfo: true});
|
||||||
|
}, 250);
|
||||||
|
};
|
||||||
|
onMouseLeave = () => {
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
}
|
||||||
|
this.setState({showInfo: false});
|
||||||
|
};
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {react15, react16, hasSameBehavior} = this.props;
|
||||||
|
const style = {
|
||||||
|
position: 'absolute',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
};
|
||||||
|
|
||||||
|
let highlight = null;
|
||||||
|
let popover = null;
|
||||||
|
if (this.state.showInfo) {
|
||||||
|
highlight = (
|
||||||
|
<div
|
||||||
|
css={{
|
||||||
|
position: 'absolute',
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
|
border: '2px solid blue',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
popover = (
|
||||||
|
<div
|
||||||
|
css={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
border: '1px solid black',
|
||||||
|
position: 'absolute',
|
||||||
|
top: '100%',
|
||||||
|
zIndex: 999,
|
||||||
|
}}>
|
||||||
|
<ResultPopover {...this.props} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasSameBehavior) {
|
||||||
|
style.border = '4px solid purple';
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
css={style}
|
||||||
|
onMouseEnter={this.onMouseEnter}
|
||||||
|
onMouseLeave={this.onMouseLeave}>
|
||||||
|
<div css={{position: 'absolute', width: '50%', height: '100%'}}>
|
||||||
|
<RendererResult version={15} {...react15} />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
css={{
|
||||||
|
position: 'absolute',
|
||||||
|
width: '50%',
|
||||||
|
left: '50%',
|
||||||
|
height: '100%',
|
||||||
|
}}>
|
||||||
|
<RendererResult version={16} {...react16} />
|
||||||
|
</div>
|
||||||
|
{highlight}
|
||||||
|
{popover}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function ColumnHeader({children}) {
|
function ColumnHeader({children}) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user