Navigation Menu

Skip to content

Commit

Permalink
feat(community-testimonial): upgrade to styled-components
Browse files Browse the repository at this point in the history
BREAKING CHANGE: styled-components now a peer dependency
  • Loading branch information
Anatolii Gorovyi authored and jraff committed Aug 29, 2019
1 parent b982240 commit 518c30b
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 75 deletions.
34 changes: 30 additions & 4 deletions packages/Testimonial/Testimonial.jsx
Expand Up @@ -5,8 +5,34 @@ import Paragraph from '@tds/core-paragraph'
import Heading from '@tds/core-heading'
import safeRest from '@tds/shared-safe-rest'
import { componentWithName } from '@tds/util-prop-types'
import { media } from '@tds/core-responsive'
import styled from 'styled-components'

import styles from './Testimonial.scss'
const StyledImageAndQuote = styled.div({
display: 'flex',
flexDirection: 'column',

...media.from('sm').css({
flexDirection: 'row',
alignItems: 'center',
}),
})

const StyledImage = styled.div({
fontSize: 0,
marginBottom: '1rem',
maxWidth: '60px',
maxHeight: '60px',

...media.from('sm').css({
display: 'flex',
alignItems: 'center',
maxHeight: '60px',
maxWidth: '60px',
marginRight: '1rem',
marginBottom: 0,
}),
})

