@instructure/ui-metric 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +29 -280
  2. package/es/Metric/{index.js → v1/index.js} +1 -1
  3. package/es/Metric/v2/index.js +71 -0
  4. package/es/Metric/v2/props.js +26 -0
  5. package/es/Metric/v2/styles.js +65 -0
  6. package/es/MetricGroup/{index.js → v1/index.js} +1 -1
  7. package/es/MetricGroup/v2/index.js +60 -0
  8. package/es/{index.js → MetricGroup/v2/props.js} +3 -2
  9. package/es/MetricGroup/v2/styles.js +44 -0
  10. package/es/MetricGroup/v2/theme.js +39 -0
  11. package/es/exports/a.js +25 -0
  12. package/es/exports/b.js +25 -0
  13. package/lib/Metric/{index.js → v1/index.js} +1 -1
  14. package/lib/Metric/v2/index.js +78 -0
  15. package/lib/Metric/v2/props.js +31 -0
  16. package/lib/Metric/v2/styles.js +71 -0
  17. package/lib/MetricGroup/{index.js → v1/index.js} +1 -1
  18. package/lib/MetricGroup/v2/index.js +66 -0
  19. package/lib/MetricGroup/v2/props.js +31 -0
  20. package/lib/MetricGroup/v2/styles.js +50 -0
  21. package/lib/MetricGroup/v2/theme.js +45 -0
  22. package/lib/{index.js → exports/a.js} +4 -4
  23. package/lib/exports/b.js +19 -0
  24. package/package.json +38 -16
  25. package/src/Metric/{index.tsx → v1/index.tsx} +1 -1
  26. package/src/Metric/v2/README.md +30 -0
  27. package/src/Metric/v2/index.tsx +79 -0
  28. package/src/Metric/v2/props.ts +63 -0
  29. package/src/Metric/v2/styles.ts +77 -0
  30. package/src/MetricGroup/{index.tsx → v1/index.tsx} +1 -1
  31. package/src/MetricGroup/v2/README.md +16 -0
  32. package/src/MetricGroup/v2/index.tsx +70 -0
  33. package/src/MetricGroup/v2/props.ts +46 -0
  34. package/src/MetricGroup/v2/styles.ts +47 -0
  35. package/src/MetricGroup/v2/theme.ts +45 -0
  36. package/src/{index.ts → exports/a.ts} +4 -4
  37. package/src/exports/b.ts +29 -0
  38. package/tsconfig.build.tsbuildinfo +1 -1
  39. package/types/Metric/v1/index.d.ts.map +1 -0
  40. package/types/Metric/v1/props.d.ts.map +1 -0
  41. package/types/Metric/v1/styles.d.ts.map +1 -0
  42. package/types/Metric/v1/theme.d.ts.map +1 -0
  43. package/types/Metric/v2/index.d.ts +33 -0
  44. package/types/Metric/v2/index.d.ts.map +1 -0
  45. package/types/Metric/v2/props.d.ts +23 -0
  46. package/types/Metric/v2/props.d.ts.map +1 -0
  47. package/types/Metric/v2/styles.d.ts +17 -0
  48. package/types/Metric/v2/styles.d.ts.map +1 -0
  49. package/types/MetricGroup/v1/index.d.ts.map +1 -0
  50. package/types/MetricGroup/v1/props.d.ts.map +1 -0
  51. package/types/MetricGroup/v1/styles.d.ts.map +1 -0
  52. package/types/MetricGroup/v1/theme.d.ts.map +1 -0
  53. package/types/MetricGroup/v2/index.d.ts +15 -0
  54. package/types/MetricGroup/v2/index.d.ts.map +1 -0
  55. package/types/MetricGroup/v2/props.d.ts +16 -0
  56. package/types/MetricGroup/v2/props.d.ts.map +1 -0
  57. package/types/MetricGroup/v2/styles.d.ts +11 -0
  58. package/types/MetricGroup/v2/styles.d.ts.map +1 -0
  59. package/types/MetricGroup/v2/theme.d.ts +10 -0
  60. package/types/MetricGroup/v2/theme.d.ts.map +1 -0
  61. package/types/exports/a.d.ts +5 -0
  62. package/types/exports/a.d.ts.map +1 -0
  63. package/types/exports/b.d.ts +5 -0
  64. package/types/exports/b.d.ts.map +1 -0
  65. package/types/Metric/index.d.ts.map +0 -1
  66. package/types/Metric/props.d.ts.map +0 -1
  67. package/types/Metric/styles.d.ts.map +0 -1
  68. package/types/Metric/theme.d.ts.map +0 -1
  69. package/types/MetricGroup/index.d.ts.map +0 -1
  70. package/types/MetricGroup/props.d.ts.map +0 -1
  71. package/types/MetricGroup/styles.d.ts.map +0 -1
  72. package/types/MetricGroup/theme.d.ts.map +0 -1
  73. package/types/index.d.ts +0 -5
  74. package/types/index.d.ts.map +0 -1
  75. /package/es/Metric/{props.js → v1/props.js} +0 -0
  76. /package/es/Metric/{styles.js → v1/styles.js} +0 -0
  77. /package/es/Metric/{theme.js → v1/theme.js} +0 -0
  78. /package/es/MetricGroup/{props.js → v1/props.js} +0 -0
  79. /package/es/MetricGroup/{styles.js → v1/styles.js} +0 -0
  80. /package/es/MetricGroup/{theme.js → v1/theme.js} +0 -0
  81. /package/lib/Metric/{props.js → v1/props.js} +0 -0
  82. /package/lib/Metric/{styles.js → v1/styles.js} +0 -0
  83. /package/lib/Metric/{theme.js → v1/theme.js} +0 -0
  84. /package/lib/MetricGroup/{props.js → v1/props.js} +0 -0
  85. /package/lib/MetricGroup/{styles.js → v1/styles.js} +0 -0
  86. /package/lib/MetricGroup/{theme.js → v1/theme.js} +0 -0
  87. /package/src/Metric/{README.md → v1/README.md} +0 -0
  88. /package/src/Metric/{props.ts → v1/props.ts} +0 -0
  89. /package/src/Metric/{styles.ts → v1/styles.ts} +0 -0
  90. /package/src/Metric/{theme.ts → v1/theme.ts} +0 -0
  91. /package/src/MetricGroup/{README.md → v1/README.md} +0 -0
  92. /package/src/MetricGroup/{props.ts → v1/props.ts} +0 -0
  93. /package/src/MetricGroup/{styles.ts → v1/styles.ts} +0 -0
  94. /package/src/MetricGroup/{theme.ts → v1/theme.ts} +0 -0
  95. /package/types/Metric/{index.d.ts → v1/index.d.ts} +0 -0
  96. /package/types/Metric/{props.d.ts → v1/props.d.ts} +0 -0
  97. /package/types/Metric/{styles.d.ts → v1/styles.d.ts} +0 -0
  98. /package/types/Metric/{theme.d.ts → v1/theme.d.ts} +0 -0
  99. /package/types/MetricGroup/{index.d.ts → v1/index.d.ts} +0 -0
  100. /package/types/MetricGroup/{props.d.ts → v1/props.d.ts} +0 -0
  101. /package/types/MetricGroup/{styles.d.ts → v1/styles.d.ts} +0 -0
  102. /package/types/MetricGroup/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ /**
32
+ * Generates the theme object for the component from the theme and provided additional information
33
+ * @param {Object} theme The actual theme object.
34
+ * @return {Object} The final theme object with the overrides and component variables
35
+ */
36
+ const generateComponentTheme = theme => {
37
+ const typography = theme.typography;
38
+ const componentVariables = {
39
+ lineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeightCondensed
40
+ };
41
+ return {
42
+ ...componentVariables
43
+ };
44
+ };
45
+ var _default = exports.default = generateComponentTheme;
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "Metric", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Metric.Metric;
9
+ return _v.Metric;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "MetricGroup", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _MetricGroup.MetricGroup;
15
+ return _v2.MetricGroup;
16
16
  }
