@opentrons/components 0.1.7-alpha.1 → 0.2.0-alpha.0

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 (251) hide show
  1. package/cssModuleSideEffect.ts +22 -0
  2. package/lib/assets/localization/en/index.d.ts +12 -0
  3. package/lib/assets/localization/index.d.ts +12 -0
  4. package/lib/atoms/AnimationVideo/index.d.ts +13 -0
  5. package/lib/atoms/InlineNotification/index.d.ts +1 -1
  6. package/lib/atoms/ListButton/ListButtonChildren/index.d.ts +0 -1
  7. package/lib/atoms/StyledText/PlaceholderStyledText.d.ts +14 -0
  8. package/lib/atoms/StyledText/index.d.ts +1 -0
  9. package/lib/atoms/buttons/BasicButton.d.ts +12 -0
  10. package/lib/atoms/buttons/index.d.ts +1 -0
  11. package/lib/atoms/index.d.ts +1 -0
  12. package/lib/hardware-sim/BaseDeck/BaseDeck.d.ts +10 -8
  13. package/lib/hardware-sim/Deck/FlexTrash.d.ts +4 -1
  14. package/lib/hardware-sim/Deck/MoveLabwareOnDeck.d.ts +3 -2
  15. package/lib/hardware-sim/Deck/RobotCoordsForeignDiv.d.ts +6 -5
  16. package/lib/hardware-sim/Deck/RobotCoordsForeignObject.d.ts +8 -5
  17. package/lib/hardware-sim/Deck/RobotCoordsText.d.ts +11 -1
  18. package/lib/hardware-sim/Deck/RobotWorkSpace.d.ts +30 -14
  19. package/lib/hardware-sim/Deck/__tests__/resolveLabwareLocation.test.d.ts +1 -0
  20. package/lib/hardware-sim/Deck/resolveLabwareLocation.d.ts +20 -0
  21. package/lib/hardware-sim/DeckConfigurator/AbsorbanceReaderItem.d.ts +11 -0
  22. package/lib/hardware-sim/DeckConfigurator/EmptyConfigItem.d.ts +11 -0
  23. package/lib/hardware-sim/DeckConfigurator/FlexStackerItem.d.ts +12 -0
  24. package/lib/hardware-sim/DeckConfigurator/HeaterShakerItem.d.ts +11 -0
  25. package/lib/hardware-sim/DeckConfigurator/MagneticBlockItem.d.ts +12 -0
  26. package/lib/hardware-sim/DeckConfigurator/StagingAreaConfigItem.d.ts +11 -0
  27. package/lib/hardware-sim/DeckConfigurator/{StaticFixture.d.ts → StaticItem.d.ts} +1 -1
  28. package/lib/hardware-sim/DeckConfigurator/TemperatureModuleItem.d.ts +11 -0
  29. package/lib/hardware-sim/DeckConfigurator/ThermocyclerItem.d.ts +11 -0
  30. package/lib/hardware-sim/DeckConfigurator/TrashBinConfigItem.d.ts +11 -0
  31. package/lib/hardware-sim/DeckConfigurator/WasteChuteConfigItem.d.ts +11 -0
  32. package/lib/hardware-sim/DeckConfigurator/constants.d.ts +5 -8
  33. package/lib/hardware-sim/DeckConfigurator/index.d.ts +4 -3
  34. package/lib/hardware-sim/Labware/CalibrationBlockRender.d.ts +15 -0
  35. package/lib/hardware-sim/Labware/Labware.d.ts +7 -8
  36. package/lib/hardware-sim/Labware/LabwareAdapter/index.d.ts +2 -2
  37. package/lib/hardware-sim/Labware/LabwareRender.d.ts +46 -5
  38. package/lib/hardware-sim/Labware/index.d.ts +1 -0
  39. package/lib/hardware-sim/Labware/labwareInternals/FilledWells.d.ts +3 -4
  40. package/lib/hardware-sim/Labware/labwareInternals/LabwareOutline.d.ts +20 -9
  41. package/lib/hardware-sim/Labware/labwareInternals/LabwareWellLabels.d.ts +2 -2
  42. package/lib/hardware-sim/Labware/labwareInternals/StaticLabware.d.ts +2 -2
  43. package/lib/hardware-sim/Labware/labwareInternals/StrokedWells.d.ts +2 -2
  44. package/lib/hardware-sim/Labware/labwareInternals/StyledWells.d.ts +2 -2
  45. package/lib/hardware-sim/Labware/labwareInternals/Well.d.ts +1 -2
  46. package/lib/hardware-sim/Labware/labwareInternals/WellLabels.d.ts +2 -2
  47. package/lib/hardware-sim/Module/index.d.ts +24 -2
  48. package/lib/hardware-sim/Pipette/PipetteRender.d.ts +2 -2
  49. package/lib/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpace.d.ts +5 -3
  50. package/lib/hocs/withStyleProps.d.ts +26 -0
  51. package/lib/hooks/useConditionalConfirm.d.ts +4 -0
  52. package/lib/icons/Icon.d.ts +7 -7
  53. package/lib/icons/ModuleIcon.d.ts +4 -3
  54. package/lib/instrument/index.d.ts +0 -2
  55. package/lib/legacy-hardware-sim/index.d.ts +0 -1
  56. package/lib/lists/index.d.ts +0 -1
  57. package/lib/molecules/CustomizeExpandButton/__tests__/CustomizeExpandButton.test.d.ts +1 -0
  58. package/lib/molecules/CustomizeExpandButton/index.d.ts +29 -0
  59. package/lib/molecules/DeckInfoLabel/index.d.ts +8 -16
  60. package/lib/molecules/index.d.ts +2 -1
  61. package/lib/organisms/CommandText/index.d.ts +2 -2
  62. package/lib/organisms/CommandText/useCommandTextString/index.d.ts +2 -2
  63. package/lib/organisms/CommandText/useCommandTextString/utils/getLabwareDefinitionsFromCommands.d.ts +2 -2
  64. package/lib/organisms/CommandText/useCommandTextString/utils/getLabwareLocation.d.ts +3 -3
  65. package/lib/organisms/CommandText/useCommandTextString/utils/getLabwareName.d.ts +2 -2
  66. package/lib/organisms/FixtureOption/index.d.ts +2 -2
  67. package/lib/organisms/ProtocolDeck/index.d.ts +10 -0
  68. package/lib/organisms/ProtocolTimelineScrubber/CommandItem.d.ts +2 -2
  69. package/lib/organisms/ProtocolTimelineScrubber/utils.d.ts +2 -2
  70. package/lib/organisms/index.d.ts +1 -0
  71. package/lib/primitives/ForeignObject.d.ts +8 -18
  72. package/lib/primitives/style-props.d.ts +1 -1
  73. package/lib/structure/index.d.ts +2 -3
  74. package/package.json +6 -3
  75. package/src/alerts/alerts.module.css +2 -2
  76. package/src/assets/localization/en/deck_configuration.json +12 -0
  77. package/src/assets/localization/en/index.ts +2 -0
  78. package/src/assets/localization/en/protocol_command_text.json +1 -1
  79. package/src/atoms/AnimationVideo/__tests__/AnimationVideo.test.tsx +40 -0
  80. package/src/atoms/AnimationVideo/index.tsx +44 -0
  81. package/src/atoms/CheckboxField/__tests__/CheckboxField.test.tsx +0 -3
  82. package/src/atoms/CheckboxField/index.tsx +1 -1
  83. package/src/atoms/InlineNotification/index.tsx +86 -70
  84. package/src/atoms/ListButton/ListButton.stories.tsx +21 -7
  85. package/src/atoms/ListButton/ListButtonChildren/index.ts +0 -1
  86. package/src/atoms/ListItem/ListItemChildren/ListItemDescriptor.tsx +2 -2
  87. package/src/atoms/MenuList/OverflowBtn.tsx +39 -41
  88. package/src/atoms/Snackbar/Snackbar.stories.tsx +59 -23
  89. package/src/atoms/Snackbar/index.tsx +48 -38
  90. package/src/atoms/StyledText/PlaceholderStyledText.tsx +46 -0
  91. package/src/atoms/StyledText/index.ts +1 -0
  92. package/src/atoms/StyledText/placeholderstyledtext.module.css +25 -0
  93. package/src/atoms/buttons/BasicButton.tsx +100 -0
  94. package/src/atoms/buttons/SecondaryButton.tsx +5 -2
  95. package/src/atoms/buttons/__tests__/BasicButton.test.tsx +87 -0
  96. package/src/atoms/buttons/buttons.stories.tsx +91 -55
  97. package/src/atoms/buttons/index.ts +1 -0
  98. package/src/atoms/index.ts +1 -0
  99. package/src/buttons/buttons.module.css +92 -92
  100. package/src/controls/styles.module.css +15 -15
  101. package/src/forms/Select.module.css +23 -23
  102. package/src/forms/forms.module.css +38 -37
  103. package/src/hardware-sim/BaseDeck/BaseDeck.stories.tsx +7 -7
  104. package/src/hardware-sim/BaseDeck/BaseDeck.tsx +98 -61
  105. package/src/hardware-sim/BaseDeck/WasteChuteFixture.tsx +22 -28
  106. package/src/hardware-sim/BaseDeck/basedeck.module.css +20 -0
  107. package/src/hardware-sim/Deck/FlexTrash.tsx +50 -30
  108. package/src/hardware-sim/Deck/MoveLabwareOnDeck.stories.tsx +2 -2
  109. package/src/hardware-sim/Deck/MoveLabwareOnDeck.tsx +122 -156
  110. package/src/hardware-sim/Deck/RobotCoordsForeignDiv.tsx +35 -27
  111. package/src/hardware-sim/Deck/RobotCoordsForeignObject.tsx +32 -29
  112. package/src/hardware-sim/Deck/RobotCoordsText.tsx +12 -11
  113. package/src/hardware-sim/Deck/RobotWorkSpace.tsx +74 -54
  114. package/src/hardware-sim/Deck/SlotLabels.tsx +51 -51
  115. package/src/hardware-sim/Deck/__tests__/resolveLabwareLocation.test.ts +138 -0
  116. package/src/hardware-sim/Deck/deck.module.css +54 -0
  117. package/src/hardware-sim/Deck/resolveLabwareLocation.ts +154 -0
  118. package/src/hardware-sim/DeckConfigurator/{FlexStackerFixture.tsx → AbsorbanceReaderItem.tsx} +34 -31
  119. package/src/hardware-sim/DeckConfigurator/{EmptyConfigFixture.tsx → EmptyConfigItem.tsx} +72 -44
  120. package/src/hardware-sim/DeckConfigurator/{AbsorbanceReaderFixture.tsx → FlexStackerItem.tsx} +46 -27
  121. package/src/hardware-sim/DeckConfigurator/{HeaterShakerFixture.tsx → HeaterShakerItem.tsx} +40 -28
  122. package/src/hardware-sim/DeckConfigurator/{MagneticBlockFixture.tsx → MagneticBlockItem.tsx} +41 -58
  123. package/src/hardware-sim/DeckConfigurator/{StagingAreaConfigFixture.tsx → StagingAreaConfigItem.tsx} +41 -23
  124. package/src/hardware-sim/DeckConfigurator/{StaticFixture.tsx → StaticItem.tsx} +16 -9
  125. package/src/hardware-sim/DeckConfigurator/{TemperatureModuleFixture.tsx → TemperatureModuleItem.tsx} +42 -26
  126. package/src/hardware-sim/DeckConfigurator/{ThermocyclerFixture.tsx → ThermocyclerItem.tsx} +31 -21
  127. package/src/hardware-sim/DeckConfigurator/{TrashBinConfigFixture.tsx → TrashBinConfigItem.tsx} +42 -27
  128. package/src/hardware-sim/DeckConfigurator/{WasteChuteConfigFixture.tsx → WasteChuteConfigItem.tsx} +38 -27
  129. package/src/hardware-sim/DeckConfigurator/constants.ts +5 -9
  130. package/src/hardware-sim/DeckConfigurator/index.tsx +236 -206
  131. package/src/hardware-sim/Labware/CalibrationBlockRender.stories.tsx +49 -0
  132. package/src/hardware-sim/Labware/CalibrationBlockRender.tsx +172 -0
  133. package/src/hardware-sim/Labware/Labware.tsx +30 -15
  134. package/src/hardware-sim/Labware/LabwareAdapter/index.tsx +2 -2
  135. package/src/hardware-sim/Labware/LabwareRender.stories.tsx +36 -21
  136. package/src/hardware-sim/Labware/LabwareRender.tsx +70 -15
  137. package/src/hardware-sim/Labware/__tests__/Labware.test.tsx +9 -4
  138. package/src/hardware-sim/Labware/__tests__/LabwareRender.test.tsx +14 -5
  139. package/src/hardware-sim/Labware/index.ts +1 -0
  140. package/src/hardware-sim/Labware/labware.module.css +8 -0
  141. package/src/hardware-sim/Labware/labwareInternals/FilledWells.tsx +3 -4
  142. package/src/hardware-sim/Labware/labwareInternals/LabwareOutline.tsx +48 -23
  143. package/src/hardware-sim/Labware/labwareInternals/LabwareWellLabels.tsx +3 -3
  144. package/src/hardware-sim/Labware/labwareInternals/StaticLabware.tsx +2 -2
  145. package/src/hardware-sim/Labware/labwareInternals/StrokedWells.tsx +2 -2
  146. package/src/hardware-sim/Labware/labwareInternals/StyledWells.tsx +2 -2
  147. package/src/hardware-sim/Labware/labwareInternals/Well.tsx +1 -2
  148. package/src/hardware-sim/Labware/labwareInternals/WellLabels.tsx +10 -11
  149. package/src/hardware-sim/Labware/labwareInternals/__tests__/LabwareWellLabels.test.tsx +2 -2
  150. package/src/hardware-sim/Labware/labwareInternals/__tests__/StrokedWells.test.tsx +2 -2
  151. package/src/hardware-sim/Labware/labwareInternals/__tests__/WellLabels.test.tsx +2 -2
  152. package/src/hardware-sim/Module/Module.stories.tsx +45 -15
  153. package/src/hardware-sim/Module/Thermocycler/index.tsx +2 -2
  154. package/src/hardware-sim/Module/index.tsx +41 -18
  155. package/src/hardware-sim/Pipette/PipetteRender.stories.tsx +2 -2
  156. package/src/hardware-sim/Pipette/PipetteRender.tsx +5 -7
  157. package/src/hardware-sim/Pipette/__tests__/PipetteRender.test.tsx +2 -2
  158. package/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpace.tsx +15 -14
  159. package/src/hardware-sim/RobotCoordinateSpace/robotcoordinatespace.module.css +3 -0
  160. package/src/hocs/withStyleProps.ts +53 -0
  161. package/src/hooks/useConditionalConfirm.ts +15 -5
  162. package/src/icons/Icon.tsx +38 -29
  163. package/src/icons/ModuleIcon.tsx +5 -3
  164. package/src/icons/icon-data.ts +26 -2
  165. package/src/icons/icon.module.css +10 -0
  166. package/src/index.module.css +1 -0
  167. package/src/instrument/InstrumentDiagram.tsx +0 -2
  168. package/src/instrument/PipetteSelect.module.css +3 -3
  169. package/src/instrument/index.ts +0 -2
  170. package/src/legacy-hardware-sim/LabwareNameOverlay.module.css +5 -5
  171. package/src/legacy-hardware-sim/ModuleItem.module.css +19 -19
  172. package/src/legacy-hardware-sim/index.ts +0 -1
  173. package/src/lists/index.ts +0 -1
  174. package/src/lists/lists.module.css +23 -23
  175. package/src/modals/modals.module.css +55 -55
  176. package/src/molecules/CustomizeExpandButton/__tests__/CustomizeExpandButton.test.tsx +88 -0
  177. package/src/molecules/CustomizeExpandButton/index.tsx +189 -0
  178. package/src/molecules/DeckInfoLabel/DeckInfoLabel.stories.tsx +10 -6
  179. package/src/molecules/DeckInfoLabel/__tests__/DeckInfoLabel.test.tsx +15 -11
  180. package/src/molecules/DeckInfoLabel/deckinfolabel.module.css +42 -0
  181. package/src/molecules/DeckInfoLabel/index.tsx +36 -62
  182. package/src/molecules/DropdownMenu/index.tsx +17 -13
  183. package/src/molecules/InfoScreen/index.tsx +6 -2
  184. package/src/molecules/ReleaseNotes/styles.module.css +15 -15
  185. package/src/molecules/index.ts +2 -1
  186. package/src/nav/SidePanel.module.css +6 -6
  187. package/src/organisms/CommandText/__tests__/CommandText.test.tsx +12 -12
  188. package/src/organisms/CommandText/index.tsx +2 -2
  189. package/src/organisms/CommandText/useCommandTextString/index.ts +2 -2
  190. package/src/organisms/CommandText/useCommandTextString/utils/__tests__/getFinalLabwareLocation.test.ts +4 -4
  191. package/src/organisms/CommandText/useCommandTextString/utils/commandText/__tests__/getPipettingCommandText.test.tsx +3 -3
  192. package/src/organisms/CommandText/useCommandTextString/utils/commandText/getFlexStackerCommandText.ts +2 -4
  193. package/src/organisms/CommandText/useCommandTextString/utils/commandText/getMoveToWellCommandText.ts +19 -3
  194. package/src/organisms/CommandText/useCommandTextString/utils/commandText/getPipettingCommandText.ts +19 -10
  195. package/src/organisms/CommandText/useCommandTextString/utils/getLabwareDefinitionsFromCommands.ts +9 -9
  196. package/src/organisms/CommandText/useCommandTextString/utils/getLabwareLocation.tsx +3 -3
  197. package/src/organisms/CommandText/useCommandTextString/utils/getLabwareName.ts +2 -2
  198. package/src/organisms/DeckLabelSet/index.tsx +1 -3
  199. package/src/organisms/FixtureOption/__tests__/FixtureOption.test.tsx +0 -2
  200. package/src/organisms/FixtureOption/index.tsx +42 -71
  201. package/src/organisms/ProtocolDeck/index.tsx +118 -0
  202. package/src/organisms/ProtocolTimelineScrubber/CommandItem.tsx +2 -2
  203. package/src/organisms/ProtocolTimelineScrubber/PipetteVisuals.tsx +1 -1
  204. package/src/organisms/ProtocolTimelineScrubber/utils.ts +3 -3
  205. package/src/organisms/index.ts +1 -0
  206. package/src/primitives/ForeignObject.tsx +20 -61
  207. package/src/primitives/style-props.ts +1 -0
  208. package/src/slotmap/styles.module.css +1 -1
  209. package/src/structure/Pill.module.css +1 -1
  210. package/src/structure/Splash.module.css +1 -1
  211. package/src/structure/index.ts +2 -4
  212. package/src/structure/structure.module.css +11 -11
  213. package/src/styles/colors.module.css +1 -0
  214. package/src/styles/global.css +179 -0
  215. package/src/styles/index.module.css +1 -1
  216. package/src/styles/typography.module.css +1 -0
  217. package/src/testing/utils/renderWithProviders.tsx +3 -6
  218. package/src/tooltips/tooltips.module.css +14 -14
  219. package/vite.config.mts +6 -3
  220. package/lib/atoms/ListButton/ListButtonChildren/ListButtonRadioButton.d.ts +0 -14
  221. package/lib/hardware-sim/DeckConfigurator/AbsorbanceReaderFixture.d.ts +0 -10
  222. package/lib/hardware-sim/DeckConfigurator/EmptyConfigFixture.d.ts +0 -8
  223. package/lib/hardware-sim/DeckConfigurator/FlexStackerFixture.d.ts +0 -11
  224. package/lib/hardware-sim/DeckConfigurator/HeaterShakerFixture.d.ts +0 -10
  225. package/lib/hardware-sim/DeckConfigurator/MagneticBlockFixture.d.ts +0 -11
  226. package/lib/hardware-sim/DeckConfigurator/StagingAreaConfigFixture.d.ts +0 -10
  227. package/lib/hardware-sim/DeckConfigurator/TemperatureModuleFixture.d.ts +0 -10
  228. package/lib/hardware-sim/DeckConfigurator/ThermocyclerFixture.d.ts +0 -10
  229. package/lib/hardware-sim/DeckConfigurator/TrashBinConfigFixture.d.ts +0 -10
  230. package/lib/hardware-sim/DeckConfigurator/WasteChuteConfigFixture.d.ts +0 -11
  231. package/lib/hardware-sim/utils.d.ts +0 -3
  232. package/lib/instrument/InstrumentGroup.d.ts +0 -11
  233. package/lib/instrument/InstrumentInfo.d.ts +0 -18
  234. package/lib/legacy-hardware-sim/ModuleItem.d.ts +0 -17
  235. package/lib/lists/TitledList.d.ts +0 -44
  236. package/lib/structure/Card.d.ts +0 -18
  237. package/src/atoms/ListButton/ListButtonChildren/ListButtonRadioButton.tsx +0 -109
  238. package/src/atoms/ListButton/__tests__/ListButtonRadioButton.test.tsx +0 -28
  239. package/src/hardware-sim/utils.ts +0 -18
  240. package/src/instrument/InstrumentDiagram.stories.tsx +0 -43
  241. package/src/instrument/InstrumentGroup.stories.tsx +0 -89
  242. package/src/instrument/InstrumentGroup.tsx +0 -35
  243. package/src/instrument/InstrumentInfo.tsx +0 -106
  244. package/src/instrument/__tests__/InstrumentInfo.test.tsx +0 -58
  245. package/src/instrument/instrument.module.css +0 -45
  246. package/src/legacy-hardware-sim/ModuleItem.tsx +0 -145
  247. package/src/lists/TitledList.tsx +0 -154
  248. package/src/structure/Card.stories.tsx +0 -29
  249. package/src/structure/Card.tsx +0 -65
  250. /package/lib/atoms/{ListButton/__tests__/ListButtonRadioButton.test.d.ts → AnimationVideo/__tests__/AnimationVideo.test.d.ts} +0 -0
  251. /package/lib/{instrument/__tests__/InstrumentInfo.test.d.ts → atoms/buttons/__tests__/BasicButton.test.d.ts} +0 -0