/**
* Testimonial component for displaying testimonial in a standalone, pre-styled component.
Expand All @@ -24,13 +50,13 @@ const Testimonial = ({ testimonialStyle, testimonial, image, title, additionalIn
) : (
<Paragraph size="large">{testimonial}</Paragraph>
)}
<div className={styles.imageAndQuote}>
{image && <div className={styles.image}>{image}</div>}
<StyledImageAndQuote>
{image && <StyledImage>{image}</StyledImage>}
<div>
<Paragraph bold>{title}</Paragraph>
<Paragraph>{additionalInfo}</Paragraph>
</div>
</div>
</StyledImageAndQuote>
</Box>
)
}
Expand Down
27 changes: 0 additions & 27 deletions packages/Testimonial/Testimonial.scss

This file was deleted.

9 changes: 5 additions & 4 deletions packages/Testimonial/__tests__/Testimonial.spec.jsx
@@ -1,12 +1,13 @@
import React from 'react'
import { shallow } from 'enzyme'
import { shallow, mount } from 'enzyme'

import Image from '@tds/core-image'

import Testimonial from '../Testimonial'

describe('Testimonial', () => {
const doShallow = (props = {}) => shallow(<Testimonial {...props} />)
const doMount = (props = {}) => mount(<Testimonial {...props} />)

const props = {
testimonial:
Expand All @@ -25,14 +26,14 @@ describe('Testimonial', () => {
}

it('renders', () => {
const testimonial = doShallow({ ...props })
const testimonial = doMount({ ...props })

expect(testimonial).toMatchSnapshot()
})

it('renders without an image', () => {
const testimonial = doShallow({ ...props, image: null })
expect(testimonial.find('.image').length).toEqual(0)
expect(testimonial.find('Image').exists()).toEqual(false)
})

it('renders testimonial text as a large paragraph by default', () => {
Expand All @@ -47,7 +48,7 @@ describe('Testimonial', () => {

it('renders with an image', () => {
const testimonial = doShallow({ ...props })
expect(testimonial.find('.image').exists()).toEqual(true)
expect(testimonial.find('Image').exists()).toEqual(true)
})

it('passes additional attributes to the element', () => {
Expand Down
218 changes: 182 additions & 36 deletions packages/Testimonial/__tests__/__snapshots__/Testimonial.spec.jsx.snap
@@ -1,51 +1,197 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testimonial renders 1`] = `
<Box
between={3}
inline={false}
tag="div"
.c0 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.c1 {
font-size: 0;
margin-bottom: 1rem;
max-width: 60px;
max-height: 60px;
}
@media (min-width:576px) {
.c0 {
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
}
@media (min-width:576px) {
.c1 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
max-height: 60px;
max-width: 60px;
margin-right: 1rem;
margin-bottom: 0;
}
}
<Testimonial
additionalInfo="Pinnacle Reforestation"
image={
<Image
alt="Image of co-workers collaborating"
height={60}
rounded="circle"
src="image-example.jpg"
width={60}
/>
}
testimonial="My office is where ever my customers are. TELUS helps me stay connected whether I'm making a sale or doing payroll."
testimonialStyle="largeText"
title="Dave Smith, Foreman"
>
<Paragraph
align="left"
bold={false}
invert={false}
size="large"
>
My office is where ever my customers are. TELUS helps me stay connected whether I'm making a sale or doing payroll.
</Paragraph>
<div
className="imageAndQuote"
<Box
between={3}
inline={false}
tag="div"
>
<div
className="image"
className="TDS_Box-modules__betweenBottomMargin-3___1jBrz TDS_Box-modules__stack___33m4D"
>
<Image
alt="Image of co-workers collaborating"
height={60}
rounded="circle"
src="image-example.jpg"
width={60}
/>
</div>
<div>
<Paragraph
align="left"
bold={true}
invert={false}
size="medium"
>
Dave Smith, Foreman
</Paragraph>
<Paragraph
align="left"
bold={false}
invert={false}
size="medium"
size="large"
>
Pinnacle Reforestation
<p
className="TDS_Typography-modules__wordBreak___3OZx_ TDS_Spacing-modules__noSpacing___XPYDG TDS_Typography-modules__color___2CNH8 TDS_Typography-modules__large___24W-w TDS_Typography-modules__wordBreak___3OZx_ TDS_Typography-modules__largeFont___3k7bm TDS_Typography-modules__wordBreak___3OZx_ TDS_Paragraph-modules__leftAlign___KgwhE"
>
My office is where ever my customers are. TELUS helps me stay connected whether I'm making a sale or doing payroll.
</p>
</Paragraph>
<Testimonial__StyledImageAndQuote>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "Testimonial__StyledImageAndQuote-sc-9sgiob-0",
"isStatic": true,
"lastClassName": "c0",
"rules": Array [
"display: flex; flex-direction: column; @media (min-width: 576px) {
flex-direction: row; align-items: center;
}",
],
},
"displayName": "Testimonial__StyledImageAndQuote",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "Testimonial__StyledImageAndQuote-sc-9sgiob-0",
"target": "div",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<div
className="c0"
>
<Testimonial__StyledImage>
<StyledComponent
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
"attrs": Array [],
"componentStyle": ComponentStyle {
"componentId": "Testimonial__StyledImage-sc-9sgiob-1",
"isStatic": true,
"lastClassName": "c1",
"rules": Array [
"font-size: 0; margin-bottom: 1rem; max-width: 60px; max-height: 60px; @media (min-width: 576px) {
display: flex; align-items: center; max-height: 60px; max-width: 60px; margin-right: 1rem; margin-bottom: 0;
}",
],
},
"displayName": "Testimonial__StyledImage",
"foldedComponentIds": Array [],
"render": [Function],
"styledComponentId": "Testimonial__StyledImage-sc-9sgiob-1",
"target": "div",
"toString": [Function],
"warnTooManyClasses": [Function],
"withComponent": [Function],
}
}
forwardedRef={null}
>
<div
className="c1"
>
<Image
alt="Image of co-workers collaborating"
height={60}
rounded="circle"
src="image-example.jpg"
width={60}
>
<img
alt="Image of co-workers collaborating"
className="TDS_Image-modules__fluid___1qw3M TDS_Borders-modules__circular___OppHT"
height={60}
src="image-example.jpg"
width={60}
/>
</Image>
</div>
</StyledComponent>
</Testimonial__StyledImage>
<div>
<Paragraph
align="left"
bold={true}
invert={false}
size="medium"
>
<p
className="TDS_Typography-modules__wordBreak___3OZx_ TDS_Spacing-modules__noSpacing___XPYDG TDS_Typography-modules__color___2CNH8 TDS_Typography-modules__medium___1rxfE TDS_Typography-modules__wordBreak___3OZx_ TDS_Typography-modules__boldFont___2YS3O TDS_Typography-modules__wordBreak___3OZx_ TDS_Paragraph-modules__leftAlign___KgwhE"
>
Dave Smith, Foreman
</p>
</Paragraph>
<Paragraph
align="left"
bold={false}
invert={false}
size="medium"
>
<p
className="TDS_Typography-modules__wordBreak___3OZx_ TDS_Spacing-modules__noSpacing___XPYDG TDS_Typography-modules__color___2CNH8 TDS_Typography-modules__medium___1rxfE TDS_Typography-modules__wordBreak___3OZx_ TDS_Typography-modules__mediumFont___XMrRj TDS_Paragraph-modules__leftAlign___KgwhE"
>
Pinnacle Reforestation
</p>
</Paragraph>
</div>
</div>
</StyledComponent>
</Testimonial__StyledImageAndQuote>
</div>
</div>
</Box>
</Box>
</Testimonial>
`;
1 change: 0 additions & 1 deletion packages/Testimonial/index.cjs.js
@@ -1,4 +1,3 @@
require('./dist/index.css')
const Testimonial = require('./dist/index.cjs')

module.exports = Testimonial
1 change: 0 additions & 1 deletion packages/Testimonial/index.es.js
@@ -1,4 +1,3 @@
import './dist/index.css'
import Testimonial from './dist/index.es'

export default Testimonial
5 changes: 3 additions & 2 deletions packages/Testimonial/package.json
Expand Up @@ -21,8 +21,9 @@
},
"homepage": "http://tds.telus.com",
"peerDependencies": {
"react": ">=15",
"react-dom": ">=15"
"react": "^16.8.2",
"react-dom": "^16.8.2",
"styled-components": "^4.1.3"
},
"dependencies": {
"@tds/core-box": "^1.0.1",
Expand Down

0 comments on commit 518c30b

Please sign in to comment.