@orchestrator-ui/orchestrator-ui-components 3.10.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/.turbo/turbo-lint.log +2 -11
  3. package/.turbo/turbo-test.log +6 -6
  4. package/CHANGELOG.md +319 -307
  5. package/dist/index.d.ts +812 -794
  6. package/dist/index.js +1047 -488
  7. package/dist/index.js.map +1 -1
  8. package/eslint.config.js +5 -0
  9. package/package.json +6 -7
  10. package/src/components/WfoForms/UserInputForm.tsx +0 -1
  11. package/src/components/WfoForms/formFields/AcceptField.tsx +2 -2
  12. package/src/components/WfoForms/formFields/ListSelectField.tsx +0 -1
  13. package/src/components/WfoForms/formFields/SelectField/SelectField.tsx +1 -1
  14. package/src/components/WfoForms/formFields/deprecated/ImsNodeIdField.tsx +2 -2
  15. package/src/components/WfoForms/formFields/deprecated/ImsPortIdField.tsx +2 -2
  16. package/src/components/WfoForms/formFields/deprecated/VlanField.tsx +11 -11
  17. package/src/components/WfoPageTemplate/WfoPageHeader/WfoHamburgerMenu.tsx +1 -1
  18. package/src/components/WfoSubscription/WfoCustomerDescriptionsField.tsx +2 -3
  19. package/src/components/WfoTable/WfoTableSettingsModal/WfoTableSettingsModal.tsx +1 -1
  20. package/src/components/WfoWorkflowSteps/WfoStep/WfoStep.tsx +4 -2
  21. package/src/components/WfoWorkflowSteps/WfoWorkflowStepList/WfoWorkflowStepList.tsx +4 -6
  22. package/src/configuration/version.ts +1 -1
  23. package/src/pages/processes/WfoProcessDetail.tsx +3 -3
  24. package/src/rtk/api.ts +4 -2
  25. package/src/types/types.ts +1 -1
  26. package/src/utils/getDefaultTableConfig.ts +20 -16
  27. package/src/utils/getEnvironmentVariables.ts +13 -10
  28. package/eslintrc.js +0 -3
  29. package/src/stories/Button.jsx +0 -62
  30. package/src/stories/Button.stories.js +0 -45
  31. package/src/stories/Configure.mdx +0 -452
  32. package/src/stories/Header.jsx +0 -74
  33. package/src/stories/Header.stories.js +0 -23
  34. package/src/stories/Page.jsx +0 -89
  35. package/src/stories/Page.stories.js +0 -25
  36. package/src/stories/assets/accessibility.png +0 -0
  37. package/src/stories/assets/accessibility.svg +0 -5
  38. package/src/stories/assets/addon-library.png +0 -0
  39. package/src/stories/assets/assets.png +0 -0
  40. package/src/stories/assets/context.png +0 -0
  41. package/src/stories/assets/discord.svg +0 -15
  42. package/src/stories/assets/docs.png +0 -0
  43. package/src/stories/assets/figma-plugin.png +0 -0
  44. package/src/stories/assets/github.svg +0 -3
  45. package/src/stories/assets/share.png +0 -0
  46. package/src/stories/assets/styling.png +0 -0
  47. package/src/stories/assets/testing.png +0 -0
  48. package/src/stories/assets/theming.png +0 -0
  49. package/src/stories/assets/tutorials.svg +0 -12
  50. package/src/stories/assets/youtube.svg +0 -4
  51. package/src/stories/button.css +0 -30
  52. package/src/stories/colors.mdx +0 -13
  53. package/src/stories/header.css +0 -32
  54. package/src/stories/page.css +0 -69
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from 'eslint/config';
2
+
3
+ import wfoConfig from '@orchestrator-ui/eslint-config-custom';
4
+
5
+ export default defineConfig([wfoConfig]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchestrator-ui/orchestrator-ui-components",
3
- "version": "3.10.0",
3
+ "version": "4.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Library of UI Components used to display the workflow orchestrator frontend",
6
6
  "author": {
@@ -30,26 +30,25 @@
30
30
  "generate-version": "node -p \"'export const ORCHESTRATOR_UI_LIBRARY_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/configuration/version.ts && prettier --write src/configuration/version.ts",
31
31
  "build": "npm run generate-version && tsup src/index.ts",
32
32
  "tsc": "tsc --noEmit",
33
- "lint": "eslint \"src/**/*.ts*\"",
33
+ "lint": "eslint",
34
34
  "dev": "npm run build -- --watch"
35
35
  },
36
36
  "dependencies": {
37
- "@elastic/eui": "^97.0.0",
37
+ "@elastic/eui": "101.3.0",
38
38
  "@emotion/css": "^11.11.2",
39
39
  "@emotion/react": "^11.11.4",
40
40
  "@rtk-query/graphql-request-base-query": "^2.3.1",
41
- "eslint": "^8.57.0",
42
41
  "graphql-request": "^6.1.0",
43
42
  "invariant": "^2.2.4",
44
43
  "lodash": "^4.17.21",
45
44
  "moment": "^2.29.4",
46
45
  "moment-timezone": "^0.5.43",
47
46
  "next-auth": "^4.24.5",
48
- "next-intl": "^3.4.1",
47
+ "next-intl": "^3.26.5",
49
48
  "next-query-params": "^5.0.0",
50
49
  "object-hash": "^3.0.0",
51
50
  "prism-themes": "^1.9.0",
52
- "pydantic-forms": "^0.0.18",
51
+ "pydantic-forms": "^0.1.2",
53
52
  "react-diff-view": "^3.2.0",
54
53
  "react-draggable": "^4.4.6",
55
54
  "react-redux": "^9.1.2",
@@ -81,7 +80,7 @@
81
80
  "uniforms-bridge-simple-schema-2": "^3.8.1"
82
81
  },
83
82
  "peerDependencies": {
84
- "next": "^14.2.25 || ^15.2.3",
83
+ "next": "^15.3.1",
85
84
  "react": "^18.3.1",
86
85
  "react-dom": "^18.3.1"
87
86
  },
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
2
  /*
4
3
  * Copyright 2019-2023 SURF.
5
4
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -114,8 +114,8 @@ function Accept({
114
114
  state.skip
115
115
  ? 'SKIPPED'
116
116
  : state.allChecked
117
- ? 'ACCEPTED'
118
- : 'INCOMPLETE',
117
+ ? 'ACCEPTED'
118
+ : 'INCOMPLETE',
119
119
  );
120
120
 
121
121
  return { ...state };
@@ -12,7 +12,6 @@
12
12
  * limitations under the License.
13
13
  *
14
14
  */
15
-
16
15
  /* NOTE: This component is only needed to avoid the circular import that started to be a problem
17
16
  after the upgrade to react-script 5.0. The original SelectField would import itself to handle the list:
18
17
  that seems to be impossible with the new webpack.
@@ -101,7 +101,7 @@ export function UnconnectedSelectField({
101
101
  if (selectedValue && selectedValue.value !== 'undefined') {
102
102
  onChange(selectedValue.value);
103
103
  }
104
- }, []);
104
+ }, [onChange, selectedValue]);
105
105
 
106
106
  if (fieldType === Array) {
107
107
  // Avoid circular import with our own ListSelectField (instead of recursively trying to use SelectField)
@@ -80,8 +80,8 @@ function ImsNodeId({
80
80
  isLoading && locationCode
81
81
  ? t('widgets.node_select.nodes_loading')
82
82
  : nodes.length
83
- ? t('widgets.node_select.select_node')
84
- : t('forms.widgets.node_select.no_nodes_placeholder');
83
+ ? t('widgets.node_select.select_node')
84
+ : t('forms.widgets.node_select.no_nodes_placeholder');
85
85
 
86
86
  const imsNodeIdLabelLookup =
87
87
  nodes?.reduce<{ [index: string]: string }>(function (mapping, node) {
@@ -140,8 +140,8 @@ function ImsPortId({
140
140
  const portPlaceholder = loading
141
141
  ? t('widgets.nodePort.loadingPorts')
142
142
  : nodeId
143
- ? t('widgets.nodePort.selectPort')
144
- : t('widgets.nodePort.selectNodeFirst');
143
+ ? t('widgets.nodePort.selectPort')
144
+ : t('widgets.nodePort.selectNodeFirst');
145
145
 
146
146
  const nodeOptions: Option[] =
147
147
  nodeSubscriptionOptions?.map(nodeToOptionCorelink) || [];
@@ -165,7 +165,7 @@ function Vlan({
165
165
  ) {
166
166
  onChange('');
167
167
  }
168
- }, [onChange, subscriptionId, isFetched, portIsTagged]);
168
+ }, [onChange, subscriptionId, isFetched, portIsTagged, value, disabled]);
169
169
 
170
170
  const [usedVlansInIms, setUsedVlansInIms] = useState<VlanRange[]>([]);
171
171
  const [missingInIms, setMissingInIms] = useState(false);
@@ -212,20 +212,20 @@ function Vlan({
212
212
  const placeholder = isLoading
213
213
  ? t('widgets.vlan.loadingIms')
214
214
  : subscriptionId
215
- ? t('widgets.vlan.placeholder')
216
- : t('widgets.vlan.placeholderNoServicePort');
215
+ ? t('widgets.vlan.placeholder')
216
+ : t('widgets.vlan.placeholderNoServicePort');
217
217
 
218
218
  const errorMessageExtra = missingInIms
219
219
  ? t('widgets.vlan.missingInIms')
220
220
  : !validFormat
221
- ? t('widgets.vlan.invalidVlan')
222
- : vlansInUse.length
223
- ? vlansInUse.length >= 1 && vlansInUse[0] === 0
224
- ? t('widgets.vlan.untaggedPortInUse')
225
- : t('widgets.vlan.vlansInUseError', {
226
- vlans: vlanRangeFromNumbers(vlansInUse),
227
- })
228
- : undefined;
221
+ ? t('widgets.vlan.invalidVlan')
222
+ : vlansInUse.length
223
+ ? vlansInUse.length >= 1 && vlansInUse[0] === 0
224
+ ? t('widgets.vlan.untaggedPortInUse')
225
+ : t('widgets.vlan.vlansInUseError', {
226
+ vlans: vlanRangeFromNumbers(vlansInUse),
227
+ })
228
+ : undefined;
229
229
 
230
230
  let message = '';
231
231
  if (!isLoading && subscriptionId) {
@@ -14,7 +14,7 @@ import { WfoQuestionCircle } from '@/icons/WfoQuestionCircle';
14
14
  import { useGetVersionsQuery } from '@/rtk/endpoints/versions';
15
15
  import { toOptionalArrayEntry } from '@/utils';
16
16
 
17
- export const WfoHamburgerMenu = ({}) => {
17
+ export const WfoHamburgerMenu = () => {
18
18
  const t = useTranslations('hamburgerMenu');
19
19
  const [isPopoverOpen, setPopoverIsOpen] = useState(false);
20
20
  const { theme, isDarkThemeActive } = useOrchestratorTheme();
@@ -28,9 +28,8 @@ export const WfoCustomerDescriptionsField: FC<
28
28
  customerDescriptionsCustomerNameStyle,
29
29
  customerDescriptionsFormStyle,
30
30
  } = useWithOrchestratorTheme(getSubscriptionDetailStyles);
31
- const [updateCustomerDescription, {}] =
32
- useUpdateCustomerDescriptionMutation();
33
- const [setCustomerDescription, {}] = useSetCustomerDescriptionMutation();
31
+ const [updateCustomerDescription] = useUpdateCustomerDescriptionMutation();
32
+ const [setCustomerDescription] = useSetCustomerDescriptionMutation();
34
33
  const customerIds = customerDescriptions.map(
35
34
  (customerDescription) => customerDescription.customerId,
36
35
  );
@@ -85,7 +85,7 @@ export const TableSettingsModal = <T,>({
85
85
  {columns.map(({ field, name, isVisible }) => (
86
86
  <div key={field.toString()}>
87
87
  <EuiFormRow
88
- display="columnCompressedSwitch"
88
+ display="columnCompressed"
89
89
  label={name}
90
90
  css={formRowStyle}
91
91
  >
@@ -60,8 +60,10 @@ export const WfoStep = React.forwardRef(
60
60
  getStepToggleExpandStyle,
61
61
  } = useWithOrchestratorTheme(getWorkflowStepsStyles);
62
62
  const t = useTranslations('processes.steps');
63
- const hasHtmlMail =
64
- step.stateDelta?.hasOwnProperty('confirmation_mail');
63
+ const hasHtmlMail = Object.prototype.hasOwnProperty.call(
64
+ step?.stateDelta || {},
65
+ 'confirmation_mail',
66
+ );
65
67
 
66
68
  const stepContent = step.stateDelta
67
69
  ? getStepContent(step.stateDelta, showHiddenKeys)
@@ -43,14 +43,12 @@ export const WfoProcessSubscriptionDelta = ({
43
43
  }) => {
44
44
  const { data, isFetching } = useGetRawProcessDetailQuery({ processId });
45
45
 
46
- const subscriptionKey =
46
+ const subscriptionId =
47
47
  data?.current_state?.subscription?.subscription_id ?? '';
48
48
  const newText = data?.current_state?.subscription ?? null;
49
- const oldText =
50
- data?.current_state?.__old_subscriptions__ &&
51
- subscriptionKey in data?.current_state?.__old_subscriptions__
52
- ? data?.current_state?.__old_subscriptions__[subscriptionKey]
53
- : null;
49
+ const oldSubscriptions = data?.current_state?.__old_subscriptions__ || {};
50
+ const oldSubscription = subscriptionId in oldSubscriptions;
51
+ const oldText = oldSubscription || null;
54
52
 
55
53
  return isFetching ? (
56
54
  <WfoLoading />
@@ -1 +1 @@
1
- export const ORCHESTRATOR_UI_LIBRARY_VERSION = '3.10.0';
1
+ export const ORCHESTRATOR_UI_LIBRARY_VERSION = '4.0.1';
@@ -154,7 +154,7 @@ export const WfoProcessDetail = ({
154
154
  question: t(
155
155
  processIsTask ? 'retryTaskQuestion' : 'retryWorkflowQuestion',
156
156
  {
157
- workflowName: processDetail?.workflowName,
157
+ workflowName: processDetail?.workflowName || '',
158
158
  },
159
159
  ),
160
160
  onConfirm: () => {
@@ -169,7 +169,7 @@ export const WfoProcessDetail = ({
169
169
  question: t(
170
170
  processIsTask ? 'abortTaskQuestion' : 'abortWorkflowQuestion',
171
171
  {
172
- workflowName: processDetail?.workflowName,
172
+ workflowName: processDetail?.workflowName || '',
173
173
  },
174
174
  ),
175
175
  onConfirm: () => {
@@ -183,7 +183,7 @@ export const WfoProcessDetail = ({
183
183
  const deleteAction = () =>
184
184
  showConfirmDialog({
185
185
  question: t('deleteQuestion', {
186
- workflowName: processDetail?.workflowName,
186
+ workflowName: processDetail?.workflowName || '',
187
187
  }),
188
188
  onConfirm: () => {
189
189
  if (processDetail?.processId) {
package/src/rtk/api.ts CHANGED
@@ -142,7 +142,7 @@ export const orchestratorApi = createApi({
142
142
  );
143
143
 
144
144
  switch (baseQueryType) {
145
- case BaseQueryTypes.fetch:
145
+ case BaseQueryTypes.fetch: {
146
146
  const fetchFn = fetchBaseQuery({
147
147
  baseUrl: customApi
148
148
  ? customApi.apiBaseUrl
@@ -152,7 +152,8 @@ export const orchestratorApi = createApi({
152
152
  catchErrorResponse(response, authActive),
153
153
  });
154
154
  return fetchFn(args, api, {});
155
- default:
155
+ }
156
+ default: {
156
157
  const graphqlFn = wfoGraphqlRequestBaseQuery(
157
158
  {
158
159
  url: customApi
@@ -166,6 +167,7 @@ export const orchestratorApi = createApi({
166
167
  authActive,
167
168
  );
168
169
  return graphqlFn(args, api, {});
170
+ }
169
171
  }
170
172
  },
171
173
  endpoints: () => ({}),
@@ -304,7 +304,7 @@ export type GraphQLPageInfo = {
304
304
  hasNextPage: boolean;
305
305
  hasPreviousPage: boolean;
306
306
  startCursor: number | null;
307
- totalItems: number | null;
307
+ totalItems: number;
308
308
  endCursor: number | null;
309
309
  sortFields: string[];
310
310
  filterFields: string[];
@@ -33,7 +33,7 @@ function getTableConfig<T>(
33
33
 
34
34
  export const getDefaultTableConfig = <T>(storageKey: string) => {
35
35
  switch (storageKey) {
36
- case METADATA_PRODUCT_BLOCKS_TABLE_LOCAL_STORAGE_KEY:
36
+ case METADATA_PRODUCT_BLOCKS_TABLE_LOCAL_STORAGE_KEY: {
37
37
  const productBlockColumns: (keyof ProductBlockDefinition)[] = [
38
38
  'productBlockId',
39
39
  'status',
@@ -41,14 +41,14 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
41
41
  'createdAt',
42
42
  ];
43
43
  return getTableConfig<T>(productBlockColumns as (keyof T)[]);
44
-
45
- case METADATA_RESOURCE_TYPES_TABLE_LOCAL_STORAGE_KEY:
44
+ }
45
+ case METADATA_RESOURCE_TYPES_TABLE_LOCAL_STORAGE_KEY: {
46
46
  const resourceTypeColumns: (keyof ResourceTypeDefinition)[] = [
47
47
  'resourceTypeId',
48
48
  ];
49
49
  return getTableConfig<T>(resourceTypeColumns as (keyof T)[]);
50
-
51
- case METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY:
50
+ }
51
+ case METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY: {
52
52
  const productColumns: (keyof ProductDefinition)[] = [
53
53
  'productId',
54
54
  'productType',
@@ -56,22 +56,22 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
56
56
  'createdAt',
57
57
  ];
58
58
  return getTableConfig<T>(productColumns as (keyof T)[]);
59
-
60
- case METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY:
59
+ }
60
+ case METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY: {
61
61
  const workflowColumns: (keyof WorkflowDefinition)[] = [
62
62
  'workflowId',
63
63
  'createdAt',
64
64
  ];
65
65
  return getTableConfig<T>(workflowColumns as (keyof T)[]);
66
-
67
- case METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY:
66
+ }
67
+ case METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY: {
68
68
  const taskColumns: (keyof WorkflowDefinition)[] = [
69
69
  'workflowId',
70
70
  'createdAt',
71
71
  ];
72
72
  return getTableConfig<T>(taskColumns as (keyof T)[]);
73
-
74
- case ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY:
73
+ }
74
+ case ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY: {
75
75
  const activeProcessColumns: (keyof ProcessListItem)[] = [
76
76
  'productName',
77
77
  'customer',
@@ -80,8 +80,8 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
80
80
  'startedAt',
81
81
  ];
82
82
  return getTableConfig<T>(activeProcessColumns as (keyof T)[]);
83
-
84
- case COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY:
83
+ }
84
+ case COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY: {
85
85
  const completedProcessColumns: (keyof ProcessListItem)[] = [
86
86
  'lastStep',
87
87
  'productName',
@@ -91,7 +91,8 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
91
91
  'startedAt',
92
92
  ];
93
93
  return getTableConfig<T>(completedProcessColumns as (keyof T)[]);
94
- case ACTIVE_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY:
94
+ }
95
+ case ACTIVE_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY: {
95
96
  const activeTasksColumns: (keyof ProcessListItem)[] = [
96
97
  'assignee',
97
98
  'workflowTarget',
@@ -100,7 +101,8 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
100
101
  'processId',
101
102
  ];
102
103
  return getTableConfig<T>(activeTasksColumns as (keyof T)[]);
103
- case COMPLETED_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY:
104
+ }
105
+ case COMPLETED_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY: {
104
106
  const completedTasksColumns: (keyof ProcessListItem)[] = [
105
107
  'assignee',
106
108
  'workflowTarget',
@@ -109,13 +111,15 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
109
111
  'processId',
110
112
  ];
111
113
  return getTableConfig<T>(completedTasksColumns as (keyof T)[]);
112
- case SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY:
114
+ }
115
+ case SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY: {
113
116
  const subscriptionColumns: (keyof SubscriptionListItem)[] = [
114
117
  'productName',
115
118
  'customerFullname',
116
119
  'metadata',
117
120
  ];
118
121
  return getTableConfig<T>(subscriptionColumns as (keyof T)[]);
122
+ }
119
123
  default:
120
124
  return getTableConfig();
121
125
  }
@@ -7,18 +7,21 @@ export function getEnvironmentVariables<T>(
7
7
  ): Record<keyof T, string> {
8
8
  const missingEnvironmentVariables: string[] = [];
9
9
 
10
- const environmentVariablesWithValues = envVars.reduce((acc, currentKey) => {
11
- const value = process.env[currentKey.toString()];
10
+ const environmentVariablesWithValues = envVars.reduce(
11
+ (acc, currentKey) => {
12
+ const value = process.env[currentKey.toString()];
12
13
 
13
- if (value === undefined) {
14
- missingEnvironmentVariables.push(currentKey.toString());
15
- }
14
+ if (value === undefined) {
15
+ missingEnvironmentVariables.push(currentKey.toString());
16
+ }
16
17
 
17
- return {
18
- ...acc,
19
- [currentKey]: value || '',
20
- };
21
- }, {} as Record<keyof T, string>);
18
+ return {
19
+ ...acc,
20
+ [currentKey]: value || '',
21
+ };
22
+ },
23
+ {} as Record<keyof T, string>,
24
+ );
22
25
 
23
26
  if (missingEnvironmentVariables.length > 0) {
24
27
  console.warn(
package/eslintrc.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['@orchestrator-ui/eslint-config-custom'],
3
- };
@@ -1,62 +0,0 @@
1
- import React from 'react';
2
-
3
- import PropTypes from 'prop-types';
4
-
5
- import './button.css';
6
-
7
- /**
8
- * Primary UI component for user interaction
9
- */
10
- export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
11
- const mode = primary
12
- ? 'storybook-button--primary'
13
- : 'storybook-button--secondary';
14
- return (
15
- <button
16
- type="button"
17
- className={[
18
- 'storybook-button',
19
- `storybook-button--${size}`,
20
- mode,
21
- ].join(' ')}
22
- {...props}
23
- >
24
- {label}
25
- <style jsx>{`
26
- button {
27
- background-color: ${backgroundColor};
28
- }
29
- `}</style>
30
- </button>
31
- );
32
- };
33
-
34
- Button.propTypes = {
35
- /**
36
- * Is this the principal call to action on the page?
37
- */
38
- primary: PropTypes.bool,
39
- /**
40
- * What background color to use
41
- */
42
- backgroundColor: PropTypes.string,
43
- /**
44
- * How large should the button be?
45
- */
46
- size: PropTypes.oneOf(['small', 'medium', 'large']),
47
- /**
48
- * Button contents
49
- */
50
- label: PropTypes.string.isRequired,
51
- /**
52
- * Optional click handler
53
- */
54
- onClick: PropTypes.func,
55
- };
56
-
57
- Button.defaultProps = {
58
- backgroundColor: null,
59
- primary: false,
60
- size: 'medium',
61
- onClick: undefined,
62
- };
@@ -1,45 +0,0 @@
1
- import { Button } from './Button';
2
-
3
- // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
4
- export default {
5
- title: 'Example/Button',
6
- component: Button,
7
- parameters: {
8
- // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
9
- layout: 'centered',
10
- },
11
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
12
- tags: ['autodocs'],
13
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
14
- argTypes: {
15
- backgroundColor: { control: 'color' },
16
- },
17
- };
18
-
19
- // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
20
- export const Primary = {
21
- args: {
22
- primary: true,
23
- label: 'Button',
24
- },
25
- };
26
-
27
- export const Secondary = {
28
- args: {
29
- label: 'Button',
30
- },
31
- };
32
-
33
- export const Large = {
34
- args: {
35
- size: 'large',
36
- label: 'Button',
37
- },
38
- };
39
-
40
- export const Small = {
41
- args: {
42
- size: 'small',
43
- label: 'Button',
44
- },
45
- };