diff --git a/.changeset/the-man.md b/.changeset/the-man.md
new file mode 100644
index 00000000..73cd0ab0
--- /dev/null
+++ b/.changeset/the-man.md
@@ -0,0 +1,5 @@
+---
+"@nordcom/nordstar-card": patch
+---
+
+Add `` child component.
diff --git a/packages/components/card/src/card.module.scss b/packages/components/card/src/card.module.scss
index 35686863..073297d6 100644
--- a/packages/components/card/src/card.module.scss
+++ b/packages/components/card/src/card.module.scss
@@ -1,12 +1,20 @@
.container {
- padding: var(--layout-block-padding);
-
border-width: var(--border-width-half);
border-style: solid;
border-radius: var(--border-radius);
font-family: var(--font-body);
+ &:not([data-padding='false']) {
+ $padding: var(--layout-block-padding);
+
+ padding: $padding;
+
+ .divider {
+ margin: $padding calc($padding * -1);
+ }
+ }
+
&[data-variant='solid'] {
border-width: 0;
@@ -36,4 +44,11 @@
&[data-color='secondary'] {
border-color: var(--color-accent-secondary);
}
+
+ .divider {
+ height: var(--border-width-half);
+
+ // TODO: Use the proper color based on `data-color`.
+ background: var(--color-background-highlight);
+ }
}
diff --git a/packages/components/card/src/card.stories.tsx b/packages/components/card/src/card.stories.tsx
index 3a885cba..bb811c9b 100644
--- a/packages/components/card/src/card.stories.tsx
+++ b/packages/components/card/src/card.stories.tsx
@@ -20,13 +20,26 @@ const story: Meta = {
}
};
-const Template = (args: CardProps) => Content inside of the card;
+const Template = (args: CardProps) => ;
export const Default = {
render: Template,
args: {
variant: 'default',
- color: 'default'
+ color: 'default',
+ children: (
+ <>
+ Hello World!
+
+ Content inside of the card
+
+ Another line of content inside of the card.
+
+ And another one.
+
+ Imaginary footer
+ >
+ )
}
};
@@ -34,21 +47,24 @@ export const DefaultSolid = {
render: Template,
args: {
variant: 'solid',
- color: 'default'
+ color: 'default',
+ children: <>Content inside of the card>
}
};
export const PrimarySolid = {
render: Template,
args: {
variant: 'solid',
- color: 'primary'
+ color: 'primary',
+ children: <>Content inside of the card>
}
};
export const SecondarySolid = {
render: Template,
args: {
variant: 'solid',
- color: 'secondary'
+ color: 'secondary',
+ children: <>Content inside of the card>
}
};
diff --git a/packages/components/card/src/card.tsx b/packages/components/card/src/card.tsx
index 6e8d57e4..4981d00b 100644
--- a/packages/components/card/src/card.tsx
+++ b/packages/components/card/src/card.tsx
@@ -1,5 +1,5 @@
-import type { As, CSSCustomProperties, NordstarColor } from '@nordcom/nordstar-system';
-import { forwardRef } from '@nordcom/nordstar-system';
+import { forwardRef, type As, type CSSCustomProperties, type NordstarColor } from '@nordcom/nordstar-system';
+import type { ComponentProps } from 'react';
import styles from './card.module.scss';
export type CardProps = {
@@ -16,16 +16,33 @@ export type CardProps = {
* @param {As} [props.as] - The element to render the component as.
* @param {'default' | 'solid'} [props.variant='default'] - The variant of the card.
* @param {NordstarColor} [props.color='default'] - The color scheme of the card.
+ * @param {CSSCustomProperties} [props.style] - Custom CSS properties.
+ * @param {React.ReactNode} [props.children] - The children of the component.
* @returns {React.ReactNode} The `` component.
*/
+
const Card = forwardRef<'section', CardProps>(
- ({ as: Tag = 'section', className, variant = 'default', color = 'default', ...props }, ref) => {
+ ({ as, className, variant = 'default', color = 'default', ...props }, ref) => {
+ const Tag = as || 'section';
const classes = `${styles.container}${className ? ` ${className}` : ''}`;
- return ;
+ return ;
}
);
-
Card.displayName = 'Nordstar.Card';
-export default Card;
+export type CardDividerProps = {} & ComponentProps<'hr'>;
+
+/**
+ * ``, a component to render card dividers.
+ * @param {object} props - `` props.
+ * @returns {React.ReactNode} The `` component.
+ */
+const Divider = ({ className, ...props }: CardDividerProps) => {
+ const classes = `${styles.divider}${className ? ` ${className}` : ''}`;
+
+ return ;
+};
+Divider.displayName = 'Nordstar.Card.Divider';
+
+export default Object.assign(Card, { Divider });