@codecademy/gamut 67.6.1-alpha.7ad049.0 → 67.6.1-alpha.9dd240.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Card/elements.d.ts +11 -10
- package/dist/Form/elements/Form.d.ts +5 -5
- package/dist/List/elements.d.ts +6 -5
- package/dist/Pagination/AnimatedPaginationButtons.d.ts +1 -0
- package/dist/Tip/__tests__/helpers.d.ts +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +7 -7
- package/dist/BarChart/Bar/elements.d.ts +0 -1392
- package/dist/BarChart/Bar/elements.js +0 -61
- package/dist/BarChart/Bar/index.d.ts +0 -1
- package/dist/BarChart/Bar/index.js +0 -2
- package/dist/BarChart/BarChartProvider.d.ts +0 -33
- package/dist/BarChart/BarChartProvider.js +0 -39
- package/dist/BarChart/BarRow.d.ts +0 -7
- package/dist/BarChart/BarRow.js +0 -213
- package/dist/BarChart/GridLines.d.ts +0 -6
- package/dist/BarChart/GridLines.js +0 -45
- package/dist/BarChart/ScaleChartHeader.d.ts +0 -17
- package/dist/BarChart/ScaleChartHeader.js +0 -58
- package/dist/BarChart/index.d.ts +0 -4
- package/dist/BarChart/index.js +0 -81
- package/dist/BarChart/types.d.ts +0 -56
- package/dist/BarChart/types.js +0 -1
- package/dist/BarChart/utils/index.d.ts +0 -23
- package/dist/BarChart/utils/index.js +0 -56
package/dist/BarChart/types.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { ColorAlias } from '@codecademy/gamut-styles';
|
|
2
|
-
import { GamutIconProps } from '@codecademy/gamut-icons';
|
|
3
|
-
import { HTMLProps } from 'react';
|
|
4
|
-
import { ButtonProps } from '../Button';
|
|
5
|
-
type BarChartAriaLabel = {
|
|
6
|
-
'aria-label': string;
|
|
7
|
-
'aria-labelledby'?: never;
|
|
8
|
-
};
|
|
9
|
-
type BarChartAriaLabelledBy = {
|
|
10
|
-
'aria-label'?: never;
|
|
11
|
-
'aria-labelledby': string;
|
|
12
|
-
};
|
|
13
|
-
type BarChartLabel = BarChartAriaLabel | BarChartAriaLabelledBy;
|
|
14
|
-
export type BarChartStyles = {
|
|
15
|
-
/** Color for text labels. Defaults to 'text' */
|
|
16
|
-
textColor?: ColorAlias;
|
|
17
|
-
/** Color for the foreground/progress bar. Defaults to 'feedback-warning' */
|
|
18
|
-
foregroundBarColor?: ColorAlias;
|
|
19
|
-
/** Color for the background/total bar. Defaults to 'paleBlue' */
|
|
20
|
-
backgroundBarColor?: ColorAlias;
|
|
21
|
-
};
|
|
22
|
-
export type BarProps = {
|
|
23
|
-
/** Label displayed on the y-axis for this bar */
|
|
24
|
-
yLabel: string;
|
|
25
|
-
/** The foreground/progress bar value (always shown) */
|
|
26
|
-
seriesOneValue: number;
|
|
27
|
-
/** The background/total bar value (optional - creates stacked effect when provided) */
|
|
28
|
-
seriesTwoValue?: number;
|
|
29
|
-
/** Optional icon to display next to the label */
|
|
30
|
-
icon?: React.ComponentType<GamutIconProps>;
|
|
31
|
-
/** Click handler - makes row interactive as a button */
|
|
32
|
-
onClick?: ButtonProps['onClick'];
|
|
33
|
-
/** Link href - makes row interactive as an anchor */
|
|
34
|
-
href?: HTMLProps<HTMLAnchorElement>['href'];
|
|
35
|
-
};
|
|
36
|
-
export type BarChartProps = BarChartLabel & {
|
|
37
|
-
/** Whether to animate bars on mount */
|
|
38
|
-
animate?: boolean;
|
|
39
|
-
/** Array of bar data to render */
|
|
40
|
-
barValues: BarProps[];
|
|
41
|
-
/** Maximum value for the x-axis scale */
|
|
42
|
-
maxRange: number;
|
|
43
|
-
/** Minimum value for the x-axis scale (usually 0) */
|
|
44
|
-
minRange: number;
|
|
45
|
-
/** Sort order for bars */
|
|
46
|
-
order?: 'ascending' | 'descending';
|
|
47
|
-
/** Property to sort bars by */
|
|
48
|
-
sortBy?: 'label' | 'value' | 'none';
|
|
49
|
-
/** Unit label to display (e.g., "XP") */
|
|
50
|
-
unit?: string;
|
|
51
|
-
/** Style configuration for colors */
|
|
52
|
-
styleConfig?: BarChartStyles;
|
|
53
|
-
/** Interval for x-axis scale markers */
|
|
54
|
-
xScale?: number;
|
|
55
|
-
};
|
|
56
|
-
export {};
|
package/dist/BarChart/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export declare const numDigits: (num: number) => number;
|
|
2
|
-
export declare const columnBaseSize: (experience?: number) => {
|
|
3
|
-
sm: number;
|
|
4
|
-
md: number;
|
|
5
|
-
lg: number;
|
|
6
|
-
xl: number;
|
|
7
|
-
};
|
|
8
|
-
export declare const calculatePercent: (value: number, total: number) => number;
|
|
9
|
-
export declare const calculateBarWidth: ({ value, maxRange, }: {
|
|
10
|
-
value: number;
|
|
11
|
-
maxRange: number;
|
|
12
|
-
}) => number;
|
|
13
|
-
export declare const calculateTicksAndRange: (maxTicks: number, minPoint: number, maxPoint: number) => [number, number, number];
|
|
14
|
-
/**
|
|
15
|
-
* Returns a "nice" number approximately equal to range
|
|
16
|
-
* Rounds the number if round = true
|
|
17
|
-
* Takes the ceiling if round = false.
|
|
18
|
-
* A nice number is a simple decimal number, for example if a number is 1234, a nice number would be 1000 or 2000.
|
|
19
|
-
*/
|
|
20
|
-
export declare const niceNum: (range: number, roundDown: boolean) => number;
|
|
21
|
-
export declare const getPercentDiff: (v1: number, v2: number) => number;
|
|
22
|
-
export declare const formatNumberUS: (num: number) => string;
|
|
23
|
-
export declare const formatNumberUSCompact: (num: number) => string;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export const numDigits = num => {
|
|
2
|
-
return Math.max(Math.floor(Math.log10(Math.abs(num))), 0) + 1;
|
|
3
|
-
};
|
|
4
|
-
export const columnBaseSize = (experience = 3) => {
|
|
5
|
-
const digits = numDigits(experience);
|
|
6
|
-
return {
|
|
7
|
-
sm: digits > 4 ? 5 : 4,
|
|
8
|
-
md: digits > 4 ? 5 : 4,
|
|
9
|
-
lg: digits > 4 ? 4 : 5,
|
|
10
|
-
xl: digits > 4 ? 5 : 4
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const calculatePercent = (value, total) => {
|
|
14
|
-
return value / total * 100;
|
|
15
|
-
};
|
|
16
|
-
export const calculateBarWidth = ({
|
|
17
|
-
value,
|
|
18
|
-
maxRange
|
|
19
|
-
}) => {
|
|
20
|
-
return Math.floor(calculatePercent(value, maxRange));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// Calculate tick spacing and nice minimum and maximum data points on the axis.
|
|
24
|
-
|
|
25
|
-
export const calculateTicksAndRange = (maxTicks, minPoint, maxPoint) => {
|
|
26
|
-
const range = niceNum(maxPoint - minPoint, false);
|
|
27
|
-
const tickSpacing = niceNum(range / (maxTicks - 1), true);
|
|
28
|
-
const niceMin = Math.floor(minPoint / tickSpacing) * tickSpacing;
|
|
29
|
-
const niceMax = Math.ceil(maxPoint / tickSpacing) * tickSpacing;
|
|
30
|
-
const tickCount = range / tickSpacing;
|
|
31
|
-
return [tickCount, niceMin, niceMax];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns a "nice" number approximately equal to range
|
|
36
|
-
* Rounds the number if round = true
|
|
37
|
-
* Takes the ceiling if round = false.
|
|
38
|
-
* A nice number is a simple decimal number, for example if a number is 1234, a nice number would be 1000 or 2000.
|
|
39
|
-
*/
|
|
40
|
-
export const niceNum = (range, roundDown) => {
|
|
41
|
-
const exponent = Math.floor(Math.log10(range));
|
|
42
|
-
const fraction = range / 10 ** exponent;
|
|
43
|
-
let niceFraction;
|
|
44
|
-
if (roundDown) {
|
|
45
|
-
if (fraction < 1.5) niceFraction = 1;else if (fraction < 3) niceFraction = 2;else if (fraction < 7) niceFraction = 5;else niceFraction = 10;
|
|
46
|
-
} else if (fraction <= 1) niceFraction = 1;else if (fraction <= 2) niceFraction = 2;else if (fraction <= 5) niceFraction = 5;else niceFraction = 10;
|
|
47
|
-
return niceFraction * 10 ** exponent;
|
|
48
|
-
};
|
|
49
|
-
export const getPercentDiff = (v1, v2) => {
|
|
50
|
-
return Math.abs(v1 - v2) / ((v1 + v2) / 2) * 100;
|
|
51
|
-
};
|
|
52
|
-
export const formatNumberUS = num => Intl.NumberFormat('en').format(num);
|
|
53
|
-
export const formatNumberUSCompact = num => Intl.NumberFormat('en', {
|
|
54
|
-
notation: 'compact',
|
|
55
|
-
compactDisplay: 'short'
|
|
56
|
-
}).format(num);
|