Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace default exports with individual exports and namespaced imports #1907

Merged
merged 30 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0f83fdb
Replace default export in Helpers to enable tree-shaking
Jul 16, 2021
540bc67
Fix label helpers export
Jul 16, 2021
641c024
Update exports for axis helpers
Jul 16, 2021
a87d3c4
Update exports for collections helpers
Jul 16, 2021
e19be47
Update imports for data
Jul 16, 2021
5eb239f
Update default transitions and domain
Jul 16, 2021
78148b4
Update exports for events and immutable
Jul 19, 2021
ada8e53
Update exports for log and scale
Jul 19, 2021
b23cb5c
Update exports for custom prop types
Jul 20, 2021
086fe30
Update exports for selection
Jul 20, 2021
1928994
Update exports for style
Jul 20, 2021
48c7e39
Update exports for transitions
Jul 20, 2021
f46d547
Update common props exports
Jul 20, 2021
1ed1c32
Remove accidental export *
Jul 20, 2021
01be471
Remove accidental import *
Jul 21, 2021
9d30adb
Update sinon test fixes
Jul 20, 2021
988de61
Upgrade sinon version
Jul 21, 2021
2c918f5
Remove proxyquire
Jul 21, 2021
0a7b0b2
Re-add sinon sandboxes
Jul 21, 2021
51c3e27
Update helper-methods exports
Jul 21, 2021
30ca414
Various debug work
ryan-roemer Jul 21, 2021
027b845
Set up internal impl to stub.
ryan-roemer Jul 27, 2021
fcf4fab
Pass env var for TEST_MODULE
ryan-roemer Jul 27, 2021
7bc2e99
Minor cleanup
ryan-roemer Jul 27, 2021
359ae82
Add test watch scripts
Jul 28, 2021
372e0d9
Run prettier
Jul 28, 2021
f9fbb33
Fix text size linter error
Jul 28, 2021
3742284
Upgrade karma
Jul 28, 2021
9e63247
Add node polyfill plugin to webpack test config
Aug 4, 2021
0b8f59c
Fix LabelHelpers function
Aug 4, 2021
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
Prev Previous commit
Next Next commit
Update default transitions and domain
  • Loading branch information
Becca Bailey committed Aug 2, 2021
commit 5eb239f66f41b3bb43af85b7076481bfd59fe4bb
4 changes: 2 additions & 2 deletions packages/victory-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export { default as Whisker } from "./victory-primitives/whisker";
export { default as addEvents } from "./victory-util/add-events";
export * as Collection from "./victory-util/collection";
export * as Data from "./victory-util/data";
export { default as DefaultTransitions } from "./victory-util/default-transitions";
export { default as Domain } from "./victory-util/domain";
export * as DefaultTransitions from "./victory-util/default-transitions";
export * as Domain from "./victory-util/domain";
export { default as Events } from "./victory-util/events";
export * as Helpers from "./victory-util/helpers";
export { default as Immutable } from "./victory-util/immutable";
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-core/src/victory-util/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
without
} from "lodash";
import * as Collection from "./collection";
import Domain from "./domain";
import * as Domain from "./domain";
import * as Helpers from "./helpers";

/**
Expand Down
148 changes: 73 additions & 75 deletions packages/victory-core/src/victory-util/default-transitions.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,77 @@
/* eslint-disable func-style */
export default {
continuousTransitions() {
return {
onLoad: {
duration: 2000
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
}
};
},
export function continuousTransitions() {
return {
onLoad: {
duration: 2000
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
}
};
}

continuousPolarTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ _y: 0, _y1: 0, _y0: 0 }),
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 })
},
onExit: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
},
onEnter: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
after: (datum) => ({
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
})
export function continuousPolarTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ _y: 0, _y1: 0, _y0: 0 }),
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 })
},
onExit: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
};
},

discreteTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ opacity: 0 }),
after: (datum) => datum
},
onExit: {
duration: 600,
before: () => ({ opacity: 0 })
},
onEnter: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
onEnter: {
duration: 600,
before: () => ({ opacity: 0 }),
after: (datum) => datum
}
};
}
};
after: (datum) => ({
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
})
}
};
}

