Skip to content

Commit 75bb403

Browse files
committed
Adding small title to carousels
1 parent d520c3d commit 75bb403

7 files changed

Lines changed: 42 additions & 8 deletions

File tree

packages/core/.lintstagedrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
'src/**/*.js':
2-
- flow
2+
- flow focus-check

packages/core/src/components/Carousel/Carousel.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
margin: 0 0 1.5rem 0;
77
}
88

9+
.title.large {
10+
font-size: var(--fontsize-large-ii);
11+
}
12+
13+
.title.small {
14+
font-size: var(--fontsize-large-i);
15+
}
16+
917
.controls {
1018
display: flex;
1119
justify-content: space-between;

packages/core/src/components/Carousel/Carousel.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import css from './Carousel.css';
1111

1212
type Props = {
1313
children: Array<React.Node>,
14-
title: string,
14+
title?: string,
1515
slidesToShow: number,
1616
withoutControls: boolean,
1717
dragging: boolean,
@@ -20,6 +20,7 @@ type Props = {
2020
accessibilityNextLabel: string,
2121
accessibilityPrevLabel: string,
2222
infinite?: boolean,
23+
titleSize: 'small' | 'large'
2324
};
2425

2526
const Carousel = (props: Props) => {
@@ -34,12 +35,16 @@ const Carousel = (props: Props) => {
3435
accessibilityNextLabel,
3536
accessibilityPrevLabel,
3637
infinite,
38+
titleSize,
3739
} = props;
3840
const [slideIndex, setSlideIndex] = React.useState(0);
3941

4042
const renderTopRightControls = () => (
4143
<div className={css.controls}>
42-
<h2 className={css.title}>{title}</h2>
44+
{ title && <h2 className={cx(css.title, {
45+
[css.small]: titleSize === 'small',
46+
[css.large]: titleSize === 'large'
47+
})}>{title}</h2> }
4348
{slidesToShow < children.length && (
4449
<div className={css.buttons}>
4550
<BtnContainer
@@ -114,6 +119,7 @@ Carousel.defaultProps = {
114119
useCenterControls: false,
115120
accessibilityNextLabel: 'Show next slide',
116121
accessibilityPrevLabel: 'Show previous slide',
122+
titleSize: 'large'
117123
};
118124

119125
export default Carousel;

packages/core/src/components/MobileCarousel/MobileCarousel.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@
2323
}
2424

2525
.title {
26-
margin: 0 0 1.5rem 0;
2726
font-family: var(--font-avenir);
28-
font-size: var(--fontsize-large-ii);
2927
font-weight: var(--fontweight-demi);
3028
letter-spacing: normal;
3129
}
30+
31+
.title.large {
32+
font-size: var(--fontsize-large-ii);
33+
margin: 0 0 1.5rem 0;
34+
}
35+
36+
.title.small {
37+
font-size: var(--fontsize-regular);
38+
margin: 0 0 1rem 0;
39+
}

packages/core/src/components/MobileCarousel/MobileCarousel.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
import * as React from 'react';
44
import shortid from 'shortid';
5+
import cx from 'classnames';
56

67
import css from './MobileCarousel.css';
78

89
type Props = {
910
children: Array<React.Node>,
10-
title: string
11+
title: string,
12+
titleSize: 'small' | 'large'
1113
}
1214

13-
const MobileCarousel = ({ children, title }: Props) => {
15+
const MobileCarousel = ({ children, title, titleSize }: Props) => {
1416
return (
1517
<div>
16-
<h2 className={css.title}>{title}</h2>
18+
{ title && <h2 className={cx(css.title, {
19+
[css.small]: titleSize === 'small',
20+
[css.large]: titleSize === 'large'
21+
})}>{title}</h2> }
1722
<div className={css.slides}>
1823
{children.map((slide) => (
1924
<div key={shortid.generate()} className={css.slide}>
@@ -27,6 +32,7 @@ const MobileCarousel = ({ children, title }: Props) => {
2732

2833
MobileCarousel.defaultProps = {
2934
title: '',
35+
titleSize: 'large',
3036
children: []
3137
};
3238

packages/playground/stories/Carousel.story.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ storiesOf('Carousel', module)
3535
.add('With Title', () => (
3636
<Carousel title="Carousel Title" slidesToShow={4} onChange={action('Slide changed')}>{slides}</Carousel>
3737
))
38+
.add('With small Title', () => (
39+
<Carousel titleSize="small" title="Carousel Title" slidesToShow={4} onChange={action('Slide changed')}>{slides}</Carousel>
40+
))
3841
.add('With Center controls', () => (
3942
<Carousel title="Carousel Title" useCenterControls useTopRightControls={false} slidesToShow={4} onChange={action('Slide changed')}>{slides}</Carousel>
4043
));

packages/playground/stories/MobileCarousel.story.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ storiesOf('MobileCarousel', module)
3434
))
3535
.add('With Title', () => (
3636
<MobileCarousel title="Carousel Title" slidesToShow={4} onChange={action('Slide changed')}>{slides}</MobileCarousel>
37+
))
38+
.add('With small Title', () => (
39+
<MobileCarousel titleSize="small" title="Carousel Title" slidesToShow={4} onChange={action('Slide changed')}>{slides}</MobileCarousel>
3740
));

0 commit comments

Comments
 (0)