Skip to content

Commit

Permalink
Merge pull request #106 from ruedap/ts-css-prop
Browse files Browse the repository at this point in the history
Improve module declaration of css prop for TypeScript
  • Loading branch information
ruedap authored May 26, 2020
2 parents 6843fbc + 851d244 commit 785d9af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions components/templates/styleguide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Styleguide = () => {
<FooBar />
<FooBarTag4 />
<Styled.Title>Styleguide</Styled.Title>
<div css={Styled.prop}>This is css prop</div>
<Styled.Tag1>Cool Styles</Styled.Tag1>
<Styled.Tag2>
With <code>:hover</code>.
Expand Down
5 changes: 5 additions & 0 deletions components/templates/styleguide/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const hover = css`
}
`

export const prop = css`
font-size: 200%;
color: indigo;
`

export const bounce = keyframes`
from {
transform: scale(1.01);
Expand Down
3 changes: 0 additions & 3 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// To solve the issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31245
/// <reference types="styled-components/cssprop" />

import { AppProps } from 'next/app'
import Router from 'next/router'
import { ThemeProvider, DefaultTheme } from 'styled-components'
Expand Down
9 changes: 9 additions & 0 deletions types/cssprop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31245
// https://github.com/styled-components/styled-components/issues/2528#issuecomment-509780963
import { CSSProp } from 'styled-components'

declare module 'react' {
interface HTMLAttributes<T> extends DOMAttributes<T> {
css?: CSSProp
}
}

1 comment on commit 785d9af

@vercel
Copy link

@vercel vercel bot commented on 785d9af May 26, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.