Skip to content

Commit 1f54098

Browse files
authored
186 cleanup diversity and inclusion section (#214)
Adjust relative sizes of image and text block Adjust text block padding
1 parent a74794c commit 1f54098

File tree

1 file changed

+66
-21
lines changed
  • sections/diversity-and-inclusion-section

1 file changed

+66
-21
lines changed

sections/diversity-and-inclusion-section/index.js

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,76 @@ import styled from 'styled-components'
66
import { Heading, Text } from 'components'
77
import { TABLET_LARGE_SIZE } from 'styles/constants'
88

9-
const IMAGE_BREAKPOINT = '839px'
9+
// for reference: image assets and sizes:
10+
// filename width X height
11+
// painted-hand-mobile.png 414px x 400px
12+
// painted-hand-tablet.png 500px x 534px
13+
// painted-hand-desktop.png 709px x 534px
14+
15+
const TABLET_IMAGE_BREAKPOINT = '828px' // width of painted-hand-mobile.png times two
16+
const DESKTOP_IMAGE_BREAKPOINT = '1442px' // width of painted-hand-desktop.png times two plus 24px padding
17+
const HEIGHT = '534px'
1018

1119
const { h2 } = Heading.VARIANT
1220

1321
const Container = styled.div`
14-
display: flex;
15-
flex-direction: row;
16-
@media only screen and (max-width: ${IMAGE_BREAKPOINT}) {
17-
flex-direction: column-reverse;
18-
height: auto;
22+
display: grid;
23+
grid-template-columns: 50% 50%;
24+
height: ${HEIGHT};
25+
overflow-y: hidden;
26+
27+
@media only screen and (max-width: ${TABLET_IMAGE_BREAKPOINT}) {
28+
display: grid;
29+
grid-template-columns: 100%;
30+
grid-template-rows: 50% 50%;
31+
height: 100%;
1932
}
2033
`
2134

2235
const Picture = styled.picture`
2336
img {
2437
width: 100%;
25-
height: 100%;
38+
height: auto;
39+
}
40+
41+
@media only screen and (min-width: ${TABLET_IMAGE_BREAKPOINT}) and (max-width: ${TABLET_LARGE_SIZE}) {
42+
img {
43+
width: auto;
44+
height: 100%;
45+
}
46+
}
47+
48+
@media only screen and (max-width: ${TABLET_IMAGE_BREAKPOINT}) {
49+
grid-row-start: 2;
50+
img {
51+
height: 100%;
52+
width: 100%;
53+
}
2654
}
2755
`
2856

2957
const TextContainer = styled.div`
30-
width: 50%;
3158
display: flex;
3259
flex-direction: column;
3360
flex-grow: 1;
3461
flex-shrink: 1;
35-
padding: ${rem('101px')} ${rem('80px')} ${rem('101px')} ${rem('70px')};
62+
63+
width: 100%;
64+
height: ${HEIGHT};
65+
66+
padding: ${rem('101px')} 7% ${rem('101px')} 7%;
3667
background: linear-gradient(61.68deg, #ff68ba 2.29%, #edc281 100.63%);
3768
justify-content: center;
3869
align-items: center;
3970
4071
@media only screen and (max-width: ${TABLET_LARGE_SIZE}) {
41-
align-items: center;
42-
padding: ${rem('48px')} ${rem('24px')};
72+
padding: ${rem('70px')} ${rem('24px')};
4373
}
4474
45-
@media only screen and (max-width: ${IMAGE_BREAKPOINT}) {
46-
align-items: center;
75+
@media only screen and (max-width: ${TABLET_IMAGE_BREAKPOINT}) {
76+
grid-row-start: 1;
77+
height: 100%;
4778
padding: ${rem('84px')} ${rem('36px')};
48-
width: 100%;
4979
}
5080
`
5181

@@ -67,21 +97,36 @@ const StyledHeading = styled(Heading)`
6797
@media only screen and (max-width: ${TABLET_LARGE_SIZE}) {
6898
margin-bottom: ${rem('32px')};
6999
}
70-
@media only screen and (max-width: ${IMAGE_BREAKPOINT}) {
100+
@media only screen and (max-width: ${TABLET_IMAGE_BREAKPOINT}) {
71101
margin-bottom: ${rem('26px')};
72102
}
73103
`
74104

105+
const TabletImage = styled.source.attrs((props) => ({
106+
...props,
107+
media: `(min-width: ${TABLET_IMAGE_BREAKPOINT}) and (max-width:${DESKTOP_IMAGE_BREAKPOINT})`,
108+
srcSet: '/painted-hand-tablet.png',
109+
}))``
110+
111+
const DesktopImage = styled.source.attrs((props) => ({
112+
...props,
113+
media: `(min-width:${DESKTOP_IMAGE_BREAKPOINT})`,
114+
srcSet: '/painted-hand-desktop.png',
115+
}))``
116+
117+
const MobileImage = styled.img.attrs((props) => ({
118+
...props,
119+
src: '/painted-hand-mobile.png',
120+
alt: 'Inclusive community',
121+
}))``
122+
75123
const DiversityAndInclusionSection = () => (
76124
<section>
77125
<Container>
78126
<Picture>
79-
<source
80-
media="(min-width:770px) and (max-width:1200px)"
81-
srcSet="/painted-hand-tablet.png"
82-
/>
83-
<source media="(min-width:1201px)" srcSet="/painted-hand-desktop.png" />
84-
<img src="/painted-hand-mobile.png" alt="Unicorn Pool Float" />
127+
<TabletImage />
128+
<DesktopImage />
129+
<MobileImage />
85130
</Picture>
86131
<TextContainer>
87132
<TextWrapper>

0 commit comments

Comments
 (0)