Skip to content

Commit

Permalink
chore(react-image): migrate to new SB controlls setup (microsoft#18972)
Browse files Browse the repository at this point in the history
* chore(react-image): migrate to new SB controlls setup
* refactor(react-image): remove redundant api declared by native img
* Change files
  • Loading branch information
Hotell authored and PeterDraex committed Aug 6, 2021
1 parent d5a0fc8 commit 5abfc99
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore(react-image): migrate to new SB controlls setup",
"packageName": "@fluentui/react-image",
"email": "martinhochel@microsoft.com",
"dependentChangeType": "none"
}
4 changes: 4 additions & 0 deletions packages/react-image/.storybook/preview.js
@@ -1,3 +1,7 @@
import * as rootPreview from '../../../.storybook/preview';

/** @type {typeof rootPreview.decorators} */
export const decorators = [...rootPreview.decorators];

/** @type {typeof rootPreview.parameters} */
export const parameters = { ...rootPreview.parameters };
4 changes: 0 additions & 4 deletions packages/react-image/etc/react-image.api.md
Expand Up @@ -9,18 +9,15 @@ import * as React_2 from 'react';

// @public (undocumented)
const Image_2: React_2.FunctionComponent<ImageProps & React_2.RefAttributes<HTMLElement>>;

export { Image_2 as Image }

// @public (undocumented)
export interface ImageProps extends ComponentPropsCompat, React_2.ImgHTMLAttributes<HTMLImageElement> {
alt?: string;
bordered?: boolean;
circular?: boolean;
fit?: 'none' | 'center' | 'contain' | 'cover';
fluid?: boolean;
rounded?: boolean;
src?: string;
}

// @public (undocumented)
Expand All @@ -38,7 +35,6 @@ export const useImage: (props: ImageProps, ref: React_2.Ref<HTMLElement>, defaul
// @public (undocumented)
export const useImageStyles: (state: ImageState) => void;


// (No @packageDocumentation comment for this package)

```
27 changes: 25 additions & 2 deletions packages/react-image/src/Image.stories.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
import { Image } from './index';
import { makeStyles } from '@fluentui/react-make-styles';
import { ArgTypes, Meta, Parameters } from '@storybook/react';

import { Image, ImageProps } from './index';

/**
* Temporary Stack until there's one in its own package.
Expand Down Expand Up @@ -31,6 +33,27 @@ const Stack = (props: React.PropsWithChildren<{ horizontal?: boolean }>) => {
return <div {...rest} className={horizontal ? hStack : vStack} />;
};

export const Default = (props: ImageProps) => {
return <Image {...props} />;
};
Default.argTypes = {
alt: {
control: 'text',
defaultValue: 'Image placeholder',
description: `description of the image, which isn't mandatory but is incredibly useful for accessibility`,
},
src: {
control: 'text',
defaultValue: 'https://via.placeholder.com/300x300',
description: 'path to the image you want to display',
},
} as ArgTypes;
Default.parameters = {
controls: {
disable: false,
},
} as Parameters;

export const ImageAppearanceShape = () => (
<Stack horizontal>
<Image
Expand Down Expand Up @@ -185,4 +208,4 @@ export const ImageFluid = () => (
export default {
title: 'Components/Image',
component: Image,
};
} as Meta;
10 changes: 0 additions & 10 deletions packages/react-image/src/components/Image/Image.types.ts
Expand Up @@ -2,11 +2,6 @@ import * as React from 'react';
import { ComponentPropsCompat } from '@fluentui/react-utilities';

export interface ImageProps extends ComponentPropsCompat, React.ImgHTMLAttributes<HTMLImageElement> {
/**
* An alternative text for an image.
*/
alt?: string;

/**
* An image can appear with rectangular border.
*/
Expand All @@ -31,11 +26,6 @@ export interface ImageProps extends ComponentPropsCompat, React.ImgHTMLAttribute
* An image can appear rounded.
*/
rounded?: boolean;

/**
* An image can have source URL.
*/
src?: string;
}

export interface ImageState extends ImageProps {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-image/tsconfig.json
Expand Up @@ -12,6 +12,6 @@
"importHelpers": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"types": ["jest", "custom-global", "inline-style-expand-shorthand"]
"types": ["jest", "custom-global", "inline-style-expand-shorthand", "storybook__addons"]
}
}

0 comments on commit 5abfc99

Please sign in to comment.