feat: Iframe component API and docs improvements

This commit is contained in:
Demenech 2024-04-09 16:07:12 -03:00
parent 4b5d549190
commit b7ee5a1869
3 changed files with 17 additions and 12 deletions

View File

@ -7,7 +7,7 @@ import 'ag-grid-community/styles/ag-theme-alpine.css';
import { Data } from '../types/properties'; import { Data } from '../types/properties';
export type ExcelProps = { export type ExcelProps = {
data: Pick<Data, 'url'>; data: Required<Pick<Data, 'url'>>;
}; };
export function Excel({ data }: ExcelProps) { export function Excel({ data }: ExcelProps) {

View File

@ -1,14 +1,17 @@
import { CSSProperties } from "react"; import { CSSProperties } from 'react';
import { Data } from '../types/properties';
export interface IframeProps { export interface IframeProps {
url: string; data: Required<Pick<Data, 'url'>>;
style?: CSSProperties; style?: CSSProperties;
} }
export function Iframe({ export function Iframe({ data, style }: IframeProps) {
url, style const url = data.url;
}: IframeProps) {
return ( return (
<iframe src={url} style={style ?? { width: `100%`, height: `100%` }}></iframe> <iframe
src={url}
style={style ?? { width: `100%`, height: `100%` }}
></iframe>
); );
} }

View File

@ -7,13 +7,13 @@ const meta: Meta = {
component: Iframe, component: Iframe,
tags: ['autodocs'], tags: ['autodocs'],
argTypes: { argTypes: {
url: { data: {
description: description:
'Page to display inside of the component', 'Object with a `url` property pointing to the page to be embeded.',
}, },
style: { style: {
description: description:
'Style of the component', 'Style object of the component. See example at https://react.dev/learn#displaying-data. Defaults to `{ width: "100%", height: "100%" }`',
}, },
}, },
}; };
@ -25,7 +25,9 @@ type Story = StoryObj<IframeProps>;
export const Normal: Story = { export const Normal: Story = {
name: 'Iframe', name: 'Iframe',
args: { args: {
data: {
url: 'https://app.powerbi.com/view?r=eyJrIjoiYzBmN2Q2MzYtYzE3MS00ODkxLWE5OWMtZTQ2MjBlMDljMDk4IiwidCI6Ijk1M2IwZjgzLTFjZTYtNDVjMy04MmM5LTFkODQ3ZTM3MjMzOSIsImMiOjh9', url: 'https://app.powerbi.com/view?r=eyJrIjoiYzBmN2Q2MzYtYzE3MS00ODkxLWE5OWMtZTQ2MjBlMDljMDk4IiwidCI6Ijk1M2IwZjgzLTFjZTYtNDVjMy04MmM5LTFkODQ3ZTM3MjMzOSIsImMiOjh9',
style: {width: `100%`, height: `100%`} },
style: { width: `100%`, height: `100%` },
}, },
}; };