@@ -1,28 +1,44 @@
1
1
  import * as React from 'react'
2
2
 
3
+ import { Snackbar as SnackbarComponent } from '.'
4
+ import { Flex, STYLE_PROPS } from '../../primitives'
3
5
  import {
4
6
  ALIGN_CENTER,
5
7
  DIRECTION_COLUMN,
6
8
  DIRECTION_ROW,
7
- Flex,
8
9
  JUSTIFY_CENTER,
9
- LegacyStyledText,
10
- PrimaryButton,
11
- SPACING,
12
- VIEWPORT,
13
- } from '@opentrons/components'
10
+ } from '../../styles'
11
+ import { SPACING, VIEWPORT } from '../../ui-style-constants'
12
+ import { PrimaryButton } from '../buttons'
13
+ import { StyledText } from '../StyledText'
14
14
 
15
- import { Snackbar } from './index'
15
+ import type { Meta, StoryObj } from '@storybook/react'
16
16
 
17
- import type { Meta, Story } from '@storybook/react'
18
-
19
- export default {
17
+ const meta: Meta<typeof SnackbarComponent> = {
20
18
  title: 'Helix/Atoms/Snackbar',
21
- component: Snackbar,
19
+ component: SnackbarComponent,
22
20
  parameters: VIEWPORT.touchScreenViewport,
23
- } as Meta
21
+ argTypes: {
22
+ // Disable all StyleProps
23
+ ...Object.fromEntries(
24
+ [...STYLE_PROPS, 'as', 'ref', 'theme', 'forwardedAs'].map(prop => [
25
+ prop,
26
+ { table: { disable: true } },
27
+ ])
28
+ ),
29
+ message: {
30
+ control: 'text',
31
+ },
32
+ duration: {
33
+ control: 'number',
34
+ },
35
+ },
36
+ }
24
37
 
