-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(odd): menuList and MenuItem ODD support (#12511)
closes RAUT-403
- Loading branch information
Showing
9 changed files
with
167 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,56 @@ | ||
import styled from 'styled-components' | ||
import { | ||
SPACING, | ||
Btn, | ||
COLORS, | ||
TEXT_ALIGN_LEFT, | ||
TYPOGRAPHY, | ||
ALIGN_CENTER, | ||
RESPONSIVENESS, | ||
StyleProps, | ||
} from '@opentrons/components' | ||
|
||
import type { PrimitiveComponent } from '@opentrons/components' | ||
|
||
type BtnComponent = PrimitiveComponent<'button'> | ||
|
||
export const MenuItem: BtnComponent = styled(Btn)` | ||
text-align: ${TEXT_ALIGN_LEFT}; | ||
interface ButtonProps extends StyleProps { | ||
/** optional isAlert boolean to turn the background red, only seen in ODD */ | ||
isAlert?: boolean | ||
} | ||
export const MenuItem = styled.button<ButtonProps>` | ||
text-align: ${TYPOGRAPHY.textAlignLeft}; | ||
font-size: ${TYPOGRAPHY.fontSizeP}; | ||
background-color: ${COLORS.transparent}; | ||
color: ${COLORS.darkBlackEnabled}; | ||
padding: ${SPACING.spacing3} 0.75rem ${SPACING.spacing3} 0.75rem; | ||
&:hover { | ||
&:hover, | ||
&:active { | ||
background-color: ${COLORS.lightBlue}; | ||
} | ||
&:disabled, | ||
&.disabled { | ||
&:disabled { | ||
background-color: ${COLORS.transparent}; | ||
color: ${COLORS.black}${COLORS.opacity50HexCode}; | ||
} | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
align-items: ${ALIGN_CENTER}; | ||
text-align: ${TYPOGRAPHY.textAlignCenter}; | ||
font-size: ${TYPOGRAPHY.fontSize28}; | ||
background-color: ${({ isAlert }) => | ||
isAlert ? COLORS.errorEnabled : COLORS.transparent}; | ||
color: ${({ isAlert }) => | ||
isAlert ? COLORS.white : COLORS.darkBlackEnabled}; | ||
padding: 1.625rem 1.5rem; | ||
height: 4.875rem; | ||
line-height: ${TYPOGRAPHY.lineHeight36}; | ||
&:hover, | ||
&:active { | ||
background-color: ${({ isAlert }) => | ||
isAlert ? COLORS.errorEnabled : COLORS.darkBlack_twenty}; | ||
} | ||
&:disabled { | ||
background-color: ${({ isAlert }) => | ||
isAlert ? COLORS.errorEnabled : COLORS.transparent}; | ||
color: ${({ isAlert }) => | ||
isAlert ? COLORS.white : COLORS.darkBlack_sixty}; | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,27 @@ | ||
import * as React from 'react' | ||
import { css } from 'styled-components' | ||
import { | ||
Flex, | ||
TYPOGRAPHY, | ||
COLORS, | ||
TEXT_ALIGN_LEFT, | ||
SPACING, | ||
} from '@opentrons/components' | ||
import { MenuList } from './index' | ||
import { MenuItem } from './MenuItem' | ||
|
||
import type { Story, Meta } from '@storybook/react' | ||
|
||
export default { | ||
title: 'App/Atoms/MenuList', | ||
component: MenuList, | ||
onClick: { action: 'clicked' }, | ||
} as Meta | ||
|
||
const Template: Story<React.ComponentProps<typeof MenuList>> = args => ( | ||
<MenuList {...args} /> | ||
) | ||
|
||
const style = css` | ||
width: auto; | ||
text-align: ${TEXT_ALIGN_LEFT}; | ||
font-size: ${TYPOGRAPHY.fontSizeP}; | ||
padding-bottom: ${TYPOGRAPHY.fontSizeH6}; | ||
background-color: transparent; | ||
color: ${COLORS.darkBlackEnabled}; | ||
padding-left: ${TYPOGRAPHY.fontSizeLabel}; | ||
padding-right: ${TYPOGRAPHY.fontSizeLabel}; | ||
padding-top: ${SPACING.spacing3}; | ||
&:hover { | ||
background-color: ${COLORS.lightBlue}; | ||
} | ||
&:disabled, | ||
&.disabled { | ||
color: ${COLORS.darkGreyDisabled}; | ||
} | ||
` | ||
const btn = <Flex css={style}>{'Example menu btn'}</Flex> | ||
|
||
const menuBtn = 'example menu btn' | ||
export const Primary = Template.bind({}) | ||
Primary.args = { | ||
buttons: [btn, btn], | ||
children: ( | ||
<> | ||
<MenuItem>{menuBtn}</MenuItem> | ||
<MenuItem>{menuBtn}</MenuItem> | ||
<MenuItem>{menuBtn}</MenuItem> | ||
</> | ||
), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.