Skip to content

Commit

Permalink
feat: Add custom css to lux components (#112)
Browse files Browse the repository at this point in the history
* add style prop to components

* code review changes

* missed some code-review type lines

* removed semi from article

* document custom styling prop
  • Loading branch information
mindip authored and ryang72 committed Nov 17, 2018
1 parent 18299cf commit cbca503
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/components/Article/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /article

import { Playground, PropsTable } from 'docz'
import Article from '.'
import { css } from 'react-emotion'

# Article

Expand All @@ -16,6 +17,7 @@ Note that `Article` expects an array of `Content`, which

<Playground>
<Article
style={css`color: red;`}
dropcap={true}
content={[
{
Expand Down
3 changes: 3 additions & 0 deletions src/components/Article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface ArticleProps {
/** The paragraphs of content for the story. */
content: Content[]
dropcap: boolean
/** custom css for the article component */
style?: string
}

/** A footer to go at the bottom of every page. */
Expand Down Expand Up @@ -70,6 +72,7 @@ export default class Article extends React.Component<ArticleProps> {
}
`
: ''};
${this.props.style};
`}
>
{renderedContent}
Expand Down
6 changes: 5 additions & 1 deletion src/components/ArticleGrid/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /article-grid

import { Playground, PropsTable } from 'docz'
import ArticleGrid from '.'
import { css } from 'react-emotion'

# ArticleGrid

Expand All @@ -13,5 +14,8 @@ A grid of articles for displaying on grid layout flatpages.
<PropsTable of={ArticleGrid} />

<Playground>
<ArticleGrid heading="News" articles={[]} />
<ArticleGrid style={css`
color: blue;
`}
heading="News" articles={[]} />
</Playground>
2 changes: 2 additions & 0 deletions src/components/ArticleGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ArticleGridProps {
articles: ArticleCardData[]
maxColumns: number
minColumns: number
style?: string
}

export default class ArticleGrid extends React.Component<ArticleGridProps> {
Expand Down Expand Up @@ -47,6 +48,7 @@ export default class ArticleGrid extends React.Component<ArticleGridProps> {
id={!!this.props.heading ? slugify(this.props.heading) : undefined}
className={css`
margin-top: 20px;
${this.props.style};
`}
>
{!!this.props.heading && (
Expand Down
6 changes: 5 additions & 1 deletion src/components/Byline/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /byline

import { Playground, PropsTable } from 'docz'
import Byline from '.'
import { css } from 'react-emotion'

# Byline

Expand All @@ -13,6 +14,9 @@ Every story needs an author and a byline.
<PropsTable of={Byline} />

<Playground>
<Byline authors="Tanner Walters" />
<Byline style={css`
font-weight: bold
`}
authors="Tanner Walters" />
<Byline authors={["Tanner Walters", "Mackenzie Possee", "Jacob Preal"]} />
</Playground>
3 changes: 3 additions & 0 deletions src/components/Byline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import toSentence from '../../utils/toSentence'
interface BylineProps {
/** The authors of the story. */
authors: string | string[]
/** Custom css for the byline */
style?: string
}

/** The byline of the story. */
Expand All @@ -21,6 +23,7 @@ export default function Byline(props: BylineProps) {
<div
className={css`
padding-top: 5px;
${props.style};
`}
>
By {authorString}
Expand Down
3 changes: 2 additions & 1 deletion src/components/CoverPhoto/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /cover-photo

import { Playground, PropsTable } from 'docz'
import CoverPhoto from '.'
import { css } from 'react-emotion'

# Cover Photo

Expand All @@ -13,7 +14,7 @@ A cover photo.
<PropsTable of={CoverPhoto} />

<Playground>
<CoverPhoto headline="Gene Block starts meme factory" authors="Tanner Walters" imageURL="https://features.dailybruin.com/2017/close-to-home/img/web.enterprise.anonymous.DLee.jpg"
<CoverPhoto style={css`border-radius: 10em;`} headline="Gene Block starts meme factory" authors="Tanner Walters" imageURL="https://features.dailybruin.com/2017/close-to-home/img/web.enterprise.anonymous.DLee.jpg"
xPosition="center"
yPosition="center"
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/CoverPhoto/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface CoverPhotoProps {
xPosition: XPosition
yPosition: YPosition
darken?: number
style?: string
}

export default class CoverPhoto extends React.Component<CoverPhotoProps> {
Expand Down Expand Up @@ -52,6 +53,7 @@ export default class CoverPhoto extends React.Component<CoverPhotoProps> {
display: grid;
align-items: ${this.props.yPosition};
justify-content: ${this.props.xPosition};
${this.props.style}
`}
>
<div
Expand Down
5 changes: 5 additions & 0 deletions src/components/Footer/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /footer

import { Playground, PropsTable } from 'docz'
import Footer from '.'
import { css } from 'react-emotion'

# Footer

Expand All @@ -14,6 +15,10 @@ Every web page needs a footer.

<Playground>
<Footer
style={css`
background-color: #0B5FFF;
color: #FFF;
`}
githubLink={'https://dailybruin.com/'}
developers={['Nathan Smith', 'Michael Zhang', 'Dustin Newman']}
/>
Expand Down
17 changes: 10 additions & 7 deletions src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ interface FooterProps {
copyrightYear: number
/** What type of project this footer is being used in. */
footerType: ComponentType
/** Custom css for the footer component */
style?: string
}

/** A footer to go at the bottom of every page. */
class Footer extends React.Component<FooterProps> {
static defaultProps = {
license: License.Copyright,
footerType: ComponentType.Default
footerType: ComponentType.Default,
}

render() {
if(this.props.footerType === ComponentType.Default) {
if (this.props.footerType === ComponentType.Default) {
return (
<footer
className={css`
Expand All @@ -50,6 +52,7 @@ class Footer extends React.Component<FooterProps> {
@media (max-width: 600px) {
font-size: 0.8rem;
}
${this.props.style};
`}
>
<div>
Expand All @@ -66,7 +69,9 @@ class Footer extends React.Component<FooterProps> {
>
Site code available on{' '}
<a
href={`https://github.com/dailybruin/${this.props.githubName}`}
href={`https://github.com/dailybruin/${
this.props.githubName
}`}
>
GitHub
</a>
Expand All @@ -85,11 +90,9 @@ class Footer extends React.Component<FooterProps> {
</div>
</footer>
)
} else /** this.props.footerType === ComponentType.MainSite */{
} /** this.props.footerType === ComponentType.MainSite */ else {
/** This should be updated if more typeEnums are added */
return(
<MainSiteFooter/>
)
return <MainSiteFooter />
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Headline/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /headline

import { Playground, PropsTable } from 'docz'
import Headline from '.'
import { css } from 'react-emotion'

# Headline

Expand All @@ -13,5 +14,5 @@ Every story needs a headline.
<PropsTable of={Headline} />

<Playground>
<Headline text="Gene Block Starts Meme Factory"/>
<Headline style={css`color: #0B5FFF;`} text="Gene Block Starts Meme Factory"/>
</Playground>
4 changes: 3 additions & 1 deletion src/components/Headline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { css } from 'react-emotion'
interface HeadlineProps {
/** The headline of the story. */
text: string
/** Custom css for the headline component */
style?: string
}

/** The story's headline. */
export default function Headline(props: HeadlineProps) {
return <h1>{props.text}</h1>
return <h1 className={props.style}>{props.text}</h1>
}
4 changes: 4 additions & 0 deletions src/components/Image/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ route: /image

import { Playground, PropsTable } from 'docz'
import Image from '.'
import { css } from 'react-emotion'

# Image

Expand All @@ -18,5 +19,8 @@ An image with a caption.
caption="Freshman attacker Ashworth Molthen has registered 21 goals on the season, finding the back of the net in 13 of the 16 games so far this year for UCLA men’s water polo. UCLA is one of two teams remaining in the MPSF conference that remains undefeated."
credit="Amy Dixon/Photo editor"
alt="Ashworth Molthen playing water polo."
style={css`
color: red;
`}
/>
</Playground>
5 changes: 3 additions & 2 deletions src/components/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ export interface ImageProps {
caption: string
credit: string
alt: string
/** Custom css for the image component */
style?: string
}

export default function Image(props: ImageProps) {
if (!props.alt) {
throw new Error('Image requires a meaningful `alt` value.')
}

return (
<figure>
<figure className={props.style}>
<img
className={css`
width: 100%;
Expand Down

0 comments on commit cbca503

Please sign in to comment.