Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Features
- Update styles for Menu underlined primary @miroslavstastny ([#20](https://github.com/stardust-ui/react/pull/20))
- Add Avatar `getInitials` prop and `presenceIndicatorBackground` variable @mnajdova ([#38](https://github.com/stardust-ui/react/pull/38))
- Add 'fluid' variant and size variables to Image @kuzhelov ([#54](https://github.com/stardust-ui/react/pull/54))

<!--------------------------------[ v0.2.5 ]------------------------------- -->
## [v0.2.5](https://github.com/stardust-ui/react/tree/v0.2.5) (2018-08-03)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Image } from '@stardust-ui/react'

const ImageExample = () => <Image src="//placehold.it/100" />
const ImageExample = () => <Image src="public/images/wireframe/square-image.png" />

export default ImageExample
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'
import { Image, Layout } from '@stardust-ui/react'

const ImageExampleFluent = () => (
<div>
<Layout
style={{ maxWidth: '70px' }}
debug
renderMainArea={() => <Image fluid src="public/images/wireframe/square-image.png" />}
/>
<Layout
style={{ maxWidth: '100px' }}
debug
renderMainArea={() => <Image fluid src="public/images/wireframe/square-image.png" />}
/>
<Layout
style={{ maxWidth: '150px' }}
debug
renderMainArea={() => <Image fluid src="public/images/wireframe/square-image.png" />}
/>
</div>
)

export default ImageExampleFluent
5 changes: 5 additions & 0 deletions docs/src/examples/components/Image/Variations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Variations = () => (
<ExampleSection title="Variations">
<ComponentExample
title="Fluid"
description="An image can take up the width of its container."
examplePath="components/Image/Variations/ImageExampleFluid"
/>
<ComponentExample
title="Circular"
description="An image may appear circular."
Expand Down
10 changes: 7 additions & 3 deletions src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ class Image extends UIComponent<any, any> {

static displayName = 'Image'

static handledProps = ['as', 'avatar', 'circular', 'className']

static rules = imageRules

static variables = imageVariables

static propTypes = {
/** */
/** An element type to render as. */
as: customPropTypes.as,

/** An image may be formatted to appear inline with text as an avatar. */
Expand All @@ -29,9 +27,15 @@ class Image extends UIComponent<any, any> {
/** An image can appear circular. */
circular: PropTypes.bool,

/** Additional classes. */
className: PropTypes.string,

/** An image can take up the width of its container. */
fluid: PropTypes.bool,
}

static handledProps = ['as', 'avatar', 'circular', 'className', 'fluid']

static defaultProps = {
as: 'img',
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Image/imageRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export default {
root: ({ props, variables }) => ({
display: 'inline-block',
verticalAlign: 'middle',
width: variables.width || (props.fluid && '100%'),
height: variables.height || 'auto',
...(props.circular && { borderRadius: pxToRem(9999) }),
...(props.avatar && {
width: variables.avatarSize,
Expand Down
14 changes: 6 additions & 8 deletions src/components/Image/imageVariables.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { pxToRem } from '../../lib'

export default () => {
const vars: any = {}

vars.avatarRadius = pxToRem(9999)
vars.avatarSize = pxToRem(32)

return vars
}
export default () => ({
width: undefined,
height: undefined,
avatarRadius: pxToRem(9999),
avatarSize: pxToRem(32),
})