Skip to content
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

🎨 Improve story for Divider #744

Merged
merged 3 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/storybook-react/stories/Divider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit silly. How do we deal with styled components in the stories? Should we use the same eslint config for the stories that we use in Core React?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote yes 👍

import React from 'react'
import styled from 'styled-components'
import { Divider, DividerProps } from '@equinor/eds-core-react'
Expand All @@ -22,9 +25,7 @@ export default {
},
} as Meta

type WrapperProps = React.HTMLAttributes<HTMLDivElement>

const Wrapper = styled.div<WrapperProps>`
const Wrapper = styled.div`
padding: 32px;
background-color: #999;
`
Expand Down
25 changes: 13 additions & 12 deletions libraries/core-react/src/Divider/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ export type DividerProps = {
className?: string
}

export const Divider = forwardRef<HTMLHRElement, DividerProps>(
({ color = 'medium', variant = 'medium', className = '' }, ref) => {
const styleProps = {
backgroundColor: tokens.color[color],
marginTop: tokens[variant].spacings.top,
marginBottom: tokens[variant].spacings.bottom,
dividerHeight: tokens.height,
}
return <StyledDivider {...styleProps} className={className} ref={ref} />
},
)
export const Divider = forwardRef<HTMLHRElement, DividerProps>(function Divider(
{ color = 'medium', variant = 'medium', className = '' },
ref,
) {
const styleProps = {
backgroundColor: tokens.color[color],
marginTop: tokens[variant].spacings.top,
marginBottom: tokens[variant].spacings.bottom,
dividerHeight: tokens.height,
}
return <StyledDivider {...styleProps} className={className} ref={ref} />
})

Divider.displayName = 'Divider'
// Divider.displayName = 'Divider'
2 changes: 1 addition & 1 deletion libraries/core-react/src/Divider/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { Divider, DividerProps } from './Divider'
export * from './Divider'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By re-exporting * we don’t get error messages about the types not being exported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did kinda the same for Banner