@indico-data/design-system 2.0.2 → 2.1.2

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 (36) hide show
  1. package/.commitlintrc.ts +13 -0
  2. package/.harness/pipeline.yaml +1 -1
  3. package/.releaserc.json +16 -1
  4. package/README.md +73 -0
  5. package/lib/index.css +84 -67
  6. package/lib/index.d.ts +49 -156
  7. package/lib/index.esm.css +84 -67
  8. package/lib/index.esm.js +1 -287
  9. package/lib/index.esm.js.map +1 -1
  10. package/lib/index.js +0 -291
  11. package/lib/index.js.map +1 -1
  12. package/lib/legacy/components/index.d.ts +0 -2
  13. package/package.json +4 -3
  14. package/src/components/button/{Button.scss → styles/Button.scss} +5 -69
  15. package/src/components/button/styles/_variables.scss +89 -0
  16. package/src/index.ts +0 -5
  17. package/src/legacy/components/index.ts +0 -2
  18. package/src/styles/index.scss +1 -1
  19. package/src/styles/variables/themes/dark.scss +70 -74
  20. package/src/stylesAndAnimations/colors/constants.ts +60 -60
  21. package/lib/legacy/components/Wizard/Wizard.d.ts +0 -48
  22. package/lib/legacy/components/Wizard/Wizard.stories.d.ts +0 -29
  23. package/lib/legacy/components/Wizard/Wizard.styles.d.ts +0 -4
  24. package/lib/legacy/components/Wizard/index.d.ts +0 -2
  25. package/lib/legacy/components/WizardWithSidebar/WizardWithSidebar.d.ts +0 -58
  26. package/lib/legacy/components/WizardWithSidebar/WizardWithSidebar.stories.d.ts +0 -46
  27. package/lib/legacy/components/WizardWithSidebar/WizardWithSidebar.styles.d.ts +0 -9
  28. package/lib/legacy/components/WizardWithSidebar/index.d.ts +0 -2
  29. package/src/legacy/components/Wizard/Wizard.stories.tsx +0 -180
  30. package/src/legacy/components/Wizard/Wizard.styles.ts +0 -72
  31. package/src/legacy/components/Wizard/Wizard.tsx +0 -211
  32. package/src/legacy/components/Wizard/index.ts +0 -2
  33. package/src/legacy/components/WizardWithSidebar/WizardWithSidebar.stories.tsx +0 -143
  34. package/src/legacy/components/WizardWithSidebar/WizardWithSidebar.styles.ts +0 -107
  35. package/src/legacy/components/WizardWithSidebar/WizardWithSidebar.tsx +0 -278
  36. package/src/legacy/components/WizardWithSidebar/index.ts +0 -2
