') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Add info message for area trace opacity by VeraZab · Pull Request #198 · plotly/react-chart-editor · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/components/containers/Section.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,13 @@ import Info from '../fields/Info';
import MenuPanel from './MenuPanel';
import React, {Component, cloneElement} from 'react';
import PropTypes from 'prop-types';
import unpackPlotProps from 'lib/unpackPlotProps';
import {containerConnectedContextTypes} from 'lib/connectToContainer';
import {
containerConnectedContextTypes,
localize,
unpackPlotProps,
} from '../../lib';

export default class Section extends Component {
class Section extends Component {
constructor(props, context) {
super(props, context);

Expand All@@ -21,6 +24,8 @@ export default class Section extends Component {
}

processAndSetChildren(nextProps, nextContext) {
const {fullContainer} = nextContext;
const {localize: _} = nextProps;
this.sectionVisible = false;

const children = React.Children.toArray(nextProps.children);
Expand All@@ -47,6 +52,22 @@ export default class Section extends Component {
let newProps = {};
if (child.plotProps) {
plotProps = child.plotProps;
} else if (
fullContainer &&
fullContainer.type === 'scatter' &&
!fullContainer.opacity &&
child.props.attr === 'opacity'
) {
this.sectionVisible = true;
const child = (
<Info>
{_(
'Trace opacity is not supported for a scatter trace with fill ' +
'or for a scatter trace that gets filled by another scatter trace.'
)}
</Info>
);
this.children.push(child);
} else if (isAttr) {
if (child.type.supplyPlotProps) {
plotProps = child.type.supplyPlotProps(child.props, nextContext);
Expand DownExpand Up@@ -94,3 +115,4 @@ Section.propTypes = {
};

Section.contextTypes = containerConnectedContextTypes;
export default localize(Section);
2 changes: 1 addition & 1 deletion src/components/containers/__tests__/Section-test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ describe('Section', () => {
</TestEditor>
).find('[name="test-section"]');

expect(wrapper.children().length).toBe(1);
expect(wrapper.children().length).toBe(2);
expect(wrapper.find('.extra').text()).toBe('special extra');
});

Expand Down
5 changes: 4 additions & 1 deletion src/lib/index.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,9 @@ import bem from './bem';
import connectAnnotationToLayout from './connectAnnotationToLayout';
import connectAxesToLayout from './connectAxesToLayout';
import connectLayoutToPlot, {getLayoutContext} from './connectLayoutToPlot';
import connectToContainer from './connectToContainer';
import connectToContainer, {
containerConnectedContextTypes,
} from './connectToContainer';
import connectTraceToPlot from './connectTraceToPlot';
import dereference from './dereference';
import findFullTraceIndex from './findFullTraceIndex';
Expand DownExpand Up@@ -37,6 +39,7 @@ export {
connectLayoutToPlot,
connectToContainer,
connectTraceToPlot,
containerConnectedContextTypes,
customTraceToPlotlyTrace,
dereference,
findFullTraceIndex,
Expand Down
16 changes: 8 additions & 8 deletions src/styles/components/fields/_field.scss
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,24 +53,24 @@
}
}

&__delete{
&__delete{
display: flex;
align-items: center;
justify-content: center;
padding-left: var(--spacing-quarter-unit);
opacity: 0.5;
svg{
svg{
display: block;
path{
fill: var(--color-text-base)
path{
fill: var(--color-text-base);
}
}
&:hover{
&:hover{
cursor: pointer;
opacity: 1;
svg{
path{
fill: var(--color-sienna)
svg{
path{
fill: var(--color-sienna);
}
}
}
Expand Down