@instructure/ui-instructure 10.21.1-snapshot-11
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 +11 -0
- package/README.md +30 -0
- package/es/AiInformation/index.js +179 -0
- package/es/AiInformation/props.js +26 -0
- package/es/AiInformation/styles.js +85 -0
- package/es/AiInformation/theme.js +52 -0
- package/es/DataPermissionLevels/index.js +144 -0
- package/es/DataPermissionLevels/props.js +26 -0
- package/es/DataPermissionLevels/styles.js +96 -0
- package/es/DataPermissionLevels/theme.js +54 -0
- package/es/NutritionFacts/index.js +152 -0
- package/es/NutritionFacts/props.js +26 -0
- package/es/NutritionFacts/styles.js +72 -0
- package/es/NutritionFacts/theme.js +49 -0
- package/es/index.js +26 -0
- package/lib/AiInformation/index.js +185 -0
- package/lib/AiInformation/props.js +31 -0
- package/lib/AiInformation/styles.js +91 -0
- package/lib/AiInformation/theme.js +58 -0
- package/lib/DataPermissionLevels/index.js +151 -0
- package/lib/DataPermissionLevels/props.js +31 -0
- package/lib/DataPermissionLevels/styles.js +102 -0
- package/lib/DataPermissionLevels/theme.js +60 -0
- package/lib/NutritionFacts/index.js +159 -0
- package/lib/NutritionFacts/props.js +31 -0
- package/lib/NutritionFacts/styles.js +78 -0
- package/lib/NutritionFacts/theme.js +55 -0
- package/lib/index.js +26 -0
- package/lib/package.json +1 -0
- package/package.json +54 -0
- package/src/AiInformation/README.md +298 -0
- package/src/AiInformation/index.tsx +182 -0
- package/src/AiInformation/props.ts +163 -0
- package/src/AiInformation/styles.ts +92 -0
- package/src/AiInformation/theme.ts +58 -0
- package/src/DataPermissionLevels/README.md +47 -0
- package/src/DataPermissionLevels/index.tsx +137 -0
- package/src/DataPermissionLevels/props.ts +109 -0
- package/src/DataPermissionLevels/styles.ts +106 -0
- package/src/DataPermissionLevels/theme.ts +59 -0
- package/src/NutritionFacts/README.md +99 -0
- package/src/NutritionFacts/index.tsx +147 -0
- package/src/NutritionFacts/props.ts +106 -0
- package/src/NutritionFacts/styles.ts +79 -0
- package/src/NutritionFacts/theme.ts +52 -0
- package/src/index.ts +29 -0
- package/tsconfig.build.json +50 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/AiInformation/index.d.ts +10 -0
- package/types/AiInformation/index.d.ts.map +1 -0
- package/types/AiInformation/props.d.ts +92 -0
- package/types/AiInformation/props.d.ts.map +1 -0
- package/types/AiInformation/styles.d.ts +14 -0
- package/types/AiInformation/styles.d.ts.map +1 -0
- package/types/AiInformation/theme.d.ts +10 -0
- package/types/AiInformation/theme.d.ts.map +1 -0
- package/types/DataPermissionLevels/index.d.ts +10 -0
- package/types/DataPermissionLevels/index.d.ts.map +1 -0
- package/types/DataPermissionLevels/props.d.ts +55 -0
- package/types/DataPermissionLevels/props.d.ts.map +1 -0
- package/types/DataPermissionLevels/styles.d.ts +14 -0
- package/types/DataPermissionLevels/styles.d.ts.map +1 -0
- package/types/DataPermissionLevels/theme.d.ts +10 -0
- package/types/DataPermissionLevels/theme.d.ts.map +1 -0
- package/types/NutritionFacts/index.d.ts +10 -0
- package/types/NutritionFacts/index.d.ts.map +1 -0
- package/types/NutritionFacts/props.d.ts +55 -0
- package/types/NutritionFacts/props.d.ts.map +1 -0
- package/types/NutritionFacts/styles.d.ts +14 -0
- package/types/NutritionFacts/styles.d.ts.map +1 -0
- package/types/NutritionFacts/theme.d.ts +10 -0
- package/types/NutritionFacts/theme.d.ts.map +1 -0
- package/types/index.d.ts +7 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,109 @@
|
|
|
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 { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
26
|
+
import type {
|
|
27
|
+
DataPermissionLevelsTheme,
|
|
28
|
+
OtherHTMLAttributes
|
|
29
|
+
} from '@instructure/shared-types'
|
|
30
|
+
|
|
31
|
+
type DataPermissionLevelsOwnProps = {
|
|
32
|
+
/**
|
|
33
|
+
* i18n text for the label of the modal
|
|
34
|
+
*/
|
|
35
|
+
modalLabel: string
|
|
36
|
+
/**
|
|
37
|
+
* i18n text for the dataPermissionLevels title
|
|
38
|
+
*/
|
|
39
|
+
title: string
|
|
40
|
+
/**
|
|
41
|
+
* i18n text for the "model and data" heading of the dataPermissionLevels
|
|
42
|
+
*/
|
|
43
|
+
data: {
|
|
44
|
+
level: string
|
|
45
|
+
title: string
|
|
46
|
+
description: string
|
|
47
|
+
highlighted?: boolean
|
|
48
|
+
}[]
|
|
49
|
+
/**
|
|
50
|
+
* i18n text for the close button
|
|
51
|
+
*/
|
|
52
|
+
closeButtonText: string
|
|
53
|
+
/**
|
|
54
|
+
* i18n text for the close iconButton
|
|
55
|
+
*/
|
|
56
|
+
closeIconButtonScreenReaderLabel: string
|
|
57
|
+
/**
|
|
58
|
+
* i18n text for the "current feature" text
|
|
59
|
+
*/
|
|
60
|
+
currentFeatureText: string
|
|
61
|
+
/**
|
|
62
|
+
* i18n text for the current feature
|
|
63
|
+
*/
|
|
64
|
+
currentFeature: string
|
|
65
|
+
/**
|
|
66
|
+
* i18n text for the trigger
|
|
67
|
+
*/
|
|
68
|
+
triggerText: string
|
|
69
|
+
/**
|
|
70
|
+
* sets the modal size to 'fullscreen'. Used for small viewports
|
|
71
|
+
*/
|
|
72
|
+
fullscreen?: boolean
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type PropKeys = keyof DataPermissionLevelsOwnProps
|
|
76
|
+
|
|
77
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
78
|
+
|
|
79
|
+
type DataPermissionLevelsProps = DataPermissionLevelsOwnProps &
|
|
80
|
+
WithStyleProps<DataPermissionLevelsTheme, DataPermissionLevelsStyle> &
|
|
81
|
+
OtherHTMLAttributes<DataPermissionLevelsOwnProps>
|
|
82
|
+
|
|
83
|
+
type DataPermissionLevelsStyle = ComponentStyle<
|
|
84
|
+
| 'dataPermissionLevels'
|
|
85
|
+
| 'body'
|
|
86
|
+
| 'card'
|
|
87
|
+
| 'level'
|
|
88
|
+
| 'highlightedCard'
|
|
89
|
+
| 'currentFeature'
|
|
90
|
+
| 'contentContainer'
|
|
91
|
+
| 'permissionTitle'
|
|
92
|
+
> & {
|
|
93
|
+
maxWidth?: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const allowedProps: AllowedPropKeys = [
|
|
97
|
+
'fullscreen',
|
|
98
|
+
'modalLabel',
|
|
99
|
+
'title',
|
|
100
|
+
'data',
|
|
101
|
+
'closeButtonText',
|
|
102
|
+
'closeIconButtonScreenReaderLabel',
|
|
103
|
+
'currentFeatureText',
|
|
104
|
+
'currentFeature',
|
|
105
|
+
'triggerText'
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
export type { DataPermissionLevelsProps, DataPermissionLevelsStyle }
|
|
109
|
+
export { allowedProps }
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { DataPermissionLevelsTheme } from '@instructure/shared-types'
|
|
26
|
+
import type {
|
|
27
|
+
DataPermissionLevelsProps,
|
|
28
|
+
DataPermissionLevelsStyle
|
|
29
|
+
} from './props'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ---
|
|
33
|
+
* private: true
|
|
34
|
+
* ---
|
|
35
|
+
* Generates the style object from the theme and provided additional information
|
|
36
|
+
* @param {Object} componentTheme The theme variable object.
|
|
37
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
+
* @return {Object} The final style object, which will be used in the component
|
|
39
|
+
*/
|
|
40
|
+
const generateStyle = (
|
|
41
|
+
componentTheme: DataPermissionLevelsTheme,
|
|
42
|
+
_props: DataPermissionLevelsProps
|
|
43
|
+
): DataPermissionLevelsStyle => {
|
|
44
|
+
return {
|
|
45
|
+
dataPermissionLevels: {
|
|
46
|
+
label: 'data-permission-levels'
|
|
47
|
+
},
|
|
48
|
+
body: {
|
|
49
|
+
label: 'data-permission-levels__body',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
padding: componentTheme?.bodyPadding
|
|
53
|
+
},
|
|
54
|
+
card: {
|
|
55
|
+
label: 'data-permission-levels__card',
|
|
56
|
+
padding: '2px',
|
|
57
|
+
borderStyle: 'solid',
|
|
58
|
+
borderColor: 'transparent',
|
|
59
|
+
borderWidth: componentTheme?.cardBorderWidth,
|
|
60
|
+
display: 'flex',
|
|
61
|
+
flexDirection: 'column'
|
|
62
|
+
},
|
|
63
|
+
highlightedCard: {
|
|
64
|
+
label: 'data-permission-levels__highlighted-card',
|
|
65
|
+
borderStyle: 'solid',
|
|
66
|
+
borderWidth: componentTheme?.cardBorderWidth,
|
|
67
|
+
borderColor: componentTheme?.cardBorderColor,
|
|
68
|
+
borderRadius: componentTheme?.cardBorderRadius,
|
|
69
|
+
padding: '2px',
|
|
70
|
+
display: 'flex',
|
|
71
|
+
flexDirection: 'column',
|
|
72
|
+
background: `
|
|
73
|
+
linear-gradient(to right, ${componentTheme.aiTextLeftGradientColor} 0%, ${componentTheme.aiTextRightGradientColor} 100%) padding-box,
|
|
74
|
+
linear-gradient(to right, ${componentTheme.aiTextLeftGradientColor} 0%, ${componentTheme.aiTextRightGradientColor} 100%) border-box`,
|
|
75
|
+
border: 'solid transparent'
|
|
76
|
+
},
|
|
77
|
+
level: {
|
|
78
|
+
label: 'data-permission-levels__level',
|
|
79
|
+
color: componentTheme?.levelColor
|
|
80
|
+
},
|
|
81
|
+
currentFeature: {
|
|
82
|
+
label: 'data-permission-levels__current-feature',
|
|
83
|
+
background: `
|
|
84
|
+
linear-gradient(to right, ${componentTheme.aiTextLeftGradientColor} 0%, ${componentTheme.aiTextRightGradientColor} 100%)`,
|
|
85
|
+
paddingLeft: componentTheme?.currentFeaturePaddingSides,
|
|
86
|
+
paddingRight: componentTheme?.currentFeaturePaddingSides,
|
|
87
|
+
paddingTop: componentTheme?.currentFeaturePaddingTopBottom,
|
|
88
|
+
paddingBottom: componentTheme?.currentFeaturePaddingTopBottom,
|
|
89
|
+
borderTopLeftRadius: componentTheme?.cardBorderRadius,
|
|
90
|
+
borderTopRightRadius: componentTheme?.cardBorderRadius
|
|
91
|
+
},
|
|
92
|
+
contentContainer: {
|
|
93
|
+
label: 'data-permission-levels__content-container',
|
|
94
|
+
background: 'white',
|
|
95
|
+
padding: '10px',
|
|
96
|
+
display: 'flex',
|
|
97
|
+
flexDirection: 'column'
|
|
98
|
+
},
|
|
99
|
+
permissionTitle: {
|
|
100
|
+
label: 'data-permission-levels__permission-title',
|
|
101
|
+
marginBottom: componentTheme?.permissionTitleBottomMargin
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default generateStyle
|
|
@@ -0,0 +1,59 @@
|
|
|
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 type { DataPermissionLevelsTheme } 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): DataPermissionLevelsTheme => {
|
|
34
|
+
const { colors, spacing, borders } = theme
|
|
35
|
+
|
|
36
|
+
const componentVariables: DataPermissionLevelsTheme = {
|
|
37
|
+
cardBorderRadius: borders?.radiusMedium,
|
|
38
|
+
cardBorderColor: colors?.ui?.lineStroke,
|
|
39
|
+
cardBorderWidth: borders?.widthMedium,
|
|
40
|
+
cardPadding: spacing?.space12,
|
|
41
|
+
cardExplainerContainerBottomMargin: spacing?.space8,
|
|
42
|
+
cardGap: spacing?.modalElements,
|
|
43
|
+
currentFeaturePaddingSides: spacing?.space12,
|
|
44
|
+
currentFeaturePaddingTopBottom: spacing?.space8,
|
|
45
|
+
permissionTitleBottomMargin: spacing?.space8,
|
|
46
|
+
levelColor: colors?.contrasts?.violet5790,
|
|
47
|
+
|
|
48
|
+
bodyPadding: spacing?.paddingCardLarge,
|
|
49
|
+
|
|
50
|
+
aiTextLeftGradientColor: colors?.contrasts?.violet4570,
|
|
51
|
+
aiTextRightGradientColor: colors?.contrasts?.sea4570
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
...componentVariables
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default generateComponentTheme
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
describes: NutritionFacts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
This component is made to display specific AI related data in Instructure products.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
---
|
|
9
|
+
type: example
|
|
10
|
+
---
|
|
11
|
+
<div>
|
|
12
|
+
<NutritionFacts
|
|
13
|
+
modalLabel="This is a modal for AI facts"
|
|
14
|
+
title="Nutrition Facts"
|
|
15
|
+
featureName="Feature Name"
|
|
16
|
+
closeButtonText="Close"
|
|
17
|
+
closeIconButtonScreenReaderLabel="Close"
|
|
18
|
+
triggerText="Nutrition Facts"
|
|
19
|
+
data={[
|
|
20
|
+
{
|
|
21
|
+
blockTitle: "Model & Data",
|
|
22
|
+
segmentData:[
|
|
23
|
+
{
|
|
24
|
+
segmentTitle: "Base Model",
|
|
25
|
+
description: "The foundational AI on which further training and customizations are built.",
|
|
26
|
+
value: "Value",
|
|
27
|
+
valueDescription: "Description"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
segmentTitle: "Trained with User Data",
|
|
31
|
+
description: "Indicates the AI model has been given customer data in order to improve its results.",
|
|
32
|
+
value: "Value",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
segmentTitle: "Data Shared with Model",
|
|
36
|
+
description: "Indicates which training or operational content was given to the model.",
|
|
37
|
+
value: "Value",
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
blockTitle: "Privacy & Compliance",
|
|
43
|
+
segmentData:[
|
|
44
|
+
{
|
|
45
|
+
segmentTitle: "Data Retention",
|
|
46
|
+
description: "How long the model stores customer data.",
|
|
47
|
+
value: "Value",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
segmentTitle: "Data Logging",
|
|
51
|
+
description: "Recording the AI's performance for auditing, analysis, and improvement.",
|
|
52
|
+
value: "Value",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
segmentTitle: "Regions Supported",
|
|
56
|
+
description: "The locations where the AI model is officially available and supported.",
|
|
57
|
+
value: "Value",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
segmentTitle: "PII",
|
|
61
|
+
description: "Sensitive data that can be used to identify an individual.",
|
|
62
|
+
value: "Value",
|
|
63
|
+
},
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
blockTitle: "Outputs",
|
|
68
|
+
segmentData:[
|
|
69
|
+
{
|
|
70
|
+
segmentTitle: "AI Settings Control",
|
|
71
|
+
description: "The ability to turn the AI on or off within the product.",
|
|
72
|
+
value: "Value",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
segmentTitle: "Human in the Loop",
|
|
76
|
+
description: "Indicates if a human is involved in the AI's process or output.",
|
|
77
|
+
value: "Value",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
segmentTitle: "Guardrails",
|
|
81
|
+
description: "Preventative safety mechanisms or limitations built into the AI model.",
|
|
82
|
+
value: "Value",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
segmentTitle: "Expected Risks",
|
|
86
|
+
description: "Any risks the model may pose to the user.",
|
|
87
|
+
value: "Value",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
segmentTitle: "Intended Outcomes",
|
|
91
|
+
description: "The specific results the AI model is meant to achieve.",
|
|
92
|
+
value: "Value",
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
]}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
```
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
import { useState } from 'react'
|
|
25
|
+
import { Modal } from '@instructure/ui-modal'
|
|
26
|
+
import { Button, CloseButton } from '@instructure/ui-buttons'
|
|
27
|
+
import { Heading } from '@instructure/ui-heading'
|
|
28
|
+
import { Text } from '@instructure/ui-text'
|
|
29
|
+
import { Link } from '@instructure/ui-link'
|
|
30
|
+
import { useStyle } from '@instructure/emotion'
|
|
31
|
+
|
|
32
|
+
import { NutritionFactsProps } from './props'
|
|
33
|
+
import generateStyle from './styles'
|
|
34
|
+
import generateComponentTheme from './theme'
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
---
|
|
38
|
+
category: components/AI Components
|
|
39
|
+
---
|
|
40
|
+
**/
|
|
41
|
+
const NutritionFacts = ({
|
|
42
|
+
modalLabel,
|
|
43
|
+
title,
|
|
44
|
+
featureName,
|
|
45
|
+
data,
|
|
46
|
+
closeButtonText,
|
|
47
|
+
closeIconButtonScreenReaderLabel,
|
|
48
|
+
triggerText,
|
|
49
|
+
fullscreen = false
|
|
50
|
+
}: NutritionFactsProps) => {
|
|
51
|
+
const [open, setOpen] = useState(false)
|
|
52
|
+
|
|
53
|
+
const styles = useStyle({
|
|
54
|
+
generateStyle,
|
|
55
|
+
generateComponentTheme,
|
|
56
|
+
componentId: 'NutritionFacts',
|
|
57
|
+
displayName: 'NutritionFacts'
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div>
|
|
62
|
+
<Link
|
|
63
|
+
variant="standalone"
|
|
64
|
+
onClick={(e) => {
|
|
65
|
+
e.preventDefault()
|
|
66
|
+
setOpen(true)
|
|
67
|
+
}}
|
|
68
|
+
forceButtonRole={false}
|
|
69
|
+
href="#"
|
|
70
|
+
>
|
|
71
|
+
{triggerText}
|
|
72
|
+
</Link>
|
|
73
|
+
<Modal
|
|
74
|
+
open={open}
|
|
75
|
+
onDismiss={() => {
|
|
76
|
+
setOpen(false)
|
|
77
|
+
}}
|
|
78
|
+
label={modalLabel}
|
|
79
|
+
shouldCloseOnDocumentClick
|
|
80
|
+
size={fullscreen ? 'fullscreen' : 'medium'}
|
|
81
|
+
>
|
|
82
|
+
<Modal.Header spacing="compact">
|
|
83
|
+
<Heading aiVariant="stacked">{title}</Heading>
|
|
84
|
+
<CloseButton
|
|
85
|
+
size="medium"
|
|
86
|
+
placement="end"
|
|
87
|
+
offset="small"
|
|
88
|
+
onClick={() => setOpen(false)}
|
|
89
|
+
screenReaderLabel={closeIconButtonScreenReaderLabel}
|
|
90
|
+
/>
|
|
91
|
+
</Modal.Header>
|
|
92
|
+
<Modal.Body>
|
|
93
|
+
<div css={styles?.body}>
|
|
94
|
+
<Heading variant="titleSection" level="h3">
|
|
95
|
+
{' '}
|
|
96
|
+
{featureName}{' '}
|
|
97
|
+
</Heading>
|
|
98
|
+
{data.map(({ blockTitle, segmentData }, index) => {
|
|
99
|
+
return (
|
|
100
|
+
<div key={index} css={styles?.blockContainer}>
|
|
101
|
+
<Heading variant="titleModule" level="h4">
|
|
102
|
+
{' '}
|
|
103
|
+
{blockTitle}{' '}
|
|
104
|
+
</Heading>
|
|
105
|
+
<div css={styles?.segmentContainer}>
|
|
106
|
+
{segmentData.map(
|
|
107
|
+
(
|
|
108
|
+
{ segmentTitle, description, value, valueDescription },
|
|
109
|
+
index
|
|
110
|
+
) => {
|
|
111
|
+
return (
|
|
112
|
+
<div key={index} css={styles?.segmentCard}>
|
|
113
|
+
<div css={styles?.segmentCardExplainerContainer}>
|
|
114
|
+
<Heading variant="label">
|
|
115
|
+
{' '}
|
|
116
|
+
{segmentTitle}{' '}
|
|
117
|
+
</Heading>
|
|
118
|
+
<Text variant="contentSmall" color="secondary">
|
|
119
|
+
{' '}
|
|
120
|
+
{description}{' '}
|
|
121
|
+
</Text>
|
|
122
|
+
</div>
|
|
123
|
+
<Text variant="content"> {value} </Text>
|
|
124
|
+
<Text variant="contentSmall" color="secondary">
|
|
125
|
+
{' '}
|
|
126
|
+
{valueDescription}{' '}
|
|
127
|
+
</Text>
|
|
128
|
+
</div>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
)}
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
</Modal.Body>
|
|
138
|
+
<Modal.Footer>
|
|
139
|
+
<Button onClick={() => setOpen(false)}>{closeButtonText}</Button>
|
|
140
|
+
</Modal.Footer>
|
|
141
|
+
</Modal>
|
|
142
|
+
</div>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default NutritionFacts
|
|
147
|
+
export { NutritionFacts }
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
26
|
+
import type {
|
|
27
|
+
NutritionFactsTheme,
|
|
28
|
+
OtherHTMLAttributes
|
|
29
|
+
} from '@instructure/shared-types'
|
|
30
|
+
|
|
31
|
+
type BlockType = {
|
|
32
|
+
blockTitle: string
|
|
33
|
+
segmentData: {
|
|
34
|
+
segmentTitle: string
|
|
35
|
+
description: string
|
|
36
|
+
value: string
|
|
37
|
+
valueDescription?: string
|
|
38
|
+
}[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type NutritionFactsOwnProps = {
|
|
42
|
+
/**
|
|
43
|
+
* i18n text for the label of the modal
|
|
44
|
+
*/
|
|
45
|
+
modalLabel: string
|
|
46
|
+
/**
|
|
47
|
+
* i18n text for the Nutrition Facts title
|
|
48
|
+
*/
|
|
49
|
+
title: string
|
|
50
|
+
/**
|
|
51
|
+
* i18n text for the feature name that the Nutrition Facts describes
|
|
52
|
+
*/
|
|
53
|
+
featureName: string
|
|
54
|
+
/**
|
|
55
|
+
* i18n text for the "model and data" heading of the Nutrition Facts
|
|
56
|
+
*/
|
|
57
|
+
data: BlockType[]
|
|
58
|
+
/**
|
|
59
|
+
* i18n text for the close button
|
|
60
|
+
*/
|
|
61
|
+
closeButtonText: string
|
|
62
|
+
/**
|
|
63
|
+
* i18n text for the close iconButton
|
|
64
|
+
*/
|
|
65
|
+
closeIconButtonScreenReaderLabel: string
|
|
66
|
+
/**
|
|
67
|
+
* i18n text for the trigger
|
|
68
|
+
*/
|
|
69
|
+
triggerText: string
|
|
70
|
+
/**
|
|
71
|
+
* sets the modal size to 'fullscreen'. Used for small viewports
|
|
72
|
+
*/
|
|
73
|
+
fullscreen?: boolean
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type PropKeys = keyof NutritionFactsOwnProps
|
|
77
|
+
|
|
78
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
79
|
+
|
|
80
|
+
type NutritionFactsProps = NutritionFactsOwnProps &
|
|
81
|
+
WithStyleProps<NutritionFactsTheme, NutritionFactsStyle> &
|
|
82
|
+
OtherHTMLAttributes<NutritionFactsOwnProps>
|
|
83
|
+
|
|
84
|
+
type NutritionFactsStyle = ComponentStyle<
|
|
85
|
+
| 'segmentCard'
|
|
86
|
+
| 'segmentCardExplainerContainer'
|
|
87
|
+
| 'segmentContainer'
|
|
88
|
+
| 'blockContainer'
|
|
89
|
+
| 'body'
|
|
90
|
+
> & {
|
|
91
|
+
maxWidth?: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const allowedProps: AllowedPropKeys = [
|
|
95
|
+
'fullscreen',
|
|
96
|
+
'modalLabel',
|
|
97
|
+
'title',
|
|
98
|
+
'featureName',
|
|
99
|
+
'data',
|
|
100
|
+
'closeButtonText',
|
|
101
|
+
'closeIconButtonScreenReaderLabel',
|
|
102
|
+
'triggerText'
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
export type { NutritionFactsProps, NutritionFactsStyle }
|
|
106
|
+
export { allowedProps }
|