Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card component #274

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
68f991b
✨ card component added
scar055 Nov 7, 2023
5159fcb
🚚 moved card to map and renamed
scar055 Nov 7, 2023
d44fa80
✨ card list added
scar055 Nov 7, 2023
46eb865
💄 styles file added
scar055 Nov 7, 2023
da8ae4e
💄 added voorbeeld van card component
scar055 Nov 8, 2023
e1b485b
✨ card list is gemaakt
scar055 Nov 8, 2023
1832844
🚚 class names renamed
scar055 Nov 8, 2023
c74861c
🚚 renamed classnames
scar055 Nov 8, 2023
a02e967
💄 list type none
scar055 Nov 8, 2023
2ccacfa
🎨 card list item alle items die nodig zijn added
scar055 Nov 8, 2023
7342d23
🔥 delete link import
scar055 Nov 8, 2023
cbc9ecf
🚧 add an optional article around card content
savitris Nov 8, 2023
7e80a99
fixup! 🚧 add an optional article around card content
scar055 Nov 9, 2023
e49549d
🎨 class name naar utrecht card toegevoegd
scar055 Nov 9, 2023
20ac015
✨ made image and preheading optional
savitris Nov 9, 2023
968409e
🎨 title optioneel gemaakt
scar055 Nov 9, 2023
2e3448d
🚚 classes changed
scar055 Nov 9, 2023
7d21653
🎨 linting
scar055 Nov 9, 2023
84ef3c9
🔥 deleted commented out code
scar055 Nov 9, 2023
b98dafe
🚚 headerlevel to headinglevel
scar055 Nov 9, 2023
e696253
🎨 aparte props voor image en link gemaakt
scar055 Nov 9, 2023
ebd8843
♻️ react fc naar props with children changed
scar055 Nov 9, 2023
ca32152
🔥 paragraph weggehaalt
scar055 Nov 9, 2023
11b4401
🔥 {} om link classnames deleted
scar055 Nov 9, 2023
0ceb056
♻️ changed a to link component
scar055 Nov 9, 2023
3ced4ba
✨ hoogte en breedte van image is nu in instelbare props
scar055 Nov 9, 2023
5e83236
♻️ ul naar cardlist component refactor
scar055 Nov 9, 2023
97b0570
✏️ L als hooftletter
scar055 Nov 9, 2023
f3a64bd
🎨 card in een if statement gestopt
scar055 Nov 9, 2023
2cac257
💄 2e card toegevoegd voor voorbeeld
scar055 Nov 9, 2023
b2b13a1
🎨 heading link conditional verbeterd
scar055 Nov 9, 2023
2dcaf0d
🎨 childeren een any type gegeven
scar055 Nov 9, 2023
cea4f04
💄 voorbeeld tekst beter gemaakt
scar055 Nov 9, 2023
62c5cdd
🎨 cardrole naar specifieke string gezet
scar055 Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/next-templates/src/app/card-component/card-list/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @license EUPL-1.2
* Copyright (c) 2021 Robbert Broersma
*/

import clsx from 'clsx';
import { ForwardedRef, forwardRef, HTMLAttributes, PropsWithChildren } from 'react';

export type CardListProps = HTMLAttributes<HTMLUListElement>;

export const CardList = forwardRef(
({ children, className, ...restProps }: PropsWithChildren<CardListProps>, ref: ForwardedRef<HTMLUListElement>) => (
<ul role="list" {...restProps} ref={ref} className={clsx('utrecht-card-list', className)}>
{children}
</ul>
),
);

CardList.displayName = 'CardList';

export default function show() {
return <CardList>test</CardList>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.utrecht-card-list-item {
background-color: var(--utrecht-color-blue-90);
max-width: 312px;
list-style: none;
}

.utrecht-card-list-item:hover {
--utrecht-link-text-decoration: underline;
--utrecht-link-text-decoration-thickness: var(--utrecht-link-hover-text-decoration-thickness);

cursor: pointer;
text-decoration-skip-ink: none;
}

.utrecht-card-list-item__image {
max-width: 100%;
object-fit: cover;
}

.utrecht-card-list-item__content {
padding-block-end: 1rem;
padding-block-start: 0;
padding-inline-end: 1rem;
padding-inline-start: 1rem;
}
134 changes: 134 additions & 0 deletions packages/next-templates/src/app/card-component/card/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
'use client';

import { Heading, Link, Paragraph } from '@utrecht/component-library-react';
import clsx from 'clsx';
import Image from 'next/image';
import React, { HTMLAttributes, PropsWithChildren } from 'react';
import './index.style.css';
import { CardList } from '../card-list/page';
import { type } from 'os';

interface CardListItemProps extends Omit<HTMLAttributes<HTMLLIElement>, 'children'> {
headingLevel: number;
title?: string;
preHeading?: string;
children?: any;
imageHeight?: number;
imageWidth?: number;
imageSrc?: string;
imageAlt?: string;
href?: string;
cardRole?: 'article' | string;
}

export const CardListItem = ({
headingLevel,
children,
title,
preHeading,
imageHeight,
imageWidth,
imageSrc,
imageAlt,
href,
cardRole,
...props
}: PropsWithChildren<CardListItemProps>) => {
const linkRef = React.useRef<HTMLAnchorElement>(null);

let headingContent: any = title;
if (typeof href === 'string') {
headingContent = <Link href={href}>{title}</Link>;
} else {
headingContent;
}

let card = (
<div className={'utrecht-card-list-item__content'}>
<hgroup>
<Heading level={headingLevel} className="utrecht-card-list-item__title">
{headingContent}
</Heading>
{preHeading && <p className="utrecht-card-list-item__pre-heading">{preHeading}</p>}
</hgroup>
{children}
</div>
);

if (cardRole === 'article') {
card = (
<li
{...props}
className={clsx('utrecht-card-list-item', props.className)}
onClick={() => linkRef.current?.click()}
>
{imageSrc && imageAlt && (
<Image
src={imageSrc}
alt={imageAlt}
height={imageHeight}
width={imageWidth}
className={'utrecht-card-list-item__image'}
/>
)}
<article>{card}</article>
</li>
);
} else {
card = (
<li
{...props}
className={clsx('utrecht-card-list-item', props.className)}
onClick={() => linkRef.current?.click()}
>
{imageSrc && imageAlt && (
<Image
src={imageSrc}
alt={imageAlt}
height={imageHeight}
width={imageWidth}
className={'utrecht-card-list-item__image'}
/>
)}
{card}
</li>
);
}

return card;
};
export default function Home() {
return (
<CardList>
<CardListItem
headingLevel={2}
title="test"
imageAlt="test"
imageSrc="/business_corgi.jpeg"
imageWidth={500}
imageHeight={300}
cardRole="article"
preHeading="optional testje"
>
<Paragraph>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at ipsum rhoncus, rhoncus nisl eu, sollicitudin
erat. Duis posuere bibendum diam, semper iaculis mi varius in. Interdum et malesuada fames ac ante ipsum
primis in faucibus. Aliquam erat volutpat.
</Paragraph>
</CardListItem>
<CardListItem
headingLevel={2}
title="test"
imageAlt="test"
imageSrc="/business_corgi.jpeg"
imageWidth={500}
imageHeight={300}
href="#"
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at ipsum rhoncus, rhoncus nisl eu, sollicitudin
erat. Duis posuere bibendum diam, semper iaculis mi varius in. Interdum et malesuada fames ac ante ipsum primis
in faucibus. Aliquam erat volutpat.
</CardListItem>
</CardList>
);
}
Loading