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

Migrate BaseStyles to TypeScript #982

Merged
merged 4 commits into from
Jan 26, 2021
Merged
Changes from 1 commit
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
20 changes: 13 additions & 7 deletions src/BaseStyles.js → src/BaseStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import styled, {createGlobalStyle} from 'styled-components'
import PropTypes from 'prop-types'
import {TYPOGRAPHY, COMMON} from './constants'
import {TYPOGRAPHY, COMMON, SystemTypographyProps, SystemCommonProps} from './constants'
import useMouseIntent from './hooks/useMouseIntent'
import theme from './theme'

Expand All @@ -26,19 +26,24 @@ const GlobalStyle = createGlobalStyle`
}

`
const Base = props => {

const Base = styled.div<SystemTypographyProps & SystemCommonProps>`
${TYPOGRAPHY};
${COMMON};
`

export type BaseStylesProps = React.ComponentProps<typeof Base>
colebemis marked this conversation as resolved.
Show resolved Hide resolved

const BaseStyles: React.FC<BaseStylesProps> = props => {
const {color, lineHeight, fontFamily, theme, ...rest} = props
useMouseIntent()
return (
<div {...rest}>
<Base {...rest}>
<GlobalStyle />
{props.children}
</div>
</Base>
)
}
const BaseStyles = styled(Base)`
${TYPOGRAPHY} ${COMMON};
`

BaseStyles.defaultProps = {
color: 'gray.9',
Expand All @@ -52,4 +57,5 @@ BaseStyles.propTypes = {
...COMMON.propTypes,
theme: PropTypes.object
}

export default BaseStyles