Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Image): add props interface #147

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ import { customPropTypes, UIComponent } from '../../lib'
import { ImageBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

import { ComponentVariablesInput, IComponentPartStylesInput } from '../../../types/theme'
import { Extendable, ReactChildren } from '../../../types/utils'

export interface IImageProps {
accessibility?: Accessibility
as?: any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I was adding the accessibility prop as object | Function, as I didn't know that there is prop for this. We may need to update this in the other components

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, will do

avatar?: boolean
children?: ReactChildren
circular?: boolean
className?: string
fluid?: boolean
styles?: IComponentPartStylesInput
variables?: ComponentVariablesInput
}

/**
* An image is a graphic representation of something.
* @accessibility
Expand All @@ -18,7 +33,7 @@ import { Accessibility } from '../../lib/accessibility/interfaces'
* - when image has role='presentation' then screen readers navigate to the element in scan/virtual mode. To avoid this, the attribute "aria-hidden='true'" is applied by the default image behavior
* - when alt property is used in combination with aria-label, arialabbeledby or title, additional screen readers verification is needed as each screen reader handles this combination differently.
*/
class Image extends UIComponent<any, any> {
class Image extends UIComponent<Extendable<IImageProps>, any> {
static className = 'ui-image'

static displayName = 'Image'
Expand Down
3 changes: 2 additions & 1 deletion src/themes/teams/components/Image/imageStyles.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { pxToRem } from '../../../../lib'
import { ICSSInJSStyle } from '../../../../../types/theme'
import { IImageProps } from '../../../../components/Image/Image'

export default {
root: ({ props, variables }): ICSSInJSStyle => ({
root: ({ props, variables }: { props: IImageProps; variables: any }): ICSSInJSStyle => ({
display: 'inline-block',
verticalAlign: 'middle',
width: (props.fluid && '100%') || variables.width,
Expand Down