-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added BlockQuote component lib and it's storybook.
- Loading branch information
1 parent
866dd9e
commit 332dfc9
Showing
9 changed files
with
182 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import React, { useContext } from 'react'; | ||
import styled, { css, ThemeContext } from 'styled-components'; | ||
|
||
function BlockQuote({ text, footer, size, children }) { | ||
const supportedSizes = ['xsmall', 'small', 'medium', 'large', 'xlarge']; | ||
// Set the default size. | ||
size = supportedSizes.includes(size) ? size : 'medium'; | ||
|
||
const theme = useContext(ThemeContext); | ||
const Quote = styled.blockquote` | ||
position: relative; | ||
background: ${theme.global.colors['light-3']}; | ||
color: ${theme.global.colors.text.light}; | ||
p::before { | ||
display: block; | ||
position: absolute; | ||
color: ${theme.global.colors.text.light}; | ||
content: '\\201C'; | ||
} | ||
${size === 'xsmall' && | ||
css` | ||
margin: 0.05em 0; | ||
padding: 1em 1.5em; | ||
line-height: 1.05; | ||
p::before { | ||
padding-left: 10px; | ||
font-size: 45px; | ||
left: -8px; | ||
top: 3px; | ||
} | ||
`}; | ||
${size === 'small' && | ||
css` | ||
margin: 0.15em 0; | ||
padding: 1em 2.5em; | ||
line-height: 1.25; | ||
p::before { | ||
padding-left: 10px; | ||
font-size: 60px; | ||
left: -4px; | ||
top: -5px; | ||
} | ||
`}; | ||
${size === 'medium' && | ||
css` | ||
margin: 0.25em 0; | ||
padding: 1.5em 3.5em; | ||
line-height: 1.45; | ||
p::before { | ||
padding-left: 10px; | ||
font-size: 80px; | ||
left: -4px; | ||
top: -20px; | ||
} | ||
`}; | ||
${size === 'large' && | ||
css` | ||
margin: 0.35em 0; | ||
padding: 1.5em 4.5em; | ||
line-height: 1.65; | ||
p::before { | ||
padding-left: 10px; | ||
font-size: 100px; | ||
left: 5px; | ||
top: -35px; | ||
} | ||
`}; | ||
${size === 'xlarge' && | ||
css` | ||
margin: 0.45em 0; | ||
padding: 1.5em 5.5em; | ||
line-height: 1.85; | ||
p::before { | ||
padding-left: 10px; | ||
font-size: 120px; | ||
left: 9px; | ||
top: -50px; | ||
} | ||
`}; | ||
`; | ||
if (text) { | ||
return ( | ||
<Quote> | ||
<p>{text}</p> | ||
{footer && <footer>{footer}</footer>} | ||
</Quote> | ||
); | ||
} else { | ||
return <Quote>{children}</Quote>; | ||
} | ||
} | ||
|
||
export default BlockQuote; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { storiesOf } from '@storybook/react'; | ||
import React from 'react'; | ||
import { Grommet } from 'grommet'; | ||
|
||
import { powerTheme } from '../../themes'; | ||
|
||
import BlockQuote from './BlockQuote'; | ||
|
||
storiesOf('component-lib/BlockQuote', module) | ||
.add('default', () => { | ||
return ( | ||
<Grommet full theme={powerTheme}> | ||
<BlockQuote | ||
text="Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced." | ||
footer="—Aldous Huxley"></BlockQuote> | ||
</Grommet> | ||
); | ||
}) | ||
.add('xsmall', () => { | ||
return ( | ||
<Grommet full theme={powerTheme}> | ||
<BlockQuote | ||
text="Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced." | ||
footer="—Aldous Huxley" | ||
size="xsmall"></BlockQuote> | ||
</Grommet> | ||
); | ||
}) | ||
.add('small', () => { | ||
return ( | ||
<Grommet full theme={powerTheme}> | ||
<BlockQuote | ||
text="Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced." | ||
footer="—Aldous Huxley" | ||
size="small"></BlockQuote> | ||
</Grommet> | ||
); | ||
}) | ||
.add('medium', () => { | ||
return ( | ||
<Grommet full theme={powerTheme}> | ||
<BlockQuote | ||
text="Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced." | ||
footer="—Aldous Huxley" | ||
size="medium"></BlockQuote> | ||
</Grommet> | ||
); | ||
}) | ||
.add('large', () => { | ||
return ( | ||
<Grommet full theme={powerTheme}> | ||
<BlockQuote | ||
text="Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced." | ||
footer="—Aldous Huxley" | ||
size="large"></BlockQuote> | ||
</Grommet> | ||
); | ||
}) | ||
.add('xlarge', () => { | ||
return ( | ||
<Grommet full theme={powerTheme}> | ||
<BlockQuote | ||
text="Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced." | ||
footer="—Aldous Huxley" | ||
size="xlarge"></BlockQuote> | ||
</Grommet> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './BlockQuote'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.