@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +30 -0
  3. package/es/AiInformation/index.js +179 -0
  4. package/es/AiInformation/props.js +26 -0
  5. package/es/AiInformation/styles.js +85 -0
  6. package/es/AiInformation/theme.js +52 -0
  7. package/es/DataPermissionLevels/index.js +144 -0
  8. package/es/DataPermissionLevels/props.js +26 -0
  9. package/es/DataPermissionLevels/styles.js +96 -0
  10. package/es/DataPermissionLevels/theme.js +54 -0
  11. package/es/NutritionFacts/index.js +152 -0
  12. package/es/NutritionFacts/props.js +26 -0
  13. package/es/NutritionFacts/styles.js +72 -0
  14. package/es/NutritionFacts/theme.js +49 -0
  15. package/es/index.js +26 -0
  16. package/lib/AiInformation/index.js +185 -0
  17. package/lib/AiInformation/props.js +31 -0
  18. package/lib/AiInformation/styles.js +91 -0
  19. package/lib/AiInformation/theme.js +58 -0
  20. package/lib/DataPermissionLevels/index.js +151 -0
  21. package/lib/DataPermissionLevels/props.js +31 -0
  22. package/lib/DataPermissionLevels/styles.js +102 -0
  23. package/lib/DataPermissionLevels/theme.js +60 -0
  24. package/lib/NutritionFacts/index.js +159 -0
  25. package/lib/NutritionFacts/props.js +31 -0
  26. package/lib/NutritionFacts/styles.js +78 -0
  27. package/lib/NutritionFacts/theme.js +55 -0
  28. package/lib/index.js +26 -0
  29. package/lib/package.json +1 -0
  30. package/package.json +54 -0
  31. package/src/AiInformation/README.md +298 -0
  32. package/src/AiInformation/index.tsx +182 -0
  33. package/src/AiInformation/props.ts +163 -0
  34. package/src/AiInformation/styles.ts +92 -0
  35. package/src/AiInformation/theme.ts +58 -0
  36. package/src/DataPermissionLevels/README.md +47 -0
  37. package/src/DataPermissionLevels/index.tsx +137 -0
  38. package/src/DataPermissionLevels/props.ts +109 -0
  39. package/src/DataPermissionLevels/styles.ts +106 -0
  40. package/src/DataPermissionLevels/theme.ts +59 -0
  41. package/src/NutritionFacts/README.md +99 -0
  42. package/src/NutritionFacts/index.tsx +147 -0
  43. package/src/NutritionFacts/props.ts +106 -0
  44. package/src/NutritionFacts/styles.ts +79 -0
  45. package/src/NutritionFacts/theme.ts +52 -0
  46. package/src/index.ts +29 -0
  47. package/tsconfig.build.json +50 -0
  48. package/tsconfig.build.tsbuildinfo +1 -0
  49. package/tsconfig.json +4 -0
  50. package/types/AiInformation/index.d.ts +10 -0
  51. package/types/AiInformation/index.d.ts.map +1 -0
  52. package/types/AiInformation/props.d.ts +92 -0
  53. package/types/AiInformation/props.d.ts.map +1 -0
  54. package/types/AiInformation/styles.d.ts +14 -0
  55. package/types/AiInformation/styles.d.ts.map +1 -0
  56. package/types/AiInformation/theme.d.ts +10 -0
  57. package/types/AiInformation/theme.d.ts.map +1 -0
  58. package/types/DataPermissionLevels/index.d.ts +10 -0
  59. package/types/DataPermissionLevels/index.d.ts.map +1 -0
  60. package/types/DataPermissionLevels/props.d.ts +55 -0
  61. package/types/DataPermissionLevels/props.d.ts.map +1 -0
  62. package/types/DataPermissionLevels/styles.d.ts +14 -0
  63. package/types/DataPermissionLevels/styles.d.ts.map +1 -0
  64. package/types/DataPermissionLevels/theme.d.ts +10 -0
  65. package/types/DataPermissionLevels/theme.d.ts.map +1 -0
  66. package/types/NutritionFacts/index.d.ts +10 -0
  67. package/types/NutritionFacts/index.d.ts.map +1 -0
  68. package/types/NutritionFacts/props.d.ts +55 -0
  69. package/types/NutritionFacts/props.d.ts.map +1 -0
  70. package/types/NutritionFacts/styles.d.ts +14 -0
  71. package/types/NutritionFacts/styles.d.ts.map +1 -0
  72. package/types/NutritionFacts/theme.d.ts +10 -0
  73. package/types/NutritionFacts/theme.d.ts.map +1 -0
  74. package/types/index.d.ts +7 -0
  75. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,182 @@
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 { Popover } from '@instructure/ui-popover'
26
+ import { CloseButton } from '@instructure/ui-buttons'
27
+ import { Heading } from '@instructure/ui-heading'
28
+ import { Text } from '@instructure/ui-text'
29
+ import { useStyle } from '@instructure/emotion'
30
+ import { NutritionFacts, DataPermissionLevels } from '../'
31
+
32
+ import { AiInformationProps } from './props'
33
+ import generateStyle from './styles'
34
+ import generateComponentTheme from './theme'
35
+
36
+ /**
37
+ ---
38
+ category: components/AI Components
39
+ ---
40
+ **/
41
+ const AiInformation = ({
42
+ title,
43
+ data,
44
+ trigger,
45
+ fullscreenModals = false,
46
+
47
+ dataPermissionLevelsModalLabel,
48
+ dataPermissionLevelsTitle,
49
+ dataPermissionLevelsData,
50
+ dataPermissionLevelsCloseButtonText,
51
+ dataPermissionLevelsCloseIconButtonScreenReaderLabel,
52
+ dataPermissionLevelsCurrentFeature,
53
+ dataPermissionLevelsCurrentFeatureText,
54
+
55
+ nutritionFactsModalLabel,
56
+ nutritionFactsTitle,
57
+ nutritionFactsFeatureName,
58
+ nutritionFactsData,
59
+ nutritionFactsCloseButtonText,
60
+ nutritionFactsCloseIconButtonScreenReaderLabel
61
+ }: AiInformationProps) => {
62
+ const [open, setOpen] = useState(false)
63
+
64
+ const styles = useStyle({
65
+ generateStyle,
66
+ generateComponentTheme,
67
+ componentId: 'AiInformation',
68
+ displayName: 'AiInformation'
69
+ })
70
+
71
+ return (
72
+ <div>
73
+ <Popover
74
+ renderTrigger={trigger}
75
+ isShowingContent={open}
76
+ on="click"
77
+ screenReaderLabel="Popover Dialog Example"
78
+ shouldContainFocus
79
+ shouldReturnFocus
80
+ shouldCloseOnDocumentClick
81
+ offsetY="1rem"
82
+ onShowContent={() => setOpen(true)}
83
+ onHideContent={() => setOpen(false)}
84
+ >
85
+ <div css={styles?.aiInformation}>
86
+ <div css={styles?.header}>
87
+ <Heading level="h2" aiVariant="stacked" variant="titleModule">
88
+ {title}
89
+ </Heading>
90
+ <CloseButton
91
+ placement="end"
92
+ offset="small"
93
+ onClick={() => setOpen(false)}
94
+ screenReaderLabel="Close"
95
+ />
96
+ </div>
97
+ <div>
98
+ {data.map(
99
+ (
100
+ {
101
+ featureName,
102
+ permissionLevelText,
103
+ permissionLevel,
104
+ description,
105
+ permissionLevelsModalTriggerText,
106
+ modelNameText,
107
+ modelName,
108
+ nutritionFactsModalTriggerText
109
+ },
110
+ index
111
+ ) => (
112
+ <div key={index}>
113
+ <div css={styles?.featureName}>
114
+ <Heading level="h3" variant="titleCardRegular">
115
+ {featureName}
116
+ </Heading>
117
+ </div>
118
+
119
+ <div css={styles?.permissionLevelText}>
120
+ <Heading level="h4" variant="label">
121
+ {permissionLevelText}
122
+ </Heading>
123
+ </div>
124
+ <div css={styles?.permissionLevel}>
125
+ <Text variant="legend"> {permissionLevel} </Text>
126
+ </div>
127
+ <div css={styles?.description}>
128
+ <Text variant="contentSmall"> {description} </Text>
129
+ </div>
130
+ <div css={styles?.permissionLevelsModalTriggerText}>
131
+ <DataPermissionLevels
132
+ fullscreen={fullscreenModals}
133
+ title={dataPermissionLevelsTitle}
134
+ currentFeatureText={
135
+ dataPermissionLevelsCurrentFeatureText
136
+ }
137
+ currentFeature={dataPermissionLevelsCurrentFeature}
138
+ closeIconButtonScreenReaderLabel={
139
+ dataPermissionLevelsCloseIconButtonScreenReaderLabel
140
+ }
141
+ closeButtonText={dataPermissionLevelsCloseButtonText}
142
+ modalLabel={dataPermissionLevelsModalLabel}
143
+ triggerText={permissionLevelsModalTriggerText}
144
+ data={dataPermissionLevelsData}
145
+ />
146
+ </div>
147
+ <div css={styles?.modelNameText}>
148
+ <Heading level="h3" variant="label">
149
+ {' '}
150
+ {modelNameText}{' '}
151
+ </Heading>
152
+ </div>
153
+ <div css={styles?.modelName}>
154
+ <Text variant="contentSmall"> {modelName} </Text>
155
+ </div>
156
+ <NutritionFacts
157
+ fullscreen={fullscreenModals}
158
+ modalLabel={nutritionFactsModalLabel}
159
+ title={nutritionFactsTitle}
160
+ featureName={nutritionFactsFeatureName}
161
+ closeButtonText={nutritionFactsCloseButtonText}
162
+ closeIconButtonScreenReaderLabel={
163
+ nutritionFactsCloseIconButtonScreenReaderLabel
164
+ }
165
+ triggerText={nutritionFactsModalTriggerText}
166
+ data={nutritionFactsData}
167
+ />
168
+ {data.length !== index + 1 ? (
169
+ <div css={styles?.divider} />
170
+ ) : null}
171
+ </div>
172
+ )
173
+ )}
174
+ </div>
175
+ </div>
176
+ </Popover>
177
+ </div>
178
+ )
179
+ }
180
+
181
+ export default AiInformation
182
+ export { AiInformation }
@@ -0,0 +1,163 @@
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 type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
25
+ import type {
26
+ AiInformationTheme,
27
+ OtherHTMLAttributes,
28
+ Renderable
29
+ } from '@instructure/shared-types'
30
+ import type { NutritionFactsProps, DataPermissionLevelsProps } from '../'
31
+
32
+ type AiInformationOwnProps = {
33
+ /**
34
+ * i18n text for the title of popover
35
+ */
36
+ title: string
37
+ /**
38
+ * the data structure of the Features on the popover
39
+ */
40
+ data: {
41
+ featureName: string
42
+ permissionLevelText: string
43
+ permissionLevel: string
44
+ description: string
45
+ permissionLevelsModalTriggerText: string
46
+ modelNameText: string
47
+ modelName: string
48
+ nutritionFactsModalTriggerText: string
49
+ }[]
50
+ /**
51
+ * sets the modal size to 'fullscreen' for NutritionFacts and DataPermissionLevels. Used for small viewports
52
+ */
53
+ fullscreenModals?: boolean
54
+
55
+ /**
56
+ * The element that triggers the popover
57
+ */
58
+ trigger: Renderable
59
+
60
+ // this is the same as DataPermissionLevels' props
61
+
62
+ /**
63
+ * i18n text for the label of the dataPermissionLevels modal
64
+ */
65
+ dataPermissionLevelsModalLabel: DataPermissionLevelsProps['modalLabel']
66
+ /**
67
+ * i18n text for the dataPermissionLevels title
68
+ */
69
+ dataPermissionLevelsTitle: DataPermissionLevelsProps['title']
70
+ /**
71
+ * i18n text for the "model and data" heading of the dataPermissionLevels
72
+ */
73
+ dataPermissionLevelsData: DataPermissionLevelsProps['data']
74
+ /**
75
+ * i18n text for the dataPermissionLevels close button
76
+ */
77
+ dataPermissionLevelsCloseButtonText: DataPermissionLevelsProps['closeButtonText']
78
+ /**
79
+ * i18n text for the dataPermissionLevels close iconButton
80
+ */
81
+ dataPermissionLevelsCloseIconButtonScreenReaderLabel: DataPermissionLevelsProps['closeIconButtonScreenReaderLabel']
82
+ /**
83
+ * i18n text for the dataPermissionLevels "current feature" text
84
+ */
85
+ dataPermissionLevelsCurrentFeatureText: DataPermissionLevelsProps['currentFeatureText']
86
+ /**
87
+ * i18n text for the dataPermissionLevels current feature
88
+ */
89
+ dataPermissionLevelsCurrentFeature: DataPermissionLevelsProps['currentFeature']
90
+
91
+ // this is the same as NutritionFacts' props
92
+
93
+ /**
94
+ * i18n text for the NutritionFacts label of the modal
95
+ */
96
+ nutritionFactsModalLabel: NutritionFactsProps['modalLabel']
97
+ /**
98
+ * i18n text for the NutritionFacts title
99
+ */
100
+ nutritionFactsTitle: NutritionFactsProps['title']
101
+ /**
102
+ * i18n text for the feature name that the NutritionFacts describes
103
+ */
104
+ nutritionFactsFeatureName: NutritionFactsProps['featureName']
105
+ /**
106
+ * i18n text for the "model and data" heading of the NutritionFacts
107
+ */
108
+ nutritionFactsData: NutritionFactsProps['data']
109
+ /**
110
+ * i18n text for the NutritionFacts close button
111
+ */
112
+ nutritionFactsCloseButtonText: NutritionFactsProps['closeButtonText']
113
+ /**
114
+ * i18n text for the NutritionFacts close iconButton
115
+ */
116
+ nutritionFactsCloseIconButtonScreenReaderLabel: NutritionFactsProps['closeIconButtonScreenReaderLabel']
117
+ }
118
+
119
+ type PropKeys = keyof AiInformationOwnProps
120
+
121
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
122
+
123
+ type AiInformationProps = AiInformationOwnProps &
124
+ WithStyleProps<AiInformationTheme, AiInformationStyle> &
125
+ OtherHTMLAttributes<AiInformationOwnProps>
126
+
127
+ type AiInformationStyle = ComponentStyle<
128
+ | 'aiInformation'
129
+ | 'header'
130
+ | 'featureName'
131
+ | 'permissionLevelText'
132
+ | 'permissionLevel'
133
+ | 'description'
134
+ | 'permissionLevelsModalTriggerText'
135
+ | 'modelNameText'
136
+ | 'modelName'
137
+ | 'divider'
138
+ > & {
139
+ maxWidth?: string
140
+ }
141
+
142
+ const allowedProps: AllowedPropKeys = [
143
+ 'fullscreenModals',
144
+ 'title',
145
+ 'data',
146
+ 'trigger',
147
+ 'dataPermissionLevelsModalLabel',
148
+ 'dataPermissionLevelsTitle',
149
+ 'dataPermissionLevelsData',
150
+ 'dataPermissionLevelsCloseButtonText',
151
+ 'dataPermissionLevelsCloseIconButtonScreenReaderLabel',
152
+ 'dataPermissionLevelsCurrentFeatureText',
153
+ 'dataPermissionLevelsCurrentFeature',
154
+ 'nutritionFactsModalLabel',
155
+ 'nutritionFactsTitle',
156
+ 'nutritionFactsFeatureName',
157
+ 'nutritionFactsData',
158
+ 'nutritionFactsCloseButtonText',
159
+ 'nutritionFactsCloseIconButtonScreenReaderLabel'
160
+ ]
161
+
162
+ export type { AiInformationProps, AiInformationStyle }
163
+ export { allowedProps }
@@ -0,0 +1,92 @@
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 { AiInformationTheme } from '@instructure/shared-types'
26
+ import type { AiInformationProps, AiInformationStyle } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @param {Object} props the props of the component, the style is applied to
35
+ * @return {Object} The final style object, which will be used in the component
36
+ */
37
+ const generateStyle = (
38
+ componentTheme: AiInformationTheme,
39
+ _props: AiInformationProps
40
+ ): AiInformationStyle => {
41
+ return {
42
+ aiInformation: {
43
+ label: 'ai-information',
44
+ width: '18.5rem',
45
+ padding: componentTheme.bodyPadding,
46
+ boxSizing: 'border-box'
47
+ },
48
+ header: {
49
+ label: 'ai-information__header',
50
+ marginBottom: componentTheme.headingBottomMargin
51
+ },
52
+ featureName: {
53
+ label: 'ai-information__feature-name',
54
+ marginBottom: componentTheme.featureNameBottomMargin
55
+ },
56
+ permissionLevelText: {
57
+ label: 'ai-information__permission-level-text',
58
+ marginBottom: componentTheme.permissionLevelTextBottomMargin
59
+ },
60
+ permissionLevel: {
61
+ label: 'ai-information__permission-level',
62
+ marginBottom: componentTheme.permissionLevelBottomMargin,
63
+ color: componentTheme.levelColor
64
+ },
65
+ description: {
66
+ label: 'ai-information__description',
67
+ marginBottom: componentTheme.descriptionBottomMargin
68
+ },
69
+ permissionLevelsModalTriggerText: {
70
+ label: 'ai-information__permission-levels-modal-trigger-text',
71
+ marginBottom: componentTheme.permissionLevelsModalTriggerBottomMargin
72
+ },
73
+ modelNameText: {
74
+ label: 'ai-information__model-name-text',
75
+ marginBottom: componentTheme.modelNameTextBottomMargin
76
+ },
77
+ modelName: {
78
+ label: 'ai-information__model-name',
79
+ marginBottom: componentTheme.modelNameBottomMargin
80
+ },
81
+ divider: {
82
+ label: 'ai-information__divider',
83
+ marginBottom: componentTheme.dividerMargin,
84
+ marginTop: componentTheme.dividerMargin,
85
+ borderTop: 'solid 1px',
86
+ width: '100%',
87
+ borderColor: componentTheme.dividerColor
88
+ }
89
+ }
90
+ }
91
+
92
+ export default generateStyle
@@ -0,0 +1,58 @@
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 { AiInformationTheme } 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): AiInformationTheme => {
34
+ const { colors, spacing } = theme
35
+
36
+ const componentVariables: AiInformationTheme = {
37
+ bodyPadding: spacing?.paddingCardLarge,
38
+ headingBottomMargin: spacing?.sectionElements,
39
+ featureNameBottomMargin: spacing?.moduleElements,
40
+ permissionLevelTextBottomMargin: spacing?.space8,
41
+ permissionLevelBottomMargin: spacing?.space8,
42
+ descriptionBottomMargin: spacing?.space8,
43
+ permissionLevelsModalTriggerBottomMargin: spacing?.moduleElements,
44
+ modelNameTextBottomMargin: spacing?.space4,
45
+ modelNameBottomMargin: spacing?.space4,
46
+
47
+ dividerMargin: spacing?.moduleElements,
48
+ dividerColor: colors?.ui?.surfaceDivider,
49
+
50
+ levelColor: colors?.contrasts?.violet5790
51
+ }
52
+
53
+ return {
54
+ ...componentVariables
55
+ }
56
+ }
57
+
58
+ export default generateComponentTheme
@@ -0,0 +1,47 @@
1
+ ---
2
+ describes: DataPermissionLevels
3
+ ---
4
+
5
+ This component is made to display specific AI related data in Instructure products.
6
+
7
+ ```js
8
+ ---
9
+ type: example
10
+ readonly: true
11
+ ---
12
+ <div>
13
+ <DataPermissionLevels
14
+ title="Data Permission Levels"
15
+ currentFeatureText="Current Feature:"
16
+ currentFeature="Feature name"
17
+ closeIconButtonScreenReaderLabel="Close"
18
+ closeButtonText="Close"
19
+ modalLabel="This is a Data Permission Levels modal"
20
+ triggerText="Data Permission Levels"
21
+ data={[
22
+ {
23
+ level: "LEVEL 1",
24
+ title: "Descriptive Analytics and Research",
25
+ description: "We leverage anonymized aggregate data for detailed analytics to inform model development and product improvements. No AI models are used at this level.",
26
+ highlighted:true
27
+ },
28
+ {
29
+ level: "LEVEL 2",
30
+ title: "AI-Powered Features Without Data Retention",
31
+ description: "We utilize off-the-shelf AI models and customer data as input to provide AI-powered features. No data is used for training this model."
32
+ },
33
+ {
34
+ level: "LEVEL 3",
35
+ title: "AI Customization for Individual Institutions",
36
+ description: "We customize AI solutions tailored to the unique needs and resources of educational institutions. We use customer data to fine-tune data and train AI models that only serve your institution. Your institution’s data only serves them through trained models."
37
+ },
38
+ {
39
+ level: "LEVEL 4",
40
+ title: "Collaborative AI Consortium",
41
+ description: "We established a consortium with educational institutions that shares anonymized data, best practices, and research findings. This fosters collaboration and accelerates the responsible development of AI in education. Specialized AI models are created for better outcomes in education, cost savings, and more."
42
+ },
43
+ ]}
44
+
45
+ />
46
+ </div>
47
+ ```
@@ -0,0 +1,137 @@
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 { DataPermissionLevelsProps } from './props'
33
+ import generateStyle from './styles'
34
+ import generateComponentTheme from './theme'
35
+
36
+ /**
37
+ ---
38
+ category: components/AI Components
39
+ ---
40
+ **/
41
+ const DataPermissionLevels = ({
42
+ modalLabel,
43
+ title,
44
+ data,
45
+ closeButtonText,
46
+ closeIconButtonScreenReaderLabel,
47
+ currentFeature,
48
+ currentFeatureText,
49
+ triggerText,
50
+ fullscreen = false
51
+ }: DataPermissionLevelsProps) => {
52
+ const [open, setOpen] = useState(false)
53
+
54
+ const styles = useStyle({
55
+ generateStyle,
56
+ generateComponentTheme,
57
+ componentId: 'DataPermissionLevels',
58
+ displayName: 'DataPermissionLevels'
59
+ })
60
+
61
+ return (
62
+ <div>
63
+ <Link
64
+ variant="standalone"
65
+ onClick={(e) => {
66
+ e.preventDefault()
67
+ setOpen(true)
68
+ }}
69
+ forceButtonRole={false}
70
+ href="#"
71
+ >
72
+ {triggerText}
73
+ </Link>
74
+ <Modal
75
+ size={fullscreen ? 'fullscreen' : 'medium'}
76
+ open={open}
77
+ onDismiss={() => {
78
+ setOpen(false)
79
+ }}
80
+ label={modalLabel}
81
+ shouldCloseOnDocumentClick
82
+ >
83
+ <Modal.Header spacing="compact">
84
+ <Heading aiVariant="stacked">{title}</Heading>
85
+ <CloseButton
86
+ size="medium"
87
+ placement="end"
88
+ offset="small"
89
+ onClick={() => setOpen(false)}
90
+ screenReaderLabel={closeIconButtonScreenReaderLabel}
91
+ />
92
+ </Modal.Header>
93
+ <Modal.Body>
94
+ <div css={styles?.body}>
95
+ {data.map(({ level, title, description, highlighted }, index) => (
96
+ <div
97
+ key={index}
98
+ css={highlighted ? styles?.highlightedCard : styles?.card}
99
+ >
100
+ {highlighted ? (
101
+ <div css={styles?.currentFeature}>
102
+ <Heading
103
+ color="primary-inverse"
104
+ level="reset"
105
+ variant="labelInline"
106
+ >
107
+ {currentFeatureText}{' '}
108
+ </Heading>
109
+ <Text color="primary-inverse" variant="content">
110
+ {currentFeature}
111
+ </Text>
112
+ </div>
113
+ ) : null}
114
+
115
+ <div css={styles?.contentContainer}>
116
+ <div css={styles?.level}>{level}</div>
117
+ <div css={styles?.permissionTitle}>
118
+ <Text variant="descriptionPage">{title} </Text>
119
+ </div>
120
+ <Text variant="content" color="secondary">
121
+ {description}
122
+ </Text>
123
+ </div>
124
+ </div>
125
+ ))}
126
+ </div>
127
+ </Modal.Body>
128
+ <Modal.Footer>
129
+ <Button onClick={() => setOpen(false)}>{closeButtonText}</Button>
130
+ </Modal.Footer>
131
+ </Modal>
132
+ </div>
133
+ )
134
+ }
135
+
136
+ export default DataPermissionLevels
137
+ export { DataPermissionLevels }