Skip to content

Commit ce499e1

Browse files
authored
feat: Impact Slider padding options (#865)
1 parent 5d9054c commit ce499e1

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/components/Organisms/ImpactSlider/ImpactSlider.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111

1212
const ImpactSlider = ({
1313
heading, cartID, donateLink, rowID, items, step, max,
14-
backgroundColour = 'grey_light', opacityAnimation = false, children, defaultSliderValue = null
14+
backgroundColour = 'grey_light', opacityAnimation = false, children,
15+
defaultSliderValue = null, paddingTop = '2rem', paddingBottom = '2rem'
1516
}) => {
1617
// Use the lowest possible amount as our default:
1718
const [currentAmount, setCurrentAmount] = useState(defaultSliderValue || step);
@@ -28,7 +29,12 @@ const ImpactSlider = ({
2829
};
2930

3031
return (
31-
<OuterWrapper backgroundColour={backgroundColour} id={rowID}>
32+
<OuterWrapper
33+
backgroundColour={backgroundColour}
34+
id={rowID}
35+
paddingTop={paddingTop}
36+
paddingBottom={paddingBottom}
37+
>
3238
<InnerWrapper>
3339
<Text tag="h1" family="Anton" weight="normal" size="xl">{heading}</Text>
3440
<Copy>
@@ -82,6 +88,8 @@ ImpactSlider.propTypes = {
8288
defaultSliderValue: PropTypes.number,
8389
opacityAnimation: PropTypes.bool,
8490
backgroundColour: PropTypes.string,
91+
paddingTop: PropTypes.string,
92+
paddingBottom: PropTypes.string,
8593
items: PropTypes.arrayOf(
8694
PropTypes.shape({
8795
poundsPerItem: PropTypes.number.isRequired,

src/components/Organisms/ImpactSlider/ImpactSlider.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Impact Slider (w/opacity animation)
1+
# Impact Slider (w/opacity animation & default padding options)
22

33
```js
44
const { testImpactSliderItems} = require('../../../styleguide/data/data');
@@ -20,7 +20,7 @@ import Text from '../../Atoms/Text/Text';
2020
</ImpactSlider>
2121
```
2222

23-
# Impact Slider (w/o opacity animation, w/default value)
23+
# Impact Slider (w/o opacity animation, w/default value & custom padding options)
2424
```js
2525
const { testImpactSliderItems} = require('../../../styleguide/data/data');
2626
import Text from '../../Atoms/Text/Text';
@@ -35,6 +35,8 @@ import Text from '../../Atoms/Text/Text';
3535
max={100}
3636
defaultSliderValue={45}
3737
backgroundColour="white"
38+
paddingTop="6rem"
39+
paddingBottom="6rem"
3840
>
3941
<Text tag="p" color="black">
4042
Use this slider to see how your donation can make a difference to lives in the UK and around the globe this winter.

src/components/Organisms/ImpactSlider/ImpactSlider.style.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import styled from 'styled-components';
1+
import styled, { css } from 'styled-components';
22
import Text from '../../Atoms/Text/Text';
33
import Button from '../../Atoms/Button/Button';
44

55
const OuterWrapper = styled.div`
66
position: relative;
77
max-width: 100%;
88
background-color: ${props => props.theme.color(`${props.backgroundColour}`)};
9-
padding: 32px 16px;
10-
11-
@media ${({ theme }) => theme.allBreakpoints('M')} {
12-
padding: 50px;
13-
}
14-
@media ${({ theme }) => theme.allBreakpoints('L')} {
15-
padding: 64px 0;
16-
}
9+
${({ paddingTop, paddingBottom }) => css`padding: ${paddingTop} 2rem ${paddingBottom};`}
1710
`;
1811

1912
const InnerWrapper = styled.div`

0 commit comments

Comments
 (0)