@@ -1,143 +0,0 @@
1
- import React, { useState } from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
-
4
- import { WizardWithSidebar } from './WizardWithSidebar';
5
- import { COLORS } from '@/legacy/tokens';
6
-
7
- const meta = {
8
- component: WizardWithSidebar,
9
- title: 'legacy/wizards/WizardWithSidebar',
10
- args: {
11
- buttonColor: `${COLORS.blueDarknut}`,
12
- backgroundColor: '#ffffff',
13
- color: '#000000',
14
- stepSchema: {
15
- 'Library Details': { inputsRequiringValidation: ['libraryName'], description: [] },
16
- 'Configure Source': {
17
- inputsRequiringValidation: [],
18
- description: [
19
- 'Select workflows to use for document ingestion to build your library.',
20
- 'Select a folder to use for document ingestion to build your library.',
21
- ],
22
- },
23
- Summary: { inputsRequiringValidation: [], description: [] },
24
- },
25
- onCancel: () => console.info('cancelling'),
26
- onSubmit: () => console.info('submitting'),
27
- wizardTitle: 'New Teach Task',
28
- confirmCancel: {
29
- title: 'Are you sure you want to stop creating this Task?',
30
- message: 'Your Task will not be saved, nor available to be labeled.',
31
- confirmText: 'Yes, go ahead',
32
- rejectText: 'No, go back',
33
- },
34
- submitButtonLabel: 'Add Teach Task',
35
- // Evidently, we need to add this prop or its corresponding logic within the component evaluates to false in storybook.
36
- // Was not happening in earlier version, so was not necessary.
37
- onNextPress: () => true,
38
- },
39
- } satisfies Meta<typeof WizardWithSidebar>;
40
-
41
- export default meta;
42
- type Story = StoryObj<typeof WizardWithSidebar>;
43
-
44
- const steps = Object.keys(meta.args.stepSchema);
45
- function StoryRender(props: any) {
46
- const [currentStep, setCurrentStep] = useState('');
47
-
48
- const currentStepContent = () => {
49
- if (currentStep === steps[0]) {
50
- return <div style={{ height: '300px', width: '500px' }}>First step content</div>;
51
- }
52
-
53
- if (currentStep === steps[1]) {
54
- return <div style={{ height: '300px', width: '500px' }}>Second step content</div>;
55
- }
56
-
57
- if (currentStep === steps[2]) {
58
- return <div style={{ height: '300px', width: '500px' }}>Third step content</div>;
59
- }
60
- };
61
-
62
- return (
63
- <WizardWithSidebar {...props} onStepChange={(step) => setCurrentStep(step)}>
64
- {currentStepContent()}
65
- </WizardWithSidebar>
66
- );
67
- }
68
-
69
- export const FirstStep: Story = {
70
- render: (args) => {
71
- return <StoryRender {...args} />;
72
- },
73
- };
74
-
75
- export const SecondStep: Story = {
76
- args: {
77
- startingStep: steps[1],
78
- },
79
- render: (args) => {
80
- return <StoryRender {...args} />;
81
- },
82
- };
83
-
84
- export const LastStep: Story = {
85
- args: {
86
- startingStep: steps[2],
87
- },
88
- render: (args) => {
89
- return <StoryRender {...args} />;
90
- },
91
- };
92
-
93
- export const DisabledNextStep: Story = {
94
- args: {
95
- disableNextStep: true,
96
- },
97
- render: (args) => {
98
- return <StoryRender {...args} />;
99
- },
100
- };
101
-
102
- export const DisabledPreviousStep: Story = {
103
- args: {
104
- startingStep: steps[1],
105
- disablePrevStep: true,
106
- },
107
- render: (args) => {
108
- return <StoryRender {...args} />;
109
- },
110
- };
111
-
112
- export const SubmitProcessing: Story = {
113
- args: {
114
- submitProcessing: 'Adding Library',
115
- startingStep: steps[2],
116
- },
117
- render: (args) => {
118
- return <StoryRender {...args} />;
119
- },
120
- };
121
-
122
- export const LastStepOverride: Story = {
123
- args: {
124
- startingStep: steps[2],
125
- isLastStep: false,
126
- },
127
- render: (args) => {
128
- return <StoryRender {...args} />;
129
- },
130
- };
131
-
132
- export const WithValidationErrors: Story = {
133
- args: {
134
- startingStep: steps[2],
135
- validationErrors: {
136
- libraryName: ['Library name must be at least 6 characters.'],
137
- },
138
- isLastStep: false,
139
- },
140
- render: (args) => {
141
- return <StoryRender {...args} />;
142
- },
143
- };
@@ -1,107 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- import { TYPOGRAPHY, SPACING, COLORS } from '@/legacy/tokens';
4
-
5
- export const StyledWizardWithSidebar = styled.div<{
6
- backgroundcolor?: string;
7
- color?: string;
8
- buttoncolor?: string;
9
- className?: string;
10
- ['data-cy']?: string;
11
- id?: string;
12
- }>`
13
- height: 750px;
14
- display: flex;
15
- /* display: flex;
16
- /* min-height: 455px; */
17
- background-color: ${(props) => (props.backgroundcolor ? props.backgroundcolor : 'currentColor')};
18
- color: ${(props) => (props.color ? props.color : 'inherit')};
19
- border-radius: 4px;
20
- h2 {
21
- font-size: ${TYPOGRAPHY.fontSize.subheadLarge};
22
- margin-bottom: ${SPACING.md};
23
- color: ${(props) => (props.color ? props.color : 'inherit')};
24
- font-weight: bold;
25
- }
26
-
27
- .wizard-sidebar {
28
- width: 245px;
29
- padding: 30px;
30
- border-right: 1px solid ${COLORS.silverChalice};
31
-
32
- .sidebar-step {
33
- margin-bottom: ${SPACING.sm};
34
- display: flex;
35
- align-items: center;
36
- color: ${COLORS.silverChalice};
37
- &.current-step,
38
- &.prior-step {
39
- color: ${COLORS.black};
40
- }
41
-
42
- &:last-child {
43
- margin-bottom: 0;
44
- }
45
-
46
- .sidebar-step__check-icon {
47
- fill: ${COLORS.green};
48
- margin-right: ${SPACING.sm};
49
- width: 24px;
50
- height: 24px;
51
- }
52
-
53
- .sidebar-step__number-icon {
54
- margin-right: ${SPACING.sm};
55
- width: 24px;
56
- height: 24px;
57
- border-radius: 50%;
58
- border: 1px solid currentColor;
59
- display: flex;
60
- align-items: center;
61
- justify-content: center;
62
- font-size: ${TYPOGRAPHY.fontSize.caption};
63
- }
64
- }
65
- }
66
-
67
- .wizard-content__wrapper {
68
- display: flex;
69
- justify-content: space-between;
70
- flex-wrap: wrap;
71
- flex-direction: column;
72
- height: 100%;
73
- }
74
- .wizard-content {
75
- width: 100%;
76
- padding: 30px;
77
-
78
- .wizard-content__header {
79
- flex: 0 0 100%;
80
- }
81
- .wizard-content__body {
82
- flex: 0 0 100%;
83
- }
84
- }
85
-
86
- .wizard-actions {
87
- width: 100%;
88
- display: flex;
89
- align-items: center;
90
- justify-content: end;
91
- }
92
-
93
- nav {
94
- display: flex;
95
- align-items: center;
96
- justify-content: end;
97
- // override for some styling in AppChrome IPA component
98
- padding-left: 0 !important;
99
- padding-right: 0 !important;
100
- margin-top: ${SPACING.md};
101
- }
102
- .wizard-buttons {
103
- display: flex;
104
- align-items: center;
105
- font-size: ${TYPOGRAPHY.fontSize.subheadSmall};
106
- }
107
- `;
@@ -1,278 +0,0 @@
1
- // TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
2
-
3
- import React, { useEffect, useMemo, useState } from 'react';
4
- import classNames from 'classnames';
5
-
6
- import { ConfirmModal, Icon, IconButton } from '@/legacy/components';
7
- import { Button } from '@/components/button';
8
- import { PermafrostComponent } from '@/types';
9
-
10
- import { StyledWizardWithSidebar } from './WizardWithSidebar.styles';
11
-
12
- export type CancelText = {
13
- // "confirm" button text
14
- confirmText: string;
15
- message?: string;
16
- // "reject" button text
17
- rejectText: string;
18
- title: string;
19
- // Optional, supporting text
20
- };
21
-
22
- type Props = PermafrostComponent & {
23
- children: React.ReactNode;
24
- /**
25
- * text for the cancel confirmation modal
26
- */
27
- confirmCancel: CancelText;
28
- disableNextStep?: boolean;
29
- disablePrevStep?: boolean;
30
- disableSubmit?: boolean;
31
- isLastStep?: boolean;
32
- /**
33
- * for testing/mocking purposes
34
- */
35
- startingStep?: string;
36
- stepSchema: {
37
- [key: string]: {
38
- inputsRequiringValidation: string[];
39
- description: string[];
40
- };
41
- };
42
- /**
43
- * the text to appear on the submit button
44
- */
45
- submitButtonLabel: string;
46
- /**
47
- * Puts button in "busy" mode, and replaces button label with this text
48
- */
49
- submitProcessing?: string;
50
- wizardTitle: string;
51
- onCancel?(): void;
52
- onNextPress?(): boolean;
53
- /**
54
- * returns the current step name to the parent component
55
- */
56
- onStepChange(stepName: string): void;
57
- onSubmit(): void;
58
- /**
59
- * Allows for any custom attribute to be added directly to "next button" in wizard
60
- */
61
- nextButtonProps?: {
62
- 'data-cy': string;
63
- };
64
-
65
- bottomNav?: boolean;
66
- validationErrors?: any;
67
- backgroundColor?: string;
68
- color?: string;
69
- buttonColor?: string;
70
- };
71
-
72
- export function WizardWithSidebar(props: Props) {
73
- const {
74
- children,
75
- className,
76
- confirmCancel,
77
- disableNextStep,
78
- disablePrevStep,
79
- disableSubmit,
80
- id,
81
- isLastStep,
82
- onCancel,
83
- onNextPress,
84
- onStepChange,
85
- onSubmit,
86
- startingStep,
87
- stepSchema,
88
- submitButtonLabel,
89
- submitProcessing = '',
90
- wizardTitle,
91
- nextButtonProps,
92
- validationErrors,
93
- backgroundColor,
94
- color,
95
- buttonColor,
96
- } = props;
97
-
98
- const steps = Object.keys(stepSchema);
99
- const [currentStep, setCurrentStep] = useState<string>(startingStep || steps[0]);
100
- const [openCancelConfirm, setOpenCancelConfirm] = useState<boolean>(false);
101
-
102
- const onLastStep: boolean = useMemo(() => {
103
- if (isLastStep !== undefined) {
104
- return isLastStep;
105
- }
106
-
107
- return steps.indexOf(currentStep) === steps.length - 1;
108
- }, [isLastStep, steps, currentStep]);
109
-
110
- const isBusy = !!(submitProcessing && submitProcessing.length > 0);
111
-
112
- const nextStep = () => {
113
- if (!onLastStep) {
114
- const currentIndex = steps.indexOf(currentStep);
115
-
116
- setCurrentStep(steps[currentIndex + 1]);
117
- }
118
- };
119
-
120
- const prevStep = () => {
121
- const currentIndex = steps.indexOf(currentStep);
122
-
123
- if (currentIndex !== 0) {
124
- setCurrentStep(steps[currentIndex - 1]);
125
- }
126
- };
127
-
128
- // handles the user's selection in the cancel confirmation modal
129
- const handleCancelRequest = (confirmCancel: boolean) => {
130
- if (confirmCancel && onCancel) {
131
- onCancel();
132
- }
133
-
134
- setOpenCancelConfirm(false);
135
- };
136
-
137
- const handleNextPress = () => {
138
- const allowNext = onNextPress ? onNextPress() : true;
139
-
140
- if (!allowNext) {
141
- return;
142
- }
143
-
144
- if (onLastStep) {
145
- handleSubmit();
146
- } else {
147
- nextStep();
148
- }
149
- };
150
-
151
- const handleSubmit = () => {
152
- onSubmit();
153
- };
154
-
155
- // report current step to the consuming component
156
- useEffect(() => {
157
- onStepChange(currentStep);
158
- }, [currentStep]);
159
-
160
- // ensures `currentStep` is reset on unmount, just in case
161
- useEffect(() => {
162
- return () => setCurrentStep(steps[0] || '');
163
- }, []);
164
-
165
- return (
166
- <StyledWizardWithSidebar
167
- className={className}
168
- data-cy={props['data-cy']}
169
- id={id}
170
- backgroundcolor={backgroundColor}
171
- color={color}
172
- buttoncolor={buttonColor}
173
- >
174
- <div className="wizard-sidebar">
175
- <h2> {wizardTitle}</h2>
176
-
177
- {steps.map((step: string, index: number) => {
178
- return (
179
- <div
180
- className={classNames('sidebar-step', {
181
- ['current-step']: index === steps.indexOf(currentStep),
182
- ['prior-step']: index < steps.indexOf(currentStep),
183
- })}
184
- key={step}
185
- >
186
- {(Object.keys(validationErrors ? validationErrors : []).some((error) =>
187
- stepSchema[step].inputsRequiringValidation.includes(error),
188
- ) ||
189
- index > steps.indexOf(currentStep)) && (
190
- <div className="sidebar-step__number-icon">{index + 1}</div>
191
- )}
192
-
193
- {!Object.keys(validationErrors ? validationErrors : []).some((error) =>
194
- stepSchema[step].inputsRequiringValidation.includes(error),
195
- ) &&
196
- index <= steps.indexOf(currentStep) && (
197
- <Icon name="fa-check-circle" className="sidebar-step__check-icon" />
198
- )}
199
- {step}
200
- </div>
201
- );
202
- })}
203
- </div>
204
- <div className="wizard-content">
205
- <div className="wizard-content__wrapper">
206
- <div className="wizard-content__items">
207
- <div className="wizard-content__header">
208
- <h2>{currentStep}</h2>
209
- </div>
210
- <div className="wizard-content__body">{children}</div>
211
- </div>
212
- <nav className="wizard-actions">
213
- <div className="wizard-buttons">
214
- <Button
215
- ariaLabel="cancel"
216
- variant="text"
217
- color="secondary"
218
- onClick={() => setOpenCancelConfirm(true)}
219
- >
220
- Cancel
221
- </Button>
222
-
223
- {steps.indexOf(currentStep) !== 0 && (
224
- <Button
225
- variant="outline"
226
- color="secondary"
227
- iconName="fa-arrow-left"
228
- ariaLabel="previous step"
229
- onClick={prevStep}
230
- isDisabled={disablePrevStep}
231
- className="mr-1"
232
- >
233
- Previous Step
234
- </Button>
235
- )}
236
-
237
- {onLastStep ? (
238
- <Button
239
- ariaLabel="submit"
240
- iconName="check"
241
- color="secondary"
242
- isLoading={isBusy}
243
- onClick={handleNextPress}
244
- isDisabled={disableSubmit}
245
- >
246
- {isBusy ? submitProcessing : submitButtonLabel}
247
- </Button>
248
- ) : (
249
- <Button
250
- ariaLabel="next step"
251
- iconPosition="right"
252
- color="secondary"
253
- iconName="fa-arrow-right"
254
- onClick={handleNextPress}
255
- isDisabled={disableNextStep}
256
- {...nextButtonProps}
257
- >
258
- Next Step
259
- </Button>
260
- )}
261
- </div>
262
- </nav>
263
- </div>
264
- </div>
265
-
266
- <ConfirmModal
267
- title={confirmCancel.title}
268
- message={confirmCancel.message}
269
- confirmText={confirmCancel.confirmText}
270
- rejectText={confirmCancel.rejectText}
271
- open={openCancelConfirm}
272
- clickOutsideHandler={() => setOpenCancelConfirm(false)}
273
- responseHandler={handleCancelRequest}
274
- width={430}
275
- />
276
- </StyledWizardWithSidebar>
277
- );
278
- }
@@ -1,2 +0,0 @@
1
- export { WizardWithSidebar } from './WizardWithSidebar';
2
- export { StyledWizardWithSidebar } from './WizardWithSidebar.styles';