-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(action-bar): Refactor ActionBar component #1396
feat(action-bar): Refactor ActionBar component #1396
Conversation
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
5580ee6
to
9065cd4
Compare
Overall I'm torn on this refactor. I didn't have comments on specific lines, so I'll review here: With many conversions to compound components, we've been moving to using layout components which give us a lot of niceties: many style props come for free and defaults are easily overridden. For example: Using styledexport interface SomeStyledProps {
position: ...
}
const SomeStyledComponent = styled('div')<SomeStypedProps & StyledType>({
display: 'flex',
...
position: 'fixed',
left: 0,
right: 0,
top: 0,
...
({position}) => ({position})
})
const SomeComponent = createComponent({
Component(props: SomeComponentProps, ref, Element) {
return <SomeStyledComponent ref={ref} as={Element} {...props} />
}
}) Layout componentsinterface SomeComponentProps extends FlexProps {}
const SomeComponent = createComponent({
Component(props: SomeComponentProps, ref, Element) {
return (
<Flex
ref={ref}
as={Element}
position="fixed"
top={0}
left={0}
right={0}
{...props}
/>
)
}
}) We don't export prop types anymore with interface Props {
foo: string
}
const Component = createComponent('div')({
Component(props: Props) {
return <div />
}
})
type Props1 = Props // Props
type Props2 = ExtractProps<typeof Component> // Props & React.HTMLAttributes<HTMLDivElement>
type Props3 = ExtractProps<typeof Component, never> // Props
type Props4 = ExtractProps<typeof Component, 'aside'> // Props & React.HTMLAttributes<HTMLElement> If someone wants to extend const MyComponent = (props: ExtractProps<typeof Component, 'aside'>) => {
return <Component as="aside" {...props} />
} Also, If |
Co-authored-by: Nicholas Boll <nicholas.boll@gmail.com>
<ActionBar /> | ||
`; | ||
|
||
expectTransform(input, expected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions:
- Will this support default imports?
import ActionBar from '@workday/canvas-kit-react/action-bar
- Will this support imports from
@workday/canvas-kit-react
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- No. There is no default import from action-bar files.
- Yes. It supports imports from main directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small copy nit. The rest looks great! Thanks!!
Co-authored-by: Alan B Smith <a.bax.smith@gmail.com>
@@ -1,5 +1 @@ | |||
import ActionBar from './lib/ActionBar'; | |||
|
|||
export default ActionBar; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIll the codemod also update any default imports to named imports? E.g.
import ActionBar from '@workday/canvas-kit-react/action-bar';
becomes this:
import { ActionBar } from '@workday/canvas-kit-react/action-bar';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching it! I've updated existing codemod to add a script that changes default import to named or renamed import from action-bar
package. Now codemod should cover this problem.
This PR will be on hold by tomorrow. @alanbsmith found a change that is not covered by codemod but It's reasonable to have opportunity to change default import to named using codemod. |
This is a visual regression test that isn't showing the buttons. Is this intentional? https://www.chromatic.com/test?appId=5d854c26ba934e0020f5e98a&id=61d8c63dd73a51003ae4758a |
Summary
ChildrenContainer
and replace it styles toActionBarContainer
.Resolves: #1382
BREAKING CHANGES
Change
fixed
prop from component toposition
to set container position (fixed
position has been set as default).