17
17
  });
18
- var _Metric = require("./Metric");
19
- var _MetricGroup = require("./MetricGroup");
18
+ var _v = require("../Metric/v1");
19
+ var _v2 = require("../MetricGroup/v1");
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Metric", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.Metric;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "MetricGroup", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _v2.MetricGroup;
16
+ }
17
+ });
18
+ var _v = require("../Metric/v2");
19
+ var _v2 = require("../MetricGroup/v2");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-metric",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "A UI component for displaying Metrics",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,19 +15,19 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.6.0",
19
- "@instructure/emotion": "11.6.0",
20
- "@instructure/shared-types": "11.6.0",
21
- "@instructure/ui-react-utils": "11.6.0"
18
+ "@instructure/console": "11.6.1-snapshot-129",
19
+ "@instructure/emotion": "11.6.1-snapshot-129",
20
+ "@instructure/shared-types": "11.6.1-snapshot-129",
21
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@testing-library/jest-dom": "^6.6.3",
25
25
  "@testing-library/react": "15.0.7",
26
26
  "vitest": "^3.2.2",
27
- "@instructure/ui-axe-check": "11.6.0",
28
- "@instructure/ui-babel-preset": "11.6.0",
29
- "@instructure/ui-color-utils": "11.6.0",
30
- "@instructure/ui-themes": "11.6.0"
27
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129",
28
+ "@instructure/ui-color-utils": "11.6.1-snapshot-129",
29
+ "@instructure/ui-themes": "11.6.1-snapshot-129",
30
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=18 <=19"
@@ -37,17 +37,39 @@
37
37
  },
