COMPLETE: CardMedia component

This commit is contained in:
doryan 2024-02-03 02:05:53 +04:00
parent bea06db606
commit 6342db227c
15 changed files with 1017 additions and 1086 deletions

219
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,17 @@
// import { forwardRef } from 'react';
// import { CardMediaProps, CardMedia } from "./card.types";
import React, { forwardRef } from 'react';
import { CardMediaProps, CardMediaType } from './card.types';
// export const CardMedia = forwardRef<CardMedia, CardMediaProps>(
// ({rounded = true, preview = true, type, ...props}, ref) => {
// const classes = `m3 m3-card-media${rounded ? ' media-rounded' : ''}${preview ? ' media-preview' : ''} ${props.className ?? ''}`.trimEnd();
// switch (type){
// case "audio":
// break;
// case "iframe":
// break;
// case "img":
// break;
// case "picture":
// break;
// case "video":
// break;
// default:
// break;
// }
// }
export const CardMedia = forwardRef<CardMediaType, CardMediaProps>(
(
{ rounded = true, preview = true, type, className = '', ...props },
ref,
) => {
const classes =
`m3 m3-card-media${rounded ? ' m3-rounded' : ''}${preview ? ' m3-preview' : ''} ${className}`.trimEnd();
return React.createElement(type, {
...props,
className: classes,
ref: ref,
});
},
);

View File

@ -9,13 +9,13 @@ export interface CardActionAreaProps
export interface CardProps extends ContainerProps {}
export interface CardMediaProps extends HTMLAttributes<CardMedia> {
export interface CardMediaProps extends HTMLAttributes<CardMediaType> {
type: 'img' | 'video' | 'picture' | 'iframe' | 'audio';
rounded?: boolean;
preview?: boolean;
}
export type CardMedia = HTMLImageElement &
export type CardMediaType = HTMLImageElement &
HTMLVideoElement &
HTMLPictureElement &
HTMLMediaElement &

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long