diff --git a/extensions/cornerstone-dicom-rt/src/utils/promptHydrateRT.ts b/extensions/cornerstone-dicom-rt/src/utils/promptHydrateRT.ts index 4af78caeeb7..29e99bd044b 100644 --- a/extensions/cornerstone-dicom-rt/src/utils/promptHydrateRT.ts +++ b/extensions/cornerstone-dicom-rt/src/utils/promptHydrateRT.ts @@ -1,3 +1,4 @@ +import { ButtonEnums } from '@ohif/ui'; import hydrateRTDisplaySet from './_hydrateRT'; const RESPONSE = { @@ -38,12 +39,12 @@ function _askHydrate(uiViewportDialogService, viewportIndex) { const message = 'Do you want to open this Segmentation?'; const actions = [ { - type: 'secondary', + type: ButtonEnums.type.secondary, text: 'No', value: RESPONSE.CANCEL, }, { - type: 'primary', + type: ButtonEnums.type.primary, text: 'Yes', value: RESPONSE.HYDRATE_SEG, }, diff --git a/extensions/cornerstone-dicom-seg/src/panels/callInputDialog.tsx b/extensions/cornerstone-dicom-seg/src/panels/callInputDialog.tsx index 69c30346975..6909d93fcde 100644 --- a/extensions/cornerstone-dicom-seg/src/panels/callInputDialog.tsx +++ b/extensions/cornerstone-dicom-seg/src/panels/callInputDialog.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Input, Dialog } from '@ohif/ui'; +import { Input, Dialog, ButtonEnums } from '@ohif/ui'; function callInputDialog(uiDialogService, label, callback) { const dialogId = 'enter-segment-label'; @@ -29,8 +29,8 @@ function callInputDialog(uiDialogService, label, callback) { noCloseButton: true, onClose: () => uiDialogService.dismiss({ id: dialogId }), actions: [ - { id: 'cancel', text: 'Cancel', type: 'primary' }, - { id: 'save', text: 'Confirm', type: 'secondary' }, + { id: 'cancel', text: 'Cancel', type: ButtonEnums.type.secondary }, + { id: 'save', text: 'Confirm', type: ButtonEnums.type.primary }, ], onSubmit: onSubmitHandler, body: ({ value, setValue }) => { diff --git a/extensions/cornerstone-dicom-seg/src/utils/promptHydrateSEG.ts b/extensions/cornerstone-dicom-seg/src/utils/promptHydrateSEG.ts index c0b9385f130..7d6ee24523a 100644 --- a/extensions/cornerstone-dicom-seg/src/utils/promptHydrateSEG.ts +++ b/extensions/cornerstone-dicom-seg/src/utils/promptHydrateSEG.ts @@ -1,3 +1,4 @@ +import { ButtonEnums } from '@ohif/ui'; import hydrateSEGDisplaySet from './_hydrateSEG'; const RESPONSE = { @@ -6,11 +7,7 @@ const RESPONSE = { HYDRATE_SEG: 5, }; -function promptHydrateSEG({ - servicesManager, - segDisplaySet, - viewportIndex, -}) { +function promptHydrateSEG({ servicesManager, segDisplaySet, viewportIndex }) { const { uiViewportDialogService } = servicesManager.services; return new Promise(async function(resolve, reject) { @@ -36,12 +33,12 @@ function _askHydrate(uiViewportDialogService, viewportIndex) { const message = 'Do you want to open this Segmentation?'; const actions = [ { - type: 'secondary', + type: ButtonEnums.type.secondary, text: 'No', value: RESPONSE.CANCEL, }, { - type: 'primary', + type: ButtonEnums.type.primary, text: 'Yes', value: RESPONSE.HYDRATE_SEG, }, diff --git a/extensions/cornerstone/src/components/DicomUpload/DicomUpload.tsx b/extensions/cornerstone/src/components/DicomUpload/DicomUpload.tsx index 26e596e9522..e90728cb368 100644 --- a/extensions/cornerstone/src/components/DicomUpload/DicomUpload.tsx +++ b/extensions/cornerstone/src/components/DicomUpload/DicomUpload.tsx @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import DicomFileUploader from '../../utils/DicomFileUploader'; import DicomUploadProgress from './DicomUploadProgress'; -import { Button } from '@ohif/ui'; +import { Button, ButtonEnums } from '@ohif/ui'; import './DicomUpload.css'; type DicomUploadProps = { @@ -46,12 +46,7 @@ function DicomUpload({ {({ getRootProps, getInputProps }) => (
- @@ -62,9 +57,7 @@ function DicomUpload({ {({ getRootProps, getInputProps }) => (
diff --git a/extensions/cornerstone/src/utils/callInputDialog.tsx b/extensions/cornerstone/src/utils/callInputDialog.tsx index b141ece63b5..efcd83c3ccc 100644 --- a/extensions/cornerstone/src/utils/callInputDialog.tsx +++ b/extensions/cornerstone/src/utils/callInputDialog.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Input, Dialog } from '@ohif/ui'; +import { Input, Dialog, ButtonEnums } from '@ohif/ui'; /** * @@ -60,8 +60,8 @@ function callInputDialog( noCloseButton: true, onClose: () => uiDialogService.dismiss({ id: dialogId }), actions: [ - { id: 'cancel', text: 'Cancel', type: 'primary' }, - { id: 'save', text: 'Save', type: 'secondary' }, + { id: 'cancel', text: 'Cancel', type: ButtonEnums.type.secondary }, + { id: 'save', text: 'Save', type: ButtonEnums.type.primary }, ], onSubmit: onSubmitHandler, body: ({ value, setValue }) => { diff --git a/extensions/default/src/Panels/ActionButtons.tsx b/extensions/default/src/Panels/ActionButtons.tsx index f372a1ee086..133f2b81409 100644 --- a/extensions/default/src/Panels/ActionButtons.tsx +++ b/extensions/default/src/Panels/ActionButtons.tsx @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; -import { Button, ButtonGroup } from '@ohif/ui'; +import { LegacyButton, ButtonGroup } from '@ohif/ui'; function ActionButtons({ onExportClick, onCreateReportClick }) { const { t } = useTranslation('MeasurementTable'); @@ -10,12 +10,16 @@ function ActionButtons({ onExportClick, onCreateReportClick }) { return ( - - + ); diff --git a/extensions/default/src/Panels/DataSourceSelector.tsx b/extensions/default/src/Panels/DataSourceSelector.tsx index decb24ad83d..06ed1890955 100644 --- a/extensions/default/src/Panels/DataSourceSelector.tsx +++ b/extensions/default/src/Panels/DataSourceSelector.tsx @@ -3,7 +3,7 @@ import classnames from 'classnames'; import { useNavigate } from 'react-router-dom'; import { useAppConfig } from '@state'; -import { Button } from '@ohif/ui'; +import { Button, ButtonEnums } from '@ohif/ui'; function DataSourceSelector() { const [appConfig] = useAppConfig(); @@ -33,7 +33,8 @@ function DataSourceSelector() {

{ds.friendlyName}

), actions: [ - { id: 'cancel', text: 'Cancel', type: 'secondary' }, + { + id: 'cancel', + text: 'Cancel', + type: ButtonEnums.type.secondary, + }, { id: 'yes', text: 'Yes', - type: 'primary', + type: ButtonEnums.type.primary, classes: ['reject-yes-button'], }, ], diff --git a/extensions/tmtv/src/Panels/PanelPetSUV.tsx b/extensions/tmtv/src/Panels/PanelPetSUV.tsx index 9cb5dbfd610..52f90fad1e4 100644 --- a/extensions/tmtv/src/Panels/PanelPetSUV.tsx +++ b/extensions/tmtv/src/Panels/PanelPetSUV.tsx @@ -225,9 +225,7 @@ export default function PanelPetSUV({ servicesManager, commandsManager }) { value={metadata.SeriesTime || ''} onChange={() => {}} /> - +
} diff --git a/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/ExportReports.tsx b/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/ExportReports.tsx index 415b80015e4..020ccc4d4c7 100644 --- a/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/ExportReports.tsx +++ b/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/ExportReports.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Button, ButtonGroup } from '@ohif/ui'; +import { LegacyButton, ButtonGroup } from '@ohif/ui'; import { useTranslation } from 'react-i18next'; function ExportReports({ segmentations, tmtvValue, config, commandsManager }) { @@ -9,8 +9,9 @@ function ExportReports({ segmentations, tmtvValue, config, commandsManager }) { <> {segmentations?.length ? (
+ {/* TODO Revisit design of ButtonGroup later - for now use LegacyButton for its children.*/} - + - +
) : null} diff --git a/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/PanelROIThresholdSegmentation.tsx b/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/PanelROIThresholdSegmentation.tsx index a18dee1c2d7..799376b72d5 100644 --- a/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/PanelROIThresholdSegmentation.tsx +++ b/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/PanelROIThresholdSegmentation.tsx @@ -181,7 +181,6 @@ export default function PanelRoiThresholdSegmentation({
- +
+ {/* TODO Revisit design of ButtonGroup later - for now use LegacyButton for its children.*/} - - +
diff --git a/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/segmentationEditHandler.tsx b/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/segmentationEditHandler.tsx index bfa4d01779e..50ab5cbc6d4 100644 --- a/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/segmentationEditHandler.tsx +++ b/extensions/tmtv/src/Panels/PanelROIThresholdSegmentation/segmentationEditHandler.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Input, Dialog } from '@ohif/ui'; +import { Input, Dialog, ButtonEnums } from '@ohif/ui'; function segmentationItemEditHandler({ id, servicesManager }) { const { segmentationService, uiDialogService } = servicesManager.services; @@ -44,23 +44,20 @@ function segmentationItemEditHandler({ id, servicesManager }) { } }; return ( -
- -
+ ); }, actions: [ - // temp: swap button types until colors are updated - { id: 'cancel', text: 'Cancel', type: 'primary' }, - { id: 'save', text: 'Save', type: 'secondary' }, + { id: 'cancel', text: 'Cancel', type: ButtonEnums.type.secondary }, + { id: 'save', text: 'Save', type: ButtonEnums.type.primary }, ], onSubmit: onSubmitHandler, }, diff --git a/platform/app/cypress/integration/measurement-tracking/OHIFContextMenuCustomization.spec.js b/platform/app/cypress/integration/measurement-tracking/OHIFContextMenuCustomization.spec.js index e87f1bb80c3..2d65781262c 100644 --- a/platform/app/cypress/integration/measurement-tracking/OHIFContextMenuCustomization.spec.js +++ b/platform/app/cypress/integration/measurement-tracking/OHIFContextMenuCustomization.spec.js @@ -1,5 +1,5 @@ -describe('OHIF Context Menu', function () { - beforeEach(function () { +describe('OHIF Context Menu', function() { + beforeEach(function() { cy.checkStudyRouteInViewer( '1.2.840.113619.2.5.1762583153.215519.978957063.78' ); @@ -10,10 +10,10 @@ describe('OHIF Context Menu', function () { cy.resetViewport().wait(50); }); - it('checks context menu customization', function () { + it('checks context menu customization', function() { // Add length measurement cy.addLengthMeasurement(); - cy.get('[data-cy="prompt-begin-tracking-yes"]').click(); + cy.get('[data-cy="prompt-begin-tracking-yes-btn"]').click(); cy.get('[data-cy="measurement-item"]').click(); const [x1, y1] = [150, 100]; diff --git a/platform/app/cypress/integration/measurement-tracking/OHIFCornerstoneToolbar.spec.js b/platform/app/cypress/integration/measurement-tracking/OHIFCornerstoneToolbar.spec.js index c20aa75c63c..76c3fa2e4ad 100644 --- a/platform/app/cypress/integration/measurement-tracking/OHIFCornerstoneToolbar.spec.js +++ b/platform/app/cypress/integration/measurement-tracking/OHIFCornerstoneToolbar.spec.js @@ -113,7 +113,7 @@ describe('OHIF Cornerstone Toolbar', () => { cy.addLengthMeasurement(); cy.get('[data-cy="viewport-notification"]').should('exist'); cy.get('[data-cy="viewport-notification"]').should('be.visible'); - cy.get('[data-cy="prompt-begin-tracking-yes"]').click(); + cy.get('[data-cy="prompt-begin-tracking-yes-btn"]').click(); //Verify the measurement exists in the table cy.get('@measurementsPanel').should('be.visible'); diff --git a/platform/app/cypress/integration/measurement-tracking/OHIFMeasurementPanel.spec.js b/platform/app/cypress/integration/measurement-tracking/OHIFMeasurementPanel.spec.js index c96d777010f..f41cd748075 100644 --- a/platform/app/cypress/integration/measurement-tracking/OHIFMeasurementPanel.spec.js +++ b/platform/app/cypress/integration/measurement-tracking/OHIFMeasurementPanel.spec.js @@ -27,7 +27,7 @@ describe('OHIF Measurement Panel', function() { cy.addLengthMeasurement(); cy.get('[data-cy="viewport-notification"]').should('exist'); cy.get('[data-cy="viewport-notification"]').should('be.visible'); - cy.get('[data-cy="prompt-begin-tracking-yes"]').click(); + cy.get('[data-cy="prompt-begin-tracking-yes-btn"]').click(); cy.get('[data-cy="measurement-item"]').click(); cy.get('[data-cy="measurement-item"]') @@ -46,7 +46,7 @@ describe('OHIF Measurement Panel', function() { it('checks if image would jump when clicked on a measurement item', function() { // Add length measurement cy.addLengthMeasurement(); - cy.get('[data-cy="prompt-begin-tracking-yes"]').click(); + cy.get('[data-cy="prompt-begin-tracking-yes-btn"]').click(); cy.scrollToIndex(13); diff --git a/platform/app/src/routes/WorkList/WorkList.tsx b/platform/app/src/routes/WorkList/WorkList.tsx index 921e4798e16..5111d0d0d43 100644 --- a/platform/app/src/routes/WorkList/WorkList.tsx +++ b/platform/app/src/routes/WorkList/WorkList.tsx @@ -15,7 +15,7 @@ import { utils, hotkeys, ServicesManager } from '@ohif/core'; import { Icon, StudyListExpandedRow, - Button, + LegacyButton, EmptyStudies, StudyListTable, StudyListPagination, @@ -363,16 +363,17 @@ function WorkList({ ''}?${query.toString()}`} // to={`${mode.routeName}/dicomweb?StudyInstanceUIDs=${studyInstanceUid}`} > - + ); })} diff --git a/platform/app/tailwind.config.js b/platform/app/tailwind.config.js index e224be2060a..b263999191e 100644 --- a/platform/app/tailwind.config.js +++ b/platform/app/tailwind.config.js @@ -74,9 +74,16 @@ module.exports = { }, customblue: { + 10: '#0A163F', + 20: '#0B1F54', + 30: '#09286e', + 40: '#0E307F', + 50: '#0F3A94', + 80: '#1454D4', 100: '#c4fdff', 200: '#38daff', 300: '#1D204D', + 400: '#90A0C1', }, customgray: { diff --git a/platform/ui/src/components/Button/Button.tsx b/platform/ui/src/components/Button/Button.tsx index 8e8fcf7a20f..e5da5c2c7f6 100644 --- a/platform/ui/src/components/Button/Button.tsx +++ b/platform/ui/src/components/Button/Button.tsx @@ -1,181 +1,89 @@ import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; +import * as ButtonEnums from './ButtonEnums'; -const baseClasses = - 'leading-none font-sans text-center justify-center items-center outline-none transition duration-300 ease-in-out focus:outline-none'; - -const defaults = { - color: 'default', - disabled: false, - fullWidth: false, - rounded: 'medium', - border: 'none', - size: 'medium', - type: 'button', - variant: 'contained', +const sizeClasses = { + [ButtonEnums.size.small]: 'h-[26px] text-[13px]', + [ButtonEnums.size.medium]: 'h-[32px] text-[14px]', }; -const roundedClasses = { - none: '', - small: 'rounded', - medium: 'rounded-md', - large: 'rounded-lg', - full: 'rounded-full', -}; +const layoutClasses = + 'box-content inline-flex flex-row items-center justify-center gap-[5px] justify center px-[10px] outline-none rounded'; -const variants = { - text: { - default: - 'text-primary-light hover:bg-primary-light hover:text-white active:opacity-80 focus:bg-primary-light focus:text-white', - primary: - 'text-primary-main hover:bg-primary-main hover:text-white active:opacity-80 focus:bg-primary-main focus:text-white', - secondary: - 'text-secondary-light hover:bg-secondary-light hover:text-white active:opacity-80 focus:bg-secondary-light focus:text-white', - white: - 'text-white hover:bg-white hover:text-black active:opacity-80 focus:bg-white focus:text-black', - black: - 'text-black hover:bg-black hover:text-white focus:bg-black focus:text-white active:opacity-80', - }, - outlined: { - default: - 'text-primary-light hover:bg-primary-light hover:text-black focus:text-black focus:bg-primary-light active:opacity-80', - primary: - 'text-primary-main hover:opacity-80 active:opacity-100 focus:opacity-80', - secondary: - 'text-secondary-light hover:opacity-80 active:opacity-100 focus:opacity-80', - translucent: - 'text-white hover:opacity-80 active:opacity-100 focus:opacity-80', - white: - 'text-black hover:bg-primary-main focus:bg-primary-main hover:border-black focus:border-black', - black: - 'text-white hover:bg-primary-main focus:bg-primary-main hover:border-black focus:border-black', - primaryActive: - 'text-primary-active hover:opacity-80 active:opacity-100 focus:opacity-80', - primaryLight: - 'border bg-transparent border-primary-main text-white hover:opacity-80 active:opacity-100 focus:opacity-80', - }, - contained: { - default: 'text-black hover:opacity-80 active:opacity-100 focus:opacity-80', - primary: 'text-white hover:opacity-80 active:opacity-100 focus:opacity-80', - primaryDark: - 'text-primary-active hover:opacity-80 active:opacity-100 focus:opacity-80', - secondary: - 'text-white hover:opacity-80 active:opacity-100 focus:opacity-80', - white: 'text-black hover:opacity-80 active:opacity-100 focus:opacity-80', - black: 'text-white hover:opacity-80 active:opacity-100 focus:opacity-80', - light: - 'border text-black hover:opacity-80 active:opacity-100 focus:opacity-80', - }, - disabled: { - default: 'cursor-not-allowed opacity-50 text-black', - primary: 'cursor-not-allowed opacity-50 text-white', - secondary: 'cursor-not-allowed opacity-50 text-white', - white: 'cursor-not-allowed opacity-50 text-black', - black: 'cursor-not-allowed opacity-50 text-white', - light: 'cursor-not-allowed opacity-50 border text-black', - }, -}; +const baseFontTextClasses = + 'leading-[1.2] font-sans text-center whitespace-nowrap'; -const defaultVariantBackGroundColor = { - text: { - default: '', - primary: '', - secondary: '', - white: '', - black: '', - }, - outlined: { - default: 'bg-transparent', - primary: 'bg-transparent', - secondary: 'bg-transparent', - black: 'bg-black', - white: '', - }, - contained: { - default: 'bg-primary-light', - primary: 'bg-primary-main', - primaryDark: 'bg-primary-dark', - secondary: 'bg-secondary-light', - white: 'bg-white', - black: 'bg-black', - light: 'bg-primary-light', - }, - disabled: { - default: 'bg-primary-light', - primary: 'bg-primary-main', - secondary: 'bg-secondary-light', - white: 'bg-white', - black: 'bg-black', - light: 'bg-primary-light', - }, +const fontTextClasses = { + [ButtonEnums.type.primary]: classnames(baseFontTextClasses, 'font-semibold'), + [ButtonEnums.type.secondary]: classnames(baseFontTextClasses, 'font-400'), }; -const _getVariantClass = (variant, color, bgColor = null) => { - const defaultBackgroundColor = defaultVariantBackGroundColor[variant][color]; - - if (!bgColor) { - bgColor = defaultBackgroundColor; - } - - return `${variants[variant][color]} ${bgColor}`; +const baseEnabledEffectClasses = + 'transition duration-300 ease-in-out focus:outline-none'; + +const enabledEffectClasses = { + [ButtonEnums.type.primary]: classnames( + baseEnabledEffectClasses, + 'hover:bg-customblue-80 active:bg-customblue-40' + ), + [ButtonEnums.type.secondary]: classnames( + baseEnabledEffectClasses, + 'hover:bg-customblue-50 active:bg-customblue-20' + ), }; -const borderClasses = { - none: '', - light: 'border border-primary-light', - primary: 'border border-primary-main', - primaryActive: 'border border-primary-active', - secondary: 'border border-secondary-light', - white: 'border border-white', - black: 'border border-black', +const baseEnabledClasses = 'text-white'; + +const enabledClasses = { + [ButtonEnums.type.primary]: classnames( + 'bg-primary-main', + baseEnabledClasses, + enabledEffectClasses[ButtonEnums.type.primary] + ), + [ButtonEnums.type.secondary]: classnames( + 'bg-customblue-30', + baseEnabledClasses, + enabledEffectClasses[ButtonEnums.type.secondary] + ), }; -const sizeClasses = { - small: 'py-2 px-2 text-sm min-w-md', - medium: 'py-2 px-2 text-lg min-w-md', - large: 'py-2 px-6 text-xl min-w-md', - initial: '', -}; +const disabledClasses = + 'bg-inputfield-placeholder text-common-light cursor-default'; -const fullWidthClasses = { - true: 'flex w-full', - false: 'inline-flex', +const defaults = { + color: 'default', + disabled: false, + rounded: 'small', + size: ButtonEnums.size.medium, + type: ButtonEnums.type.primary, }; const Button = ({ children, - variant = defaults.variant, - color = defaults.color, - border = defaults.border, size = defaults.size, - rounded = defaults.rounded, disabled = defaults.disabled, type = defaults.type, - fullWidth = defaults.fullWidth, - bgColor = null, startIcon: startIconProp, endIcon: endIconProp, name, className, onClick, - /** TODO: All possible props should be explicitly defined -- avoid spreading props */ - ...rest }) => { const startIcon = startIconProp && ( -
+ <> {React.cloneElement(startIconProp, { className: classnames('w-4 h-4 fill-current'), })} -
+ ); const endIcon = endIconProp && ( -
+ <> {React.cloneElement(endIconProp, { className: classnames('w-4 h-4 fill-current'), })} -
+ ); const buttonElement = useRef(null); @@ -187,12 +95,11 @@ const Button = ({ }; const finalClassName = classnames( - baseClasses, - _getVariantClass(variant, color, bgColor), - borderClasses[border], - roundedClasses[rounded], + layoutClasses, + fontTextClasses[type], + disabled ? disabledClasses : enabledClasses[type], sizeClasses[size], - fullWidthClasses[fullWidth], + children ? 'min-w-[32px]' : '', // minimum width for buttons with text; icon only button does NOT get a minimum width className ); @@ -202,9 +109,7 @@ const Button = ({ disabled={disabled} ref={buttonElement} onClick={handleOnClick} - type={type} data-cy={`${name}-btn`} - {...rest} > {startIcon} {children} @@ -214,10 +119,11 @@ const Button = ({ }; Button.defaultProps = { - color: defaults.color, disabled: false, children: '', onClick: () => {}, + type: defaults.type, + size: defaults.size, }; Button.propTypes = { @@ -226,39 +132,11 @@ Button.propTypes = { /** Callback to be called when the button is clicked */ onClick: PropTypes.func.isRequired, /** Button size */ - size: PropTypes.oneOf(['small', 'medium', 'large', 'initial', 'inherit']), - /** Button corner roundness */ - rounded: PropTypes.oneOf(['none', 'small', 'medium', 'large', 'full']), - variant: PropTypes.oneOf(['text', 'outlined', 'contained', 'disabled']), - /* color prop must have all the possible keys of variants defined above */ - color: PropTypes.oneOf([ - 'default', - 'primary', - 'primaryDark', - 'primaryActive', - 'secondary', - 'white', - 'black', - 'inherit', - 'light', - 'translucent', - ]), - border: PropTypes.oneOf([ - 'none', - 'light', - 'default', - 'primary', - 'primaryActive', - 'secondary', - 'white', - 'black', - ]), - /** Whether the button should have full width */ - fullWidth: PropTypes.bool, + size: PropTypes.oneOf([ButtonEnums.size.medium, ButtonEnums.size.small]), /** Whether the button should be disabled */ disabled: PropTypes.bool, /** Button type */ - type: PropTypes.string, + type: PropTypes.oneOf([ButtonEnums.type.primary, ButtonEnums.type.secondary]), name: PropTypes.string, /** Button start icon name - if any icon is specified */ startIcon: PropTypes.node, @@ -266,8 +144,6 @@ Button.propTypes = { endIcon: PropTypes.node, /** Additional TailwindCSS classnames */ className: PropTypes.string, - /** Background color for the button to override*/ - bgColor: PropTypes.string, }; export default Button; diff --git a/platform/ui/src/components/Button/ButtonEnums.ts b/platform/ui/src/components/Button/ButtonEnums.ts new file mode 100644 index 00000000000..2dee84b522a --- /dev/null +++ b/platform/ui/src/components/Button/ButtonEnums.ts @@ -0,0 +1,10 @@ +enum type { + primary = 'primary', + secondary = 'secondary', +} +enum size { + medium = 'medium', + small = 'small', +} + +export { type, size }; diff --git a/platform/ui/src/components/Button/__stories__/button.stories.mdx b/platform/ui/src/components/Button/__stories__/button.stories.mdx index e01f38d6442..5e6fa623658 100644 --- a/platform/ui/src/components/Button/__stories__/button.stories.mdx +++ b/platform/ui/src/components/Button/__stories__/button.stories.mdx @@ -1,4 +1,4 @@ -import Button from '../Button'; +import Button, {ButtonType, ButtonSize} from '../Button'; import { ArgsTable, Story, Canvas, Meta } from '@storybook/addon-docs'; import { createComponentTemplate, @@ -24,7 +24,7 @@ export const buttonTemplate = createComponentTemplate(Button); ## Overview You can use the button component to create a button. It can be used in different -ways, the default button is a simple button with a text. +ways, the default button is a simple button with text. @@ -38,37 +38,29 @@ ways, the default button is a simple button with a text. ## Usage -### Variants +### Types -There can be different variants of buttons: `text`, `outlined`, `contained`, and -`disabled`. +There can be different types of buttons: `primary`, and `secondary`. - +
- - - - + +
-### Colors +### Sizes -There are different colors for the button: `default`, `primary`, `secondary`, -`white`, `black`, `inherit`, `light`. +There are different sizes for the button: `small`, and `medium`. The size refers +to the button's height. -
- - - - - - - +
+ +
@@ -79,19 +71,19 @@ You can mix different props together to create a button. - ### Disabled -You can disable the button by setting the variant to `disabled`. +You can disable the button by setting the `disabled` property to true. - + @@ -159,18 +151,6 @@ End Icon is the same as start icon, but for the end of the button. -### Full width - -You can make the button full width by setting the `fullWidth` prop to `true`. - - - - - - - ## Contribute