@arbor-education/design-system.components 0.25.2 → 0.25.3

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.
@@ -43,6 +43,31 @@ describe('Row component', () => {
43
43
  expect(row).toHaveClass('ds-row', 'custom-row');
44
44
  });
45
45
 
46
+ describe('href behaviour', () => {
47
+ test('wraps value in an anchor when href is provided', () => {
48
+ render(<Row label="Profile" value="View profile" href="/students/123" />);
49
+
50
+ const link = screen.getByRole('link', { name: 'View profile' });
51
+ expect(link).toBeInTheDocument();
52
+ expect(link).toHaveAttribute('href', '/students/123');
53
+ });
54
+
55
+ test('uses href as link text when no value is provided', () => {
56
+ render(<Row label="Document" href="/documents/report.pdf" />);
57
+
58
+ const link = screen.getByRole('link', { name: '/documents/report.pdf' });
59
+ expect(link).toBeInTheDocument();
60
+ expect(link).toHaveAttribute('href', '/documents/report.pdf');
61
+ });
62
+
63
+ test('renders value as plain text when href is not provided', () => {
64
+ render(<Row label="Profile" value="View profile" />);
65
+
66
+ expect(screen.getByText('View profile')).toBeInTheDocument();
67
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
68
+ });
69
+ });
70
+
46
71
  describe('click behaviour', () => {
47
72
  test('calls onClick handler when clicked', () => {
48
73
  const handleClick = vi.fn();
@@ -8,6 +8,7 @@ export type RowProps = {
8
8
  style?: CSSProperties;
9
9
  label?: ReactNode;
10
10
  value?: ReactNode;
11
+ href?: string;
11
12
  note?: ReactNode;
12
13
  onClick?: MouseEventHandler<HTMLDivElement>;
13
14
  };
@@ -18,6 +19,7 @@ export const Row = (props: RowProps) => {
18
19
  style,
19
20
  label,
20
21
  value,
22
+ href,
21
23
  note,
22
24
  onClick,
23
25
  } = props;
@@ -44,7 +46,15 @@ export const Row = (props: RowProps) => {
44
46
  tabIndex={isClickable ? 0 : -1}
45
47
  >
46
48
  <span className="ds-row__label">{label}</span>
47
- <span className="ds-row__value">{value}</span>
49
+ <span className="ds-row__value">
50
+ {href
51
+ ? (
52
+ <a href={href}>
53
+ {value || href}
54
+ </a>
55
+ )
56
+ : value}
57
+ </span>
48
58
  <span className="ds-row__note">{note}</span>
49
59
  {isClickable && (
50
60
  <>