Skip to content

Commit

Permalink
improvement(styles): Improve module declaration of css prop for TypeS…
Browse files Browse the repository at this point in the history
…cript
  • Loading branch information
ruedap committed May 26, 2020
1 parent 6843fbc commit 851d244
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
}
}

0 comments on commit 851d244

Please sign in to comment.