@momo-kits/collapse 0.92.3-tracking.3 → 0.92.6-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.tsx +16 -11
- package/package.json +1 -1
- package/styles.ts +4 -0
- package/types.ts +2 -0
package/index.tsx
CHANGED
|
@@ -40,15 +40,17 @@ const Collapse: FC<CollapseProps> = ({
|
|
|
40
40
|
titleSize = 'medium',
|
|
41
41
|
useBackgroundCollapseButton = false,
|
|
42
42
|
headerAlign = 'flex-start',
|
|
43
|
+
expandDefault = false,
|
|
43
44
|
}) => {
|
|
44
45
|
const {theme} = useContext(ApplicationContext);
|
|
45
|
-
const [expanded, setExpanded] = useState(
|
|
46
|
+
const [expanded, setExpanded] = useState(expandDefault);
|
|
46
47
|
|
|
47
48
|
const iconSource = expanded
|
|
48
49
|
? 'arrow_chevron_up_small'
|
|
49
50
|
: 'arrow_chevron_down_small';
|
|
50
|
-
const radiusStyle = {borderBottomLeftRadius: 0, borderBottomRightRadius: 0};
|
|
51
51
|
const borderWidth = showBorder ? 1 : 0;
|
|
52
|
+
const borderColor = theme.colors.border.default;
|
|
53
|
+
const backgroundColor = theme.colors.background.surface;
|
|
52
54
|
|
|
53
55
|
const getTitleTypo = () => {
|
|
54
56
|
switch (titleSize) {
|
|
@@ -133,12 +135,6 @@ const Collapse: FC<CollapseProps> = ({
|
|
|
133
135
|
onPress={onPressHeader}
|
|
134
136
|
style={[
|
|
135
137
|
styles.header,
|
|
136
|
-
{
|
|
137
|
-
backgroundColor: theme.colors.background.surface,
|
|
138
|
-
borderColor: theme.colors.border.default,
|
|
139
|
-
borderWidth,
|
|
140
|
-
},
|
|
141
|
-
expanded && radiusStyle,
|
|
142
138
|
{
|
|
143
139
|
alignItems: headerAlign,
|
|
144
140
|
},
|
|
@@ -186,8 +182,9 @@ const Collapse: FC<CollapseProps> = ({
|
|
|
186
182
|
scrollEnabled && {
|
|
187
183
|
maxHeight: scrollContentMaxHeight,
|
|
188
184
|
},
|
|
189
|
-
{
|
|
190
|
-
|
|
185
|
+
expanded && {
|
|
186
|
+
borderTopWidth: borderWidth,
|
|
187
|
+
borderColor,
|
|
191
188
|
},
|
|
192
189
|
]}>
|
|
193
190
|
{expanded && children}
|
|
@@ -195,7 +192,15 @@ const Collapse: FC<CollapseProps> = ({
|
|
|
195
192
|
);
|
|
196
193
|
};
|
|
197
194
|
return (
|
|
198
|
-
<View
|
|
195
|
+
<View
|
|
196
|
+
style={[
|
|
197
|
+
styles.root,
|
|
198
|
+
{
|
|
199
|
+
borderWidth,
|
|
200
|
+
borderColor,
|
|
201
|
+
backgroundColor,
|
|
202
|
+
},
|
|
203
|
+
]}>
|
|
199
204
|
{renderHeader()}
|
|
200
205
|
{renderContent()}
|
|
201
206
|
</View>
|
package/package.json
CHANGED
package/styles.ts
CHANGED