File tree 6 files changed +55
-2
lines changed
6 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -895,6 +895,8 @@ export default NavBarItemActifWithChildren;
895
895
896
896
## Default
897
897
898
+ By default, the title bar is sticky on the top when you scroll down the page. If you want to disable that behavior you can set to false the ` isSticky ` property of the component.
899
+
898
900
### Installation
899
901
900
902
``` shell script
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ export const Default = (args) => <Title {...args} />;
35
35
Default . args = {
36
36
title : 'Toolkit Axa' ,
37
37
subtitle : 'Info complémentaire' ,
38
+ isSticky : true ,
38
39
} ;
39
40
Default . argTypes = {
40
41
toggleMenu : { action : 'onToggle' } ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ type Props = {
12
12
toggleMenu ?: ( ) => void ;
13
13
className ?: string ;
14
14
classModifier ?: string ;
15
+ isSticky ?: boolean ;
15
16
} ;
16
17
const Title = ( {
17
18
title,
@@ -20,7 +21,16 @@ const Title = ({
20
21
toggleMenu,
21
22
className,
22
23
classModifier,
24
+ isSticky = true ,
23
25
} : Props ) => {
26
+ if ( isSticky ) {
27
+ // eslint-disable-next-line no-param-reassign
28
+ classModifier =
29
+ ! classModifier || classModifier . length === 0
30
+ ? 'sticky'
31
+ : `${ classModifier } sticky` ;
32
+ }
33
+
24
34
const componentClassName = getComponentClassName (
25
35
className ,
26
36
classModifier ,
Original file line number Diff line number Diff line change 7
7
padding : 0.66rem 0 ;
8
8
margin-bottom : 2rem ;
9
9
10
+ & --sticky {
11
+ position : sticky ;
12
+ top : 0 ;
13
+ z-index : 110 ;
14
+ }
15
+
10
16
& --fixed {
11
17
position : fixed ;
12
18
width : 100% ;
Original file line number Diff line number Diff line change @@ -20,4 +20,15 @@ describe('<Title>', () => {
20
20
) ;
21
21
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
22
22
} ) ;
23
+
24
+ it ( 'renders Title with classModifier' , ( ) => {
25
+ const { asFragment } = render (
26
+ < Title
27
+ title = "Toolkit Axa"
28
+ subtitle = "Info complémentaire"
29
+ classModifier = "test"
30
+ />
31
+ ) ;
32
+ expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
33
+ } ) ;
23
34
} ) ;
Original file line number Diff line number Diff line change 3
3
exports [` <Title > renders Title correctly 1`] = `
4
4
<DocumentFragment >
5
5
<div
6
- class = " af-title-bar"
6
+ class = " af-title-bar af-title-bar--sticky "
7
7
>
8
8
<div
9
9
class = " container af-title-bar__wrapper"
@@ -44,7 +44,30 @@ exports[`<Title> renders Title correctly 1`] = `
44
44
exports[`<Title > renders Title correctly without menu 1`] = `
45
45
<DocumentFragment >
46
46
<div
47
- class = " af-title-bar"
47
+ class = " af-title-bar af-title-bar--sticky"
48
+ >
49
+ <div
50
+ class = " container af-title-bar__wrapper"
51
+ >
52
+ <h1
53
+ class = " af-title-bar__title"
54
+ >
55
+ Toolkit Axa
56
+ <span
57
+ class = " af-title-bar__subtitle"
58
+ >
59
+ Info complémentaire
60
+ </span >
61
+ </h1 >
62
+ </div >
63
+ </div >
64
+ </DocumentFragment >
65
+ `;
66
+
67
+ exports[`<Title > renders Title with classModifier 1`] = `
68
+ <DocumentFragment >
69
+ <div
70
+ class = " af-title-bar af-title-bar--test af-title-bar--sticky"
48
71
>
49
72
<div
50
73
class = " container af-title-bar__wrapper"
You can’t perform that action at this time.
0 commit comments