33 basicAccordion ,
44 chevronAndDisabled ,
55} from "@/codeSnippets/accordion" ;
6+ import { Section } from "@/components/Section" ;
67import { useCodeSnippet } from "@/hooks/useCodeSnippet" ;
78import { Accordion , Radio , Typography } from "@equinor/eds-mobile-components" ;
89import { useState } from "react" ;
@@ -13,146 +14,128 @@ export default function AccordionScreen() {
1314 const { ViewCode, CodeSnippetDialog } = useCodeSnippet ( ) ;
1415
1516 return (
16- < ScrollView style = { styles . container } >
17- < View style = { styles . section } >
18- < Typography variant = "h5" > Accordion</ Typography >
19- < Typography variant = "p" >
17+ < ScrollView contentInsetAdjustmentBehavior = "automatic" >
18+ < Section >
19+ < Typography >
2020 Accordions tuck content away until it's needed —
2121 perfect for keeping screens tidy while still giving users
2222 access to all the details.
2323 </ Typography >
24- </ View >
24+ </ Section >
2525
26- < View style = { styles . section } >
27- < Typography variant = "h6" > Basic Accordion</ Typography >
28- < Typography variant = "p" >
26+ < Section title = "Basic Accordion" >
27+ < Typography >
2928 Tap to expand, tap again to collapse. Simple! Works well for
3029 FAQs, settings, or any content you want to group together.
3130 </ Typography >
32- < Accordion >
33- < Accordion . Item title = "First Item" >
34- < Typography variant = "p" >
35- This is the content of the first accordion item. You
36- can put any content here.
37- </ Typography >
38- </ Accordion . Item >
31+ </ Section >
3932
40- < Accordion . Item title = "Second Item" >
41- < Typography variant = "p" >
42- This accordion demonstrates a list of items:
43- </ Typography >
44- < View style = { styles . list } >
45- < Typography variant = "p" >
46- • First list item
47- </ Typography >
48- < Typography variant = "p" >
49- • Second list item
50- </ Typography >
51- < Typography variant = "p" >
52- • Third list item
53- </ Typography >
54- < Typography variant = "p" >
55- • Fourth list item
56- </ Typography >
57- </ View >
58- </ Accordion . Item >
33+ < Accordion >
34+ < Accordion . Item title = "First Item" >
35+ < Typography >
36+ This is the content of the first accordion item. You can
37+ put any content here.
38+ </ Typography >
39+ </ Accordion . Item >
5940
60- < Accordion . Item title = "Third Item" >
61- < Typography variant = "p" >
62- You can also have a group of radio buttons within
63- the accordion
64- </ Typography >
65- < View style = { styles . radioGroup } >
66- < View style = { styles . radioOption } >
67- < Radio
68- checked = { selectedOption === 0 }
69- onPress = { ( ) => setSelectedOption ( 0 ) }
70- color = "primary"
71- />
72- < Typography variant = "p" > Option 1</ Typography >
73- </ View >
74- < View style = { styles . radioOption } >
75- < Radio
76- checked = { selectedOption === 1 }
77- onPress = { ( ) => setSelectedOption ( 1 ) }
78- color = "primary"
79- />
80- < Typography variant = "p" > Option 2</ Typography >
81- </ View >
82- < View style = { styles . radioOption } >
83- < Radio
84- checked = { selectedOption === 2 }
85- onPress = { ( ) => setSelectedOption ( 2 ) }
86- color = "primary"
87- />
88- < Typography variant = "p" > Option 3</ Typography >
89- </ View >
41+ < Accordion . Item title = "Second Item" >
42+ < Typography >
43+ This accordion demonstrates a list of items:
44+ </ Typography >
45+ < View style = { styles . list } >
46+ < Typography > • First list item</ Typography >
47+ < Typography > • Second list item</ Typography >
48+ < Typography > • Third list item</ Typography >
49+ < Typography > • Fourth list item</ Typography >
50+ </ View >
51+ </ Accordion . Item >
52+
53+ < Accordion . Item title = "Third Item" >
54+ < Typography >
55+ You can also have a group of radio buttons within the
56+ accordion
57+ </ Typography >
58+ < View style = { styles . radioGroup } >
59+ < View style = { styles . radioOption } >
60+ < Radio
61+ checked = { selectedOption === 0 }
62+ onPress = { ( ) => setSelectedOption ( 0 ) }
63+ color = "primary"
64+ />
65+ < Typography > Option 1</ Typography >
66+ </ View >
67+ < View style = { styles . radioOption } >
68+ < Radio
69+ checked = { selectedOption === 1 }
70+ onPress = { ( ) => setSelectedOption ( 1 ) }
71+ color = "primary"
72+ />
73+ < Typography > Option 2</ Typography >
74+ </ View >
75+ < View style = { styles . radioOption } >
76+ < Radio
77+ checked = { selectedOption === 2 }
78+ onPress = { ( ) => setSelectedOption ( 2 ) }
79+ color = "primary"
80+ />
81+ < Typography > Option 3</ Typography >
9082 </ View >
91- </ Accordion . Item >
92- </ Accordion >
93- < ViewCode title = "Basic Accordion" code = { basicAccordion } / >
94- </ View >
83+ </ View >
84+ </ Accordion . Item >
85+ </ Accordion >
86+ < ViewCode title = "Basic Accordion" code = { basicAccordion } / >
9587
96- < View style = { styles . section } >
97- < Typography variant = "h6" >
98- Accordion with Default Open
99- </ Typography >
100- < Typography variant = "p" >
88+ < Section title = "Default open" >
89+ < Typography >
10190 Sometimes you want content visible right away — just set it
10291 to open by default and users see it straight off.
10392 </ Typography >
93+ </ Section >
10494
105- < Accordion >
106- < Accordion . Item title = "Expanded by Default" defaultOpen >
107- < Typography variant = "p" >
108- This item is expanded by default using the
109- defaultOpen prop.
110- </ Typography >
111- </ Accordion . Item >
112- </ Accordion >
113- < ViewCode
114- title = "Accordion with Default Open"
115- code = { accordionDefaultOpen }
116- />
117- </ View >
95+ < Accordion >
96+ < Accordion . Item title = "Expanded by Default" defaultOpen >
97+ < Typography >
98+ This item is expanded by default using the defaultOpen
99+ prop.
100+ </ Typography >
101+ </ Accordion . Item >
102+ </ Accordion >
103+ < ViewCode
104+ title = "Accordion with Default Open"
105+ code = { accordionDefaultOpen }
106+ />
118107
119- < View style = { styles . section } >
120- < Typography variant = "h6" >
121- Chevron Position & Disabled Accordions
122- </ Typography >
108+ < Section title = "Other options" >
123109 < Typography variant = "p" >
124110 You can move the chevron to the right for a different
125111 layout. If some content isn't ready yet, disable the
126112 item to let users know.
127113 </ Typography >
128- < Accordion >
129- < Accordion . Item title = "Item A" chevronPosition = "right" >
130- < Typography variant = "p" > Content for Item A</ Typography >
131- </ Accordion . Item >
132- </ Accordion >
114+ </ Section >
115+ < Accordion >
116+ < Accordion . Item title = "Item A" chevronPosition = "right" >
117+ < Typography variant = "p" > Content for Item A</ Typography >
118+ </ Accordion . Item >
119+ </ Accordion >
133120
134- < Accordion >
135- < Accordion . Item
136- title = "This accordion is disabled"
137- chevronPosition = "right"
138- disabled
139- />
140- </ Accordion >
141- < ViewCode
142- title = "Chevron Position & Disabled"
143- code = { chevronAndDisabled }
121+ < Accordion >
122+ < Accordion . Item
123+ title = "This accordion is disabled"
124+ chevronPosition = "right"
125+ disabled
144126 />
145- </ View >
127+ </ Accordion >
128+ < ViewCode
129+ title = "Chevron Position & Disabled"
130+ code = { chevronAndDisabled }
131+ />
146132
147133 < CodeSnippetDialog />
148134 </ ScrollView >
149135 ) ;
150136}
151137
152138const styles = StyleSheet . create ( {
153- container : {
154- flex : 1 ,
155- } ,
156139 section : {
157140 padding : 16 ,
158141 gap : 16 ,
0 commit comments