@ultraviolet/plus 0.5.0 → 0.5.1
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/index.d.ts +261 -1
- package/dist/src/components/EstimateCost/Components/CustomUnitInput.js +48 -0
- package/dist/src/components/EstimateCost/Components/Item.js +327 -0
- package/dist/src/components/EstimateCost/Components/LineThrough.js +15 -0
- package/dist/src/components/EstimateCost/Components/NumberInput.js +41 -0
- package/dist/src/components/EstimateCost/Components/Region.js +50 -0
- package/dist/src/components/EstimateCost/Components/Regular.js +44 -0
- package/dist/src/components/EstimateCost/Components/Strong.js +37 -0
- package/dist/src/components/EstimateCost/Components/Unit.js +61 -0
- package/dist/src/components/EstimateCost/Components/UnitInput.js +122 -0
- package/dist/src/components/EstimateCost/Components/Zone.js +50 -0
- package/dist/src/components/EstimateCost/EstimateCost.js +126 -0
- package/dist/src/components/EstimateCost/EstimateCostContent.js +299 -0
- package/dist/src/components/EstimateCost/EstimateCostProvider.js +39 -0
- package/dist/src/components/EstimateCost/OverlayComponent.js +139 -0
- package/dist/src/components/EstimateCost/OverlayContext.js +19 -0
- package/dist/src/components/EstimateCost/componentStyle.js +196 -0
- package/dist/src/components/EstimateCost/constants.js +31 -0
- package/dist/src/components/EstimateCost/helper.js +23 -0
- package/dist/src/components/EstimateCost/locales/en.js +23 -0
- package/dist/src/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const APPROXIMATE_HOURS_IN_MONTH = 730;
|
|
2
|
+
|
|
3
|
+
// As we base ou calculation on hours we need to multiply them by a multiplier
|
|
4
|
+
// 1 month = 730 hours
|
|
5
|
+
const multiplier = {
|
|
6
|
+
seconds: 1 / 60 / 60,
|
|
7
|
+
minutes: 1 / 60,
|
|
8
|
+
hours: 1,
|
|
9
|
+
days: 24,
|
|
10
|
+
months: APPROXIMATE_HOURS_IN_MONTH
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// This is used to tell how many decimals depending on time unit
|
|
14
|
+
// "hours": 5 === 5 decimals on hour unit
|
|
15
|
+
const maximumFractionDigits = {
|
|
16
|
+
seconds: 10,
|
|
17
|
+
minutes: 8,
|
|
18
|
+
hours: 5,
|
|
19
|
+
days: 3,
|
|
20
|
+
months: 2
|
|
21
|
+
};
|
|
22
|
+
const maximumFractionDigitsLong = {
|
|
23
|
+
seconds: 12,
|
|
24
|
+
minutes: 10,
|
|
25
|
+
hours: 8,
|
|
26
|
+
days: 4,
|
|
27
|
+
months: 2
|
|
28
|
+
};
|
|
29
|
+
const MAX_CELL_WIDTH = '537px';
|
|
30
|
+
|
|
31
|
+
export { APPROXIMATE_HOURS_IN_MONTH, MAX_CELL_WIDTH, maximumFractionDigits, maximumFractionDigitsLong, multiplier };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { multiplier } from './constants.js';
|
|
2
|
+
|
|
3
|
+
// time unit = hours, days, months
|
|
4
|
+
// timeAmount = number of hours / days / months
|
|
5
|
+
const calculatePrice = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
price,
|
|
8
|
+
amount,
|
|
9
|
+
amountFree = 0,
|
|
10
|
+
timeUnit,
|
|
11
|
+
timeAmount,
|
|
12
|
+
discount = 0
|
|
13
|
+
} = _ref;
|
|
14
|
+
const value = (price - price * discount) * (timeAmount * multiplier[`${timeUnit}`]) * Math.max(amount - amountFree, 0);
|
|
15
|
+
|
|
16
|
+
// Avoid having negative price in any cases
|
|
17
|
+
if (value < 0) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { calculatePrice };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var EstimateCostLocales = {
|
|
2
|
+
'estimate.cost.description': 'This summary provides a cost estimation based on your configuration, the amount of time you expect to use the resource for, and the scale of your expected usage. For the purposes of this calculation, we consider that 1 month equals to 730 hours.',
|
|
3
|
+
'estimate.cost.label': 'Estimated cost',
|
|
4
|
+
'estimate.cost.beta.free': 'Free During Beta',
|
|
5
|
+
'estimate.cost.beta.discount': '% off during Beta',
|
|
6
|
+
'estimate.cost.beta.badge': 'Beta Version',
|
|
7
|
+
'estimate.cost.units.seconds.label': 'Second(s)',
|
|
8
|
+
'estimate.cost.units.minutes.label': 'Minute(s)',
|
|
9
|
+
'estimate.cost.units.hours.label': 'Hour(s)',
|
|
10
|
+
'estimate.cost.units.days.label': 'Day(s)',
|
|
11
|
+
'estimate.cost.units.months.label': 'Month(s)',
|
|
12
|
+
'estimate.cost.units.years.label': 'Year(s)',
|
|
13
|
+
'estimate.cost.fees.oneTime.title': 'One time fees',
|
|
14
|
+
'estimate.cost.fees.monthly.title': 'Each month',
|
|
15
|
+
'estimate.cost.fees.commitment': 'Commitment Fees',
|
|
16
|
+
'estimate.cost.units.gb.label': 'GB',
|
|
17
|
+
'estimate.cost.notDefined': 'Not defined',
|
|
18
|
+
'estimate.cost.submit.label': 'Create',
|
|
19
|
+
'estimate.cost.region.label': 'Region',
|
|
20
|
+
'estimate.cost.az.label': 'Availability Zone'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { EstimateCostLocales as default };
|
package/dist/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ContentCard } from './components/ContentCard/index.js';
|
|
2
2
|
export { ContentCardGroup } from './components/ContentCardGroup/index.js';
|
|
3
3
|
export { CodeEditor } from './components/CodeEditor/CodeEditor.js';
|
|
4
|
+
export { EstimateCost } from './components/EstimateCost/EstimateCost.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/plus",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Ultraviolet Plus",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-flatten-children": "1.1.2",
|
|
57
57
|
"react-intersection-observer": "9.5.3",
|
|
58
58
|
"@ultraviolet/themes": "1.5.0",
|
|
59
|
-
"@ultraviolet/ui": "1.27.
|
|
59
|
+
"@ultraviolet/ui": "1.27.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "rollup -c ../../rollup.config.mjs"
|