@bundle-stats/ui 3.3.0-alpha.1 → 3.3.1-beta.12
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/CHANGELOG.md +65 -13
- package/lib/app/app.js +126 -104
- package/lib/app/app.module.css +11 -4
- package/lib/app/app.stories.js +1 -22
- package/lib/app/header/header.js +3 -11
- package/lib/assets/icons.svg +0 -8
- package/lib/components/asset-info/asset-info.module.css +1 -0
- package/lib/components/bundle-assets/bundle-assets.js +105 -52
- package/lib/components/bundle-assets/bundle-assets.module.css +24 -26
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +16 -42
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
- package/lib/components/bundle-modules/bundle-modules.js +68 -68
- package/lib/components/bundle-modules/bundle-modules.module.css +11 -2
- package/lib/components/bundle-modules/bundle-modules.utils.js +14 -10
- package/lib/components/bundle-modules/index.js +4 -4
- package/lib/components/bundle-packages/bundle-packages.js +100 -44
- package/lib/components/bundle-packages/bundle-packages.module.css +17 -21
- package/lib/components/delta/delta.module.css +1 -0
- package/lib/components/index.js +0 -8
- package/lib/components/job-header/job-header.js +3 -1
- package/lib/components/job-header/job-header.module.css +6 -8
- package/lib/components/jobs-header/jobs-header.module.css +5 -0
- package/lib/components/metrics-table/metrics-table.js +72 -59
- package/lib/components/metrics-table/metrics-table.module.css +18 -7
- package/lib/components/metrics-table-search/metrics-table-search.module.css +5 -4
- package/lib/components/metrics-table-title/metrics-table-title.js +9 -7
- package/lib/components/metrics-table-title/metrics-table-title.module.css +2 -0
- package/lib/components/module-info/module-info.js +2 -2
- package/lib/components/module-info/module-info.module.css +1 -0
- package/lib/components/summary/summary.js +7 -12
- package/lib/components/summary/summary.module.css +1 -1
- package/lib/components/summary/summary.stories.js +0 -29
- package/lib/components/summary-item/summary-item.js +18 -38
- package/lib/components/summary-item/summary-item.module.css +1 -34
- package/lib/components/summary-item/summary-item.stories.js +53 -51
- package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
- package/lib/constants.js +4 -4
- package/lib/css/default.css +14 -3
- package/lib/css/variables.css +17 -17
- package/lib/hooks/search-params.js +31 -31
- package/lib/layout/box/box.module.css +9 -0
- package/lib/layout/footer/footer.module.css +1 -1
- package/lib/layout/index.js +8 -0
- package/lib/layout/separator.js +48 -0
- package/lib/layout/separator.module.css +5 -0
- package/lib/ui/alert/alert.js +3 -13
- package/lib/ui/dropdown/dropdown.js +21 -26
- package/lib/ui/dropdown/dropdown.module.css +11 -12
- package/lib/ui/dropdown/dropdown.stories.js +2 -9
- package/lib/ui/empty-set/empty-set.js +5 -4
- package/lib/ui/empty-set/empty-set.module.css +2 -2
- package/lib/ui/filters/filters.container.js +1 -1
- package/lib/ui/filters/filters.js +22 -7
- package/lib/ui/filters/filters.module.css +3 -3
- package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +1 -1
- package/lib/ui/hover-card/hover-card.js +102 -0
- package/lib/ui/hover-card/hover-card.module.css +29 -0
- package/lib/ui/hover-card/hover-card.stories.js +56 -0
- package/lib/{components/budget-info → ui/hover-card}/index.js +4 -4
- package/lib/ui/icon/icon.js +6 -8
- package/lib/ui/icon/icon.module.css +1 -0
- package/lib/ui/index.js +8 -8
- package/lib/ui/table/table.js +5 -74
- package/lib/ui/table/table.module.css +41 -25
- package/lib/ui/table/table.stories.js +1 -1
- package/lib/ui/{popover → tag}/index.js +4 -4
- package/lib/ui/tag/tag.js +72 -0
- package/lib/ui/tag/tag.module.css +55 -0
- package/lib/ui/tag/tag.stories.js +38 -0
- package/lib/ui/tooltip/tooltip.js +10 -9
- package/lib/ui/tooltip/tooltip.module.css +2 -1
- package/lib-esm/app/app.js +121 -103
- package/lib-esm/app/app.module.css +11 -4
- package/lib-esm/app/app.stories.js +1 -22
- package/lib-esm/app/header/header.js +3 -10
- package/lib-esm/assets/icons.svg +0 -8
- package/lib-esm/components/asset-info/asset-info.module.css +1 -0
- package/lib-esm/components/bundle-assets/bundle-assets.js +98 -56
- package/lib-esm/components/bundle-assets/bundle-assets.module.css +24 -26
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +13 -26
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
- package/lib-esm/components/bundle-modules/bundle-modules.js +50 -51
- package/lib-esm/components/bundle-modules/bundle-modules.module.css +11 -2
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js +14 -6
- package/lib-esm/components/bundle-modules/index.js +5 -3
- package/lib-esm/components/bundle-packages/bundle-packages.js +88 -41
- package/lib-esm/components/bundle-packages/bundle-packages.module.css +17 -21
- package/lib-esm/components/delta/delta.module.css +1 -0
- package/lib-esm/components/index.js +0 -1
- package/lib-esm/components/job-header/job-header.js +2 -1
- package/lib-esm/components/job-header/job-header.module.css +6 -8
- package/lib-esm/components/jobs-header/jobs-header.module.css +5 -0
- package/lib-esm/components/metrics-table/metrics-table.js +61 -53
- package/lib-esm/components/metrics-table/metrics-table.module.css +18 -7
- package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +5 -4
- package/lib-esm/components/metrics-table-title/metrics-table-title.js +8 -7
- package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +2 -0
- package/lib-esm/components/module-info/module-info.js +2 -2
- package/lib-esm/components/module-info/module-info.module.css +1 -0
- package/lib-esm/components/summary/summary.js +7 -11
- package/lib-esm/components/summary/summary.module.css +1 -1
- package/lib-esm/components/summary/summary.stories.js +0 -27
- package/lib-esm/components/summary-item/summary-item.js +16 -36
- package/lib-esm/components/summary-item/summary-item.module.css +1 -34
- package/lib-esm/components/summary-item/summary-item.stories.js +38 -50
- package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
- package/lib-esm/constants.js +4 -4
- package/lib-esm/css/default.css +14 -3
- package/lib-esm/css/variables.css +17 -17
- package/lib-esm/hooks/search-params.js +27 -28
- package/lib-esm/layout/box/box.module.css +9 -0
- package/lib-esm/layout/footer/footer.module.css +1 -1
- package/lib-esm/layout/index.js +1 -0
- package/lib-esm/layout/separator.js +28 -0
- package/lib-esm/layout/separator.module.css +5 -0
- package/lib-esm/ui/alert/alert.js +3 -6
- package/lib-esm/ui/dropdown/dropdown.js +20 -25
- package/lib-esm/ui/dropdown/dropdown.module.css +11 -12
- package/lib-esm/ui/dropdown/dropdown.stories.js +2 -7
- package/lib-esm/ui/empty-set/empty-set.js +4 -4
- package/lib-esm/ui/empty-set/empty-set.module.css +2 -2
- package/lib-esm/ui/filters/filters.js +20 -5
- package/lib-esm/ui/filters/filters.module.css +3 -3
- package/lib-esm/ui/hover-card/hover-card.js +83 -0
- package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
- package/lib-esm/ui/hover-card/hover-card.stories.js +35 -0
- package/lib-esm/ui/hover-card/index.js +1 -0
- package/lib-esm/ui/icon/icon.js +3 -5
- package/lib-esm/ui/icon/icon.module.css +1 -0
- package/lib-esm/ui/index.js +1 -1
- package/lib-esm/ui/table/table.js +5 -65
- package/lib-esm/ui/table/table.module.css +41 -25
- package/lib-esm/ui/table/table.stories.js +1 -1
- package/lib-esm/ui/tag/index.js +1 -0
- package/lib-esm/ui/tag/tag.js +45 -0
- package/lib-esm/ui/tag/tag.module.css +55 -0
- package/lib-esm/ui/tag/tag.stories.js +23 -0
- package/lib-esm/ui/tooltip/tooltip.js +10 -9
- package/lib-esm/ui/tooltip/tooltip.module.css +2 -1
- package/package.json +33 -31
- package/src/app/app.jsx +136 -146
- package/src/app/app.module.css +11 -4
- package/src/app/header/header.jsx +1 -11
- package/src/assets/icons.svg +0 -8
- package/src/components/asset-info/asset-info.module.css +1 -0
- package/src/components/bundle-assets/bundle-assets.jsx +85 -31
- package/src/components/bundle-assets/bundle-assets.module.css +24 -26
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -25
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/src/components/bundle-modules/bundle-modules.jsx +53 -36
- package/src/components/bundle-modules/bundle-modules.module.css +11 -2
- package/src/components/bundle-modules/bundle-modules.utils.js +16 -4
- package/src/components/bundle-modules/index.jsx +3 -0
- package/src/components/bundle-packages/bundle-packages.jsx +89 -39
- package/src/components/bundle-packages/bundle-packages.module.css +17 -21
- package/src/components/delta/delta.module.css +1 -0
- package/src/components/index.js +0 -1
- package/src/components/job-header/job-header.jsx +2 -1
- package/src/components/job-header/job-header.module.css +6 -8
- package/src/components/jobs-header/jobs-header.module.css +5 -0
- package/src/components/metrics-table/metrics-table.jsx +53 -44
- package/src/components/metrics-table/metrics-table.module.css +18 -7
- package/src/components/metrics-table-search/metrics-table-search.module.css +5 -4
- package/src/components/metrics-table-title/metrics-table-title.jsx +20 -21
- package/src/components/metrics-table-title/metrics-table-title.module.css +2 -0
- package/src/components/module-info/module-info.jsx +3 -7
- package/src/components/module-info/module-info.module.css +1 -0
- package/src/components/summary/summary.jsx +7 -8
- package/src/components/summary/summary.module.css +1 -1
- package/src/components/summary-item/summary-item.jsx +23 -40
- package/src/components/summary-item/summary-item.module.css +1 -34
- package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
- package/src/constants.js +11 -7
- package/src/css/default.css +14 -3
- package/src/css/variables.css +17 -17
- package/src/hooks/search-params.js +42 -33
- package/src/layout/box/box.module.css +9 -0
- package/src/layout/footer/footer.module.css +1 -1
- package/src/layout/index.js +1 -0
- package/src/layout/separator.jsx +25 -0
- package/src/layout/separator.module.css +5 -0
- package/src/ui/alert/alert.jsx +2 -7
- package/src/ui/dropdown/dropdown.jsx +16 -22
- package/src/ui/dropdown/dropdown.module.css +11 -12
- package/src/ui/empty-set/empty-set.jsx +25 -21
- package/src/ui/empty-set/empty-set.module.css +2 -2
- package/src/ui/filters/filters.jsx +64 -53
- package/src/ui/filters/filters.module.css +3 -3
- package/src/ui/hover-card/hover-card.jsx +73 -0
- package/src/ui/hover-card/hover-card.module.css +29 -0
- package/src/ui/hover-card/index.js +1 -0
- package/src/ui/icon/icon.jsx +11 -9
- package/src/ui/icon/icon.module.css +1 -0
- package/src/ui/index.js +1 -1
- package/src/ui/table/table.jsx +5 -52
- package/src/ui/table/table.module.css +41 -25
- package/src/ui/tag/index.js +1 -0
- package/src/ui/tag/tag.jsx +49 -0
- package/src/ui/tag/tag.module.css +55 -0
- package/src/ui/tooltip/tooltip.jsx +10 -14
- package/src/ui/tooltip/tooltip.module.css +2 -1
- package/lib/assets/icons/alert-circle.svg +0 -1
- package/lib/assets/icons/check-circle.svg +0 -1
- package/lib/components/budget-info/budget-info.js +0 -80
- package/lib/components/budget-info/budget-info.module.css +0 -40
- package/lib/components/budget-info/budget-info.stories.js +0 -44
- package/lib/components/budget-insights/budget-insights.js +0 -200
- package/lib/components/budget-insights/budget-insights.module.css +0 -53
- package/lib/components/budget-insights/budget-insights.stories.js +0 -104
- package/lib/components/budget-insights/index.js +0 -18
- package/lib/ui/popover/popover.js +0 -92
- package/lib/ui/popover/popover.module.css +0 -66
- package/lib/ui/popover/popover.stories.js +0 -26
- package/lib-esm/assets/icons/alert-circle.svg +0 -1
- package/lib-esm/assets/icons/check-circle.svg +0 -1
- package/lib-esm/components/budget-info/budget-info.js +0 -58
- package/lib-esm/components/budget-info/budget-info.module.css +0 -40
- package/lib-esm/components/budget-info/budget-info.stories.js +0 -30
- package/lib-esm/components/budget-info/index.js +0 -1
- package/lib-esm/components/budget-insights/budget-insights.js +0 -148
- package/lib-esm/components/budget-insights/budget-insights.module.css +0 -53
- package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -84
- package/lib-esm/components/budget-insights/index.js +0 -1
- package/lib-esm/ui/popover/index.js +0 -1
- package/lib-esm/ui/popover/popover.js +0 -71
- package/lib-esm/ui/popover/popover.module.css +0 -66
- package/lib-esm/ui/popover/popover.stories.js +0 -14
- package/src/assets/icons/alert-circle.svg +0 -1
- package/src/assets/icons/check-circle.svg +0 -1
- package/src/components/budget-info/budget-info.jsx +0 -65
- package/src/components/budget-info/budget-info.module.css +0 -40
- package/src/components/budget-info/index.js +0 -1
- package/src/components/budget-insights/budget-insights.jsx +0 -157
- package/src/components/budget-insights/budget-insights.module.css +0 -53
- package/src/components/budget-insights/index.js +0 -1
- package/src/ui/popover/index.js +0 -1
- package/src/ui/popover/popover.jsx +0 -79
- package/src/ui/popover/popover.module.css +0 -66
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: flex-start;
|
|
5
|
-
border: none;
|
|
6
|
-
outline: none;
|
|
7
|
-
padding: 0;
|
|
8
|
-
background: none;
|
|
9
|
-
color: inherit;
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
line-height: inherit;
|
|
12
|
-
text-align: inherit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.button:hover,
|
|
16
|
-
.button:active,
|
|
17
|
-
.button:focus {
|
|
18
|
-
color: var(--color-primary);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.button:hover .label {
|
|
22
|
-
text-decoration: underline;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.popover {
|
|
26
|
-
padding: var(--space-small) var(--space-large) var(--space-small) var(--space-small);
|
|
27
|
-
border-radius: var(--radius-small);
|
|
28
|
-
max-width: 360px;
|
|
29
|
-
outline: none;
|
|
30
|
-
filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
|
|
31
|
-
background: var(--color-light);
|
|
32
|
-
font-size: var(--size-small);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.arrow svg {
|
|
36
|
-
display: block;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.arrow :global .fill {
|
|
40
|
-
fill: var(--color-light);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.arrow :global .stroke {
|
|
44
|
-
fill: var(--color-light);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.closeBtn {
|
|
48
|
-
position: absolute;
|
|
49
|
-
right: 0;
|
|
50
|
-
top: 0;
|
|
51
|
-
width: var(--space-large);
|
|
52
|
-
height: var(--space-large);
|
|
53
|
-
padding: var(--space-xxsmall);
|
|
54
|
-
background: none;
|
|
55
|
-
border: none;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
color: var(--color-text-ultra-light);
|
|
58
|
-
transition: var(--transition-out);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.closeBtn:hover,
|
|
62
|
-
.closeBtn:active,
|
|
63
|
-
.closeBtn:focus {
|
|
64
|
-
color: var(--color-text-light);
|
|
65
|
-
transition: var(--transition-in);
|
|
66
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { getWrapperDecorator } from '../../stories';
|
|
4
|
-
import { Popover } from '.';
|
|
5
|
-
const stories = storiesOf('UI/Popover', module);
|
|
6
|
-
stories.addDecorator(getWrapperDecorator({
|
|
7
|
-
padding: '64px'
|
|
8
|
-
}));
|
|
9
|
-
stories.add('default', () => /*#__PURE__*/React.createElement(Popover, {
|
|
10
|
-
label: "Job #100"
|
|
11
|
-
}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."));
|
|
12
|
-
stories.add('with icon', () => /*#__PURE__*/React.createElement(Popover, {
|
|
13
|
-
icon: "help"
|
|
14
|
-
}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { InsightType } from '@bundle-stats/utils';
|
|
5
|
-
import * as budgetsInsightsTransformer from '@bundle-stats/utils/lib-esm/transformers/budgets-insights';
|
|
6
|
-
|
|
7
|
-
import { Icon } from '../../ui/icon';
|
|
8
|
-
import { Tooltip } from '../../ui/tooltip';
|
|
9
|
-
|
|
10
|
-
import css from './budget-info.module.css';
|
|
11
|
-
|
|
12
|
-
const INSIGHT_TYPE_MAP = {
|
|
13
|
-
[InsightType.SUCCESS]: {
|
|
14
|
-
className: css.success,
|
|
15
|
-
glyph: Icon.ICONS.CHECK_CIRCLE,
|
|
16
|
-
},
|
|
17
|
-
[InsightType.ERROR]: {
|
|
18
|
-
className: css.error,
|
|
19
|
-
glyph: Icon.ICONS.ALERT_CIRCLE,
|
|
20
|
-
},
|
|
21
|
-
[InsightType.WARNING]: {
|
|
22
|
-
className: css.warning,
|
|
23
|
-
glyph: Icon.ICONS.WARNING,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const BudgetInfo = ({ className = '', metricId, budgetInsight }) => {
|
|
28
|
-
const budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
|
|
29
|
-
const { className: insightTypeClassName, glyph } = INSIGHT_TYPE_MAP[budgetInsightInfo.type];
|
|
30
|
-
|
|
31
|
-
const rootClassName = cx(css.root, insightTypeClassName, className);
|
|
32
|
-
const { data: messageData } = budgetInsightInfo.message;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Tooltip
|
|
36
|
-
className={rootClassName}
|
|
37
|
-
title={
|
|
38
|
-
<>
|
|
39
|
-
<strong>{messageData.metricLabel}</strong>
|
|
40
|
-
{` value (`}
|
|
41
|
-
<strong>{messageData.currentValue}</strong>
|
|
42
|
-
{`) is ${messageData.diffLabel} `}
|
|
43
|
-
<strong>{messageData.budgetValue}</strong>
|
|
44
|
-
{` budget `}
|
|
45
|
-
</>
|
|
46
|
-
}
|
|
47
|
-
>
|
|
48
|
-
<Icon className={css.icon} glyph={glyph} size="medium" />
|
|
49
|
-
</Tooltip>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
BudgetInfo.propTypes = {
|
|
54
|
-
metricId: PropTypes.string.isRequired,
|
|
55
|
-
budgetInsight: PropTypes.shape({
|
|
56
|
-
currentValue: PropTypes.number,
|
|
57
|
-
budgetValue: PropTypes.number,
|
|
58
|
-
failed: PropTypes.bool,
|
|
59
|
-
}).isRequired,
|
|
60
|
-
className: PropTypes.string,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
BudgetInfo.defaultProps = {
|
|
64
|
-
className: '',
|
|
65
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
line-height: 1em;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/* Budget error */
|
|
7
|
-
.error .icon {
|
|
8
|
-
color: var(--color-danger);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.error .icon:hover,
|
|
12
|
-
.error .icon:focus,
|
|
13
|
-
.error .icon:active
|
|
14
|
-
{
|
|
15
|
-
color: var(--color-danger-light);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Budget success */
|
|
19
|
-
.success .icon {
|
|
20
|
-
color: var(--color-success);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.success .icon:hover,
|
|
24
|
-
.success .icon:focus,
|
|
25
|
-
.success .icon:active
|
|
26
|
-
{
|
|
27
|
-
color: var(--color-success-light);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* Budget warning */
|
|
31
|
-
.warning .icon {
|
|
32
|
-
color: var(--color-warning-dark);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.warning .icon:hover,
|
|
36
|
-
.warning .icon:focus,
|
|
37
|
-
.warning .icon:active
|
|
38
|
-
{
|
|
39
|
-
color: var(--color-warning);
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './budget-info';
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
5
|
-
import * as budgetsInsightsTransformer from '@bundle-stats/utils/lib-esm/transformers/budgets-insights';
|
|
6
|
-
|
|
7
|
-
import { Box } from '../../layout/box';
|
|
8
|
-
import { Stack } from '../../layout/stack';
|
|
9
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
10
|
-
import { Alert } from '../../ui/alert';
|
|
11
|
-
import { Icon } from '../../ui/icon';
|
|
12
|
-
import { ComponentLink } from '../component-link';
|
|
13
|
-
import css from './budget-insights.module.css';
|
|
14
|
-
|
|
15
|
-
const Budget = (props) => {
|
|
16
|
-
const { className, metricId, budgetInsight, CustomLink } = props;
|
|
17
|
-
const componentLinkOptions = METRIC_COMPONENT_LINKS.get(metricId);
|
|
18
|
-
const budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
|
|
19
|
-
const { data: messageData } = budgetInsightInfo.message;
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<CustomLink className={cx(css.budget, className)} {...componentLinkOptions?.link}>
|
|
23
|
-
<strong>{messageData.metricLabel}</strong>
|
|
24
|
-
{` value (`}
|
|
25
|
-
<strong>{messageData.currentValue}</strong>
|
|
26
|
-
{`) is ${messageData.diffLabel} `}
|
|
27
|
-
<strong>{messageData.budgetValue}</strong>
|
|
28
|
-
{` budget `}
|
|
29
|
-
</CustomLink>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
Budget.propTypes = {
|
|
34
|
-
className: PropTypes.string,
|
|
35
|
-
metricId: PropTypes.string.isRequired,
|
|
36
|
-
budgetInsight: PropTypes.shape({
|
|
37
|
-
currentValue: PropTypes.number.isRequired,
|
|
38
|
-
budgetValue: PropTypes.number.isRequired,
|
|
39
|
-
failed: PropTypes.bool.isRequired,
|
|
40
|
-
}).isRequired,
|
|
41
|
-
CustomLink: PropTypes.elementType.isRequired,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
Budget.defaultProps = {
|
|
45
|
-
className: '',
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const BudgetsGroup = (props) => {
|
|
49
|
-
const { className, kind, source, budgets, CustomLink } = props;
|
|
50
|
-
const [showBudgets, setShowBudgets] = useState(false);
|
|
51
|
-
|
|
52
|
-
const isFailed = kind === 'danger';
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<Alert kind={kind} padding="none" className={cx(css.group, css[kind], className)}>
|
|
56
|
-
<Box
|
|
57
|
-
padding={['xsmall', 'small']}
|
|
58
|
-
className={css.groupHeader}
|
|
59
|
-
as="button"
|
|
60
|
-
type="button"
|
|
61
|
-
onClick={() => setShowBudgets(!showBudgets)}
|
|
62
|
-
>
|
|
63
|
-
<FlexStack space="xxsmall" className={css.groupTitle}>
|
|
64
|
-
<Icon
|
|
65
|
-
className={css.groupIcon}
|
|
66
|
-
glyph={isFailed ? Icon.ICONS.ALERT_CIRCLE : Icon.ICONS.CHECK_CIRCLE}
|
|
67
|
-
/>
|
|
68
|
-
<span>
|
|
69
|
-
<strong>{budgets.length}</strong>
|
|
70
|
-
{` budget ${budgets.length > 1 ? 'checks' : 'check'} ${isFailed ? 'failed' : 'passed'}`}
|
|
71
|
-
</span>
|
|
72
|
-
<span className={css.groupTitleToggle}>{showBudgets ? 'hide' : 'show'} all</span>
|
|
73
|
-
</FlexStack>
|
|
74
|
-
</Box>
|
|
75
|
-
|
|
76
|
-
{showBudgets && (
|
|
77
|
-
<Box padding={['xsmall', 'small']} className={css.groupContent}>
|
|
78
|
-
<Stack space="none">
|
|
79
|
-
{budgets.map(([key, budget]) => (
|
|
80
|
-
<Budget
|
|
81
|
-
key={key}
|
|
82
|
-
metricId={`${source}.${key}`}
|
|
83
|
-
budgetInsight={budget}
|
|
84
|
-
CustomLink={CustomLink}
|
|
85
|
-
/>
|
|
86
|
-
))}
|
|
87
|
-
</Stack>
|
|
88
|
-
</Box>
|
|
89
|
-
)}
|
|
90
|
-
</Alert>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
BudgetsGroup.propTypes = {
|
|
95
|
-
className: PropTypes.string,
|
|
96
|
-
kind: PropTypes.oneOf(['success', 'danger']).isRequired,
|
|
97
|
-
source: PropTypes.string.isRequired,
|
|
98
|
-
budgets: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
|
99
|
-
CustomLink: PropTypes.elementType.isRequired,
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
BudgetsGroup.defaultProps = {
|
|
103
|
-
className: '',
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const BudgetInsights = (props) => {
|
|
107
|
-
const { className, source, budgets, CustomLink } = props;
|
|
108
|
-
|
|
109
|
-
const [failedBudgets, passedBudgets] = useMemo(() => {
|
|
110
|
-
const passed = [];
|
|
111
|
-
const failed = [];
|
|
112
|
-
|
|
113
|
-
Object.entries(budgets).forEach(([key, budget]) => {
|
|
114
|
-
if (budget.failed) {
|
|
115
|
-
failed.push([key, budget]);
|
|
116
|
-
} else {
|
|
117
|
-
passed.push([key, budget]);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
return [failed, passed];
|
|
122
|
-
}, [budgets]);
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<Stack className={className} space="xsmall">
|
|
126
|
-
{failedBudgets.length > 0 && (
|
|
127
|
-
<BudgetsGroup
|
|
128
|
-
kind="danger"
|
|
129
|
-
source={source}
|
|
130
|
-
budgets={failedBudgets}
|
|
131
|
-
CustomLink={CustomLink}
|
|
132
|
-
/>
|
|
133
|
-
)}
|
|
134
|
-
|
|
135
|
-
{passedBudgets.length > 0 && (
|
|
136
|
-
<BudgetsGroup
|
|
137
|
-
kind="success"
|
|
138
|
-
source={source}
|
|
139
|
-
budgets={passedBudgets}
|
|
140
|
-
CustomLink={CustomLink}
|
|
141
|
-
/>
|
|
142
|
-
)}
|
|
143
|
-
</Stack>
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
BudgetInsights.propTypes = {
|
|
148
|
-
className: PropTypes.string,
|
|
149
|
-
source: PropTypes.string.isRequired,
|
|
150
|
-
budgets: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
|
151
|
-
CustomLink: PropTypes.elementType,
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
BudgetInsights.defaultProps = {
|
|
155
|
-
className: '',
|
|
156
|
-
CustomLink: ComponentLink,
|
|
157
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
.groupHeader {
|
|
2
|
-
width: 100%;
|
|
3
|
-
border: none;
|
|
4
|
-
background: none;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
color: inherit;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.groupTitle {
|
|
10
|
-
width: 100%;
|
|
11
|
-
align-items: center;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.groupTitle:hover {
|
|
15
|
-
color: var(--color-text-dark);
|
|
16
|
-
text-decoration: underline;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.groupTitleToggle {
|
|
20
|
-
margin: 0 0 0 auto !important;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.danger .groupIcon {
|
|
24
|
-
color: var(--color-danger);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.success .groupIcon {
|
|
28
|
-
color: var(--color-success);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.groupContent {
|
|
32
|
-
padding-top: 0px;
|
|
33
|
-
background: transparent;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.budget {
|
|
37
|
-
display: block;
|
|
38
|
-
color: var(--color-text);
|
|
39
|
-
text-decoration: none;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.budgetLabel,
|
|
43
|
-
.budgetValue {
|
|
44
|
-
color: var(--color-text-dark);
|
|
45
|
-
font-weight: 500;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.budget:hover,
|
|
49
|
-
.budget:focus,
|
|
50
|
-
.budget:active {
|
|
51
|
-
color: var(--color-text);
|
|
52
|
-
text-decoration: underline;
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './budget-insights';
|
package/src/ui/popover/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './popover';
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
usePopoverState,
|
|
6
|
-
Popover as UIPopover,
|
|
7
|
-
PopoverDisclosure as UIPopoverDisclosure,
|
|
8
|
-
PopoverArrow as UIPopoverArrow,
|
|
9
|
-
} from 'reakit/Popover';
|
|
10
|
-
|
|
11
|
-
import { Icon } from '../icon';
|
|
12
|
-
import css from './popover.module.css';
|
|
13
|
-
|
|
14
|
-
export const Popover = ({ className, icon, label, ariaLabel, children }) => {
|
|
15
|
-
const popover = usePopoverState({
|
|
16
|
-
baseId: process.env.NODE_ENV === 'test' && 'id-test',
|
|
17
|
-
gutter: 12,
|
|
18
|
-
modal: true,
|
|
19
|
-
placement: 'top',
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const onCloseButtonClick = useCallback(
|
|
23
|
-
(event) => {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
popover.toggle();
|
|
26
|
-
},
|
|
27
|
-
[popover],
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const onButtonClick = useCallback(
|
|
31
|
-
(event) => {
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
popover.toggle();
|
|
34
|
-
},
|
|
35
|
-
[popover],
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<>
|
|
40
|
-
<UIPopoverDisclosure
|
|
41
|
-
className={cx(css.button, className)}
|
|
42
|
-
{...popover}
|
|
43
|
-
onClick={onButtonClick}
|
|
44
|
-
aria-label={ariaLabel}
|
|
45
|
-
>
|
|
46
|
-
{icon && (typeof icon === 'string' ? <Icon className={css.icon} glyph={icon} /> : icon)}
|
|
47
|
-
{label && <span className={css.label}>{label}</span>}
|
|
48
|
-
</UIPopoverDisclosure>
|
|
49
|
-
<UIPopover className={css.popover} {...popover} tabIndex={0}>
|
|
50
|
-
<UIPopoverArrow className={css.arrow} {...popover} size={16} />
|
|
51
|
-
|
|
52
|
-
{typeof children === 'function' ? children({ popoverToggle: popover.toggle }) : children}
|
|
53
|
-
|
|
54
|
-
<Icon
|
|
55
|
-
glyph="close"
|
|
56
|
-
as="button"
|
|
57
|
-
type="button"
|
|
58
|
-
className={css.closeBtn}
|
|
59
|
-
onClick={onCloseButtonClick}
|
|
60
|
-
/>
|
|
61
|
-
</UIPopover>
|
|
62
|
-
</>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
Popover.propTypes = {
|
|
67
|
-
className: PropTypes.string,
|
|
68
|
-
label: PropTypes.element,
|
|
69
|
-
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
70
|
-
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,
|
|
71
|
-
ariaLabel: PropTypes.string,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
Popover.defaultProps = {
|
|
75
|
-
className: '',
|
|
76
|
-
icon: '',
|
|
77
|
-
label: '',
|
|
78
|
-
ariaLabel: 'View more info',
|
|
79
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: flex-start;
|
|
5
|
-
border: none;
|
|
6
|
-
outline: none;
|
|
7
|
-
padding: 0;
|
|
8
|
-
background: none;
|
|
9
|
-
color: inherit;
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
line-height: inherit;
|
|
12
|
-
text-align: inherit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.button:hover,
|
|
16
|
-
.button:active,
|
|
17
|
-
.button:focus {
|
|
18
|
-
color: var(--color-primary);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.button:hover .label {
|
|
22
|
-
text-decoration: underline;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.popover {
|
|
26
|
-
padding: var(--space-small) var(--space-large) var(--space-small) var(--space-small);
|
|
27
|
-
border-radius: var(--radius-small);
|
|
28
|
-
max-width: 360px;
|
|
29
|
-
outline: none;
|
|
30
|
-
filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
|
|
31
|
-
background: var(--color-light);
|
|
32
|
-
font-size: var(--size-small);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.arrow svg {
|
|
36
|
-
display: block;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.arrow :global .fill {
|
|
40
|
-
fill: var(--color-light);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.arrow :global .stroke {
|
|
44
|
-
fill: var(--color-light);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.closeBtn {
|
|
48
|
-
position: absolute;
|
|
49
|
-
right: 0;
|
|
50
|
-
top: 0;
|
|
51
|
-
width: var(--space-large);
|
|
52
|
-
height: var(--space-large);
|
|
53
|
-
padding: var(--space-xxsmall);
|
|
54
|
-
background: none;
|
|
55
|
-
border: none;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
color: var(--color-text-ultra-light);
|
|
58
|
-
transition: var(--transition-out);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.closeBtn:hover,
|
|
62
|
-
.closeBtn:active,
|
|
63
|
-
.closeBtn:focus {
|
|
64
|
-
color: var(--color-text-light);
|
|
65
|
-
transition: var(--transition-in);
|
|
66
|
-
}
|