25
- const DefaultTemplate: Story<React.ComponentProps<typeof Snackbar>> = args => {
38
+ // Define the render function as a React Functional Component
39
+ const SnackbarRenderComponent: React.FC<
40
+ React.ComponentProps<typeof SnackbarComponent>
41
+ > = args => {
26
42
  const [isShowSnackbar, setIsShowSnackbar] = React.useState<boolean>(false)
27
43
 
28
44
  const handleClick = (): void => {
@@ -31,15 +47,25 @@ const DefaultTemplate: Story<React.ComponentProps<typeof Snackbar>> = args => {
31
47
 
32
48
  return (
33
49
  <>
34
- <Flex flexDirection={DIRECTION_ROW} marginY={SPACING.spacing16}>
50
+ <Flex
51
+ flexDirection={DIRECTION_ROW}
52
+ paddingY={SPACING.spacing16}
53
+ gap={SPACING.spacing8}
54
+ >
35
55
  <PrimaryButton onClick={handleClick}>Click me</PrimaryButton>
36
- <Flex flexDirection={DIRECTION_COLUMN} marginLeft={SPACING.spacing8}>
37
- <LegacyStyledText as="p">
56
+ <Flex flexDirection={DIRECTION_COLUMN}>
57
+ <StyledText
58
+ desktopStyle="bodyDefaultRegular"
59
+ oddStyle="level4HeaderRegular"
60
+ >
38
61
  When clicking the button, the Snackbar shows up in the bottom.
39
- </LegacyStyledText>
40
- <LegacyStyledText as="p">
62
+ </StyledText>
63
+ <StyledText
64
+ desktopStyle="bodyDefaultRegular"
65
+ oddStyle="level4HeaderRegular"
66
+ >
41
67
  By default the Snackbar will disappear after 4 seconds.
42
- </LegacyStyledText>
68
+ </StyledText>
43
69
  </Flex>
44
70
  </Flex>
45
71
  {isShowSnackbar && (
@@ -51,7 +77,7 @@ const DefaultTemplate: Story<React.ComponentProps<typeof Snackbar>> = args => {
51
77
  bottom={SPACING.spacing40}
52
78
  zIndex={1000}
53
79
  >
54
- <Snackbar
80
+ <SnackbarComponent
55
81
  {...args}
56
82
  onClose={() => {
57
83
  setIsShowSnackbar(false)
@@ -63,7 +89,17 @@ const DefaultTemplate: Story<React.ComponentProps<typeof Snackbar>> = args => {
63
89
  )
64
90
  }
65
91
 
66
- export const SnackbarComponent = DefaultTemplate.bind({})
67
- SnackbarComponent.args = {
68
- message: 'Short and sweet message',
92
+ const SnackbarTemplate: Story = {
93
+ render: args => <SnackbarRenderComponent {...args} />,
94
+ }
95
+
96
+ export default meta
97
+ type Story = StoryObj<typeof SnackbarComponent>
98
+
99
+ export const Snackbar: Story = {
100
+ ...SnackbarTemplate,
101
+ args: {
102
+ message: 'Short and sweet message',
103
+ duration: 4000,
104
+ },
69
105
  }
@@ -1,4 +1,4 @@
1
- import { useState } from 'react'
1
+ import { useEffect, useState } from 'react'
2
2
  import { css } from 'styled-components'
3
3
 
4
4
  import { BORDERS, COLORS } from '../../helix-design-system'
@@ -16,14 +16,59 @@ export interface SnackbarProps extends StyleProps {
16
16
  }
17
17
 
18
18
  const SNACKBAR_ANIMATION_DURATION = 500
19
-
20
19
  const ODD_ANIMATION_OPTIMIZATIONS = `
21
20
  backface-visibility: hidden;
22
21
  perspective: 1000;
23
22
  will-change: opacity;
24
23
  `
25
24
 
25
+ export function Snackbar(props: SnackbarProps): JSX.Element {
26
+ const { message, onClose, duration = 4000, ...styleProps } = props
27
+ const [isClosed, setIsClosed] = useState<boolean>(false)
28
+
29
+ const animationStyle = isClosed ? CLOSE_STYLE : OPEN_STYLE
30
+
31
+ // Manages the snackbar closing sequencing
32
+ useEffect(() => {
33
+ if (duration == null || duration === 0) return
34
+
35
+ const closeTimer = setTimeout(() => {
36
+ // Trigger the closing animation
37
+ setIsClosed(true)
38
+
39
+ // Call onClose after animation completes, if it exists
40
+ onClose != null && setTimeout(onClose, SNACKBAR_ANIMATION_DURATION - 50)
41
+ }, duration)
42
+
43
+ return () => {
44
+ clearTimeout(closeTimer)
45
+ }
46
+ }, [duration, onClose])
47
+
48
+ return (
49
+ <Flex css={animationStyle} data-testid="Snackbar" {...styleProps}>
50
+ <StyledText
51
+ oddStyle="bodyTextSemiBold"
52
+ desktopStyle="bodyDefaultSemiBold"
53
+ >
54
+ {message}
55
+ </StyledText>
56
+ </Flex>
57
+ )
58
+ }
59
+
60
+ const COMMON_STYLE = css`
61
+ align-items: ${ALIGN_CENTER};
62
+ border-radius: ${BORDERS.borderRadius8};
63
+ box-shadow: ${BORDERS.shadowSmall};
64
+ background-color: ${COLORS.black90};
65
+ max-width: max-content;
66
+ padding: ${SPACING.spacing20} ${SPACING.spacing24};
67
+ color: ${COLORS.white};
68
+ `
69
+
26
70
  const OPEN_STYLE = css`
71
+ ${COMMON_STYLE}
27
72
  animation-duration: ${SNACKBAR_ANIMATION_DURATION}ms;
28
73
  animation-name: fadein;
29
74
  overflow: hidden;
@@ -40,6 +85,7 @@ const OPEN_STYLE = css`
40
85
  `
41
86
 
42
87
  const CLOSE_STYLE = css`
88
+ ${COMMON_STYLE}
43
89
  animation-duration: ${SNACKBAR_ANIMATION_DURATION}ms;
44
90
  animation-name: fadeout;
45
91
  overflow: hidden;
@@ -54,39 +100,3 @@ const CLOSE_STYLE = css`
54
100
  }
55
101
  }
56
102
  `
57
-
58
- export function Snackbar(props: SnackbarProps): JSX.Element {
59
- const { message, onClose, duration = 4000, ...styleProps } = props
60
- const [isClosed, setIsClosed] = useState<boolean>(false)
61
-
62
- const animationStyle = isClosed ? CLOSE_STYLE : OPEN_STYLE
63
-
64
- setTimeout(() => {
65
- setIsClosed(true)
66
- setTimeout(() => {
67
- onClose?.()
68
- }, SNACKBAR_ANIMATION_DURATION - 50)
69
- }, duration)
70
-
71
- return (
72
- <Flex
73
- css={animationStyle}
74
- alignItems={ALIGN_CENTER}
75
- borderRadius={BORDERS.borderRadius8}
76
- boxShadow={BORDERS.shadowSmall}
77
- backgroundColor={COLORS.black90}
78
- maxWidth="max-content"
79
- padding={`${SPACING.spacing20} ${SPACING.spacing24}`}
80
- data-testid="Snackbar"
81
- color={COLORS.white}
82
- {...styleProps}
83
- >
84
- <StyledText
85
- oddStyle="bodyTextSemiBold"
86
- desktopStyle="bodyDefaultSemiBold"
87
- >
88
- {message}
89
- </StyledText>
90
- </Flex>
91
- )
92
- }
@@ -0,0 +1,46 @@
1
+ import clsx from 'clsx'
2
+
3
+ import styles from './placeholderstyledtext.module.css'
4
+
5
+ import type { ReactNode } from 'react'
6
+
7
+ type StyleKey =
8
+ | 'headingSmallBold'
9
+ | 'captionBold'
10
+ | 'bodyDefaultSemiBold'
11
+ | 'smallBodyTextBold'
12
+
13
+ interface PlaceholderStyledTextProps {
14
+ children: ReactNode
15
+ color?: string
16
+ desktopStyle?: string
17
+ oddStyle?: string
18
+ }
19
+
20
+ /**
21
+ * @deprecated: NOTE: YOU SHOULD NOT BE USING THIS - THIS IS A TEMP COMPONENT
22
+ * USED FOR PROTOCOL LIBRARY TO NOT USE STYLED-COMPONENTS. USE THIS
23
+ * UNTIL WE MIGRATE STYLEDTEXT PROPERLY
24
+ */
25
+ export const PlaceholderStyledText = (
26
+ props: PlaceholderStyledTextProps
27
+ ): JSX.Element => {
28
+ const { children, color, desktopStyle, oddStyle } = props
29
+
30
+ const styleMap: Record<StyleKey, string> = {
31
+ headingSmallBold: styles.heading_small_bold,
32
+ captionBold: styles.caption_bold,
33
+ bodyDefaultSemiBold: styles.body_default_semi_bold,
34
+ smallBodyTextBold: styles.small_body_text_bold,
35
+ }
36
+ const combinedClassName = clsx(
37
+ desktopStyle != null ? styleMap[desktopStyle as StyleKey] : null,
38
+ oddStyle != null ? styleMap[oddStyle as StyleKey] : null
39
+ )
40
+
41
+ return (
42
+ <text className={combinedClassName} style={{ color: color ?? '' }}>
43
+ {children}
44
+ </text>
45
+ )
46
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './StyledText'
2
2
  export * from './LegacyStyledText'
3
+ export * from './PlaceholderStyledText'
@@ -0,0 +1,25 @@
1
+ .heading_small_bold {
2
+ @media not (height: 600px) and (width: 1024px) {
3
+ font: var(--font-weight-bold) 1.125rem/var(--line-height-24);
4
+ }
5
+ }
6
+
7
+ .caption_bold {
8
+ @media not (height: 600px) and (width: 1024px) {
9
+ font: var(--font-weight-bold) var(--font-size-h4)/var(--line-height-16);
10
+ }
11
+ }
12
+
13
+ .body_default_semi_bold {
14
+ @media not (height: 600px) and (width: 1024px) {
15
+ font: var(--font-weight-semi-bold) var(--font-size-h3)/var(--line-height-20);
16
+ }
17
+ }
18
+
19
+ .small_body_text_bold {
20
+ @media (height: 600px) and (width: 1024px) {
21
+ font-size: var(--font-size-20);
22
+ font-weight: var(--font-weight-bold);
23
+ line-height: var(--font-height-24);
24
+ }
25
+ }
@@ -0,0 +1,100 @@
1
+ import styled from 'styled-components'
2
+
3
+ import { COLORS } from '../../helix-design-system'
4
+ import { Icon } from '../../icons'
5
+ import { Flex } from '../../primitives'
6
+ import { ALIGN_CENTER } from '../../styles'
7
+ import { CURSOR_NOT_ALLOWED, CURSOR_POINTER } from '../../styles/cursor'
8
+ import { SPACING, TYPOGRAPHY } from '../../ui-style-constants'
9
+ import { StyledText } from '../StyledText/StyledText'
10
+
11
+ import type { MouseEvent } from 'react'
12
+ import type { IconName } from '../../icons'
13
+
14
+ interface BasicButtonProps {
15
+ children: string // Content of basic button
16
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void // Function to handle button click events
17
+ isDisabled?: boolean // Optional prop to control button aria-disabled
18
+ underLine?: boolean // Optional prop to control underline styling
19
+ tabIndex?: number // Optional prop for tab index
20
+ iconName?: IconName // Optional prop for icon
21
+ }
22
+
23
+ export function BasicButton({
24
+ children,
25
+ onClick,
26
+ isDisabled = false,
27
+ underLine = false,
28
+ tabIndex = 0,
29
+ iconName,
30
+ ...props
31
+ }: BasicButtonProps): JSX.Element {
32
+ const handleButtonClick = (event: MouseEvent<HTMLButtonElement>): void => {
33
+ if (isDisabled) {
34
+ event.preventDefault()
35
+ return
36
+ }
37
+ if (onClick != null) {
38
+ onClick(event)
39
+ }
40
+ }
41
+
42
+ return (
43
+ <StyledButton
44
+ data-testid={`basic_button_${children}`}
45
+ onClick={handleButtonClick}
46
+ aria-disabled={isDisabled}
47
+ underLine={underLine}
48
+ tabIndex={tabIndex}
49
+ {...props}
50
+ >
51
+ {iconName != null ? (
52
+ <Flex alignItems={ALIGN_CENTER} gap={SPACING.spacing8}>
53
+ <Icon
54
+ name={iconName}
55
+ size="1.25rem"
56
+ data-testid={`basic_button_${iconName}`}
57
+ />
58
+ <StyledText desktopStyle="bodyDefaultRegular">{children}</StyledText>
59
+ </Flex>
60
+ ) : (
61
+ <StyledText desktopStyle="bodyDefaultRegular">{children}</StyledText>
62
+ )}
63
+ </StyledButton>
64
+ )
65
+ }
66
+
67
+ const StyledButton = styled.button<{
68
+ underLine?: boolean
69
+ 'aria-disabled'?: boolean
70
+ }>`
71
+ background: none;
72
+ border: none;
73
+ padding: ${SPACING.spacing4};
74
+
75
+ color: ${props => (props['aria-disabled'] ? COLORS.grey40 : COLORS.black90)};
76
+ cursor: ${props =>
77
+ props['aria-disabled'] ? CURSOR_NOT_ALLOWED : CURSOR_POINTER};
78
+
79
+ text-decoration: ${props =>
80
+ props.underLine ? TYPOGRAPHY.textDecorationUnderline : 'none'};
81
+
82
+ ${props =>
83
+ !props['aria-disabled']
84
+ ? `
85
+ &:hover {
86
+ color: ${COLORS.blue50};
87
+ }
88
+
89
+ &:focus-visible {
90
+ color: ${COLORS.blue50};
91
+ outline: 2px solid ${COLORS.blue50};
92
+ outline-offset: ${SPACING.spacing4};
93
+ }
94
+ `
95
+ : undefined}
96
+
97
+ &[aria-disabled="true"] {
98
+ outline: none;
99
+ }
100
+ `
@@ -13,8 +13,7 @@ interface SecondaryButtonProps extends StyleProps {
13
13
  'aria-disabled'?: boolean
14
14
  }
15
15
  export const SecondaryButton = styled.button.withConfig<SecondaryButtonProps>({
16
- shouldForwardProp: p =>
17
- isntStyleProp(p) && p !== 'isDangerous' && p !== 'aria-disabled',
16
+ shouldForwardProp: p => isntStyleProp(p) && p !== 'isDangerous',
18
17
  })<SecondaryButtonProps>`
19
18
  appearance: none;
20
19
  cursor: ${props =>
@@ -92,3 +91,7 @@ export const SecondaryButton = styled.button.withConfig<SecondaryButtonProps>({
92
91
 
93
92
  ${styleProps}
94
93
  `
94
+
95
+ SecondaryButton.defaultProps = {
96
+ 'aria-disabled': false,
97
+ }
@@ -0,0 +1,87 @@
1
+ import { fireEvent, screen } from '@testing-library/react'
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
3
+
4
+ import { COLORS } from '../../../helix-design-system'
5
+ import { CURSOR_NOT_ALLOWED, CURSOR_POINTER } from '../../../styles/cursor'
6
+ import { renderWithProviders } from '../../../testing/utils'
7
+ import { TYPOGRAPHY } from '../../../ui-style-constants'
8
+ import { BasicButton } from '../BasicButton'
9
+
10
+ import type { ComponentProps } from 'react'
11
+
12
+ const render = (props: ComponentProps<typeof BasicButton>) => {
13
+ return renderWithProviders(<BasicButton {...props} />)
14
+ }
15
+
16
+ describe('BasicButton', () => {
17
+ let props: ComponentProps<typeof BasicButton>
18
+
19
+ beforeEach(() => {
20
+ props = {
21
+ children: 'basic button',
22
+ onClick: vi.fn(),
23
+ isDisabled: false,
24
+ underLine: false,
25
+ }
26
+ })
27
+
28
+ it('renders basic button with text', async () => {
29
+ render(props)
30
+ const button = screen.getByRole('button', { name: 'basic button' })
31
+ expect(button).toHaveAttribute('aria-disabled', 'false')
32
+ expect(button).toHaveStyle(`cursor: ${CURSOR_POINTER}`)
33
+ expect(button).toHaveStyle(`color: ${COLORS.black90}`)
34
+ expect(button).toHaveStyle(`text-decoration: none`)
35
+ })
36
+
37
+ it('renders basic button with icon', async () => {
38
+ props.iconName = 'alert'
39
+ render(props)
40
+ screen.getByTestId('basic_button_alert')
41
+ screen.getByRole('button', { name: 'basic button' })
42
+ })
43
+
44
+ // TODO: need to update '@testing-library/user-event' v14+
45
+ // it('has hover styles when not disabled', async () => {
46
+ // render(props)
47
+ // const button = screen.getByRole('button', { name: 'basic button' })
48
+ // await userEvent.hover(button)
49
+ // expect(button).toHaveStyle(`color: ${COLORS.blue50}`)
50
+ // })
51
+
52
+ it('calls onClick when clicked', () => {
53
+ render(props)
54
+ const button = screen.getByRole('button', { name: 'basic button' })
55
+ fireEvent.click(button)
56
+ expect(props.onClick).toHaveBeenCalled()
57
+ })
58
+
59
+ it('renders basic button with text and aria-disabled', () => {
60
+ props.isDisabled = true
61
+ render(props)
62
+ const button = screen.getByRole('button', { name: 'basic button' })
63
+ expect(button).toHaveAttribute('aria-disabled', 'true')
64
+ expect(button).toHaveStyle(`cursor: ${CURSOR_NOT_ALLOWED}`)
65
+ expect(button).toHaveStyle(`color: ${COLORS.grey40}`)
66
+ })
67
+
68
+ it('renders basic button with text and underline', () => {
69
+ props.underLine = true
70
+ render(props)
71
+ const button = screen.getByRole('button', { name: 'basic button' })
72
+ expect(button).toHaveAttribute('aria-disabled', 'false')
73
+ expect(button).toHaveStyle(`cursor: ${CURSOR_POINTER}`)
74
+ expect(button).toHaveStyle(`color: ${COLORS.black90}`)
75
+ expect(button).toHaveStyle(
76
+ `text-decoration: ${TYPOGRAPHY.textDecorationUnderline}`
77
+ )
78
+ })
79
+
80
+ it('has hover styles when not disabled', () => {
81
+ render(props)
82
+ const button = screen.getByRole('button', { name: 'basic button' })
83
+ expect(button).toHaveStyle(`color: ${COLORS.black90}`)
84
+ expect(button).toHaveAttribute('aria-disabled', 'false')
85
+ expect(button).toHaveStyle(`cursor: ${CURSOR_POINTER}`)
86
+ })
87
+ })
@@ -1,78 +1,114 @@
1
- import { Flex } from '../../primitives'
1
+ import { ICON_DATA_BY_NAME } from '../../icons/icon-data'
2
+ import { Flex, STYLE_PROPS } from '../../primitives'
2
3
  import { DIRECTION_ROW } from '../../styles'
3
4
  import { SPACING } from '../../ui-style-constants'
4
- import { AlertPrimaryButton } from './AlertPrimaryButton'
5
- import { AltPrimaryButton } from './AltPrimaryButton'
6
- import { PrimaryButton } from './PrimaryButton'
7
- import { SecondaryButton } from './SecondaryButton'
5
+ import { AlertPrimaryButton as AlertPrimaryButtonComponent } from './AlertPrimaryButton'
6
+ import { AltPrimaryButton as AltPrimaryButtonComponent } from './AltPrimaryButton'
7
+ import { BasicButton as BasicButtonComponent } from './BasicButton'
8
+ import { PrimaryButton as PrimaryButtonComponent } from './PrimaryButton'
9
+ import { SecondaryButton as SecondaryButtonComponent } from './SecondaryButton'
8
10
 
9
- import type { Meta, Story } from '@storybook/react'
10
- import type * as React from 'react'
11
+ import type { Meta, StoryObj } from '@storybook/react'
11
12
 
12
- export default {
13
+ const meta: Meta = {
13
14
  title: 'Helix/Atoms/Buttons',
14
- } as Meta
15
-
16
- const PrimaryButtonTemplate: Story<
17
- React.ComponentProps<typeof PrimaryButton>
18
- > = args => {
19
- const { children } = args
20
- return (
21
- <Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing16}>
22
- <PrimaryButton>{children}</PrimaryButton>
23
- </Flex>
24
- )
15
+ argTypes: {
16
+ ...Object.fromEntries(
17
+ [...STYLE_PROPS, 'as', 'ref', 'theme', 'forwardedAs'].map(prop => [
18
+ prop,
19
+ { table: { disable: true } },
20
+ ])
21
+ ),
22
+ children: {
23
+ control: {
24
+ type: 'text',
25
+ },
26
+ },
27
+ 'aria-disabled': {
28
+ control: {
29
+ type: 'boolean',
30
+ },
31
+ },
32
+ isDangerous: {
33
+ control: {
34
+ type: 'boolean',
35
+ },
36
+ },
37
+ },
25
38
  }
26
39
 
27
- export const Primary = PrimaryButtonTemplate.bind({})
28
- Primary.args = {
29
- children: 'primary button',
30
- }
40
+ export default meta
31
41
 
32
- const SecondaryButtonTemplate: Story<
33
- React.ComponentProps<typeof SecondaryButton>
34
- > = args => {
35
- const { children } = args
36
- return (
42
+ export const PrimaryButton: StoryObj<typeof PrimaryButtonComponent> = {
43
+ args: {
44
+ children: 'primary button',
45
+ },
46
+ render: args => (
37
47
  <Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing16}>
38
- <SecondaryButton>{children}</SecondaryButton>
48
+ <PrimaryButtonComponent {...args} />
39
49
  </Flex>
40
- )
50
+ ),
41
51
  }
42
52
 
43
- export const Secondary = SecondaryButtonTemplate.bind({})
44
- Secondary.args = {
45
- children: 'secondary button',
53
+ export const SecondaryButton: StoryObj<typeof SecondaryButtonComponent> = {
54
+ args: {
55
+ children: 'secondary button',
56
+ },
57
+ render: args => (
58
+ <Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing16}>
59
+ <SecondaryButtonComponent {...args} />
60
+ </Flex>
61
+ ),
46
62
  }
47
63
 
48
- const AlertPrimaryButtonTemplate: Story<
49
- React.ComponentProps<typeof AlertPrimaryButton>
50
- > = args => {
51
- const { children } = args
52
- return (
64
+ export const AlertPrimaryButton: StoryObj<
65
+ typeof AlertPrimaryButtonComponent
66
+ > = {
67
+ args: {
68
+ children: 'alert tertiary button',
69
+ },
70
+ render: args => (
53
71
  <Flex>
54
- <AlertPrimaryButton>{children}</AlertPrimaryButton>
72
+ <AlertPrimaryButtonComponent {...args} />
55
73
  </Flex>
56
- )
57
- }
58
-
59
- export const AlertPrimary = AlertPrimaryButtonTemplate.bind({})
60
- AlertPrimary.args = {
61
- children: 'alert tertiary button',
74
+ ),
62
75
  }
63
76
 
64
- const AltPrimaryButtonTemplate: Story<
65
- React.ComponentProps<typeof AltPrimaryButton>
66
- > = args => {
67
- const { children } = args
68
- return (
77
+ export const AltPrimaryButton: StoryObj<typeof AltPrimaryButtonComponent> = {
78
+ args: {
79
+ children: 'alt primary button',
80
+ },
81
+ render: args => (
69
82
  <Flex>
70
- <AltPrimaryButton>{children}</AltPrimaryButton>
83
+ <AltPrimaryButtonComponent {...args} />
71
84
  </Flex>
72
- )
85
+ ),
73
86
  }
74
87
 
75
- export const AltPrimary = AltPrimaryButtonTemplate.bind({})
76
- AltPrimary.args = {
77
- children: 'alt primary button',
88
+ export const BasicButton: StoryObj<typeof BasicButtonComponent> = {
89
+ args: {
90
+ children: 'basic button',
91
+ },
92
+ argTypes: {
93
+ underLine: {
94
+ control: {
95
+ type: 'boolean',
96
+ },
97
+ description:
98
+ 'Toggles the underline style for the button text (BasicButton only).',
99
+ },
100
+ iconName: {
101
+ options: Object.keys(ICON_DATA_BY_NAME),
102
+ control: {
103
+ type: 'select',
104
+ },
105
+ description:
106
+ 'Optional icon to display alongside the button text (BasicButton only).',
107
+ },
108
+ },
109
+ render: args => (
110
+ <Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing16}>
111
+ <BasicButtonComponent {...args} />
112
+ </Flex>
113
+ ),
78
114
  }