Skip to content

Commit 7e5faaa

Browse files
committed
アコーディオン付きCommonCardの角丸描画を調整
1 parent a0726f1 commit 7e5faaa

File tree

1 file changed

+38
-19
lines changed

1 file changed

+38
-19
lines changed

src/components/CommonCard.tsx

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ const styles = StyleSheet.create({
4747
paddingHorizontal: 16,
4848
flexDirection: 'row',
4949
alignItems: 'center',
50+
},
51+
cardShadow: {
5052
shadowColor: '#333',
5153
shadowOpacity: 0.25,
5254
shadowRadius: 4,
@@ -300,17 +302,40 @@ export const CommonCard: React.FC<Props> = ({
300302
[disabled, line.color]
301303
);
302304

305+
const cardRadius = isLEDTheme ? 0 : 8;
306+
const wrapperRadiusStyle = useMemo(
307+
() => ({
308+
borderRadius: cardRadius,
309+
backgroundColor: line.color ?? '#333',
310+
overflow: 'hidden' as const,
311+
}),
312+
[cardRadius, line.color]
313+
);
314+
const headerRadiusStyle = useMemo(() => {
315+
if (!hasAccordion) {
316+
return {
317+
borderRadius: cardRadius,
318+
};
319+
}
320+
321+
if (!expanded) {
322+
return undefined;
323+
}
324+
325+
return {
326+
borderTopLeftRadius: cardRadius,
327+
borderTopRightRadius: cardRadius,
328+
borderBottomLeftRadius: 0,
329+
borderBottomRightRadius: 0,
330+
};
331+
}, [cardRadius, expanded, hasAccordion]);
332+
const rootShadowStyle = hasAccordion ? undefined : styles.cardShadow;
333+
const accordionWrapperStyle = hasAccordion
334+
? [styles.cardShadow, wrapperRadiusStyle]
335+
: undefined;
336+
303337
return (
304-
<View
305-
style={
306-
hasAccordion
307-
? {
308-
borderRadius: isLEDTheme ? 0 : 8,
309-
overflow: 'hidden',
310-
}
311-
: undefined
312-
}
313-
>
338+
<View style={accordionWrapperStyle}>
314339
{hasAccordion && (
315340
<View
316341
style={[
@@ -327,19 +352,13 @@ export const CommonCard: React.FC<Props> = ({
327352
testID={testID}
328353
style={[
329354
styles.root,
330-
{
331-
borderRadius: isLEDTheme ? 0 : 8,
332-
},
355+
rootShadowStyle,
356+
headerRadiusStyle,
333357
additionalRootStyle,
334358
]}
335359
>
336360
<View
337-
style={[
338-
styles.insetBorder,
339-
{
340-
borderRadius: isLEDTheme ? 0 : 8,
341-
},
342-
]}
361+
style={[styles.insetBorder, headerRadiusStyle]}
343362
pointerEvents="none"
344363
/>
345364
{mark ? (

0 commit comments

Comments
 (0)