38
38
  "sideEffects": false,
39
39
  "exports": {
40
- ".": {
41
- "types": "./types/index.d.ts",
42
- "import": "./es/index.js",
43
- "require": "./lib/index.js",
44
- "default": "./es/index.js"
45
- },
46
40
  "./lib/*": "./lib/*",
47
41
  "./es/*": "./es/*",
48
42
  "./types/*": "./types/*",
49
43
  "./package.json": "./package.json",
50
- "./src/*": "./src/*"
44
+ "./src/*": "./src/*",
45
+ ".": {
46
+ "src": "./src/exports/a.ts",
47
+ "types": "./types/exports/a.d.ts",
48
+ "import": "./es/exports/a.js",
49
+ "require": "./lib/exports/a.js",
50
+ "default": "./es/exports/a.js"
51
+ },
52
+ "./v11_6": {
53
+ "src": "./src/exports/a.ts",
54
+ "types": "./types/exports/a.d.ts",
55
+ "import": "./es/exports/a.js",
56
+ "require": "./lib/exports/a.js",
57
+ "default": "./es/exports/a.js"
58
+ },
59
+ "./v11_7": {
60
+ "src": "./src/exports/b.ts",
61
+ "types": "./types/exports/b.d.ts",
62
+ "import": "./es/exports/b.js",
63
+ "require": "./lib/exports/b.js",
64
+ "default": "./es/exports/b.js"
65
+ },
66
+ "./latest": {
67
+ "src": "./src/exports/b.ts",
68
+ "types": "./types/exports/b.d.ts",
69
+ "import": "./es/exports/b.js",
70
+ "require": "./lib/exports/b.js",
71
+ "default": "./es/exports/b.js"
72
+ }
51
73
  },
