@opentrons/components 0.1.6-alpha.2 → 0.1.6-alpha.21
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/Makefile +5 -1
- package/package.json +6 -7
- package/src/__mocks__/file.js +10 -0
- package/src/alerts/AlertItem.stories.tsx +49 -0
- package/src/alerts/AlertItem.tsx +85 -0
- package/src/alerts/index.ts +3 -0
- package/src/atoms/Checkbox/Checkbox.stories.tsx +24 -0
- package/src/atoms/Checkbox/index.tsx +127 -0
- package/src/atoms/CheckboxField/CheckboxField.stories.tsx +30 -0
- package/src/atoms/CheckboxField/index.tsx +171 -0
- package/src/atoms/Chip/Chip.stories.tsx +59 -0
- package/src/atoms/Chip/index.tsx +172 -0
- package/src/atoms/Divider/index.tsx +15 -0
- package/src/atoms/InputField/InputField.stories.tsx +77 -0
- package/src/atoms/InputField/index.tsx +383 -0
- package/src/atoms/ListButton/ListButton.stories.tsx +133 -0
- package/src/atoms/ListButton/ListButtonChildren/ListButtonAccordion.tsx +65 -0
- package/src/atoms/ListButton/ListButtonChildren/ListButtonAccordionContainer.tsx +23 -0
- package/src/atoms/ListButton/ListButtonChildren/ListButtonRadioButton.tsx +108 -0
- package/src/atoms/ListButton/ListButtonChildren/index.ts +3 -0
- package/src/atoms/ListButton/index.tsx +72 -0
- package/src/atoms/ListItem/ListItem.stories.tsx +96 -0
- package/src/atoms/ListItem/ListItemChildren/ListItemCustomize.tsx +78 -0
- package/src/atoms/ListItem/ListItemChildren/ListItemDescriptor.tsx +42 -0
- package/src/atoms/ListItem/ListItemChildren/index.ts +2 -0
- package/src/atoms/ListItem/index.tsx +89 -0
- package/src/atoms/MenuList/MenuItem.stories.tsx +20 -0
- package/src/atoms/MenuList/MenuItem.tsx +55 -0
- package/src/atoms/MenuList/MenuList.stories.tsx +31 -0
- package/src/atoms/MenuList/OverflowBtn.stories.tsx +17 -0
- package/src/atoms/MenuList/OverflowBtn.tsx +76 -0
- package/src/atoms/MenuList/index.tsx +50 -0
- package/src/atoms/Snackbar/Snackbar.stories.tsx +67 -0
- package/src/atoms/Snackbar/index.tsx +91 -0
- package/src/atoms/StepMeter/index.tsx +53 -0
- package/src/atoms/StyledText/LegacyStyledText.stories.tsx +106 -0
- package/src/atoms/StyledText/LegacyStyledText.tsx +95 -0
- package/src/atoms/StyledText/StyledText.stories.tsx +46 -0
- package/src/atoms/StyledText/StyledText.tsx +323 -0
- package/src/atoms/StyledText/index.ts +2 -0
- package/src/atoms/Tag/Tag.stories.tsx +48 -0
- package/src/atoms/Tag/index.tsx +116 -0
- package/src/atoms/Toast/ODDToast.stories.tsx +68 -0
- package/src/atoms/Toast/Toast.stories.tsx +55 -0
- package/src/atoms/Toast/index.tsx +439 -0
- package/src/atoms/ToggleGroup/ToggleGroup.stories.tsx +39 -0
- package/src/atoms/ToggleGroup/index.tsx +91 -0
- package/src/atoms/Tooltip/Tooltip.stories.tsx +99 -0
- package/src/atoms/Tooltip/index.tsx +38 -0
- package/src/atoms/buttons/AlertPrimaryButton.tsx +26 -0
- package/src/atoms/buttons/AltPrimaryButton.tsx +31 -0
- package/src/atoms/buttons/EmptySelectorButton.stories.tsx +36 -0
- package/src/atoms/buttons/EmptySelectorButton.tsx +83 -0
- package/src/atoms/buttons/LargeButton.stories.tsx +99 -0
- package/src/atoms/buttons/LargeButton.tsx +320 -0
- package/src/atoms/buttons/PrimaryButton.tsx +36 -0
- package/src/atoms/buttons/RadioButton.stories.tsx +35 -0
- package/src/atoms/buttons/RadioButton.tsx +217 -0
- package/src/atoms/buttons/SecondaryButton.tsx +62 -0
- package/src/atoms/buttons/buttons.stories.tsx +78 -0
- package/src/atoms/buttons/index.ts +6 -0
- package/src/atoms/index.ts +20 -0
- package/src/barrel.ts +10 -0
- package/src/buttons/Button.tsx +96 -0
- package/src/buttons/DeprecatedPrimaryButton.tsx +24 -0
- package/src/buttons/FlatButton.tsx +21 -0
- package/src/buttons/IconButton.tsx +37 -0
- package/src/buttons/OutlineButton.tsx +24 -0
- package/src/buttons/index.ts +7 -0
- package/src/controls/ControlInfo.tsx +13 -0
- package/src/controls/LabeledButton.tsx +28 -0
- package/src/controls/LabeledCheckbox.tsx +35 -0
- package/src/controls/LabeledControl.tsx +24 -0
- package/src/controls/LabeledRadioGroup.tsx +27 -0
- package/src/controls/LabeledSelect.tsx +34 -0
- package/src/controls/LabeledToggle.tsx +35 -0
- package/src/controls/StackedLabeledControl.tsx +28 -0
- package/src/controls/ToggleButton.tsx +25 -0
- package/src/controls/index.ts +10 -0
- package/src/forms/DeprecatedCheckboxField.stories.tsx +31 -0
- package/src/forms/DeprecatedCheckboxField.tsx +94 -0
- package/src/forms/DropdownField.stories.tsx +44 -0
- package/src/forms/DropdownField.tsx +106 -0
- package/src/forms/FormGroup.stories.tsx +31 -0
- package/src/forms/FormGroup.tsx +53 -0
- package/src/forms/InputField.stories.tsx +41 -0
- package/src/forms/LegacyInputField.tsx +123 -0
- package/src/forms/RadioGroup.stories.tsx +44 -0
- package/src/forms/RadioGroup.tsx +87 -0
- package/src/forms/Select.stories.tsx +117 -0
- package/src/forms/Select.tsx +132 -0
- package/src/forms/SelectField.tsx +94 -0
- package/src/forms/ToggleField.stories.tsx +31 -0
- package/src/forms/ToggleField.tsx +59 -0
- package/src/forms/index.ts +8 -0
- package/src/hardware-sim/BaseDeck/BaseDeck.stories.tsx +94 -0
- package/src/hardware-sim/BaseDeck/BaseDeck.tsx +423 -0
- package/src/hardware-sim/BaseDeck/SingleSlotFixture.tsx +199 -0
- package/src/hardware-sim/BaseDeck/SlotBase.tsx +5 -0
- package/src/hardware-sim/BaseDeck/SlotClip.tsx +15 -0
- package/src/hardware-sim/BaseDeck/StagingAreaFixture.tsx +114 -0
- package/src/hardware-sim/BaseDeck/WasteChuteFixture.tsx +114 -0
- package/src/hardware-sim/BaseDeck/WasteChuteStagingAreaFixture.tsx +68 -0
- package/src/hardware-sim/BaseDeck/__fixtures__/index.ts +165 -0
- package/src/hardware-sim/BaseDeck/index.ts +5 -0
- package/src/hardware-sim/BaseDeck/something.test.tsx +7 -0
- package/src/hardware-sim/Deck/DeckFromLayers.tsx +58 -0
- package/src/hardware-sim/Deck/FlexTrash.tsx +128 -0
- package/src/hardware-sim/Deck/MoveLabwareOnDeck.stories.tsx +97 -0
- package/src/hardware-sim/Deck/MoveLabwareOnDeck.tsx +251 -0
- package/src/hardware-sim/Deck/OT2Layers.tsx +153 -0
- package/src/hardware-sim/Deck/RobotCoordsForeignDiv.tsx +46 -0
- package/src/hardware-sim/Deck/RobotCoordsForeignObject.tsx +42 -0
- package/src/hardware-sim/Deck/RobotCoordsText.tsx +32 -0
- package/src/hardware-sim/Deck/RobotWorkSpace.tsx +90 -0
- package/src/hardware-sim/Deck/SlotLabels.tsx +111 -0
- package/src/hardware-sim/Deck/__mocks__/getDeckDefinitions.ts +29 -0
- package/src/hardware-sim/Deck/constants.ts +12 -0
- package/src/hardware-sim/Deck/index.tsx +8 -0
- package/src/hardware-sim/DeckConfigurator/AbsorbanceReaderFixture.tsx +91 -0
- package/src/hardware-sim/DeckConfigurator/DeckConfigurator.stories.tsx +110 -0
- package/src/hardware-sim/DeckConfigurator/EmptyConfigFixture.tsx +131 -0
- package/src/hardware-sim/DeckConfigurator/HeaterShakerFixture.tsx +102 -0
- package/src/hardware-sim/DeckConfigurator/MagneticBlockFixture.tsx +130 -0
- package/src/hardware-sim/DeckConfigurator/StagingAreaConfigFixture.tsx +89 -0
- package/src/hardware-sim/DeckConfigurator/StaticFixture.tsx +54 -0
- package/src/hardware-sim/DeckConfigurator/TemperatureModuleFixture.tsx +103 -0
- package/src/hardware-sim/DeckConfigurator/ThermocyclerFixture.tsx +89 -0
- package/src/hardware-sim/DeckConfigurator/TrashBinConfigFixture.tsx +99 -0
- package/src/hardware-sim/DeckConfigurator/WasteChuteConfigFixture.tsx +96 -0
- package/src/hardware-sim/DeckConfigurator/constants.ts +81 -0
- package/src/hardware-sim/DeckConfigurator/index.tsx +285 -0
- package/src/hardware-sim/DeckSlotLocation/index.tsx +88 -0
- package/src/hardware-sim/Labware/Labware.tsx +173 -0
- package/src/hardware-sim/Labware/LabwareAdapter/Opentrons96DeepWellAdapter.tsx +23 -0
- package/src/hardware-sim/Labware/LabwareAdapter/Opentrons96FlatBottomAdapter.tsx +7 -0
- package/src/hardware-sim/Labware/LabwareAdapter/OpentronsAluminumFlatBottomPlate.tsx +13 -0
- package/src/hardware-sim/Labware/LabwareAdapter/OpentronsAutoclavableDeckRiser.tsx +100 -0
- package/src/hardware-sim/Labware/LabwareAdapter/OpentronsFlex96TiprackAdapter.tsx +13 -0
- package/src/hardware-sim/Labware/LabwareAdapter/OpentronsToughPCRAutoSealingLid.tsx +83 -0
- package/src/hardware-sim/Labware/LabwareAdapter/OpentronsUniversalFlatAdapter.tsx +13 -0
- package/src/hardware-sim/Labware/LabwareAdapter/index.tsx +73 -0
- package/src/hardware-sim/Labware/LabwareRender.stories.tsx +96 -0
- package/src/hardware-sim/Labware/LabwareRender.tsx +173 -0
- package/src/hardware-sim/Labware/LabwareStackRender.tsx +272 -0
- package/src/hardware-sim/Labware/index.ts +6 -0
- package/src/hardware-sim/Labware/labwareInternals/FilledWells.tsx +39 -0
- package/src/hardware-sim/Labware/labwareInternals/LabwareOutline.tsx +133 -0
- package/src/hardware-sim/Labware/labwareInternals/LabwareWellLabels.tsx +118 -0
- package/src/hardware-sim/Labware/labwareInternals/StaticLabware.tsx +121 -0
- package/src/hardware-sim/Labware/labwareInternals/StrokedWells.tsx +38 -0
- package/src/hardware-sim/Labware/labwareInternals/StyledWells.tsx +77 -0
- package/src/hardware-sim/Labware/labwareInternals/Well.tsx +74 -0
- package/src/hardware-sim/Labware/labwareInternals/WellLabels.tsx +121 -0
- package/src/hardware-sim/Labware/labwareInternals/index.ts +8 -0
- package/src/hardware-sim/Labware/labwareInternals/types.ts +18 -0
- package/src/hardware-sim/Module/HeaterShaker.tsx +83 -0
- package/src/hardware-sim/Module/MagneticBlock.tsx +49 -0
- package/src/hardware-sim/Module/MagneticModule.tsx +51 -0
- package/src/hardware-sim/Module/Module.stories.tsx +90 -0
- package/src/hardware-sim/Module/ModuleTag.tsx +38 -0
- package/src/hardware-sim/Module/PlateReader.tsx +208 -0
- package/src/hardware-sim/Module/Temperature.tsx +54 -0
- package/src/hardware-sim/Module/Thermocycler/ThermocyclerGEN1.tsx +248 -0
- package/src/hardware-sim/Module/Thermocycler/ThermocyclerGEN2.tsx +286 -0
- package/src/hardware-sim/Module/Thermocycler/index.tsx +49 -0
- package/src/hardware-sim/Module/index.tsx +227 -0
- package/src/hardware-sim/Pipette/EightEmanatingNozzles.tsx +23 -0
- package/src/hardware-sim/Pipette/EmanatingNozzle.tsx +52 -0
- package/src/hardware-sim/Pipette/PipetteRender.stories.tsx +71 -0
- package/src/hardware-sim/Pipette/PipetteRender.tsx +92 -0
- package/src/hardware-sim/Pipette/constants.ts +10 -0
- package/src/hardware-sim/Pipette/index.ts +1 -0
- package/src/hardware-sim/ProtocolDeck/LabwareInfo.tsx +68 -0
- package/src/hardware-sim/ProtocolDeck/ProtocolDeck.stories.tsx +25 -0
- package/src/hardware-sim/ProtocolDeck/__fixtures__/analysis_QIAseqFX24xv4_8.json +47145 -0
- package/src/hardware-sim/ProtocolDeck/index.tsx +174 -0
- package/src/hardware-sim/ProtocolDeck/types.ts +6 -0
- package/src/hardware-sim/ProtocolDeck/utils/getInitiallyLoadedLabwareByAdapter.ts +33 -0
- package/src/hardware-sim/ProtocolDeck/utils/getLabwareInSlots.ts +155 -0
- package/src/hardware-sim/ProtocolDeck/utils/getLabwareInfoByLiquidId.ts +42 -0
- package/src/hardware-sim/ProtocolDeck/utils/getModulesInSlots.ts +129 -0
- package/src/hardware-sim/ProtocolDeck/utils/getStandardDeckViewLayerBlockList.ts +29 -0
- package/src/hardware-sim/ProtocolDeck/utils/getWellFillFromLabwareId.ts +30 -0
- package/src/hardware-sim/ProtocolDeck/utils/index.ts +3 -0
- package/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpace.tsx +28 -0
- package/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithRef.tsx +52 -0
- package/src/hardware-sim/RobotCoordinateSpace/index.ts +2 -0
- package/src/hardware-sim/index.ts +11 -0
- package/src/hardware-sim/utils.ts +18 -0
- package/src/helix-design-system/borders.ts +32 -0
- package/src/helix-design-system/colors.ts +100 -0
- package/src/helix-design-system/index.ts +4 -0
- package/src/helix-design-system/product/index.ts +1 -0
- package/src/helix-design-system/product/typography.ts +151 -0
- package/src/helix-design-system/style.ts +2 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/useConditionalConfirm.ts +70 -0
- package/src/hooks/useDrag.ts +90 -0
- package/src/hooks/useIdle.ts +68 -0
- package/src/hooks/useInterval.ts +38 -0
- package/src/hooks/useLongPress.ts +83 -0
- package/src/hooks/useMenuHandleClickOutside.tsx +46 -0
- package/src/hooks/useMountEffect.ts +12 -0
- package/src/hooks/usePrevious.ts +19 -0
- package/src/hooks/useScrolling.ts +33 -0
- package/src/hooks/useSelectDeckLocation/SelectDeckLocation.stories.tsx +55 -0
- package/src/hooks/useSelectDeckLocation/index.tsx +331 -0
- package/src/hooks/useSwipe.ts +86 -0
- package/src/hooks/useTimeout.ts +33 -0
- package/src/hooks/useToggle.ts +27 -0
- package/src/icons/Icon.stories.tsx +37 -0
- package/src/icons/Icon.tsx +79 -0
- package/src/icons/IconList.stories.tsx +108 -0
- package/src/icons/ModuleIcon.tsx +48 -0
- package/src/icons/NotificationIcon.tsx +41 -0
- package/src/icons/icon-data.ts +821 -0
- package/src/icons/index.ts +6 -0
- package/src/images/index.ts +1 -0
- package/src/images/labware/index.ts +1 -0
- package/src/images/labware/measurement-guide/images/depth/depth-plate-flat@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/depth/depth-plate-round@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/depth/depth-plate-v@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/depth/depth-reservoir-and-tubes-flat@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/depth/depth-reservoir-and-tubes-round@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/depth/depth-reservoir-and-tubes-v@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/depth/length-tip-rack@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/footprint@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/height-alum-block-plate@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/height-alum-block-tubes@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/height-plate-and-reservoir@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/height-tip-rack@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/height-tube-rack-irregular@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/dimensions/height-tube-rack@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/offset/offset-reservoir@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/offset/offset-well-circular@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/offset/offset-well-rectangular@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/shape/shape-circular@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/shape/shape-rectangular@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/spacing/spacing-reservoir-multi-row@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/spacing/spacing-reservoir@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/spacing/spacing-well-circular@3x.png +0 -0
- package/src/images/labware/measurement-guide/images/spacing/spacing-well-rectangular@3x.png +0 -0
- package/src/images/labware/measurement-guide/index.ts +272 -0
- package/src/index.ts +2 -0
- package/src/instrument/InstrumentDiagram.stories.tsx +42 -0
- package/src/instrument/InstrumentDiagram.tsx +58 -0
- package/src/instrument/InstrumentGroup.stories.tsx +88 -0
- package/src/instrument/InstrumentGroup.tsx +35 -0
- package/src/instrument/InstrumentInfo.tsx +107 -0
- package/src/instrument/PipetteSelect.stories.tsx +40 -0
- package/src/instrument/PipetteSelect.tsx +170 -0
- package/src/instrument/eight-channel-flex.png +0 -0
- package/src/instrument/index.ts +4 -0
- package/src/instrument/multi-channel_GEN1_800px.png +0 -0
- package/src/instrument/multi-channel_GEN2_800px.png +0 -0
- package/src/instrument/ninety-six-channel-gen1.png +0 -0
- package/src/instrument/pipetteGEN2Multi.png +0 -0
- package/src/instrument/pipetteGEN2Single.png +0 -0
- package/src/instrument/pipetteMulti.png +0 -0
- package/src/instrument/pipetteSingle.png +0 -0
- package/src/instrument/single-channel-flex.png +0 -0
- package/src/instrument/single-channel_GEN2_800px.png +0 -0
- package/src/instrument/single_channel_GEN1_800px.png +0 -0
- package/src/interaction-enhancers/ClickOutside.ts +57 -0
- package/src/interaction-enhancers/HandleKeypress.tsx +69 -0
- package/src/interaction-enhancers/index.ts +4 -0
- package/src/interaction-enhancers/useHover.ts +84 -0
- package/src/interaction-enhancers/useOnClickOutside.ts +42 -0
- package/src/legacy-hardware-sim/LabwareNameOverlay.tsx +22 -0
- package/src/legacy-hardware-sim/ModuleItem.tsx +145 -0
- package/src/legacy-hardware-sim/index.ts +2 -0
- package/src/lists/SidePanelGroup.tsx +48 -0
- package/src/lists/TitledList.tsx +155 -0
- package/src/lists/index.ts +3 -0
- package/src/modals/AlertModal.tsx +89 -0
- package/src/modals/ContinueModal.tsx +32 -0
- package/src/modals/LegacyModal.tsx +59 -0
- package/src/modals/Modal.stories.tsx +52 -0
- package/src/modals/Modal.tsx +96 -0
- package/src/modals/ModalHeader.tsx +100 -0
- package/src/modals/ModalShell.tsx +155 -0
- package/src/modals/Overlay.tsx +38 -0
- package/src/modals/SpinnerModal.tsx +35 -0
- package/src/modals/SpinnerModalPage.tsx +30 -0
- package/src/modals/index.ts +10 -0
- package/src/molecules/Banner/Banner.stories.tsx +41 -0
- package/src/molecules/Banner/index.tsx +147 -0
- package/src/molecules/DeckInfoLabel/DeckInfoLabel.stories.tsx +65 -0
- package/src/molecules/DeckInfoLabel/index.tsx +95 -0
- package/src/molecules/DeckLabel/DeckLabel.stories.tsx +31 -0
- package/src/molecules/DeckLabel/index.tsx +80 -0
- package/src/molecules/DropdownMenu/DropdownMenu.stories.tsx +30 -0
- package/src/molecules/DropdownMenu/index.tsx +343 -0
- package/src/molecules/InfoScreen/InfoScreen.stories.tsx +50 -0
- package/src/molecules/InfoScreen/index.tsx +54 -0
- package/src/molecules/LiquidIcon/LiquidIcon.stories.tsx +53 -0
- package/src/molecules/LiquidIcon/index.tsx +68 -0
- package/src/molecules/ParametersTable/ParametersTable.stories.tsx +172 -0
- package/src/molecules/ParametersTable/index.tsx +198 -0
- package/src/molecules/Tabs/Tabs.stories.tsx +74 -0
- package/src/molecules/Tabs/index.tsx +94 -0
- package/src/molecules/index.ts +8 -0
- package/src/nav/SidePanel.stories.tsx +29 -0
- package/src/nav/SidePanel.tsx +21 -0
- package/src/nav/index.ts +2 -0
- package/src/organisms/DeckLabelSet/DeckLabelSet.stories.tsx +46 -0
- package/src/organisms/DeckLabelSet/index.tsx +69 -0
- package/src/organisms/EndUserAgreementFooter/index.tsx +49 -0
- package/src/organisms/Toolbox/Toolbox.stories.tsx +23 -0
- package/src/organisms/Toolbox/index.tsx +160 -0
- package/src/organisms/index.ts +3 -0
- package/src/primitives/Box.stories.tsx +25 -0
- package/src/primitives/Box.tsx +17 -0
- package/src/primitives/Btn.stories.tsx +105 -0
- package/src/primitives/Btn.tsx +266 -0
- package/src/primitives/Flex.stories.tsx +50 -0
- package/src/primitives/Flex.tsx +17 -0
- package/src/primitives/ForeignObject.tsx +70 -0
- package/src/primitives/Link.stories.tsx +27 -0
- package/src/primitives/Link.tsx +32 -0
- package/src/primitives/README.md +188 -0
- package/src/primitives/Svg.stories.tsx +36 -0
- package/src/primitives/Svg.tsx +68 -0
- package/src/primitives/Text.stories.tsx +17 -0
- package/src/primitives/Text.tsx +18 -0
- package/src/primitives/index.ts +10 -0
- package/src/primitives/style-props.ts +197 -0
- package/src/primitives/types.ts +120 -0
- package/src/robot-types.ts +4 -0
- package/src/slotmap/OT2SlotMap.tsx +73 -0
- package/src/slotmap/index.ts +1 -0
- package/src/structure/Card.stories.tsx +28 -0
- package/src/structure/Card.tsx +64 -0
- package/src/structure/LabeledValue.stories.tsx +17 -0
- package/src/structure/LabeledValue.tsx +31 -0
- package/src/structure/Pill.tsx +43 -0
- package/src/structure/Splash.stories.tsx +24 -0
- package/src/structure/Splash.tsx +22 -0
- package/src/structure/TitleBar.stories.tsx +42 -0
- package/src/structure/TitleBar.tsx +81 -0
- package/src/structure/index.ts +7 -0
- package/src/styles/borders.ts +16 -0
- package/src/styles/colors.ts +58 -0
- package/src/styles/cursor.ts +12 -0
- package/src/styles/flexbox.ts +39 -0
- package/src/styles/index.ts +8 -0
- package/src/styles/layout.ts +31 -0
- package/src/styles/position.ts +5 -0
- package/src/styles/spacing.ts +11 -0
- package/src/styles/typography.ts +90 -0
- package/src/testing/utils/index.ts +2 -0
- package/src/testing/utils/matchers.ts +31 -0
- package/src/testing/utils/renderWithProviders.tsx +53 -0
- package/src/tooltips/DeprecatedTooltip.tsx +105 -0
- package/src/tooltips/HoverTooltip.tsx +83 -0
- package/src/tooltips/LegacyTooltip.stories.tsx +98 -0
- package/src/tooltips/LegacyTooltip.tsx +151 -0
- package/src/tooltips/constants.ts +28 -0
- package/src/tooltips/index.ts +10 -0
- package/src/tooltips/styles.ts +20 -0
- package/src/tooltips/types.ts +73 -0
- package/src/tooltips/useHoverTooltip.ts +47 -0
- package/src/tooltips/usePopper.ts +87 -0
- package/src/tooltips/useTooltip.ts +100 -0
- package/src/ui-style-constants/index.ts +4 -0
- package/src/ui-style-constants/responsiveness.ts +15 -0
- package/src/ui-style-constants/spacing.ts +18 -0
- package/src/ui-style-constants/typography.ts +258 -0
- package/src/ui-style-constants/viewport.ts +18 -0
- package/src/utils.ts +56 -0
- package/{vite.config.ts → vite.config.mts} +2 -0
- package/lib/index.mjs +0 -19869
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SidePanelGroup component
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
|
|
5
|
+
import styles from './lists.module.css'
|
|
6
|
+
import { Icon } from '../icons'
|
|
7
|
+
|
|
8
|
+
import type { IconName } from '../icons'
|
|
9
|
+
|
|
10
|
+
// TODO(bc, 2021-03-31): this component is only used in one place
|
|
11
|
+
// reconsider whether it belongs in components library
|
|
12
|
+
export interface SidePanelGroupProps {
|
|
13
|
+
/** text of title */
|
|
14
|
+
title?: string
|
|
15
|
+
/** optional icon left of the title */
|
|
16
|
+
iconName?: IconName
|
|
17
|
+
/** children, most likely one or more TitledList */
|
|
18
|
+
children?: React.ReactNode
|
|
19
|
+
/** additional classnames */
|
|
20
|
+
className?: string
|
|
21
|
+
/** disables the whole SidePanelGroup if true */
|
|
22
|
+
disabled?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A component for grouping and titling multiple lists
|
|
27
|
+
*/
|
|
28
|
+
export function SidePanelGroup(props: SidePanelGroupProps): JSX.Element {
|
|
29
|
+
const { iconName, disabled } = props
|
|
30
|
+
|
|
31
|
+
const className = cx(styles.panel_group, props.className, {
|
|
32
|
+
[styles.disabled]: disabled,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className={className}>
|
|
37
|
+
{props.title && (
|
|
38
|
+
<div className={styles.title_bar}>
|
|
39
|
+
{iconName && (
|
|
40
|
+
<Icon className={styles.title_bar_icon} name={iconName} />
|
|
41
|
+
)}
|
|
42
|
+
<h2 className={styles.title}>{props.title}</h2>
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
{props.children}
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// TitledList component
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
|
|
5
|
+
import { Icon } from '../icons'
|
|
6
|
+
import { LegacyStyledText } from '../atoms'
|
|
7
|
+
import { COLORS } from '../helix-design-system'
|
|
8
|
+
import type { IconName, IconProps } from '../icons'
|
|
9
|
+
|
|
10
|
+
import styles from './lists.module.css'
|
|
11
|
+
|
|
12
|
+
// TODO(bc, 2021-03-31): reconsider whether this belongs in components library
|
|
13
|
+
// it is bloated with application specific functionality
|
|
14
|
+
|
|
15
|
+
export interface TitledListProps {
|
|
16
|
+
/** id attribute */
|
|
17
|
+
id?: string
|
|
18
|
+
/** text of title */
|
|
19
|
+
title: string
|
|
20
|
+
/** optional icon left of the title */
|
|
21
|
+
iconName?: IconName | null | undefined
|
|
22
|
+
/** props passed down to icon (`className` and `name` are ignored) */
|
|
23
|
+
iconProps?: Omit<IconProps, 'name'>
|
|
24
|
+
/** optional data test id for the container */
|
|
25
|
+
'data-test'?: string
|
|
26
|
+
// TODO(mc, 2018-01-25): enforce <li> children requirement with flow
|
|
27
|
+
/** children must all be `<li>` */
|
|
28
|
+
children?: React.ReactNode
|
|
29
|
+
/** additional classnames */
|
|
30
|
+
className?: string
|
|
31
|
+
/** component with descriptive text about the list */
|
|
32
|
+
description?: React.ReactNode
|
|
33
|
+
/** optional click action (on title div, not children) */
|
|
34
|
+
onClick?: (event: React.MouseEvent) => unknown
|
|
35
|
+
/** optional right click action (on wrapping div) */
|
|
36
|
+
onContextMenu?: (event: React.MouseEvent) => unknown
|
|
37
|
+
/** optional mouseEnter action */
|
|
38
|
+
onMouseEnter?: (event: React.MouseEvent) => unknown
|
|
39
|
+
/** optional mouseLeave action */
|
|
40
|
+
onMouseLeave?: (event: React.MouseEvent) => unknown
|
|
41
|
+
/** caret click action; if defined, list is expandable and carat is visible */
|
|
42
|
+
onCollapseToggle?: (event: React.MouseEvent) => unknown
|
|
43
|
+
/** collapse the list if true (false by default) */
|
|
44
|
+
collapsed?: boolean
|
|
45
|
+
/** set to true when TitledList is selected (eg, user clicked it) */
|
|
46
|
+
selected?: boolean
|
|
47
|
+
/** set to true when TitledList is hovered (but not when its contents are hovered) */
|
|
48
|
+
hovered?: boolean
|
|
49
|
+
/** disables the whole TitledList if true */
|
|
50
|
+
disabled?: boolean
|
|
51
|
+
/** appear disabled, but preserve collapsibility */
|
|
52
|
+
inert?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* An ordered list with optional title, icon, and description.
|
|
57
|
+
*/
|
|
58
|
+
export function TitledList(props: TitledListProps): JSX.Element {
|
|
59
|
+
const {
|
|
60
|
+
id,
|
|
61
|
+
iconName,
|
|
62
|
+
disabled,
|
|
63
|
+
inert,
|
|
64
|
+
'data-test': dataTest,
|
|
65
|
+
onCollapseToggle,
|
|
66
|
+
iconProps,
|
|
67
|
+
onMouseEnter,
|
|
68
|
+
onMouseLeave,
|
|
69
|
+
onContextMenu,
|
|
70
|
+
} = props
|
|
71
|
+
const collapsible = onCollapseToggle != null
|
|
72
|
+
|
|
73
|
+
const onClick = !disabled ? props.onClick : undefined
|
|
74
|
+
|
|
75
|
+
// clicking on the carat will not call props.onClick,
|
|
76
|
+
// so prevent bubbling up if there is an onCollapseToggle fn
|
|
77
|
+
const handleCollapseToggle = (e: React.MouseEvent): void => {
|
|
78
|
+
if (onCollapseToggle && !disabled) {
|
|
79
|
+
e.stopPropagation()
|
|
80
|
+
onCollapseToggle(e)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const hasValidChildren = React.Children.toArray(props.children).some(
|
|
85
|
+
child => child
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
const className = cx(styles.titled_list, props.className, {
|
|
89
|
+
[styles.disabled]: disabled || inert,
|
|
90
|
+
[styles.titled_list_selected]: !disabled && props.selected,
|
|
91
|
+
[styles.hover_border]: !disabled && props.hovered,
|
|
92
|
+
})
|
|
93
|
+
// @ts-expect-error(sa, 2021-6-23): cast value to boolean
|
|
94
|
+
const titleBarClass = cx(styles.titled_list_title_bar, {
|
|
95
|
+
[styles.clickable]: props.onClick,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const iconClass = cx(
|
|
99
|
+
styles.title_bar_icon,
|
|
100
|
+
styles.icon_left_of_title,
|
|
101
|
+
iconProps && iconProps.className
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
let textColor = ''
|
|
105
|
+
if (disabled) {
|
|
106
|
+
// the below hex code is for our legacy --c-font-disabled to match other text colors
|
|
107
|
+
textColor = '#9c9c9c'
|
|
108
|
+
} else if (props.selected && !disabled) {
|
|
109
|
+
// the below hex code is for our legacy --c-highlight to match other text colors
|
|
110
|
+
textColor = '#5fd8ee'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
id={id}
|
|
116
|
+
className={className}
|
|
117
|
+
data-test={dataTest}
|
|
118
|
+
{...{ onMouseEnter, onMouseLeave, onContextMenu }}
|
|
119
|
+
>
|
|
120
|
+
<div onClick={onClick} className={titleBarClass}>
|
|
121
|
+
{iconName && (
|
|
122
|
+
<Icon {...iconProps} className={iconClass} name={iconName} />
|
|
123
|
+
)}
|
|
124
|
+
<LegacyStyledText
|
|
125
|
+
as="h3"
|
|
126
|
+
backgroundColor={COLORS.white}
|
|
127
|
+
color={textColor}
|
|
128
|
+
>
|
|
129
|
+
{props.title}
|
|
130
|
+
</LegacyStyledText>
|
|
131
|
+
{collapsible && (
|
|
132
|
+
<div
|
|
133
|
+
onClick={handleCollapseToggle}
|
|
134
|
+
className={styles.title_bar_carat}
|
|
135
|
+
>
|
|
136
|
+
<Icon
|
|
137
|
+
className={styles.title_bar_icon}
|
|
138
|
+
name={
|
|
139
|
+
props.selected
|
|
140
|
+
? 'chevron-right'
|
|
141
|
+
: props.collapsed
|
|
142
|
+
? 'chevron-down'
|
|
143
|
+
: 'chevron-up'
|
|
144
|
+
}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
{!props.collapsed && props.description}
|
|
150
|
+
{!props.collapsed && hasValidChildren && (
|
|
151
|
+
<ol className={styles.list}>{props.children}</ol>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
|
|
4
|
+
import { OutlineButton } from '../buttons'
|
|
5
|
+
import { Icon } from '../icons'
|
|
6
|
+
import { LegacyModal } from './LegacyModal'
|
|
7
|
+
import styles from './modals.module.css'
|
|
8
|
+
|
|
9
|
+
import type { ButtonProps } from '../buttons'
|
|
10
|
+
import type { IconName } from '../icons'
|
|
11
|
+
|
|
12
|
+
export interface AlertModalProps {
|
|
13
|
+
/** optional handler for overlay click */
|
|
14
|
+
onCloseClick?: () => unknown
|
|
15
|
+
/** optional modal heading */
|
|
16
|
+
heading?: React.ReactNode
|
|
17
|
+
/** optional array of `ButtonProps` for `OutlineButton`s at bottom of modal */
|
|
18
|
+
buttons?: Array<ButtonProps | null | undefined>
|
|
19
|
+
/** modal contents */
|
|
20
|
+
children: React.ReactNode
|
|
21
|
+
/** optional classes to apply */
|
|
22
|
+
className?: string
|
|
23
|
+
/** optional classes to apply */
|
|
24
|
+
contentsClassName?: string
|
|
25
|
+
/** lightens overlay (alert modal over existing modal) */
|
|
26
|
+
alertOverlay?: boolean
|
|
27
|
+
/** override default alert icon */
|
|
28
|
+
iconName?: IconName | null | undefined
|
|
29
|
+
/** restricts scroll outside of Modal when open, true by default */
|
|
30
|
+
restrictOuterScroll?: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated use Modal instead
|
|
35
|
+
* Generic alert modal with a heading and a set of buttons at the bottom
|
|
36
|
+
*/
|
|
37
|
+
export function AlertModal(props: AlertModalProps): JSX.Element {
|
|
38
|
+
const {
|
|
39
|
+
heading,
|
|
40
|
+
buttons,
|
|
41
|
+
className,
|
|
42
|
+
onCloseClick,
|
|
43
|
+
alertOverlay,
|
|
44
|
+
restrictOuterScroll,
|
|
45
|
+
} = props
|
|
46
|
+
const iconName = props.iconName || 'alert'
|
|
47
|
+
const wrapperStyle = cx(
|
|
48
|
+
styles.alert_modal_wrapper,
|
|
49
|
+
{
|
|
50
|
+
[styles.no_alert_header]: !heading,
|
|
51
|
+
},
|
|
52
|
+
props.contentsClassName
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<LegacyModal
|
|
57
|
+
className={className}
|
|
58
|
+
contentsClassName={wrapperStyle}
|
|
59
|
+
onCloseClick={onCloseClick}
|
|
60
|
+
alertOverlay={alertOverlay}
|
|
61
|
+
restrictOuterScroll={restrictOuterScroll}
|
|
62
|
+
>
|
|
63
|
+
{heading && (
|
|
64
|
+
<div
|
|
65
|
+
className={cx(styles.alert_modal_heading, {
|
|
66
|
+
[styles.no_icon_heading]: props.iconName === null,
|
|
67
|
+
})}
|
|
68
|
+
>
|
|
69
|
+
{props.iconName !== null && (
|
|
70
|
+
<Icon name={iconName} className={styles.alert_modal_icon} />
|
|
71
|
+
)}
|
|
72
|
+
{heading}
|
|
73
|
+
</div>
|
|
74
|
+
)}
|
|
75
|
+
<div className={styles.alert_modal_contents}>{props.children}</div>
|
|
76
|
+
{buttons && (
|
|
77
|
+
<div className={styles.alert_modal_buttons}>
|
|
78
|
+
{(buttons.filter(Boolean) as ButtonProps[]).map((button, index) => (
|
|
79
|
+
<OutlineButton
|
|
80
|
+
{...button}
|
|
81
|
+
className={cx(styles.alert_button, button.className)}
|
|
82
|
+
key={index}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
</LegacyModal>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AlertModal } from './AlertModal'
|
|
2
|
+
|
|
3
|
+
import type { AlertModalProps } from './AlertModal'
|
|
4
|
+
|
|
5
|
+
export interface ContinueModalProps extends Omit<AlertModalProps, 'buttons'> {
|
|
6
|
+
onCancelClick: () => unknown
|
|
7
|
+
onContinueClick: () => unknown
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const CANCEL = 'Cancel'
|
|
11
|
+
const CONTINUE = 'Continue'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* * @deprecated use Modal instead
|
|
15
|
+
* AlertModal variant to prompt user to "Cancel" or "Continue" a given action
|
|
16
|
+
*/
|
|
17
|
+
export function ContinueModal(props: ContinueModalProps): JSX.Element {
|
|
18
|
+
const { onCancelClick, onContinueClick, ...passThruProps } = props
|
|
19
|
+
const buttons = [
|
|
20
|
+
{ title: CANCEL, children: CANCEL, onClick: onCancelClick },
|
|
21
|
+
{ title: CONTINUE, children: CONTINUE, onClick: onContinueClick },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<AlertModal
|
|
26
|
+
restrictOuterScroll={false}
|
|
27
|
+
onCloseClick={onCancelClick}
|
|
28
|
+
{...passThruProps}
|
|
29
|
+
buttons={buttons}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
import { RemoveScroll } from 'react-remove-scroll'
|
|
4
|
+
|
|
5
|
+
import { Overlay } from './Overlay'
|
|
6
|
+
import styles from './modals.module.css'
|
|
7
|
+
|
|
8
|
+
export interface LegacyModalProps {
|
|
9
|
+
/** handler to close the modal (attached to `Overlay` onClick) */
|
|
10
|
+
onCloseClick?: React.MouseEventHandler
|
|
11
|
+
/** Optional styled heading **/
|
|
12
|
+
heading?: string
|
|
13
|
+
/** modal contents */
|
|
14
|
+
children: React.ReactNode
|
|
15
|
+
/** classes to apply */
|
|
16
|
+
className?: string
|
|
17
|
+
/** classes to apply to the contents box */
|
|
18
|
+
contentsClassName?: string
|
|
19
|
+
/** lightens overlay (alert modal over existing modal) */
|
|
20
|
+
alertOverlay?: boolean
|
|
21
|
+
/** restricts scroll outside of Modal when open, true by default */
|
|
22
|
+
restrictOuterScroll?: boolean
|
|
23
|
+
innerRef?: React.Ref<HTMLDivElement>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use Modal instead
|
|
28
|
+
* Base modal component that fills its nearest `display:relative` ancestor
|
|
29
|
+
* with a dark overlay and displays `children` as its contents in a white box
|
|
30
|
+
*/
|
|
31
|
+
export function LegacyModal(props: LegacyModalProps): JSX.Element {
|
|
32
|
+
const {
|
|
33
|
+
contentsClassName,
|
|
34
|
+
alertOverlay,
|
|
35
|
+
onCloseClick,
|
|
36
|
+
heading,
|
|
37
|
+
innerRef,
|
|
38
|
+
restrictOuterScroll = true,
|
|
39
|
+
} = props
|
|
40
|
+
const Wrapper = restrictOuterScroll ? RemoveScroll : React.Fragment
|
|
41
|
+
return (
|
|
42
|
+
<Wrapper>
|
|
43
|
+
<div
|
|
44
|
+
className={cx(styles.modal, props.className, {
|
|
45
|
+
[styles.alert_modal]: alertOverlay,
|
|
46
|
+
})}
|
|
47
|
+
>
|
|
48
|
+
<Overlay onClick={onCloseClick} alertOverlay={alertOverlay} />
|
|
49
|
+
<div
|
|
50
|
+
ref={innerRef}
|
|
51
|
+
className={cx(styles.modal_contents, contentsClassName)}
|
|
52
|
+
>
|
|
53
|
+
{heading && <h3 className={styles.modal_heading}>{heading}</h3>}
|
|
54
|
+
{props.children}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</Wrapper>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { LegacyStyledText } from '../atoms'
|
|
4
|
+
import { SPACING, TYPOGRAPHY } from '../ui-style-constants'
|
|
5
|
+
import { PrimaryBtn } from '../primitives'
|
|
6
|
+
import { COLORS } from '../helix-design-system'
|
|
7
|
+
import { Modal } from './Modal'
|
|
8
|
+
|
|
9
|
+
import type { Story, Meta } from '@storybook/react'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Library/Molecules/modals/Modal',
|
|
13
|
+
component: Modal,
|
|
14
|
+
} as Meta
|
|
15
|
+
|
|
16
|
+
const Template: Story<React.ComponentProps<typeof Modal>> = args => (
|
|
17
|
+
<Modal {...args} />
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const Children = (
|
|
21
|
+
<>
|
|
22
|
+
<LegacyStyledText
|
|
23
|
+
fontWeight={TYPOGRAPHY.fontWeightSemiBold}
|
|
24
|
+
fontSize={TYPOGRAPHY.fontSizeP}
|
|
25
|
+
paddingTop={SPACING.spacing4}
|
|
26
|
+
>
|
|
27
|
+
{'Modal body goes here'}
|
|
28
|
+
</LegacyStyledText>
|
|
29
|
+
|
|
30
|
+
<PrimaryBtn
|
|
31
|
+
backgroundColor={COLORS.blue50}
|
|
32
|
+
marginTop="28rem"
|
|
33
|
+
textTransform={TYPOGRAPHY.textTransformNone}
|
|
34
|
+
>
|
|
35
|
+
<LegacyStyledText
|
|
36
|
+
fontWeight={TYPOGRAPHY.fontWeightRegular}
|
|
37
|
+
fontSize={TYPOGRAPHY.fontSizeP}
|
|
38
|
+
>
|
|
39
|
+
{'btn text'}
|
|
40
|
+
</LegacyStyledText>
|
|
41
|
+
</PrimaryBtn>
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
export const Primary = Template.bind({})
|
|
46
|
+
Primary.args = {
|
|
47
|
+
type: 'info',
|
|
48
|
+
onClose: () => {},
|
|
49
|
+
closeOnOutsideClick: false,
|
|
50
|
+
title: 'Modal Title',
|
|
51
|
+
children: Children,
|
|
52
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
import { Box } from '../primitives'
|
|
3
|
+
import { SPACING } from '../ui-style-constants'
|
|
4
|
+
import { COLORS } from '../helix-design-system'
|
|
5
|
+
import { ModalHeader } from './ModalHeader'
|
|
6
|
+
import { ModalShell } from './ModalShell'
|
|
7
|
+
import type { IconProps } from '../icons'
|
|
8
|
+
import type { StyleProps } from '../primitives'
|
|
9
|
+
import type { Position } from './ModalShell'
|
|
10
|
+
|
|
11
|
+
type ModalType = 'info' | 'warning' | 'error'
|
|
12
|
+
|
|
13
|
+
export interface ModalProps extends StyleProps {
|
|
14
|
+
type?: ModalType
|
|
15
|
+
onClose?: React.MouseEventHandler
|
|
16
|
+
closeOnOutsideClick?: boolean
|
|
17
|
+
title?: React.ReactNode
|
|
18
|
+
titleElement1?: JSX.Element
|
|
19
|
+
titleElement2?: JSX.Element
|
|
20
|
+
fullPage?: boolean
|
|
21
|
+
childrenPadding?: string | number
|
|
22
|
+
children?: React.ReactNode
|
|
23
|
+
footer?: React.ReactNode
|
|
24
|
+
zIndexOverlay?: number
|
|
25
|
+
showOverlay?: boolean
|
|
26
|
+
position?: Position
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* For Desktop app and Helix (which includes Protocol Designer) use only.
|
|
31
|
+
*/
|
|
32
|
+
export const Modal = (props: ModalProps): JSX.Element => {
|
|
33
|
+
const {
|
|
34
|
+
type = 'info',
|
|
35
|
+
onClose,
|
|
36
|
+
closeOnOutsideClick,
|
|
37
|
+
title,
|
|
38
|
+
childrenPadding = `${SPACING.spacing16} ${SPACING.spacing24} ${SPACING.spacing24}`,
|
|
39
|
+
children,
|
|
40
|
+
footer,
|
|
41
|
+
titleElement1,
|
|
42
|
+
titleElement2,
|
|
43
|
+
zIndexOverlay,
|
|
44
|
+
position,
|
|
45
|
+
showOverlay,
|
|
46
|
+
...styleProps
|
|
47
|
+
} = props
|
|
48
|
+
|
|
49
|
+
const iconColor = (type: ModalType): string => {
|
|
50
|
+
let iconColor: string = ''
|
|
51
|
+
switch (type) {
|
|
52
|
+
case 'warning':
|
|
53
|
+
iconColor = COLORS.yellow50
|
|
54
|
+
break
|
|
55
|
+
case 'error':
|
|
56
|
+
iconColor = COLORS.red50
|
|
57
|
+
break
|
|
58
|
+
}
|
|
59
|
+
return iconColor
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const modalIcon: IconProps = {
|
|
63
|
+
name: 'ot-alert',
|
|
64
|
+
color: iconColor(type),
|
|
65
|
+
size: '1.25rem',
|
|
66
|
+
marginRight: SPACING.spacing8,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const modalHeader = (
|
|
70
|
+
<ModalHeader
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
title={title}
|
|
73
|
+
titleElement1={titleElement1}
|
|
74
|
+
titleElement2={titleElement2}
|
|
75
|
+
icon={['error', 'warning'].includes(type) ? modalIcon : undefined}
|
|
76
|
+
color={COLORS.black90}
|
|
77
|
+
backgroundColor={COLORS.white}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
return (
|
|
81
|
+
<ModalShell
|
|
82
|
+
position={position}
|
|
83
|
+
showOverlay={showOverlay}
|
|
84
|
+
zIndexOverlay={zIndexOverlay}
|
|
85
|
+
width={styleProps.width ?? '31.25rem'}
|
|
86
|
+
header={modalHeader}
|
|
87
|
+
onOutsideClick={closeOnOutsideClick ?? false ? onClose : undefined}
|
|
88
|
+
// center within viewport aside from nav
|
|
89
|
+
marginLeft={styleProps.marginLeft ?? '5.656rem'}
|
|
90
|
+
{...styleProps}
|
|
91
|
+
footer={footer}
|
|
92
|
+
>
|
|
93
|
+
<Box padding={childrenPadding}>{children}</Box>
|
|
94
|
+
</ModalShell>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
2
|
+
import { css } from 'styled-components'
|
|
3
|
+
|
|
4
|
+
import { Icon } from '../icons'
|
|
5
|
+
import { Box, Btn, Flex } from '../primitives'
|
|
6
|
+
import { LegacyStyledText } from '../atoms'
|
|
7
|
+
import { ALIGN_CENTER, JUSTIFY_CENTER, JUSTIFY_SPACE_BETWEEN } from '../styles'
|
|
8
|
+
import { SPACING, TYPOGRAPHY } from '../ui-style-constants'
|
|
9
|
+
import { COLORS } from '../helix-design-system'
|
|
10
|
+
import type { IconProps } from '../icons'
|
|
11
|
+
|
|
12
|
+
export interface ModalHeaderProps {
|
|
13
|
+
title: React.ReactNode
|
|
14
|
+
onClose?: React.MouseEventHandler
|
|
15
|
+
titleElement1?: JSX.Element
|
|
16
|
+
titleElement2?: JSX.Element
|
|
17
|
+
backgroundColor?: string
|
|
18
|
+
color?: string
|
|
19
|
+
icon?: IconProps
|
|
20
|
+
closeButton?: React.ReactNode
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const closeIconStyles = css`
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: ${JUSTIFY_CENTER};
|
|
26
|
+
align-items: ${ALIGN_CENTER};
|
|
27
|
+
border-radius: 0.875rem;
|
|
28
|
+
width: 1.625rem;
|
|
29
|
+
height: 1.625rem;
|
|
30
|
+
&:hover {
|
|
31
|
+
background-color: ${COLORS.grey30};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:active {
|
|
35
|
+
background-color: ${COLORS.grey35};
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
export const ModalHeader = (props: ModalHeaderProps): JSX.Element => {
|
|
40
|
+
const {
|
|
41
|
+
icon,
|
|
42
|
+
onClose,
|
|
43
|
+
title,
|
|
44
|
+
titleElement1,
|
|
45
|
+
titleElement2,
|
|
46
|
+
backgroundColor,
|
|
47
|
+
color,
|
|
48
|
+
closeButton,
|
|
49
|
+
} = props
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Flex
|
|
53
|
+
alignItems={ALIGN_CENTER}
|
|
54
|
+
justifyContent={JUSTIFY_SPACE_BETWEEN}
|
|
55
|
+
paddingX={SPACING.spacing24}
|
|
56
|
+
paddingY={SPACING.spacing16}
|
|
57
|
+
backgroundColor={backgroundColor}
|
|
58
|
+
data-testid="Modal_header"
|
|
59
|
+
>
|
|
60
|
+
<Flex alignItems={ALIGN_CENTER} gridGap={SPACING.spacing8}>
|
|
61
|
+
{icon != null && <Icon {...icon} data-testid="Modal_header_icon" />}
|
|
62
|
+
{titleElement1}
|
|
63
|
+
{titleElement2}
|
|
64
|
+
{/* TODO (nd: 08/07/2024) Convert to StyledText once designs are resolved */}
|
|
65
|
+
<LegacyStyledText
|
|
66
|
+
as="h3"
|
|
67
|
+
fontWeight={TYPOGRAPHY.fontWeightSemiBold}
|
|
68
|
+
color={color}
|
|
69
|
+
>
|
|
70
|
+
{title}
|
|
71
|
+
</LegacyStyledText>
|
|
72
|
+
</Flex>
|
|
73
|
+
{closeButton != null
|
|
74
|
+
? closeButton
|
|
75
|
+
: onClose != null && (
|
|
76
|
+
<Btn
|
|
77
|
+
onClick={onClose}
|
|
78
|
+
css={closeIconStyles}
|
|
79
|
+
data-testid={`ModalHeader_icon_close${
|
|
80
|
+
typeof title === 'string' ? `_${title}` : ''
|
|
81
|
+
}`}
|
|
82
|
+
>
|
|
83
|
+
<Icon
|
|
84
|
+
name="close"
|
|
85
|
+
width={SPACING.spacing24}
|
|
86
|
+
height={SPACING.spacing24}
|
|
87
|
+
color={color}
|
|
88
|
+
/>
|
|
89
|
+
</Btn>
|
|
90
|
+
)}
|
|
91
|
+
</Flex>
|
|
92
|
+
<Box
|
|
93
|
+
borderBottom={`1px solid ${COLORS.grey30}`}
|
|
94
|
+
marginY="0"
|
|
95
|
+
width="100%"
|
|
96
|
+
data-testid="divider"
|
|
97
|
+
/>
|
|
98
|
+
</>
|
|
99
|
+
)
|
|
100
|
+
}
|