mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: add Image component
This commit is contained in:
31
src/components/Image.tsx
Normal file
31
src/components/Image.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import cx from 'classnames';
|
||||||
|
|
||||||
|
import type { FunctionalComponent } from 'preact';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
alt: string;
|
||||||
|
class?: string;
|
||||||
|
noMargin?: boolean;
|
||||||
|
src: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Image: FunctionalComponent<Props> = ({
|
||||||
|
alt,
|
||||||
|
class: className,
|
||||||
|
noMargin,
|
||||||
|
src,
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
const classes = cx('image-shadow mbe-10 mbs-0', { 'mbe-0': noMargin }, className);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class={classes}>
|
||||||
|
<img
|
||||||
|
alt={alt}
|
||||||
|
class="block h-auto w-full rounded-1 border-1 border-solid border-black/[0.1] bg-black/[0.1] shadow shadow-black/10 dark:border-white/[0.1] dark:opacity-[0.87] dark:shadow-white/10"
|
||||||
|
src={src}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './Divider';
|
export * from './Divider';
|
||||||
export * from './Headline';
|
export * from './Headline';
|
||||||
|
export * from './Image';
|
||||||
export * from './LegalDate';
|
export * from './LegalDate';
|
||||||
export * from './Link';
|
export * from './Link';
|
||||||
export * from './ListItem';
|
export * from './ListItem';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
Divider,
|
Divider,
|
||||||
Headline,
|
Headline,
|
||||||
|
Image,
|
||||||
ListItem,
|
ListItem,
|
||||||
OrderedList,
|
OrderedList,
|
||||||
Subheadline,
|
Subheadline,
|
||||||
@@ -20,6 +21,7 @@ export const mapping = {
|
|||||||
h5: Subsubheadline,
|
h5: Subsubheadline,
|
||||||
h6: Subsubheadline,
|
h6: Subsubheadline,
|
||||||
hr: Divider,
|
hr: Divider,
|
||||||
|
img: Image,
|
||||||
li: ListItem,
|
li: ListItem,
|
||||||
ol: OrderedList,
|
ol: OrderedList,
|
||||||
p: Text,
|
p: Text,
|
||||||
|
|||||||
@@ -84,4 +84,28 @@
|
|||||||
cite {
|
cite {
|
||||||
@apply pie-[0.1em];
|
@apply pie-[0.1em];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
img[src$='.svg'] {
|
||||||
|
@apply border-0 bg-transparent shadow-none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer components {
|
||||||
|
.image-shadow {
|
||||||
|
@apply relative transition-transform duration-500 ease-in-out;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
@apply absolute -z-[1] h-full w-full opacity-0 shadow-subtle transition-opacity duration-500 ease-in-out content-[''] block-start-0 inline-start-0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
@apply scale-[1.03];
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
@apply opacity-100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user