Skip to content

Commit

Permalink
Merge pull request #39 from comicrelief/feature/32_article_teaser_mol…
Browse files Browse the repository at this point in the history
…ecule

Article Teaser Molecule
  • Loading branch information
gusliedke authored Jul 4, 2019
2 parents e14128d + 19fa9af commit 5ead784
Show file tree
Hide file tree
Showing 12 changed files with 345 additions and 30 deletions.
18 changes: 14 additions & 4 deletions src/components/Atoms/Checkbox/Checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ it('renders correctly', () => {

expect(tree).toMatchInlineSnapshot(`
Array [
.c1 {
.c2 {
text-transform: inherit;
font-weight: bold;
}
.c1 {
display: block;
box-sizing: border-box;
opacity: 0;
Expand Down Expand Up @@ -73,13 +78,18 @@ it('renders correctly', () => {
/>
<span />
<span
className=""
className="c2"
color="inherit"
>
Tenis
</span>
</label>,
.c1 {
.c2 {
text-transform: inherit;
font-weight: bold;
}
.c1 {
display: block;
box-sizing: border-box;
opacity: 0;
Expand Down Expand Up @@ -139,7 +149,7 @@ it('renders correctly', () => {
/>
<span />
<span
className=""
className="c2"
color="inherit"
>
Handball
Expand Down
21 changes: 13 additions & 8 deletions src/components/Atoms/Input/input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ it('renders correctly', () => {

expect(tree).toMatchInlineSnapshot(`
.c1 {
text-transform: inherit;
font-weight: bold;
}
.c2 {
box-sizing: border-box;
width: 100%;
height: 50px;
Expand All @@ -33,23 +38,23 @@ it('renders correctly', () => {
color: #030e1a;
}
.c1:focus {
.c2:focus {
border: 1px solid #666;
}
.c1:focus::-webkit-input-placeholder {
.c2:focus::-webkit-input-placeholder {
color: transparent;
}
.c1:focus:-moz-placeholder {
.c2:focus:-moz-placeholder {
color: transparent;
}
.c1:focus::-moz-placeholder {
.c2:focus::-moz-placeholder {
color: transparent;
}
.c1:focus:-ms-input-placeholder {
.c2:focus:-ms-input-placeholder {
color: transparent;
}
Expand All @@ -64,7 +69,7 @@ it('renders correctly', () => {
}
@media (min-width:740px) {
.c1 {
.c2 {
max-width: 290px;
}
}
Expand All @@ -74,14 +79,14 @@ it('renders correctly', () => {
htmlFor="Acessibility info go here"
>
<span
className=""
className="c1"
color="inherit"
>
Label
</span>
<input
aria-describedby="Acessibility info go here"
className="c1"
className="c2"
name="fullname"
placeholder="This is the hint text"
type="text"
Expand Down
18 changes: 14 additions & 4 deletions src/components/Atoms/RadioButton/RadioButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ it('renders correctly', () => {

expect(tree).toMatchInlineSnapshot(`
Array [
.c1 {
.c2 {
text-transform: inherit;
font-weight: bold;
}
.c1 {
background-color: #FFFFFF;
z-index: 1;
top: 0;
Expand Down Expand Up @@ -81,14 +86,19 @@ it('renders correctly', () => {
/>
<span />
<span
className=""
className="c2"
color="inherit"
for="Male"
>
Male
</span>
</label>,
.c1 {
.c2 {
text-transform: inherit;
font-weight: bold;
}
.c1 {
background-color: #FFFFFF;
z-index: 1;
top: 0;
Expand Down Expand Up @@ -156,7 +166,7 @@ it('renders correctly', () => {
/>
<span />
<span
className=""
className="c2"
color="inherit"
for="Female"
>
Expand Down
13 changes: 9 additions & 4 deletions src/components/Atoms/SelectField/SelectField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ it('renders correctly', () => {

expect(tree).toMatchInlineSnapshot(`
.c1 {
text-transform: inherit;
font-weight: bold;
}
.c2 {
background-color: #FFFFFF;
width: 100%;
font-size: 1.2rem;
Expand Down Expand Up @@ -52,7 +57,7 @@ it('renders correctly', () => {
border-radius: 0;
}
.c1:focus {
.c2:focus {
border: 1px solid #666;
}
Expand All @@ -62,7 +67,7 @@ it('renders correctly', () => {
}
@media (min-width:740px) {
.c1 {
.c2 {
max-width: 290px;
}
}
Expand All @@ -71,13 +76,13 @@ it('renders correctly', () => {
className="c0"
>
<span
className=""
className="c1"
color="inherit"
>
Label
</span>
<select
className="c1"
className="c2"
>
<option
disabled={true}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Atoms/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import PropTypes from 'prop-types';
export const BaseText = styled.span`
color: ${({ color, theme }) => (color ? theme.color(color) : 'inherit')};
font-size: ${({ size, theme }) => theme.fontSize(size)};
text-transform: ${({ uppercase }) => (uppercase ? 'uppercase' : 'inherit')};
font-weight: ${({ weight }) => weight};
`;

/** Text renders different elements based on the `tag` prop */
const Text = ({ tag, children, ...rest }) => (
<BaseText {...rest} as={tag}>
const Text = ({ tag, children, weight, ...rest }) => (
<BaseText {...rest} as={tag} weight={weight}>
{children}
</BaseText>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Atoms/Text/Text.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ it('renders correctly', () => {
.c0 {
color: #fbef51;
font-size: 1.725rem;
text-transform: inherit;
}
<p
Expand Down
21 changes: 13 additions & 8 deletions src/components/Atoms/TextArea/TextArea.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ it('renders correctly', () => {

expect(tree).toMatchInlineSnapshot(`
.c1 {
text-transform: inherit;
font-weight: bold;
}
.c2 {
box-sizing: border-box;
width: 100%;
margin: 10px 0;
Expand All @@ -35,35 +40,35 @@ it('renders correctly', () => {
color: #030e1a;
}
.c1:focus {
.c2:focus {
border: 1px solid #666;
}
.c1:focus::-webkit-input-placeholder {
.c2:focus::-webkit-input-placeholder {
color: transparent;
color: $color;
font-size: $font-size;
opacity: 1;
overflow: visible;
}
.c1:focus:-moz-placeholder {
.c2:focus:-moz-placeholder {
color: transparent;
color: $color;
font-size: $font-size;
opacity: 1;
overflow: visible;
}
.c1:focus::-moz-placeholder {
.c2:focus::-moz-placeholder {
color: transparent;
color: $color;
font-size: $font-size;
opacity: 1;
overflow: visible;
}
.c1:focus:-ms-input-placeholder {
.c2:focus:-ms-input-placeholder {
color: transparent;
color: $color;
font-size: $font-size;
Expand All @@ -82,7 +87,7 @@ it('renders correctly', () => {
}
@media (min-width:740px) {
.c1 {
.c2 {
max-width: 100%;
height: 96px;
}
Expand All @@ -93,14 +98,14 @@ it('renders correctly', () => {
htmlFor="undefined"
>
<span
className=""
className="c1"
color="inherit"
>
Label
</span>
<textarea
aria-describedby="Please leave your comment here"
className="c1"
className="c2"
cols="5"
name="description"
placeholder="This is text area"
Expand Down
89 changes: 89 additions & 0 deletions src/components/Molecules/ArticleTeaser/ArticleTeaser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';

import Text from '../../Atoms/Text/Text';
import Picture from '../../Atoms/Picture/Picture';
import StyledLink from '../../Atoms/Link/Link.style';

/**
* Article tag wrapper
*/
const Wrapper = styled.article`
width: 100%;
height: 100%;
display: flex;
background-color: #fff;
`;

const Link = styled(StyledLink)`
display: flex;
height: 100%;
border: 0;
flex-direction: column;
@media ${({ theme }) => theme.breakpoint('small')} {
flex-direction: row;
}
@media ${({ theme }) => theme.breakpoint('large')} {
flex-direction: column;
}
`;

const ImageWrapper = styled.div`
height: 100%;
@media ${({ theme }) => theme.breakpoint('small')} {
width: 45%;
}
@media ${({ theme }) => theme.breakpoint('large')} {
width: 100%;
}
`;

const CopyWrapper = styled.div`
padding: 40px;
h3 {
margin: 0;
}
@media ${({ theme }) => theme.breakpoint('small')} {
width: 55%;
}
@media ${({ theme }) => theme.breakpoint('large')} {
width: 100%;
height: 100%;
}
`;

/**
* Article teaser component
*/
const ArticleTeaser = ({ date, href, images, alt, title }) => {
return (
<Wrapper>
<Link href={href} inline>
<ImageWrapper>
<Picture images={images} alt={alt} objectFit="cover" />
</ImageWrapper>
<CopyWrapper>
<Text size="xxs" weight="bold" uppercase>
{date}
</Text>
<Text size="xl" tag="h3" uppercase>
{title}
</Text>
</CopyWrapper>
</Link>
</Wrapper>
);
};

ArticleTeaser.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
images: PropTypes.object.isRequired,
alt: PropTypes.string.isRequired,
date: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
/** link url */
href: PropTypes.string.isRequired
};

export default ArticleTeaser;
Loading

0 comments on commit 5ead784

Please sign in to comment.