52
74
  "scripts": {
53
75
  "lint": "ui-scripts lint",
@@ -24,7 +24,7 @@
24
24
 
25
25
  import { Component } from 'react'
26
26
 
27
- import { withStyle } from '@instructure/emotion'
27
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
28
28
  import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
29
29
 
30
30
  import generateStyle from './styles'
@@ -0,0 +1,30 @@
1
+ ---
2
+ describes: Metric
3
+ ---
4
+
5
+ The Metric component displays 'value' and 'label'. The default alignment is 'center'.
6
+
7
+ ```javascript
8
+ ---
9
+ type: example
10
+ ---
11
+ <Metric textAlign="start" renderLabel="Grade" renderValue="80%" />
12
+ ```
13
+
14
+ The Metric component can be set to align 'start'.
15
+
16
+ ```javascript
17
+ ---
18
+ type: example
19
+ ---
20
+ <Metric renderLabel="Grade" renderValue="80%" />
21
+ ```
22
+
23
+ The Metric component can be set to align 'end'.
24
+
25
+ ```javascript
26
+ ---
27
+ type: example
28
+ ---
29
+ <Metric textAlign="end" renderLabel="Grade" renderValue="80%" />
30
+ ```
@@ -0,0 +1,79 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { forwardRef } from 'react'
26
+
27
+ import { useStyle } from '@instructure/emotion'
28
+ import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
29
+
30
+ import generateStyle from './styles'
31
+
32
+ import type { MetricProps } from './props'
33
+
34
+ /**
35
+ ---
36
+ category: components
37
+ ---
38
+ **/
39
+ const Metric = forwardRef<HTMLDivElement, MetricProps>((props, ref) => {
40
+ const {
41
+ textAlign = 'center',
42
+ renderLabel,
43
+ renderValue,
44
+ isGroupChild = false,
45
+ themeOverride
46
+ } = props
47
+
48
+ const styles = useStyle({
49
+ generateStyle,
50
+ themeOverride,
51
+ params: {
52
+ textAlign
53
+ },
54
+ componentId: 'Metric',
55
+ displayName: 'Metric'
56
+ })
57
+
58
+ return (
59
+ <div
60
+ {...passthroughProps(props)}
61
+ role={isGroupChild ? 'row' : undefined}
62
+ css={styles?.metric}
63
+ ref={ref}
64
+ data-cid="Metric"
65
+ >
66
+ <div role={isGroupChild ? 'rowheader' : undefined} css={styles?.label}>
67
+ {callRenderProp(renderLabel)}
68
+ </div>
69
+ <div role={isGroupChild ? 'gridcell' : undefined} css={styles?.value}>
70
+ {callRenderProp(renderValue)}
71
+ </div>
72
+ </div>
73
+ )
74
+ })
75
+
76
+ Metric.displayName = 'Metric'
77
+
78
+ export default Metric
79
+ export { Metric }
@@ -0,0 +1,63 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type {
26
+ MetricTheme,
27
+ OtherHTMLAttributes,
28
+ Renderable
29
+ } from '@instructure/shared-types'
30
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
31
+ import { ThemeOverrideValue } from '@instructure/emotion'
32
+
33
+ type MetricOwnProps = {
34
+ textAlign?: 'start' | 'center' | 'end'
35
+ renderLabel?: Renderable
36
+ renderValue?: Renderable
37
+ /**
38
+ * Set to true when a child of MetricGroup so the appropriate
39
+ * aria labels get set
40
+ */
41
+ isGroupChild?: boolean
42
+ }
43
+
44
+ type PropKeys = keyof MetricOwnProps
45
+
46
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
47
+
48
+ type MetricProps = MetricOwnProps &
49
+ WithStyleProps<MetricTheme, MetricStyle> &
50
+ OtherHTMLAttributes<MetricOwnProps> & {
51
+ themeOverride?: ThemeOverrideValue
52
+ }
53
+
54
+ type MetricStyle = ComponentStyle<'metric' | 'label' | 'value'>
55
+ const allowedProps: AllowedPropKeys = [
56
+ 'textAlign',
57
+ 'renderLabel',
58
+ 'renderValue',
59
+ 'isGroupChild'
60
+ ]
61
+
62
+ export type { MetricProps, MetricStyle }
63
+ export { allowedProps }
@@ -0,0 +1,77 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { MetricProps, MetricStyle } from './props'
26
+ import { NewComponentTypes } from '@instructure/ui-themes'
27
+
28
+ type StyleParams = {
29
+ textAlign: MetricProps['textAlign']
30
+ }
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param {Object} componentTheme The theme variable object.
38
+ * @param {Object} params the props of the component, the style is applied to
39
+ * @return {Object} The final style object, which will be used in the component
40
+ */
41
+ const generateStyle = (
42
+ componentTheme: NewComponentTypes['Metric'],
43
+ params: StyleParams
44
+ ): MetricStyle => {
45
+ const { textAlign } = params
46
+
47
+ return {
48
+ metric: {
49
+ label: 'metric',
50
+ display: 'flex',
51
+ flexDirection: 'column-reverse',
52
+ boxSizing: 'border-box',
53
+ paddingLeft: componentTheme.paddingHorizontal,
54
+ paddingRight: componentTheme.paddingHorizontal,
55
+ textAlign,
56
+ gap: componentTheme.gapTexts
57
+ },
58
+ label: {
59
+ label: 'metric__label',
60
+ fontWeight: componentTheme.labelFontWeight,
61
+ fontSize: componentTheme.labelFontSize,
62
+ color: componentTheme.labelColor,
63
+ fontFamily: componentTheme.labelFontFamily,
64
+ lineHeight: componentTheme.labelLineHeight
65
+ },
66
+ value: {
67
+ label: 'metric__value',
68
+ fontWeight: componentTheme.valueFontWeight,
69
+ fontSize: componentTheme.valueFontSize,
70
+ color: componentTheme.valueColor,
71
+ fontFamily: componentTheme.valueFontFamily,
72
+ lineHeight: componentTheme.valueLineHeight
73
+ }
74
+ }
75
+ }
76
+
77
+ export default generateStyle
@@ -24,7 +24,7 @@
24
24
 
25
25
  import { Children, Component, ReactElement } from 'react'
26
26
 
27
- import { withStyle } from '@instructure/emotion'
27
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
28
28
  import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils'
29
29
 
30
30
  import generateStyle from './styles'
@@ -0,0 +1,16 @@
1
+ ---
2
+ describes: MetricGroup
3
+ ---
4
+
5
+ A `MetricGroup` component displays multiple `Metric` (value + label) in rows.
6
+
7
+ ```javascript
8
+ ---
9
+ type: example
10
+ ---
11
+ <MetricGroup>
12
+ <Metric renderLabel="Grade" renderValue="80%" />
13
+ <Metric renderLabel="Late" renderValue="4" />
14
+ <Metric renderLabel="Missing" renderValue="2" />
15
+ </MetricGroup>
16
+ ```
@@ -0,0 +1,70 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Children, forwardRef, ReactElement } from 'react'
26
+
27
+ import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils'
28
+
29
+ import generateStyle from './styles'
30
+
31
+ import type { MetricGroupProps } from './props'
32
+
33
+ /**
34
+ ---
35
+ category: components
36
+ ---
37
+ **/
38
+ const MetricGroup = forwardRef<HTMLDivElement, MetricGroupProps>(
39
+ (props, ref) => {
40
+ const { children = null, ...rest } = props
41
+
42
+ const styles = generateStyle()
43
+
44
+ const renderChildren = () => {
45
+ return Children.map(children, (child) => {
46
+ return safeCloneElement(child as ReactElement, {
47
+ isGroupChild: true
48
+ })
49
+ })
50
+ }
51
+
52
+ return (
53
+ <div
54
+ {...passthroughProps(rest)}
55
+ css={styles?.metricGroup}
56
+ role="grid"
57
+ aria-readonly="true"
58
+ ref={ref}
59
+ data-cid="MetricGroup"
60
+ >
61
+ {renderChildren()}
62
+ </div>
63
+ )
64
+ }
65
+ )
66
+
67
+ MetricGroup.displayName = 'MetricGroup'
68
+
69
+ export default MetricGroup
70
+ export { MetricGroup }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { OtherHTMLAttributes } from '@instructure/shared-types'
26
+ import type { ComponentStyle } from '@instructure/emotion'
27
+
28
+ type MetricGroupOwnProps = {
29
+ /**
30
+ * children of type `Metric`
31
+ */
32
+ children?: React.ReactNode // TODO: oneOf([Metric])
33
+ }
34
+
35
+ type PropKeys = keyof MetricGroupOwnProps
36
+
37
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
38
+
39
+ type MetricGroupProps = MetricGroupOwnProps &
40
+ OtherHTMLAttributes<MetricGroupOwnProps>
41
+
42
+ type MetricGroupStyle = ComponentStyle<'metricGroup'>
43
+ const allowedProps: AllowedPropKeys = ['children']
44
+
45
+ export type { MetricGroupProps, MetricGroupStyle }
46
+ export { allowedProps }
@@ -0,0 +1,47 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { MetricGroupStyle } from './props'
26
+
27
+ /**
28
+ * ---
29
+ * private: true
30
+ * ---
31
+ * Generates the style object from the theme and provided additional information
32
+ * @return {Object} The final style object, which will be used in the component
33
+ */
34
+ const generateStyle = (): MetricGroupStyle => {
35
+ return {
36
+ metricGroup: {
37
+ label: 'metricGroup',
38
+ boxSizing: 'border-box',
39
+ display: 'flex',
40
+ flexWrap: 'wrap',
41
+ alignItems: 'flex-start',
42
+ justifyContent: 'space-around'
43
+ }
44
+ }
45
+ }
46
+
47
+ export default generateStyle
@@ -0,0 +1,45 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { Theme } from '@instructure/ui-themes'
26
+ import { MetricGroupTheme } from '@instructure/shared-types'
27
+
28
+ /**
29
+ * Generates the theme object for the component from the theme and provided additional information
30
+ * @param {Object} theme The actual theme object.
31
+ * @return {Object} The final theme object with the overrides and component variables
32
+ */
33
+ const generateComponentTheme = (theme: Theme): MetricGroupTheme => {
34
+ const { typography } = theme
35
+
36
+ const componentVariables: MetricGroupTheme = {
37
+ lineHeight: typography?.lineHeightCondensed
38
+ }
39
+
40
+ return {
41
+ ...componentVariables
42
+ }
43
+ }
44
+
45
+ export default generateComponentTheme