Skip to content

Commit

Permalink
Added example for issue #10
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-ebey committed Apr 14, 2018
1 parent 22b782b commit 7b83b5f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions examples/ThirdParty.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react'
import styledComponents from 'styled-components'
import styledComponentsTs from '../src/styled-components-ts'

// Imagine the ThirdParty component below is from a library that accepts a className to extend
// it's styling (standard react pattern)
export interface IThirdPartyProps {
label: string
className?: string
}

export const ThirdParty = ({ label, className }: IThirdPartyProps) => (
<h1 className={`class-from-lib ${className || ''}`}>{ label }</h1>
)

export interface IExtendedThirdPartyProps {
hasError?: boolean
}

// Your code to add styling would be the following
export const StyledThirdParty = styledComponentsTs<IExtendedThirdPartyProps>(styledComponents(ThirdParty))`
color: ${props => props.hasError ? 'red' : 'blue'};
`
1 change: 1 addition & 0 deletions examples/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './ExpandedImage'
export * from './MyImage'
export * from './ThirdParty'
export * from './WithComponent'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "styled-components-ts",
"version": "0.0.13",
"version": "0.0.14",
"description": "Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress and the added benefits of TypeScript 💅",
"repository": {
"type": "git",
Expand Down

0 comments on commit 7b83b5f

Please sign in to comment.