@@ -10,7 +10,7 @@ import { ObjectPageSubSection } from '@ui5/webcomponents-react/lib/ObjectPageSub
1010import { Text } from '@ui5/webcomponents-react/lib/Text' ;
1111import { Title } from '@ui5/webcomponents-react/lib/Title' ;
1212import { TitleLevel } from '@ui5/webcomponents-react/lib/TitleLevel' ;
13- import React from 'react' ;
13+ import React , { useState } from 'react' ;
1414import SampleImage from './DemoImage.png' ;
1515import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes' ;
1616
@@ -106,81 +106,47 @@ export const renderDemo = (props) => {
106106} ;
107107renderDemo . storyName = 'Default' ;
108108
109- export const renderComponentWithSections = ( props ) => (
110- < ObjectPage
111- title = "Fiori Object Page Title"
112- subTitle = "Sub Title"
113- headerActions = { [ < Button > Action</ Button > ] }
114- image = { SampleImage }
115- headerContent = {
116- < >
117- < div style = { { display : 'flex' , flexDirection : 'column' } } >
118- < Link href = "https://www.sap.com" > www.myurl.com</ Link >
119- < Text > Address 1</ Text >
120- </ div >
121- < div style = { { display : 'flex' , flexDirection : 'column' } } >
122- < Text > Address 2</ Text >
123- < Text > Address 3</ Text >
124- </ div >
125- </ >
126- }
127- mode = { props . mode }
128- style = { { height : '700px' } }
129- >
130- < ObjectPageSection title = "Test 1" id = "1" >
131- < Label > My Content 1</ Label >
132- </ ObjectPageSection >
133- < ObjectPageSection title = "Test 2" id = "2" >
134- < Label > My Content 2</ Label >
135- </ ObjectPageSection >
136- < ObjectPageSection title = "Test 3" id = "3" >
137- < Label > My Content 3</ Label >
138- </ ObjectPageSection >
139- </ ObjectPage >
140- ) ;
141- renderComponentWithSections . storyName = 'with Sections Only' ;
109+ export const renderComponentWithSections = ( props ) => {
110+ const [ numberOfSections , setNumberOfSections ] = useState ( 3 ) ;
142111
143- export const renderShortContent = ( props ) => {
144112 return (
145- < div style = { { width : 'calc(100% - 1rem)' , height : '100%' , position : 'relative' , marginTop : '2rem' } } >
146- < ObjectPage
147- title = { props . title }
148- subTitle = { props . subTitle }
149- headerActions = { [
150- < Button key = "1" design = { ButtonDesign . Emphasized } >
151- Primary Action
152- </ Button > ,
153- < Button key = "2" > Action</ Button >
154- ] }
155- image = { SampleImage }
156- headerContent = {
157- < >
158- < div style = { { display : 'flex' , flexDirection : 'column' } } >
159- < Link href = "https://www.sap.com" > www.myurl.com</ Link >
160- < Text > Address 1</ Text >
161- </ div >
162- < div style = { { display : 'flex' , flexDirection : 'column' } } >
163- < Text > Address 2</ Text >
164- < Text > Address 3</ Text >
165- </ div >
166- </ >
167- }
168- mode = { props . mode }
169- imageShapeCircle = { props . imageShapeCircle }
170- showHideHeaderButton = { props . showHideHeaderButton }
171- selectedSectionId = { props . selectedSectionId }
172- onSelectedSectionChanged = { props . onSelectedSectionChanged }
173- noHeader = { props . noHeader }
174- style = { { height : '700px' } }
175- >
176- < ObjectPageSection title = "Test 1" id = "1" >
177- < div > My Content 1</ div >
178- </ ObjectPageSection >
179- </ ObjectPage >
180- </ div >
113+ < ObjectPage
114+ title = "Fiori Object Page Title"
115+ subTitle = "Sub Title"
116+ headerActions = { [
117+ < Button key = "add-section" onClick = { ( ) => setNumberOfSections ( ( old ) => old + 1 ) } >
118+ Add Section
119+ </ Button >
120+ ] }
121+ image = { SampleImage }
122+ headerContent = {
123+ < >
124+ < div style = { { display : 'flex' , flexDirection : 'column' } } >
125+ < Link href = "https://www.sap.com" > www.myurl.com</ Link >
126+ < Text > Address 1</ Text >
127+ </ div >
128+ < div style = { { display : 'flex' , flexDirection : 'column' } } >
129+ < Text > Address 2</ Text >
130+ < Text > Address 3</ Text >
131+ </ div >
132+ </ >
133+ }
134+ mode = { props . mode }
135+ style = { { height : '700px' } }
136+ >
137+ { Array ( numberOfSections )
138+ . fill ( '' )
139+ . map ( ( _ , index ) => {
140+ return (
141+ < ObjectPageSection title = { `Section ${ index + 1 } ` } id = { `${ index } ` } key = { index } >
142+ < Label > Section Content { index + 1 } </ Label >
143+ </ ObjectPageSection >
144+ ) ;
145+ } ) }
146+ </ ObjectPage >
181147 ) ;
182148} ;
183- renderShortContent . storyName = 'Short Content ' ;
149+ renderComponentWithSections . storyName = 'with Sections Only ' ;
184150
185151export default {
186152 title : 'Components / ObjectPage' ,
0 commit comments