export function discreteTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ opacity: 0 }),
after: (datum) => datum
},
onExit: {
duration: 600,
before: () => ({ opacity: 0 })
},
onEnter: {
duration: 600,
before: () => ({ opacity: 0 }),
after: (datum) => datum
}
};
}
42 changes: 15 additions & 27 deletions packages/victory-core/src/victory-util/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ function padDomain(domain, props, axis) {
* returns a formatted domain
* @returns {Function} a function that takes props and axis and returns a formatted domain
*/
function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
export function createDomainFunction(
getDomainFromDataFunction,
formatDomainFunction
) {
getDomainFromDataFunction = isFunction(getDomainFromDataFunction)
? getDomainFromDataFunction
: getDomainFromData;
Expand All @@ -204,7 +207,7 @@ function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
* @param {String} axis: the current axis
* @returns {Array} a domain in the form of a two element array
*/
function formatDomain(domain, props, axis) {
export function formatDomain(domain, props, axis) {
return cleanDomain(padDomain(domain, props, axis), props, axis);
}

Expand All @@ -214,7 +217,7 @@ function formatDomain(domain, props, axis) {
* @param {String} axis: the current axis
* @returns {Array} the domain for the given axis
*/
function getDomain(props, axis) {
export function getDomain(props, axis) {
return createDomainFunction()(props, axis);
}

Expand All @@ -225,7 +228,7 @@ function getDomain(props, axis) {
* @param {Array} categories: an array of categories corresponding to a given axis
* @returns {Array|undefined} returns a domain from categories or undefined
*/
function getDomainFromCategories(props, axis, categories) {
export function getDomainFromCategories(props, axis, categories) {
categories = categories || Data.getCategories(props, axis);
const { polar, startAngle = 0, endAngle = 360 } = props;
if (!categories) {
Expand Down Expand Up @@ -267,7 +270,7 @@ function getDomainFromCategories(props, axis, categories) {
* @param {Array} dataset: an array of data
* @returns {Array} the domain based on data
*/
function getDomainFromData(props, axis, dataset) {
export function getDomainFromData(props, axis, dataset) {
dataset = dataset || Data.getData(props);
const { polar, startAngle = 0, endAngle = 360 } = props;
const minDomain = getMinFromProps(props, axis);
Expand Down Expand Up @@ -297,7 +300,7 @@ function getDomainFromData(props, axis, dataset) {
* @param {Number|Date} max: the current axis
* @returns {Array} the minDomain based on props
*/
function getDomainFromMinMax(min, max) {
export function getDomainFromMinMax(min, max) {
const getSinglePointDomain = (val) => {
// d3-scale does not properly resolve very small differences.
const verySmallNumber =
Expand All @@ -323,7 +326,7 @@ function getDomainFromMinMax(min, max) {
* @param {String} axis: the current axis
* @returns {Array|undefined} the domain based on props
*/
function getDomainFromProps(props, axis) {
export function getDomainFromProps(props, axis) {
const minDomain = getMinFromProps(props, axis);
const maxDomain = getMaxFromProps(props, axis);
if (isPlainObject(props.domain) && props.domain[axis]) {
Expand All @@ -343,7 +346,7 @@ function getDomainFromProps(props, axis) {
* @param {String} axis: the current axis
* @returns {Array} the domain for the given axis
*/
function getDomainWithZero(props, axis) {
export function getDomainWithZero(props, axis) {
const propsDomain = getDomainFromProps(props, axis);
if (propsDomain) {
return propsDomain;
Expand Down Expand Up @@ -395,7 +398,7 @@ function getDomainWithZero(props, axis) {
* @param {String} axis: the current axis
* @returns {Number|Date|undefined} the maxDomain based on props
*/
function getMaxFromProps(props, axis) {
export function getMaxFromProps(props, axis) {
if (isPlainObject(props.maxDomain) && props.maxDomain[axis] !== undefined) {
return props.maxDomain[axis];
}
Expand All @@ -410,7 +413,7 @@ function getMaxFromProps(props, axis) {
* @param {String} axis: the current axis
* @returns {Number|Date|undefined} the minDomain based on props
*/
function getMinFromProps(props, axis) {
export function getMinFromProps(props, axis) {
if (isPlainObject(props.minDomain) && props.minDomain[axis] !== undefined) {
return props.minDomain[axis];
}
Expand All @@ -426,7 +429,7 @@ function getMinFromProps(props, axis) {
* for a given dimension i.e. only x values.
* @returns {Array} the symmetric domain
*/
function getSymmetricDomain(domain, values) {
export function getSymmetricDomain(domain, values) {
const processedData = sortedUniq(values.sort((a, b) => a - b));
const step = processedData[1] - processedData[0];
return [domain[0], domain[1] + step];
Expand All @@ -437,7 +440,7 @@ function getSymmetricDomain(domain, values) {
* @param {Component} component: a React component instance
* @returns {Boolean} Returns true if the given component has a role included in the whitelist
*/
function isDomainComponent(component) {
export function isDomainComponent(component) {
const getRole = (child) => {
return child && child.type ? child.type.role : "";
};
Expand All @@ -463,18 +466,3 @@ function isDomainComponent(component) {
];
return includes(whitelist, role);
}

export default {
createDomainFunction,
formatDomain,
getDomain,
getDomainFromCategories,
getDomainFromData,
getDomainFromMinMax,
getDomainFromProps,
getDomainWithZero,
getMaxFromProps,
getMinFromProps,
getSymmetricDomain,
isDomainComponent
};
2 changes: 1 addition & 1 deletion packages/victory-core/src/victory-util/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as Axis from "./axis";
import Style from "./style";
import Transitions from "./transitions";
import * as Data from "./data";
import Domain from "./domain";
import * as Domain from "./domain";
import Events from "./events";
import * as Collection from "./collection";
import * as Helpers from "./helpers";
Expand Down