@korsolutions/ui 0.0.3 → 0.0.4
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/package.json +1 -1
- package/src/composites/card.tsx +23 -0
- package/src/composites/index.ts +1 -0
- package/src/index.ts +1 -7
- package/src/primitives/card/{card-content.tsx → card-body.tsx} +4 -4
- package/src/primitives/card/index.ts +3 -3
- package/src/primitives/card/types.ts +2 -2
- package/src/primitives/index.ts +7 -0
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Card as CardPrimitive, CardStyles } from "../primitives/card";
|
|
3
|
+
|
|
4
|
+
export interface CompositeCardProps {
|
|
5
|
+
title?: string;
|
|
6
|
+
footer?: React.ReactNode;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
styles?: CardStyles;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Card({ title, footer, children, styles }: CompositeCardProps) {
|
|
12
|
+
return (
|
|
13
|
+
<CardPrimitive.Root styles={styles}>
|
|
14
|
+
{title && (
|
|
15
|
+
<CardPrimitive.Header>
|
|
16
|
+
<CardPrimitive.Title>{title}</CardPrimitive.Title>
|
|
17
|
+
</CardPrimitive.Header>
|
|
18
|
+
)}
|
|
19
|
+
<CardPrimitive.Body>{children}</CardPrimitive.Body>
|
|
20
|
+
{footer && <CardPrimitive.Footer>{footer}</CardPrimitive.Footer>}
|
|
21
|
+
</CardPrimitive.Root>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./card";
|
package/src/index.ts
CHANGED
|
@@ -3,18 +3,18 @@ import { StyleProp, View, ViewStyle } from "react-native";
|
|
|
3
3
|
import { useCard } from "./context";
|
|
4
4
|
import { calculateComposedStyles } from "../../utils/calculate-styles";
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface CardBodyProps {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
|
|
9
|
-
render?: (props:
|
|
9
|
+
render?: (props: CardBodyProps) => React.ReactNode;
|
|
10
10
|
|
|
11
11
|
style?: StyleProp<ViewStyle>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function
|
|
14
|
+
export function CardBody(props: CardBodyProps) {
|
|
15
15
|
const card = useCard();
|
|
16
16
|
|
|
17
|
-
const composedStyle = calculateComposedStyles(card.styles, card.state, "
|
|
17
|
+
const composedStyle = calculateComposedStyles(card.styles, card.state, "body", props.style);
|
|
18
18
|
|
|
19
19
|
const Component = props.render ?? View;
|
|
20
20
|
return <Component {...props} style={composedStyle} />;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { CardRoot } from "./card-root";
|
|
2
2
|
import { CardHeader } from "./card-header";
|
|
3
3
|
import { CardTitle } from "./card-title";
|
|
4
|
-
import {
|
|
4
|
+
import { CardBody } from "./card-body";
|
|
5
5
|
import { CardFooter } from "./card-footer";
|
|
6
6
|
|
|
7
7
|
export const Card = {
|
|
8
8
|
Root: CardRoot,
|
|
9
9
|
Header: CardHeader,
|
|
10
10
|
Title: CardTitle,
|
|
11
|
-
|
|
11
|
+
Body: CardBody,
|
|
12
12
|
Footer: CardFooter,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type { CardRootProps } from "./card-root";
|
|
16
16
|
export type { CardHeaderProps } from "./card-header";
|
|
17
17
|
export type { CardTitleProps } from "./card-title";
|
|
18
|
-
export type {
|
|
18
|
+
export type { CardBodyProps } from "./card-body";
|
|
19
19
|
export type { CardFooterProps } from "./card-footer";
|
|
20
20
|
export type { CardStyles } from "./types";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CardRootProps } from "./card-root";
|
|
2
2
|
import { CardHeaderProps } from "./card-header";
|
|
3
3
|
import { CardTitleProps } from "./card-title";
|
|
4
|
-
import {
|
|
4
|
+
import { CardBodyProps } from "./card-body";
|
|
5
5
|
import { CardFooterProps } from "./card-footer";
|
|
6
6
|
|
|
7
7
|
export type CardState = "default";
|
|
@@ -10,6 +10,6 @@ export interface CardStyles {
|
|
|
10
10
|
root?: Partial<Record<CardState, CardRootProps["style"]>>;
|
|
11
11
|
header?: Partial<Record<CardState, CardHeaderProps["style"]>>;
|
|
12
12
|
title?: Partial<Record<CardState, CardTitleProps["style"]>>;
|
|
13
|
-
|
|
13
|
+
body?: Partial<Record<CardState, CardBodyProps["style"]>>;
|
|
14
14
|
footer?: Partial<Record<CardState, CardFooterProps["style"]>>;
|
|
15
15
|
}
|