-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image component #262
Image component #262
Changes from 10 commits
7e5abcb
6f16dfa
f7fd8a4
d2ff624
3e7745b
881db03
2a8a1bb
9ef0a01
06984d2
806696d
0440b38
e136191
c2bf6e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiImage, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<EuiImage | ||
size="l" | ||
hasShadow | ||
allowFullScreen | ||
caption="Click me to see full screen" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
import { | ||
EuiCode, | ||
} from '../../../../src/components'; | ||
|
||
import Image from './image'; | ||
const imageSource = require('!!raw-loader!./image'); | ||
const imageHtml = renderToHtml(Image); | ||
|
||
import ImageSizes from './image_size'; | ||
const imageSizesSource = require('!!raw-loader!./image_size'); | ||
const imageSizesHtml = renderToHtml(ImageSizes); | ||
|
||
export const ImageExample = { | ||
title: 'Image', | ||
sections: [ | ||
{ | ||
title: 'Image', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: imageSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: imageHtml, | ||
}], | ||
text: ( | ||
<div> | ||
<p> | ||
Use <EuiCode>EuiImage</EuiCode> when you need to place a static image | ||
into a page with an optional caption. It has the following props. | ||
</p> | ||
<ul> | ||
<li> | ||
<EuiCode>size</EuiCode> accepts <EuiCode>s / m / l / xl / original / fullWidth</EuiCode>. | ||
The later will set the figure to stretch to 100% of its container. | ||
</li> | ||
<li> | ||
<EuiCode>allowFullScreen</EuiCode> when set to true (default) will make the image | ||
clicakable to a larger version. | ||
</li> | ||
<li> | ||
<EuiCode>hasShadow</EuiCode> when set to true (default) will apply | ||
a slight shadow below the image. | ||
</li> | ||
<li> | ||
<EuiCode>caption</EuiCode> will provide a caption to the image. | ||
</li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed |
||
</ul> | ||
</div> | ||
), | ||
demo: <Image />, | ||
}, | ||
{ | ||
title: 'Images can be sized', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: imageSizesSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: imageSizesHtml, | ||
}], | ||
text: ( | ||
<p> | ||
Images can be sized by passing the <EuiCode>size</EuiCode> prop a value | ||
of <EuiCode>s / m / l / original / fullWidth</EuiCode>. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add 'xl' to this list as well |
||
</p> | ||
), | ||
demo: <ImageSizes />, | ||
}, | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiImage, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiImage | ||
size="s" | ||
hasShadow | ||
allowFullScreen | ||
caption="Small" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
<EuiSpacer /> | ||
<EuiImage | ||
size="m" | ||
hasShadow | ||
allowFullScreen | ||
caption="Medium" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
<EuiSpacer /> | ||
<EuiImage | ||
size="l" | ||
hasShadow | ||
allowFullScreen | ||
caption="Large" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
<EuiSpacer /> | ||
<EuiImage | ||
size="xl" | ||
hasShadow | ||
allowFullScreen | ||
caption="Extra large" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
<EuiSpacer /> | ||
<EuiImage | ||
hasShadow | ||
allowFullScreen | ||
caption="Original" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
<EuiSpacer /> | ||
<EuiImage | ||
hasShadow | ||
allowFullScreen | ||
size="fullWidth" | ||
caption="Full width" | ||
title="Accessible image title goes here" | ||
url="https://i.imgur.com/4qx7HhE.jpg" | ||
/> | ||
</div> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiImage is rendered 1`] = ` | ||
<figure | ||
aria-label="aria-label" | ||
class="euiImage euiImage--large testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<img | ||
class="euiImage__img" | ||
title="title" | ||
/> | ||
</figure> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Main <figure> that wraps images. | ||
.euiImage { | ||
display: inline-block; | ||
max-width: 100%; | ||
|
||
|
||
&.euiImage--hasShadow { | ||
.euiImage__img { | ||
@include euiBottomShadowMedium; | ||
} | ||
} | ||
|
||
&.euiImage--allowFullScreen:hover { | ||
.euiImage__img { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
// These sizes are mostly suggestions. Don't look too hard for meaning in their values. | ||
&.euiImage--small { | ||
width: convertToRem(120px); | ||
} | ||
|
||
&.euiImage--medium { | ||
width: convertToRem(200px); | ||
} | ||
|
||
&.euiImage--large { | ||
width: convertToRem(360px); | ||
} | ||
|
||
&.euiImage--xlarge { | ||
width: convertToRem(600px); | ||
} | ||
|
||
&.euiImage--fullWidth { | ||
width: 100%; | ||
} | ||
} | ||
|
||
// The image itself is full width within the container. | ||
.euiImage__img { | ||
width: 100%; | ||
} | ||
|
||
.euiImage__caption { | ||
text-align: center; | ||
@include euiFontSizeS; | ||
} | ||
|
||
// The FullScreen image that optionally pops up on click. | ||
.euiImageFullScreen { | ||
max-height: 80vh; | ||
max-width: 80vw; | ||
animation: euiImageFullScreen $euiAnimSpeedExtraSlow $euiAnimSlightBounce; | ||
|
||
.euiImageFullScreen__img { | ||
max-height: 80vh; | ||
max-width: 80vw; | ||
cursor: pointer; | ||
} | ||
|
||
&:hover .euiImageFullScreen__img { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
|
||
@keyframes euiImageFullScreen { | ||
0% { | ||
opacity: 0; | ||
transform: translateY($euiSizeXL * 2); | ||
} | ||
100% { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import 'image'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp: "later" -> "latter"