mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-10-29 02:55:48 -04:00
CSS modules ➡️ Stitches 🧵 (#799)
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
.frame {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin: 1em auto;
|
||||
border: 2px solid var(--kinda-light);
|
||||
border-radius: var(--rounded-edge-radius);
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
import classNames from "classnames";
|
||||
import { styled } from "../../lib/styles/stitches.config";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import styles from "./IFrame.module.css";
|
||||
const RoundedIFrame = styled("iframe", {
|
||||
width: "100%",
|
||||
display: "block",
|
||||
margin: "1em auto",
|
||||
border: "2px solid $kindaLight",
|
||||
borderRadius: "$rounded",
|
||||
});
|
||||
|
||||
export type IFrameProps = JSX.IntrinsicElements["iframe"] & {
|
||||
export type IFrameProps = ComponentProps<typeof RoundedIFrame> & {
|
||||
src: string;
|
||||
height: number;
|
||||
width?: number; // defaults to 100%
|
||||
@@ -10,17 +17,16 @@ export type IFrameProps = JSX.IntrinsicElements["iframe"] & {
|
||||
noScroll?: boolean;
|
||||
};
|
||||
|
||||
const IFrame = ({ src, title, height, width, allowScripts, noScroll, className, ...rest }: IFrameProps) => (
|
||||
<iframe
|
||||
className={classNames(styles.frame, className)}
|
||||
const IFrame = ({ src, title, height, width, allowScripts, noScroll, ...rest }: IFrameProps) => (
|
||||
<RoundedIFrame
|
||||
src={src}
|
||||
title={title}
|
||||
sandbox={allowScripts ? "allow-same-origin allow-scripts allow-popups" : undefined}
|
||||
scrolling={noScroll ? "no" : undefined}
|
||||
loading="lazy"
|
||||
style={{
|
||||
css={{
|
||||
height: `${height}px`,
|
||||
maxWidth: width ? `${width}px` : undefined,
|
||||
maxWidth: width ? `${width}px` : null,
|
||||
}}
|
||||
{...rest}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user